babylon.d.ts 2.8 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519
  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. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /**
  583. * @hidden
  584. **/
  585. export class _TimeToken {
  586. _startTimeQuery: Nullable<WebGLQuery>;
  587. _endTimeQuery: Nullable<WebGLQuery>;
  588. _timeElapsedQuery: Nullable<WebGLQuery>;
  589. _timeElapsedQueryEnded: boolean;
  590. }
  591. }
  592. declare module BABYLON {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and mip = nearest */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  774. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** nearest is mag = nearest and min = nearest and mip = linear */
  778. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  779. /** Bilinear is mag = linear and min = linear and mip = nearest */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** mag = nearest and min = nearest and mip = none */
  792. static readonly TEXTURE_NEAREST_NEAREST: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** mag = linear and min = linear and mip = none */
  798. static readonly TEXTURE_LINEAR_LINEAR: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module BABYLON {
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module BABYLON {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module BABYLON {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. get underlyingResource(): any;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export interface ProcessingOptions {
  1150. defines: string[];
  1151. indexParameters: any;
  1152. isFragment: boolean;
  1153. shouldUseHighPrecisionShader: boolean;
  1154. supportsUniformBuffers: boolean;
  1155. shadersRepository: string;
  1156. includesShadersStore: {
  1157. [key: string]: string;
  1158. };
  1159. processor?: IShaderProcessor;
  1160. version: string;
  1161. platformName: string;
  1162. lookForClosingBracketForUniformBuffer?: boolean;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeNode {
  1168. line: string;
  1169. children: ShaderCodeNode[];
  1170. additionalDefineKey?: string;
  1171. additionalDefineValue?: string;
  1172. isValid(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderCodeCursor {
  1183. private _lines;
  1184. lineIndex: number;
  1185. get currentLine(): string;
  1186. get canRead(): boolean;
  1187. set lines(value: string[]);
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1193. process(preprocessors: {
  1194. [key: string]: string;
  1195. }, options: ProcessingOptions): string;
  1196. }
  1197. }
  1198. declare module BABYLON {
  1199. /** @hidden */
  1200. export class ShaderDefineExpression {
  1201. isTrue(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. not: boolean;
  1220. constructor(define: string, not?: boolean);
  1221. isTrue(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module BABYLON {
  1237. /** @hidden */
  1238. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1239. leftOperand: ShaderDefineExpression;
  1240. rightOperand: ShaderDefineExpression;
  1241. isTrue(preprocessors: {
  1242. [key: string]: string;
  1243. }): boolean;
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /** @hidden */
  1248. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1249. define: string;
  1250. operand: string;
  1251. testValue: string;
  1252. constructor(define: string, operand: string, testValue: string);
  1253. isTrue(preprocessors: {
  1254. [key: string]: string;
  1255. }): boolean;
  1256. }
  1257. }
  1258. declare module BABYLON {
  1259. /**
  1260. * Class used to enable access to offline support
  1261. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1262. */
  1263. export interface IOfflineProvider {
  1264. /**
  1265. * Gets a boolean indicating if scene must be saved in the database
  1266. */
  1267. enableSceneOffline: boolean;
  1268. /**
  1269. * Gets a boolean indicating if textures must be saved in the database
  1270. */
  1271. enableTexturesOffline: boolean;
  1272. /**
  1273. * Open the offline support and make it available
  1274. * @param successCallback defines the callback to call on success
  1275. * @param errorCallback defines the callback to call on error
  1276. */
  1277. open(successCallback: () => void, errorCallback: () => void): void;
  1278. /**
  1279. * Loads an image from the offline support
  1280. * @param url defines the url to load from
  1281. * @param image defines the target DOM image
  1282. */
  1283. loadImage(url: string, image: HTMLImageElement): void;
  1284. /**
  1285. * Loads a file from offline support
  1286. * @param url defines the URL to load from
  1287. * @param sceneLoaded defines a callback to call on success
  1288. * @param progressCallBack defines a callback to call when progress changed
  1289. * @param errorCallback defines a callback to call on error
  1290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1291. */
  1292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to help managing file picking and drag'n'drop
  1298. * File Storage
  1299. */
  1300. export class FilesInputStore {
  1301. /**
  1302. * List of files ready to be loaded
  1303. */
  1304. static FilesToLoad: {
  1305. [key: string]: File;
  1306. };
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * Class used to define a retry strategy when error happens while loading assets
  1312. */
  1313. export class RetryStrategy {
  1314. /**
  1315. * Function used to defines an exponential back off strategy
  1316. * @param maxRetries defines the maximum number of retries (3 by default)
  1317. * @param baseInterval defines the interval between retries
  1318. * @returns the strategy function to use
  1319. */
  1320. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /**
  1325. * @ignore
  1326. * Application error to support additional information when loading a file
  1327. */
  1328. export abstract class BaseError extends Error {
  1329. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1330. }
  1331. }
  1332. declare module BABYLON {
  1333. /** @ignore */
  1334. export class LoadFileError extends BaseError {
  1335. request?: WebRequest;
  1336. file?: File;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. * @param file defines the optional file
  1342. */
  1343. constructor(message: string, object?: WebRequest | File);
  1344. }
  1345. /** @ignore */
  1346. export class RequestFileError extends BaseError {
  1347. request: WebRequest;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. */
  1353. constructor(message: string, request: WebRequest);
  1354. }
  1355. /** @ignore */
  1356. export class ReadFileError extends BaseError {
  1357. file: File;
  1358. /**
  1359. * Creates a new ReadFileError
  1360. * @param message defines the message of the error
  1361. * @param file defines the optional file
  1362. */
  1363. constructor(message: string, file: File);
  1364. }
  1365. /**
  1366. * @hidden
  1367. */
  1368. export class FileTools {
  1369. /**
  1370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1371. */
  1372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1373. /**
  1374. * Gets or sets the base URL to use to load assets
  1375. */
  1376. static BaseUrl: string;
  1377. /**
  1378. * Default behaviour for cors in the application.
  1379. * It can be a string if the expected behavior is identical in the entire app.
  1380. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1381. */
  1382. static CorsBehavior: string | ((url: string | string[]) => string);
  1383. /**
  1384. * Gets or sets a function used to pre-process url before using them to load assets
  1385. */
  1386. static PreprocessUrl: (url: string) => string;
  1387. /**
  1388. * Removes unwanted characters from an url
  1389. * @param url defines the url to clean
  1390. * @returns the cleaned url
  1391. */
  1392. private static _CleanUrl;
  1393. /**
  1394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1395. * @param url define the url we are trying
  1396. * @param element define the dom element where to configure the cors policy
  1397. */
  1398. static SetCorsBehavior(url: string | string[], element: {
  1399. crossOrigin: string | null;
  1400. }): void;
  1401. /**
  1402. * Loads an image as an HTMLImageElement.
  1403. * @param input url string, ArrayBuffer, or Blob to load
  1404. * @param onLoad callback called when the image successfully loads
  1405. * @param onError callback called when the image fails to load
  1406. * @param offlineProvider offline provider for caching
  1407. * @param mimeType optional mime type
  1408. * @returns the HTMLImageElement of the loaded image
  1409. */
  1410. 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>;
  1411. /**
  1412. * Reads a file from a File object
  1413. * @param file defines the file to load
  1414. * @param onSuccess defines the callback to call when data is loaded
  1415. * @param onProgress defines the callback to call during loading process
  1416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1417. * @param onError defines the callback to call when an error occurs
  1418. * @returns a file request object
  1419. */
  1420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file from a url
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param offlineProvider defines the offline provider for caching
  1427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1428. * @param onError callback called when the file fails to load
  1429. * @returns a file request object
  1430. */
  1431. 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;
  1432. /**
  1433. * Loads a file
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1438. * @param onError callback called when the file fails to load
  1439. * @param onOpened callback called when the web request is opened
  1440. * @returns a file request object
  1441. */
  1442. 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;
  1443. /**
  1444. * Checks if the loaded document was accessed via `file:`-Protocol.
  1445. * @returns boolean
  1446. */
  1447. static IsFileURL(): boolean;
  1448. }
  1449. }
  1450. declare module BABYLON {
  1451. /** @hidden */
  1452. export class ShaderProcessor {
  1453. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1454. private static _ProcessPrecision;
  1455. private static _ExtractOperation;
  1456. private static _BuildSubExpression;
  1457. private static _BuildExpression;
  1458. private static _MoveCursorWithinIf;
  1459. private static _MoveCursor;
  1460. private static _EvaluatePreProcessors;
  1461. private static _PreparePreProcessors;
  1462. private static _ProcessShaderConversion;
  1463. private static _ProcessIncludes;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /**
  1468. * @hidden
  1469. */
  1470. export interface IColor4Like {
  1471. r: float;
  1472. g: float;
  1473. b: float;
  1474. a: float;
  1475. }
  1476. /**
  1477. * @hidden
  1478. */
  1479. export interface IColor3Like {
  1480. r: float;
  1481. g: float;
  1482. b: float;
  1483. }
  1484. /**
  1485. * @hidden
  1486. */
  1487. export interface IVector4Like {
  1488. x: float;
  1489. y: float;
  1490. z: float;
  1491. w: float;
  1492. }
  1493. /**
  1494. * @hidden
  1495. */
  1496. export interface IVector3Like {
  1497. x: float;
  1498. y: float;
  1499. z: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IVector2Like {
  1505. x: float;
  1506. y: float;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IMatrixLike {
  1512. toArray(): DeepImmutable<Float32Array>;
  1513. updateFlag: int;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IViewportLike {
  1519. x: float;
  1520. y: float;
  1521. width: float;
  1522. height: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IPlaneLike {
  1528. normal: IVector3Like;
  1529. d: float;
  1530. normalize(): void;
  1531. }
  1532. }
  1533. declare module BABYLON {
  1534. /**
  1535. * Interface used to define common properties for effect fallbacks
  1536. */
  1537. export interface IEffectFallbacks {
  1538. /**
  1539. * Removes the defines that should be removed when falling back.
  1540. * @param currentDefines defines the current define statements for the shader.
  1541. * @param effect defines the current effect we try to compile
  1542. * @returns The resulting defines with defines of the current rank removed.
  1543. */
  1544. reduce(currentDefines: string, effect: Effect): string;
  1545. /**
  1546. * Removes the fallback from the bound mesh.
  1547. */
  1548. unBindMesh(): void;
  1549. /**
  1550. * Checks to see if more fallbacks are still availible.
  1551. */
  1552. hasMoreFallbacks: boolean;
  1553. }
  1554. }
  1555. declare module BABYLON {
  1556. /**
  1557. * Class used to evalaute queries containing `and` and `or` operators
  1558. */
  1559. export class AndOrNotEvaluator {
  1560. /**
  1561. * Evaluate a query
  1562. * @param query defines the query to evaluate
  1563. * @param evaluateCallback defines the callback used to filter result
  1564. * @returns true if the query matches
  1565. */
  1566. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1567. private static _HandleParenthesisContent;
  1568. private static _SimplifyNegation;
  1569. }
  1570. }
  1571. declare module BABYLON {
  1572. /**
  1573. * Class used to store custom tags
  1574. */
  1575. export class Tags {
  1576. /**
  1577. * Adds support for tags on the given object
  1578. * @param obj defines the object to use
  1579. */
  1580. static EnableFor(obj: any): void;
  1581. /**
  1582. * Removes tags support
  1583. * @param obj defines the object to use
  1584. */
  1585. static DisableFor(obj: any): void;
  1586. /**
  1587. * Gets a boolean indicating if the given object has tags
  1588. * @param obj defines the object to use
  1589. * @returns a boolean
  1590. */
  1591. static HasTags(obj: any): boolean;
  1592. /**
  1593. * Gets the tags available on a given object
  1594. * @param obj defines the object to use
  1595. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1596. * @returns the tags
  1597. */
  1598. static GetTags(obj: any, asString?: boolean): any;
  1599. /**
  1600. * Adds tags to an object
  1601. * @param obj defines the object to use
  1602. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1603. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1604. */
  1605. static AddTagsTo(obj: any, tagsString: string): void;
  1606. /**
  1607. * @hidden
  1608. */
  1609. static _AddTagTo(obj: any, tag: string): void;
  1610. /**
  1611. * Removes specific tags from a specific object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tags to remove
  1614. */
  1615. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1616. /**
  1617. * @hidden
  1618. */
  1619. static _RemoveTagFrom(obj: any, tag: string): void;
  1620. /**
  1621. * Defines if tags hosted on an object match a given query
  1622. * @param obj defines the object to use
  1623. * @param tagsQuery defines the tag query
  1624. * @returns a boolean
  1625. */
  1626. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1627. }
  1628. }
  1629. declare module BABYLON {
  1630. /**
  1631. * Scalar computation library
  1632. */
  1633. export class Scalar {
  1634. /**
  1635. * Two pi constants convenient for computation.
  1636. */
  1637. static TwoPi: number;
  1638. /**
  1639. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1640. * @param a number
  1641. * @param b number
  1642. * @param epsilon (default = 1.401298E-45)
  1643. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1644. */
  1645. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1646. /**
  1647. * Returns a string : the upper case translation of the number i to hexadecimal.
  1648. * @param i number
  1649. * @returns the upper case translation of the number i to hexadecimal.
  1650. */
  1651. static ToHex(i: number): string;
  1652. /**
  1653. * Returns -1 if value is negative and +1 is value is positive.
  1654. * @param value the value
  1655. * @returns the value itself if it's equal to zero.
  1656. */
  1657. static Sign(value: number): number;
  1658. /**
  1659. * Returns the value itself if it's between min and max.
  1660. * Returns min if the value is lower than min.
  1661. * Returns max if the value is greater than max.
  1662. * @param value the value to clmap
  1663. * @param min the min value to clamp to (default: 0)
  1664. * @param max the max value to clamp to (default: 1)
  1665. * @returns the clamped value
  1666. */
  1667. static Clamp(value: number, min?: number, max?: number): number;
  1668. /**
  1669. * the log2 of value.
  1670. * @param value the value to compute log2 of
  1671. * @returns the log2 of value.
  1672. */
  1673. static Log2(value: number): number;
  1674. /**
  1675. * Loops the value, so that it is never larger than length and never smaller than 0.
  1676. *
  1677. * This is similar to the modulo operator but it works with floating point numbers.
  1678. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1679. * With t = 5 and length = 2.5, the result would be 0.0.
  1680. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1681. * @param value the value
  1682. * @param length the length
  1683. * @returns the looped value
  1684. */
  1685. static Repeat(value: number, length: number): number;
  1686. /**
  1687. * Normalize the value between 0.0 and 1.0 using min and max values
  1688. * @param value value to normalize
  1689. * @param min max to normalize between
  1690. * @param max min to normalize between
  1691. * @returns the normalized value
  1692. */
  1693. static Normalize(value: number, min: number, max: number): number;
  1694. /**
  1695. * Denormalize the value from 0.0 and 1.0 using min and max values
  1696. * @param normalized value to denormalize
  1697. * @param min max to denormalize between
  1698. * @param max min to denormalize between
  1699. * @returns the denormalized value
  1700. */
  1701. static Denormalize(normalized: number, min: number, max: number): number;
  1702. /**
  1703. * Calculates the shortest difference between two given angles given in degrees.
  1704. * @param current current angle in degrees
  1705. * @param target target angle in degrees
  1706. * @returns the delta
  1707. */
  1708. static DeltaAngle(current: number, target: number): number;
  1709. /**
  1710. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1711. * @param tx value
  1712. * @param length length
  1713. * @returns The returned value will move back and forth between 0 and length
  1714. */
  1715. static PingPong(tx: number, length: number): number;
  1716. /**
  1717. * Interpolates between min and max with smoothing at the limits.
  1718. *
  1719. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1720. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1721. * @param from from
  1722. * @param to to
  1723. * @param tx value
  1724. * @returns the smooth stepped value
  1725. */
  1726. static SmoothStep(from: number, to: number, tx: number): number;
  1727. /**
  1728. * Moves a value current towards target.
  1729. *
  1730. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1731. * Negative values of maxDelta pushes the value away from target.
  1732. * @param current current value
  1733. * @param target target value
  1734. * @param maxDelta max distance to move
  1735. * @returns resulting value
  1736. */
  1737. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1738. /**
  1739. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1740. *
  1741. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1742. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting angle
  1747. */
  1748. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1751. * @param start start value
  1752. * @param end target value
  1753. * @param amount amount to lerp between
  1754. * @returns the lerped value
  1755. */
  1756. static Lerp(start: number, end: number, amount: number): number;
  1757. /**
  1758. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1760. * @param start start value
  1761. * @param end target value
  1762. * @param amount amount to lerp between
  1763. * @returns the lerped value
  1764. */
  1765. static LerpAngle(start: number, end: number, amount: number): number;
  1766. /**
  1767. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1768. * @param a start value
  1769. * @param b target value
  1770. * @param value value between a and b
  1771. * @returns the inverseLerp value
  1772. */
  1773. static InverseLerp(a: number, b: number, value: number): number;
  1774. /**
  1775. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1776. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1777. * @param value1 spline value
  1778. * @param tangent1 spline value
  1779. * @param value2 spline value
  1780. * @param tangent2 spline value
  1781. * @param amount input value
  1782. * @returns hermite result
  1783. */
  1784. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1785. /**
  1786. * Returns a random float number between and min and max values
  1787. * @param min min value of random
  1788. * @param max max value of random
  1789. * @returns random value
  1790. */
  1791. static RandomRange(min: number, max: number): number;
  1792. /**
  1793. * This function returns percentage of a number in a given range.
  1794. *
  1795. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1796. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1797. * @param number to convert to percentage
  1798. * @param min min range
  1799. * @param max max range
  1800. * @returns the percentage
  1801. */
  1802. static RangeToPercent(number: number, min: number, max: number): number;
  1803. /**
  1804. * This function returns number that corresponds to the percentage in a given range.
  1805. *
  1806. * PercentToRange(0.34,0,100) will return 34.
  1807. * @param percent to convert to number
  1808. * @param min min range
  1809. * @param max max range
  1810. * @returns the number
  1811. */
  1812. static PercentToRange(percent: number, min: number, max: number): number;
  1813. /**
  1814. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1815. * @param angle The angle to normalize in radian.
  1816. * @return The converted angle.
  1817. */
  1818. static NormalizeRadians(angle: number): number;
  1819. }
  1820. }
  1821. declare module BABYLON {
  1822. /**
  1823. * Constant used to convert a value to gamma space
  1824. * @ignorenaming
  1825. */
  1826. export const ToGammaSpace: number;
  1827. /**
  1828. * Constant used to convert a value to linear space
  1829. * @ignorenaming
  1830. */
  1831. export const ToLinearSpace = 2.2;
  1832. /**
  1833. * Constant used to define the minimal number value in Babylon.js
  1834. * @ignorenaming
  1835. */
  1836. let Epsilon: number;
  1837. }
  1838. declare module BABYLON {
  1839. /**
  1840. * Class used to represent a viewport on screen
  1841. */
  1842. export class Viewport {
  1843. /** viewport left coordinate */
  1844. x: number;
  1845. /** viewport top coordinate */
  1846. y: number;
  1847. /**viewport width */
  1848. width: number;
  1849. /** viewport height */
  1850. height: number;
  1851. /**
  1852. * Creates a Viewport object located at (x, y) and sized (width, height)
  1853. * @param x defines viewport left coordinate
  1854. * @param y defines viewport top coordinate
  1855. * @param width defines the viewport width
  1856. * @param height defines the viewport height
  1857. */
  1858. constructor(
  1859. /** viewport left coordinate */
  1860. x: number,
  1861. /** viewport top coordinate */
  1862. y: number,
  1863. /**viewport width */
  1864. width: number,
  1865. /** viewport height */
  1866. height: number);
  1867. /**
  1868. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @returns a new Viewport
  1872. */
  1873. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1874. /**
  1875. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1876. * @param renderWidth defines the rendering width
  1877. * @param renderHeight defines the rendering height
  1878. * @param ref defines the target viewport
  1879. * @returns the current viewport
  1880. */
  1881. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1882. /**
  1883. * Returns a new Viewport copied from the current one
  1884. * @returns a new Viewport
  1885. */
  1886. clone(): Viewport;
  1887. }
  1888. }
  1889. declare module BABYLON {
  1890. /**
  1891. * Class containing a set of static utilities functions for arrays.
  1892. */
  1893. export class ArrayTools {
  1894. /**
  1895. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1896. * @param size the number of element to construct and put in the array
  1897. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1898. * @returns a new array filled with new objects
  1899. */
  1900. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1901. }
  1902. }
  1903. declare module BABYLON {
  1904. /**
  1905. * Class representing a vector containing 2 coordinates
  1906. */
  1907. export class Vector2 {
  1908. /** defines the first coordinate */
  1909. x: number;
  1910. /** defines the second coordinate */
  1911. y: number;
  1912. /**
  1913. * Creates a new Vector2 from the given x and y coordinates
  1914. * @param x defines the first coordinate
  1915. * @param y defines the second coordinate
  1916. */
  1917. constructor(
  1918. /** defines the first coordinate */
  1919. x?: number,
  1920. /** defines the second coordinate */
  1921. y?: number);
  1922. /**
  1923. * Gets a string with the Vector2 coordinates
  1924. * @returns a string with the Vector2 coordinates
  1925. */
  1926. toString(): string;
  1927. /**
  1928. * Gets class name
  1929. * @returns the string "Vector2"
  1930. */
  1931. getClassName(): string;
  1932. /**
  1933. * Gets current vector hash code
  1934. * @returns the Vector2 hash code as a number
  1935. */
  1936. getHashCode(): number;
  1937. /**
  1938. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1939. * @param array defines the source array
  1940. * @param index defines the offset in source array
  1941. * @returns the current Vector2
  1942. */
  1943. toArray(array: FloatArray, index?: number): Vector2;
  1944. /**
  1945. * Copy the current vector to an array
  1946. * @returns a new array with 2 elements: the Vector2 coordinates.
  1947. */
  1948. asArray(): number[];
  1949. /**
  1950. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1951. * @param source defines the source Vector2
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. copyFromFloats(x: number, y: number): Vector2;
  1962. /**
  1963. * Sets the Vector2 coordinates with the given floats
  1964. * @param x defines the first coordinate
  1965. * @param y defines the second coordinate
  1966. * @returns the current updated Vector2
  1967. */
  1968. set(x: number, y: number): Vector2;
  1969. /**
  1970. * Add another vector with the current one
  1971. * @param otherVector defines the other vector
  1972. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1973. */
  1974. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1975. /**
  1976. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1977. * @param otherVector defines the other vector
  1978. * @param result defines the target vector
  1979. * @returns the unmodified current Vector2
  1980. */
  1981. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1982. /**
  1983. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns the current updated Vector2
  1986. */
  1987. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1988. /**
  1989. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. addVector3(otherVector: Vector3): Vector2;
  1994. /**
  1995. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1996. * @param otherVector defines the other vector
  1997. * @returns a new Vector2
  1998. */
  1999. subtract(otherVector: Vector2): Vector2;
  2000. /**
  2001. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2002. * @param otherVector defines the other vector
  2003. * @param result defines the target vector
  2004. * @returns the unmodified current Vector2
  2005. */
  2006. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2007. /**
  2008. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Multiplies in place the current Vector2 coordinates by the given ones
  2015. * @param otherVector defines the other vector
  2016. * @returns the current updated Vector2
  2017. */
  2018. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns a new Vector2
  2023. */
  2024. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2027. * @param otherVector defines the other vector
  2028. * @param result defines the target vector
  2029. * @returns the unmodified current Vector2
  2030. */
  2031. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2032. /**
  2033. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2034. * @param x defines the first coordinate
  2035. * @param y defines the second coordinate
  2036. * @returns a new Vector2
  2037. */
  2038. multiplyByFloats(x: number, y: number): Vector2;
  2039. /**
  2040. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @returns a new Vector2
  2043. */
  2044. divide(otherVector: Vector2): Vector2;
  2045. /**
  2046. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2047. * @param otherVector defines the other vector
  2048. * @param result defines the target vector
  2049. * @returns the unmodified current Vector2
  2050. */
  2051. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2052. /**
  2053. * Divides the current Vector2 coordinates by the given ones
  2054. * @param otherVector defines the other vector
  2055. * @returns the current updated Vector2
  2056. */
  2057. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2058. /**
  2059. * Gets a new Vector2 with current Vector2 negated coordinates
  2060. * @returns a new Vector2
  2061. */
  2062. negate(): Vector2;
  2063. /**
  2064. * Multiply the Vector2 coordinates by scale
  2065. * @param scale defines the scaling factor
  2066. * @returns the current updated Vector2
  2067. */
  2068. scaleInPlace(scale: number): Vector2;
  2069. /**
  2070. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2071. * @param scale defines the scaling factor
  2072. * @returns a new Vector2
  2073. */
  2074. scale(scale: number): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2084. * @param scale defines the scale factor
  2085. * @param result defines the Vector2 object where to store the result
  2086. * @returns the unmodified current Vector2
  2087. */
  2088. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2089. /**
  2090. * Gets a boolean if two vectors are equals
  2091. * @param otherVector defines the other vector
  2092. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2093. */
  2094. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2095. /**
  2096. * Gets a boolean if two vectors are equals (using an epsilon value)
  2097. * @param otherVector defines the other vector
  2098. * @param epsilon defines the minimal distance to consider equality
  2099. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2100. */
  2101. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2102. /**
  2103. * Gets a new Vector2 from current Vector2 floored values
  2104. * @returns a new Vector2
  2105. */
  2106. floor(): Vector2;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. fract(): Vector2;
  2112. /**
  2113. * Gets the length of the vector
  2114. * @returns the vector length (float)
  2115. */
  2116. length(): number;
  2117. /**
  2118. * Gets the vector squared length
  2119. * @returns the vector squared length (float)
  2120. */
  2121. lengthSquared(): number;
  2122. /**
  2123. * Normalize the vector
  2124. * @returns the current updated Vector2
  2125. */
  2126. normalize(): Vector2;
  2127. /**
  2128. * Gets a new Vector2 copied from the Vector2
  2129. * @returns a new Vector2
  2130. */
  2131. clone(): Vector2;
  2132. /**
  2133. * Gets a new Vector2(0, 0)
  2134. * @returns a new Vector2
  2135. */
  2136. static Zero(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(1, 1)
  2139. * @returns a new Vector2
  2140. */
  2141. static One(): Vector2;
  2142. /**
  2143. * Gets a new Vector2 set from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @returns a new Vector2
  2147. */
  2148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2149. /**
  2150. * Sets "result" from the given index element of the given array
  2151. * @param array defines the data source
  2152. * @param offset defines the offset in the data source
  2153. * @param result defines the target vector
  2154. */
  2155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2156. /**
  2157. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2158. * @param value1 defines 1st point of control
  2159. * @param value2 defines 2nd point of control
  2160. * @param value3 defines 3rd point of control
  2161. * @param value4 defines 4th point of control
  2162. * @param amount defines the interpolation factor
  2163. * @returns a new Vector2
  2164. */
  2165. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2166. /**
  2167. * 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".
  2168. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2169. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2170. * @param value defines the value to clamp
  2171. * @param min defines the lower limit
  2172. * @param max defines the upper limit
  2173. * @returns a new Vector2
  2174. */
  2175. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2176. /**
  2177. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2178. * @param value1 defines the 1st control point
  2179. * @param tangent1 defines the outgoing tangent
  2180. * @param value2 defines the 2nd control point
  2181. * @param tangent2 defines the incoming tangent
  2182. * @param amount defines the interpolation factor
  2183. * @returns a new Vector2
  2184. */
  2185. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2186. /**
  2187. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2188. * @param start defines the start vector
  2189. * @param end defines the end vector
  2190. * @param amount defines the interpolation factor
  2191. * @returns a new Vector2
  2192. */
  2193. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2194. /**
  2195. * Gets the dot product of the vector "left" and the vector "right"
  2196. * @param left defines first vector
  2197. * @param right defines second vector
  2198. * @returns the dot product (float)
  2199. */
  2200. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2201. /**
  2202. * Returns a new Vector2 equal to the normalized given vector
  2203. * @param vector defines the vector to normalize
  2204. * @returns a new Vector2
  2205. */
  2206. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2216. * @param left defines 1st vector
  2217. * @param right defines 2nd vector
  2218. * @returns a new Vector2
  2219. */
  2220. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @returns a new Vector2
  2226. */
  2227. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2228. /**
  2229. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2230. * @param vector defines the vector to transform
  2231. * @param transformation defines the matrix to apply
  2232. * @param result defines the target vector
  2233. */
  2234. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2235. /**
  2236. * Determines if a given vector is included in a triangle
  2237. * @param p defines the vector to test
  2238. * @param p0 defines 1st triangle point
  2239. * @param p1 defines 2nd triangle point
  2240. * @param p2 defines 3rd triangle point
  2241. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2242. */
  2243. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2244. /**
  2245. * Gets the distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the distance between vectors
  2249. */
  2250. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Returns the squared distance between the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns the squared distance between vectors
  2256. */
  2257. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2258. /**
  2259. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns a new Vector2
  2263. */
  2264. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2265. /**
  2266. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2267. * @param p defines the middle point
  2268. * @param segA defines one point of the segment
  2269. * @param segB defines the other point of the segment
  2270. * @returns the shortest distance
  2271. */
  2272. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2273. }
  2274. /**
  2275. * Class used to store (x,y,z) vector representation
  2276. * A Vector3 is the main object used in 3D geometry
  2277. * It can represent etiher the coordinates of a point the space, either a direction
  2278. * Reminder: js uses a left handed forward facing system
  2279. */
  2280. export class Vector3 {
  2281. /**
  2282. * Defines the first coordinates (on X axis)
  2283. */
  2284. x: number;
  2285. /**
  2286. * Defines the second coordinates (on Y axis)
  2287. */
  2288. y: number;
  2289. /**
  2290. * Defines the third coordinates (on Z axis)
  2291. */
  2292. z: number;
  2293. private static _UpReadOnly;
  2294. private static _ZeroReadOnly;
  2295. /**
  2296. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2297. * @param x defines the first coordinates (on X axis)
  2298. * @param y defines the second coordinates (on Y axis)
  2299. * @param z defines the third coordinates (on Z axis)
  2300. */
  2301. constructor(
  2302. /**
  2303. * Defines the first coordinates (on X axis)
  2304. */
  2305. x?: number,
  2306. /**
  2307. * Defines the second coordinates (on Y axis)
  2308. */
  2309. y?: number,
  2310. /**
  2311. * Defines the third coordinates (on Z axis)
  2312. */
  2313. z?: number);
  2314. /**
  2315. * Creates a string representation of the Vector3
  2316. * @returns a string with the Vector3 coordinates.
  2317. */
  2318. toString(): string;
  2319. /**
  2320. * Gets the class name
  2321. * @returns the string "Vector3"
  2322. */
  2323. getClassName(): string;
  2324. /**
  2325. * Creates the Vector3 hash code
  2326. * @returns a number which tends to be unique between Vector3 instances
  2327. */
  2328. getHashCode(): number;
  2329. /**
  2330. * Creates an array containing three elements : the coordinates of the Vector3
  2331. * @returns a new array of numbers
  2332. */
  2333. asArray(): number[];
  2334. /**
  2335. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2336. * @param array defines the destination array
  2337. * @param index defines the offset in the destination array
  2338. * @returns the current Vector3
  2339. */
  2340. toArray(array: FloatArray, index?: number): Vector3;
  2341. /**
  2342. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2343. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2344. */
  2345. toQuaternion(): Quaternion;
  2346. /**
  2347. * Adds the given vector to the current Vector3
  2348. * @param otherVector defines the second operand
  2349. * @returns the current updated Vector3
  2350. */
  2351. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2352. /**
  2353. * Adds the given coordinates to the current Vector3
  2354. * @param x defines the x coordinate of the operand
  2355. * @param y defines the y coordinate of the operand
  2356. * @param z defines the z coordinate of the operand
  2357. * @returns the current updated Vector3
  2358. */
  2359. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2360. /**
  2361. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2362. * @param otherVector defines the second operand
  2363. * @returns the resulting Vector3
  2364. */
  2365. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2368. * @param otherVector defines the second operand
  2369. * @param result defines the Vector3 object where to store the result
  2370. * @returns the current Vector3
  2371. */
  2372. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2373. /**
  2374. * Subtract the given vector from the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2381. * @param otherVector defines the second operand
  2382. * @returns the resulting Vector3
  2383. */
  2384. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2387. * @param otherVector defines the second operand
  2388. * @param result defines the Vector3 object where to store the result
  2389. * @returns the current Vector3
  2390. */
  2391. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2392. /**
  2393. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2394. * @param x defines the x coordinate of the operand
  2395. * @param y defines the y coordinate of the operand
  2396. * @param z defines the z coordinate of the operand
  2397. * @returns the resulting Vector3
  2398. */
  2399. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2400. /**
  2401. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2402. * @param x defines the x coordinate of the operand
  2403. * @param y defines the y coordinate of the operand
  2404. * @param z defines the z coordinate of the operand
  2405. * @param result defines the Vector3 object where to store the result
  2406. * @returns the current Vector3
  2407. */
  2408. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2409. /**
  2410. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2411. * @returns a new Vector3
  2412. */
  2413. negate(): Vector3;
  2414. /**
  2415. * Multiplies the Vector3 coordinates by the float "scale"
  2416. * @param scale defines the multiplier factor
  2417. * @returns the current updated Vector3
  2418. */
  2419. scaleInPlace(scale: number): Vector3;
  2420. /**
  2421. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2422. * @param scale defines the multiplier factor
  2423. * @returns a new Vector3
  2424. */
  2425. scale(scale: number): Vector3;
  2426. /**
  2427. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2428. * @param scale defines the multiplier factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the current Vector3
  2431. */
  2432. scaleToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2435. * @param scale defines the scale factor
  2436. * @param result defines the Vector3 object where to store the result
  2437. * @returns the unmodified current Vector3
  2438. */
  2439. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2440. /**
  2441. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2442. * @param otherVector defines the second operand
  2443. * @returns true if both vectors are equals
  2444. */
  2445. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2448. * @param otherVector defines the second operand
  2449. * @param epsilon defines the minimal distance to define values as equals
  2450. * @returns true if both vectors are distant less than epsilon
  2451. */
  2452. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2453. /**
  2454. * Returns true if the current Vector3 coordinates equals the given floats
  2455. * @param x defines the x coordinate of the operand
  2456. * @param y defines the y coordinate of the operand
  2457. * @param z defines the z coordinate of the operand
  2458. * @returns true if both vectors are equals
  2459. */
  2460. equalsToFloats(x: number, y: number, z: number): boolean;
  2461. /**
  2462. * Multiplies the current Vector3 coordinates by the given ones
  2463. * @param otherVector defines the second operand
  2464. * @returns the current updated Vector3
  2465. */
  2466. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2467. /**
  2468. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2469. * @param otherVector defines the second operand
  2470. * @returns the new Vector3
  2471. */
  2472. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2473. /**
  2474. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2475. * @param otherVector defines the second operand
  2476. * @param result defines the Vector3 object where to store the result
  2477. * @returns the current Vector3
  2478. */
  2479. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2480. /**
  2481. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2482. * @param x defines the x coordinate of the operand
  2483. * @param y defines the y coordinate of the operand
  2484. * @param z defines the z coordinate of the operand
  2485. * @returns the new Vector3
  2486. */
  2487. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2488. /**
  2489. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2490. * @param otherVector defines the second operand
  2491. * @returns the new Vector3
  2492. */
  2493. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2496. * @param otherVector defines the second operand
  2497. * @param result defines the Vector3 object where to store the result
  2498. * @returns the current Vector3
  2499. */
  2500. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2501. /**
  2502. * Divides the current Vector3 coordinates by the given ones.
  2503. * @param otherVector defines the second operand
  2504. * @returns the current updated Vector3
  2505. */
  2506. divideInPlace(otherVector: Vector3): Vector3;
  2507. /**
  2508. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2509. * @param other defines the second operand
  2510. * @returns the current updated Vector3
  2511. */
  2512. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2513. /**
  2514. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2515. * @param other defines the second operand
  2516. * @returns the current updated Vector3
  2517. */
  2518. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2521. * @param x defines the x coordinate of the operand
  2522. * @param y defines the y coordinate of the operand
  2523. * @param z defines the z coordinate of the operand
  2524. * @returns the current updated Vector3
  2525. */
  2526. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2527. /**
  2528. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2529. * @param x defines the x coordinate of the operand
  2530. * @param y defines the y coordinate of the operand
  2531. * @param z defines the z coordinate of the operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2535. /**
  2536. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2537. * Check if is non uniform within a certain amount of decimal places to account for this
  2538. * @param epsilon the amount the values can differ
  2539. * @returns if the the vector is non uniform to a certain number of decimal places
  2540. */
  2541. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2542. /**
  2543. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2544. */
  2545. get isNonUniform(): boolean;
  2546. /**
  2547. * Gets a new Vector3 from current Vector3 floored values
  2548. * @returns a new Vector3
  2549. */
  2550. floor(): Vector3;
  2551. /**
  2552. * Gets a new Vector3 from current Vector3 floored values
  2553. * @returns a new Vector3
  2554. */
  2555. fract(): Vector3;
  2556. /**
  2557. * Gets the length of the Vector3
  2558. * @returns the length of the Vector3
  2559. */
  2560. length(): number;
  2561. /**
  2562. * Gets the squared length of the Vector3
  2563. * @returns squared length of the Vector3
  2564. */
  2565. lengthSquared(): number;
  2566. /**
  2567. * Normalize the current Vector3.
  2568. * Please note that this is an in place operation.
  2569. * @returns the current updated Vector3
  2570. */
  2571. normalize(): Vector3;
  2572. /**
  2573. * Reorders the x y z properties of the vector in place
  2574. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2575. * @returns the current updated vector
  2576. */
  2577. reorderInPlace(order: string): this;
  2578. /**
  2579. * Rotates the vector around 0,0,0 by a quaternion
  2580. * @param quaternion the rotation quaternion
  2581. * @param result vector to store the result
  2582. * @returns the resulting vector
  2583. */
  2584. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2585. /**
  2586. * Rotates a vector around a given point
  2587. * @param quaternion the rotation quaternion
  2588. * @param point the point to rotate around
  2589. * @param result vector to store the result
  2590. * @returns the resulting vector
  2591. */
  2592. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2593. /**
  2594. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2595. * The cross product is then orthogonal to both current and "other"
  2596. * @param other defines the right operand
  2597. * @returns the cross product
  2598. */
  2599. cross(other: Vector3): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 with the given input length.
  2602. * Please note that this is an in place operation.
  2603. * @param len the length of the vector
  2604. * @returns the current updated Vector3
  2605. */
  2606. normalizeFromLength(len: number): Vector3;
  2607. /**
  2608. * Normalize the current Vector3 to a new vector
  2609. * @returns the new Vector3
  2610. */
  2611. normalizeToNew(): Vector3;
  2612. /**
  2613. * Normalize the current Vector3 to the reference
  2614. * @param reference define the Vector3 to update
  2615. * @returns the updated Vector3
  2616. */
  2617. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2618. /**
  2619. * Creates a new Vector3 copied from the current Vector3
  2620. * @returns the new Vector3
  2621. */
  2622. clone(): Vector3;
  2623. /**
  2624. * Copies the given vector coordinates to the current Vector3 ones
  2625. * @param source defines the source Vector3
  2626. * @returns the current updated Vector3
  2627. */
  2628. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2629. /**
  2630. * Copies the given floats to the current Vector3 coordinates
  2631. * @param x defines the x coordinate of the operand
  2632. * @param y defines the y coordinate of the operand
  2633. * @param z defines the z coordinate of the operand
  2634. * @returns the current updated Vector3
  2635. */
  2636. copyFromFloats(x: number, y: number, z: number): Vector3;
  2637. /**
  2638. * Copies the given floats to the current Vector3 coordinates
  2639. * @param x defines the x coordinate of the operand
  2640. * @param y defines the y coordinate of the operand
  2641. * @param z defines the z coordinate of the operand
  2642. * @returns the current updated Vector3
  2643. */
  2644. set(x: number, y: number, z: number): Vector3;
  2645. /**
  2646. * Copies the given float to the current Vector3 coordinates
  2647. * @param v defines the x, y and z coordinates of the operand
  2648. * @returns the current updated Vector3
  2649. */
  2650. setAll(v: number): Vector3;
  2651. /**
  2652. * Get the clip factor between two vectors
  2653. * @param vector0 defines the first operand
  2654. * @param vector1 defines the second operand
  2655. * @param axis defines the axis to use
  2656. * @param size defines the size along the axis
  2657. * @returns the clip factor
  2658. */
  2659. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2660. /**
  2661. * Get angle between two vectors
  2662. * @param vector0 angle between vector0 and vector1
  2663. * @param vector1 angle between vector0 and vector1
  2664. * @param normal direction of the normal
  2665. * @return the angle between vector0 and vector1
  2666. */
  2667. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given array
  2670. * @param array defines the source array
  2671. * @param offset defines the offset in the source array
  2672. * @returns the new Vector3
  2673. */
  2674. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2675. /**
  2676. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2677. * @param array defines the source array
  2678. * @param offset defines the offset in the source array
  2679. * @returns the new Vector3
  2680. * @deprecated Please use FromArray instead.
  2681. */
  2682. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2685. * @param array defines the source array
  2686. * @param offset defines the offset in the source array
  2687. * @param result defines the Vector3 where to store the result
  2688. */
  2689. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2690. /**
  2691. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2692. * @param array defines the source array
  2693. * @param offset defines the offset in the source array
  2694. * @param result defines the Vector3 where to store the result
  2695. * @deprecated Please use FromArrayToRef instead.
  2696. */
  2697. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2698. /**
  2699. * Sets the given vector "result" with the given floats.
  2700. * @param x defines the x coordinate of the source
  2701. * @param y defines the y coordinate of the source
  2702. * @param z defines the z coordinate of the source
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2706. /**
  2707. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2708. * @returns a new empty Vector3
  2709. */
  2710. static Zero(): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2713. * @returns a new unit Vector3
  2714. */
  2715. static One(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2718. * @returns a new up Vector3
  2719. */
  2720. static Up(): Vector3;
  2721. /**
  2722. * Gets a up Vector3 that must not be updated
  2723. */
  2724. static get UpReadOnly(): DeepImmutable<Vector3>;
  2725. /**
  2726. * Gets a zero Vector3 that must not be updated
  2727. */
  2728. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2731. * @returns a new down Vector3
  2732. */
  2733. static Down(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2736. * @returns a new forward Vector3
  2737. */
  2738. static Forward(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2741. * @returns a new forward Vector3
  2742. */
  2743. static Backward(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2746. * @returns a new right Vector3
  2747. */
  2748. static Right(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2751. * @returns a new left Vector3
  2752. */
  2753. static Left(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2756. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2757. * @param vector defines the Vector3 to transform
  2758. * @param transformation defines the transformation matrix
  2759. * @returns the transformed Vector3
  2760. */
  2761. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2762. /**
  2763. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2764. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2765. * @param vector defines the Vector3 to transform
  2766. * @param transformation defines the transformation matrix
  2767. * @param result defines the Vector3 where to store the result
  2768. */
  2769. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2770. /**
  2771. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2772. * This method computes tranformed coordinates only, not transformed direction vectors
  2773. * @param x define the x coordinate of the source vector
  2774. * @param y define the y coordinate of the source vector
  2775. * @param z define the z coordinate of the source vector
  2776. * @param transformation defines the transformation matrix
  2777. * @param result defines the Vector3 where to store the result
  2778. */
  2779. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2780. /**
  2781. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2782. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2783. * @param vector defines the Vector3 to transform
  2784. * @param transformation defines the transformation matrix
  2785. * @returns the new Vector3
  2786. */
  2787. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2788. /**
  2789. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2790. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2791. * @param vector defines the Vector3 to transform
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param x define the x coordinate of the source vector
  2800. * @param y define the y coordinate of the source vector
  2801. * @param z define the z coordinate of the source vector
  2802. * @param transformation defines the transformation matrix
  2803. * @param result defines the Vector3 where to store the result
  2804. */
  2805. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2806. /**
  2807. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2808. * @param value1 defines the first control point
  2809. * @param value2 defines the second control point
  2810. * @param value3 defines the third control point
  2811. * @param value4 defines the fourth control point
  2812. * @param amount defines the amount on the spline to use
  2813. * @returns the new Vector3
  2814. */
  2815. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2816. /**
  2817. * 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"
  2818. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2819. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2820. * @param value defines the current value
  2821. * @param min defines the lower range value
  2822. * @param max defines the upper range value
  2823. * @returns the new Vector3
  2824. */
  2825. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2826. /**
  2827. * 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"
  2828. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2829. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2830. * @param value defines the current value
  2831. * @param min defines the lower range value
  2832. * @param max defines the upper range value
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2836. /**
  2837. * Checks if a given vector is inside a specific range
  2838. * @param v defines the vector to test
  2839. * @param min defines the minimum range
  2840. * @param max defines the maximum range
  2841. */
  2842. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2843. /**
  2844. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2845. * @param value1 defines the first control point
  2846. * @param tangent1 defines the first tangent vector
  2847. * @param value2 defines the second control point
  2848. * @param tangent2 defines the second tangent vector
  2849. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2850. * @returns the new Vector3
  2851. */
  2852. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2853. /**
  2854. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2855. * @param start defines the start value
  2856. * @param end defines the end value
  2857. * @param amount max defines amount between both (between 0 and 1)
  2858. * @returns the new Vector3
  2859. */
  2860. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2861. /**
  2862. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2863. * @param start defines the start value
  2864. * @param end defines the end value
  2865. * @param amount max defines amount between both (between 0 and 1)
  2866. * @param result defines the Vector3 where to store the result
  2867. */
  2868. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2869. /**
  2870. * Returns the dot product (float) between the vectors "left" and "right"
  2871. * @param left defines the left operand
  2872. * @param right defines the right operand
  2873. * @returns the dot product
  2874. */
  2875. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2876. /**
  2877. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2878. * The cross product is then orthogonal to both "left" and "right"
  2879. * @param left defines the left operand
  2880. * @param right defines the right operand
  2881. * @returns the cross product
  2882. */
  2883. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the cross product of "left" and "right"
  2886. * The cross product is then orthogonal to both "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 as the normalization of the given vector
  2894. * @param vector defines the Vector3 to normalize
  2895. * @returns the new Vector3
  2896. */
  2897. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2898. /**
  2899. * Sets the given vector "result" with the normalization of the given first vector
  2900. * @param vector defines the Vector3 to normalize
  2901. * @param result defines the Vector3 where to store the result
  2902. */
  2903. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2904. /**
  2905. * Project a Vector3 onto screen space
  2906. * @param vector defines the Vector3 to project
  2907. * @param world defines the world matrix to use
  2908. * @param transform defines the transform (view x projection) matrix to use
  2909. * @param viewport defines the screen viewport to use
  2910. * @returns the new Vector3
  2911. */
  2912. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2913. /** @hidden */
  2914. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2915. /**
  2916. * Unproject from screen space to object space
  2917. * @param source defines the screen space Vector3 to use
  2918. * @param viewportWidth defines the current width of the viewport
  2919. * @param viewportHeight defines the current height of the viewport
  2920. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2921. * @param transform defines the transform (view x projection) matrix to use
  2922. * @returns the new Vector3
  2923. */
  2924. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2925. /**
  2926. * Unproject from screen space to object space
  2927. * @param source defines the screen space Vector3 to use
  2928. * @param viewportWidth defines the current width of the viewport
  2929. * @param viewportHeight defines the current height of the viewport
  2930. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2931. * @param view defines the view matrix to use
  2932. * @param projection defines the projection matrix to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2936. /**
  2937. * Unproject from screen space to object space
  2938. * @param source defines the screen space Vector3 to use
  2939. * @param viewportWidth defines the current width of the viewport
  2940. * @param viewportHeight defines the current height of the viewport
  2941. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2942. * @param view defines the view matrix to use
  2943. * @param projection defines the projection matrix to use
  2944. * @param result defines the Vector3 where to store the result
  2945. */
  2946. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2947. /**
  2948. * Unproject from screen space to object space
  2949. * @param sourceX defines the screen space x coordinate to use
  2950. * @param sourceY defines the screen space y coordinate to use
  2951. * @param sourceZ defines the screen space z coordinate to use
  2952. * @param viewportWidth defines the current width of the viewport
  2953. * @param viewportHeight defines the current height of the viewport
  2954. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2955. * @param view defines the view matrix to use
  2956. * @param projection defines the projection matrix to use
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2960. /**
  2961. * Gets the minimal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Gets the maximal coordinate values between two Vector3
  2969. * @param left defines the first operand
  2970. * @param right defines the second operand
  2971. * @returns the new Vector3
  2972. */
  2973. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2974. /**
  2975. * Returns the distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the distance
  2979. */
  2980. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns the squared distance between the vectors "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the squared distance
  2986. */
  2987. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2988. /**
  2989. * Returns a new Vector3 located at the center between "value1" and "value2"
  2990. * @param value1 defines the first operand
  2991. * @param value2 defines the second operand
  2992. * @returns the new Vector3
  2993. */
  2994. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2995. /**
  2996. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2997. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2998. * to something in order to rotate it from its local system to the given target system
  2999. * Note: axis1, axis2 and axis3 are normalized during this operation
  3000. * @param axis1 defines the first axis
  3001. * @param axis2 defines the second axis
  3002. * @param axis3 defines the third axis
  3003. * @returns a new Vector3
  3004. */
  3005. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3006. /**
  3007. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3008. * @param axis1 defines the first axis
  3009. * @param axis2 defines the second axis
  3010. * @param axis3 defines the third axis
  3011. * @param ref defines the Vector3 where to store the result
  3012. */
  3013. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3014. }
  3015. /**
  3016. * Vector4 class created for EulerAngle class conversion to Quaternion
  3017. */
  3018. export class Vector4 {
  3019. /** x value of the vector */
  3020. x: number;
  3021. /** y value of the vector */
  3022. y: number;
  3023. /** z value of the vector */
  3024. z: number;
  3025. /** w value of the vector */
  3026. w: number;
  3027. /**
  3028. * Creates a Vector4 object from the given floats.
  3029. * @param x x value of the vector
  3030. * @param y y value of the vector
  3031. * @param z z value of the vector
  3032. * @param w w value of the vector
  3033. */
  3034. constructor(
  3035. /** x value of the vector */
  3036. x: number,
  3037. /** y value of the vector */
  3038. y: number,
  3039. /** z value of the vector */
  3040. z: number,
  3041. /** w value of the vector */
  3042. w: number);
  3043. /**
  3044. * Returns the string with the Vector4 coordinates.
  3045. * @returns a string containing all the vector values
  3046. */
  3047. toString(): string;
  3048. /**
  3049. * Returns the string "Vector4".
  3050. * @returns "Vector4"
  3051. */
  3052. getClassName(): string;
  3053. /**
  3054. * Returns the Vector4 hash code.
  3055. * @returns a unique hash code
  3056. */
  3057. getHashCode(): number;
  3058. /**
  3059. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3060. * @returns the resulting array
  3061. */
  3062. asArray(): number[];
  3063. /**
  3064. * Populates the given array from the given index with the Vector4 coordinates.
  3065. * @param array array to populate
  3066. * @param index index of the array to start at (default: 0)
  3067. * @returns the Vector4.
  3068. */
  3069. toArray(array: FloatArray, index?: number): Vector4;
  3070. /**
  3071. * Adds the given vector to the current Vector4.
  3072. * @param otherVector the vector to add
  3073. * @returns the updated Vector4.
  3074. */
  3075. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3076. /**
  3077. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3078. * @param otherVector the vector to add
  3079. * @returns the resulting vector
  3080. */
  3081. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3082. /**
  3083. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3084. * @param otherVector the vector to add
  3085. * @param result the vector to store the result
  3086. * @returns the current Vector4.
  3087. */
  3088. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3089. /**
  3090. * Subtract in place the given vector from the current Vector4.
  3091. * @param otherVector the vector to subtract
  3092. * @returns the updated Vector4.
  3093. */
  3094. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3095. /**
  3096. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the new vector with the result
  3099. */
  3100. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3103. * @param otherVector the vector to subtract
  3104. * @param result the vector to store the result
  3105. * @returns the current Vector4.
  3106. */
  3107. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3108. /**
  3109. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3110. */
  3111. /**
  3112. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3113. * @param x value to subtract
  3114. * @param y value to subtract
  3115. * @param z value to subtract
  3116. * @param w value to subtract
  3117. * @returns new vector containing the result
  3118. */
  3119. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3120. /**
  3121. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3122. * @param x value to subtract
  3123. * @param y value to subtract
  3124. * @param z value to subtract
  3125. * @param w value to subtract
  3126. * @param result the vector to store the result in
  3127. * @returns the current Vector4.
  3128. */
  3129. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3130. /**
  3131. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3132. * @returns a new vector with the negated values
  3133. */
  3134. negate(): Vector4;
  3135. /**
  3136. * Multiplies the current Vector4 coordinates by scale (float).
  3137. * @param scale the number to scale with
  3138. * @returns the updated Vector4.
  3139. */
  3140. scaleInPlace(scale: number): Vector4;
  3141. /**
  3142. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3143. * @param scale the number to scale with
  3144. * @returns a new vector with the result
  3145. */
  3146. scale(scale: number): Vector4;
  3147. /**
  3148. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3149. * @param scale the number to scale with
  3150. * @param result a vector to store the result in
  3151. * @returns the current Vector4.
  3152. */
  3153. scaleToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3156. * @param scale defines the scale factor
  3157. * @param result defines the Vector4 object where to store the result
  3158. * @returns the unmodified current Vector4
  3159. */
  3160. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3161. /**
  3162. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3163. * @param otherVector the vector to compare against
  3164. * @returns true if they are equal
  3165. */
  3166. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3167. /**
  3168. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3169. * @param otherVector vector to compare against
  3170. * @param epsilon (Default: very small number)
  3171. * @returns true if they are equal
  3172. */
  3173. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3174. /**
  3175. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3176. * @param x x value to compare against
  3177. * @param y y value to compare against
  3178. * @param z z value to compare against
  3179. * @param w w value to compare against
  3180. * @returns true if equal
  3181. */
  3182. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3183. /**
  3184. * Multiplies in place the current Vector4 by the given one.
  3185. * @param otherVector vector to multiple with
  3186. * @returns the updated Vector4.
  3187. */
  3188. multiplyInPlace(otherVector: Vector4): Vector4;
  3189. /**
  3190. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3191. * @param otherVector vector to multiple with
  3192. * @returns resulting new vector
  3193. */
  3194. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3195. /**
  3196. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3197. * @param otherVector vector to multiple with
  3198. * @param result vector to store the result
  3199. * @returns the current Vector4.
  3200. */
  3201. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3202. /**
  3203. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3204. * @param x x value multiply with
  3205. * @param y y value multiply with
  3206. * @param z z value multiply with
  3207. * @param w w value multiply with
  3208. * @returns resulting new vector
  3209. */
  3210. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3211. /**
  3212. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3213. * @param otherVector vector to devide with
  3214. * @returns resulting new vector
  3215. */
  3216. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3217. /**
  3218. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3219. * @param otherVector vector to devide with
  3220. * @param result vector to store the result
  3221. * @returns the current Vector4.
  3222. */
  3223. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3224. /**
  3225. * Divides the current Vector3 coordinates by the given ones.
  3226. * @param otherVector vector to devide with
  3227. * @returns the updated Vector3.
  3228. */
  3229. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3230. /**
  3231. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3232. * @param other defines the second operand
  3233. * @returns the current updated Vector4
  3234. */
  3235. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3236. /**
  3237. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3238. * @param other defines the second operand
  3239. * @returns the current updated Vector4
  3240. */
  3241. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3242. /**
  3243. * Gets a new Vector4 from current Vector4 floored values
  3244. * @returns a new Vector4
  3245. */
  3246. floor(): Vector4;
  3247. /**
  3248. * Gets a new Vector4 from current Vector3 floored values
  3249. * @returns a new Vector4
  3250. */
  3251. fract(): Vector4;
  3252. /**
  3253. * Returns the Vector4 length (float).
  3254. * @returns the length
  3255. */
  3256. length(): number;
  3257. /**
  3258. * Returns the Vector4 squared length (float).
  3259. * @returns the length squared
  3260. */
  3261. lengthSquared(): number;
  3262. /**
  3263. * Normalizes in place the Vector4.
  3264. * @returns the updated Vector4.
  3265. */
  3266. normalize(): Vector4;
  3267. /**
  3268. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3269. * @returns this converted to a new vector3
  3270. */
  3271. toVector3(): Vector3;
  3272. /**
  3273. * Returns a new Vector4 copied from the current one.
  3274. * @returns the new cloned vector
  3275. */
  3276. clone(): Vector4;
  3277. /**
  3278. * Updates the current Vector4 with the given one coordinates.
  3279. * @param source the source vector to copy from
  3280. * @returns the updated Vector4.
  3281. */
  3282. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3283. /**
  3284. * Updates the current Vector4 coordinates with the given floats.
  3285. * @param x float to copy from
  3286. * @param y float to copy from
  3287. * @param z float to copy from
  3288. * @param w float to copy from
  3289. * @returns the updated Vector4.
  3290. */
  3291. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3292. /**
  3293. * Updates the current Vector4 coordinates with the given floats.
  3294. * @param x float to set from
  3295. * @param y float to set from
  3296. * @param z float to set from
  3297. * @param w float to set from
  3298. * @returns the updated Vector4.
  3299. */
  3300. set(x: number, y: number, z: number, w: number): Vector4;
  3301. /**
  3302. * Copies the given float to the current Vector3 coordinates
  3303. * @param v defines the x, y, z and w coordinates of the operand
  3304. * @returns the current updated Vector3
  3305. */
  3306. setAll(v: number): Vector4;
  3307. /**
  3308. * Returns a new Vector4 set from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @returns the new vector
  3312. */
  3313. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" from the starting index of the given Float32Array.
  3323. * @param array the array to pull values from
  3324. * @param offset the offset into the array to start at
  3325. * @param result the vector to store the result in
  3326. */
  3327. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3328. /**
  3329. * Updates the given vector "result" coordinates from the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @param result the vector to the floats in
  3335. */
  3336. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3337. /**
  3338. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3339. * @returns the new vector
  3340. */
  3341. static Zero(): Vector4;
  3342. /**
  3343. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3344. * @returns the new vector
  3345. */
  3346. static One(): Vector4;
  3347. /**
  3348. * Returns a new normalized Vector4 from the given one.
  3349. * @param vector the vector to normalize
  3350. * @returns the vector
  3351. */
  3352. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Updates the given vector "result" from the normalization of the given one.
  3355. * @param vector the vector to normalize
  3356. * @param result the vector to store the result in
  3357. */
  3358. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3359. /**
  3360. * Returns a vector with the minimum values from the left and right vectors
  3361. * @param left left vector to minimize
  3362. * @param right right vector to minimize
  3363. * @returns a new vector with the minimum of the left and right vector values
  3364. */
  3365. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns a vector with the maximum values from the left and right vectors
  3368. * @param left left vector to maximize
  3369. * @param right right vector to maximize
  3370. * @returns a new vector with the maximum of the left and right vector values
  3371. */
  3372. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3373. /**
  3374. * Returns the distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors
  3378. */
  3379. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the distance between
  3383. * @param value2 value to calulate the distance between
  3384. * @return the distance between the two vectors squared
  3385. */
  3386. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3387. /**
  3388. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3389. * @param value1 value to calulate the center between
  3390. * @param value2 value to calulate the center between
  3391. * @return the center between the two vectors
  3392. */
  3393. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3394. /**
  3395. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3396. * This methods computes transformed normalized direction vectors only.
  3397. * @param vector the vector to transform
  3398. * @param transformation the transformation matrix to apply
  3399. * @returns the new vector
  3400. */
  3401. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3404. * This methods computes transformed normalized direction vectors only.
  3405. * @param vector the vector to transform
  3406. * @param transformation the transformation matrix to apply
  3407. * @param result the vector to store the result in
  3408. */
  3409. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3410. /**
  3411. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3412. * This methods computes transformed normalized direction vectors only.
  3413. * @param x value to transform
  3414. * @param y value to transform
  3415. * @param z value to transform
  3416. * @param w value to transform
  3417. * @param transformation the transformation matrix to apply
  3418. * @param result the vector to store the results in
  3419. */
  3420. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3421. /**
  3422. * Creates a new Vector4 from a Vector3
  3423. * @param source defines the source data
  3424. * @param w defines the 4th component (default is 0)
  3425. * @returns a new Vector4
  3426. */
  3427. static FromVector3(source: Vector3, w?: number): Vector4;
  3428. }
  3429. /**
  3430. * Class used to store quaternion data
  3431. * @see https://en.wikipedia.org/wiki/Quaternion
  3432. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3433. */
  3434. export class Quaternion {
  3435. /** defines the first component (0 by default) */
  3436. x: number;
  3437. /** defines the second component (0 by default) */
  3438. y: number;
  3439. /** defines the third component (0 by default) */
  3440. z: number;
  3441. /** defines the fourth component (1.0 by default) */
  3442. w: number;
  3443. /**
  3444. * Creates a new Quaternion from the given floats
  3445. * @param x defines the first component (0 by default)
  3446. * @param y defines the second component (0 by default)
  3447. * @param z defines the third component (0 by default)
  3448. * @param w defines the fourth component (1.0 by default)
  3449. */
  3450. constructor(
  3451. /** defines the first component (0 by default) */
  3452. x?: number,
  3453. /** defines the second component (0 by default) */
  3454. y?: number,
  3455. /** defines the third component (0 by default) */
  3456. z?: number,
  3457. /** defines the fourth component (1.0 by default) */
  3458. w?: number);
  3459. /**
  3460. * Gets a string representation for the current quaternion
  3461. * @returns a string with the Quaternion coordinates
  3462. */
  3463. toString(): string;
  3464. /**
  3465. * Gets the class name of the quaternion
  3466. * @returns the string "Quaternion"
  3467. */
  3468. getClassName(): string;
  3469. /**
  3470. * Gets a hash code for this quaternion
  3471. * @returns the quaternion hash code
  3472. */
  3473. getHashCode(): number;
  3474. /**
  3475. * Copy the quaternion to an array
  3476. * @returns a new array populated with 4 elements from the quaternion coordinates
  3477. */
  3478. asArray(): number[];
  3479. /**
  3480. * Check if two quaternions are equals
  3481. * @param otherQuaternion defines the second operand
  3482. * @return true if the current quaternion and the given one coordinates are strictly equals
  3483. */
  3484. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3485. /**
  3486. * Clone the current quaternion
  3487. * @returns a new quaternion copied from the current one
  3488. */
  3489. clone(): Quaternion;
  3490. /**
  3491. * Copy a quaternion to the current one
  3492. * @param other defines the other quaternion
  3493. * @returns the updated current quaternion
  3494. */
  3495. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3496. /**
  3497. * Updates the current quaternion with the given float coordinates
  3498. * @param x defines the x coordinate
  3499. * @param y defines the y coordinate
  3500. * @param z defines the z coordinate
  3501. * @param w defines the w coordinate
  3502. * @returns the updated current quaternion
  3503. */
  3504. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3505. /**
  3506. * Updates the current quaternion from the given float coordinates
  3507. * @param x defines the x coordinate
  3508. * @param y defines the y coordinate
  3509. * @param z defines the z coordinate
  3510. * @param w defines the w coordinate
  3511. * @returns the updated current quaternion
  3512. */
  3513. set(x: number, y: number, z: number, w: number): Quaternion;
  3514. /**
  3515. * Adds two quaternions
  3516. * @param other defines the second operand
  3517. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3518. */
  3519. add(other: DeepImmutable<Quaternion>): Quaternion;
  3520. /**
  3521. * Add a quaternion to the current one
  3522. * @param other defines the quaternion to add
  3523. * @returns the current quaternion
  3524. */
  3525. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3526. /**
  3527. * Subtract two quaternions
  3528. * @param other defines the second operand
  3529. * @returns a new quaternion as the subtraction result of the given one from the current one
  3530. */
  3531. subtract(other: Quaternion): Quaternion;
  3532. /**
  3533. * Multiplies the current quaternion by a scale factor
  3534. * @param value defines the scale factor
  3535. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3536. */
  3537. scale(value: number): Quaternion;
  3538. /**
  3539. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3540. * @param scale defines the scale factor
  3541. * @param result defines the Quaternion object where to store the result
  3542. * @returns the unmodified current quaternion
  3543. */
  3544. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3545. /**
  3546. * Multiplies in place the current quaternion by a scale factor
  3547. * @param value defines the scale factor
  3548. * @returns the current modified quaternion
  3549. */
  3550. scaleInPlace(value: number): Quaternion;
  3551. /**
  3552. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3553. * @param scale defines the scale factor
  3554. * @param result defines the Quaternion object where to store the result
  3555. * @returns the unmodified current quaternion
  3556. */
  3557. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3558. /**
  3559. * Multiplies two quaternions
  3560. * @param q1 defines the second operand
  3561. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3562. */
  3563. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3564. /**
  3565. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @param result defines the target quaternion
  3568. * @returns the current quaternion
  3569. */
  3570. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3571. /**
  3572. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3573. * @param q1 defines the second operand
  3574. * @returns the currentupdated quaternion
  3575. */
  3576. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3577. /**
  3578. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3579. * @param ref defines the target quaternion
  3580. * @returns the current quaternion
  3581. */
  3582. conjugateToRef(ref: Quaternion): Quaternion;
  3583. /**
  3584. * Conjugates in place (1-q) the current quaternion
  3585. * @returns the current updated quaternion
  3586. */
  3587. conjugateInPlace(): Quaternion;
  3588. /**
  3589. * Conjugates in place (1-q) the current quaternion
  3590. * @returns a new quaternion
  3591. */
  3592. conjugate(): Quaternion;
  3593. /**
  3594. * Gets length of current quaternion
  3595. * @returns the quaternion length (float)
  3596. */
  3597. length(): number;
  3598. /**
  3599. * Normalize in place the current quaternion
  3600. * @returns the current updated quaternion
  3601. */
  3602. normalize(): Quaternion;
  3603. /**
  3604. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns a new Vector3 containing the Euler angles
  3607. */
  3608. toEulerAngles(order?: string): Vector3;
  3609. /**
  3610. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3611. * @param result defines the vector which will be filled with the Euler angles
  3612. * @param order is a reserved parameter and is ignore for now
  3613. * @returns the current unchanged quaternion
  3614. */
  3615. toEulerAnglesToRef(result: Vector3): Quaternion;
  3616. /**
  3617. * Updates the given rotation matrix with the current quaternion values
  3618. * @param result defines the target matrix
  3619. * @returns the current unchanged quaternion
  3620. */
  3621. toRotationMatrix(result: Matrix): Quaternion;
  3622. /**
  3623. * Updates the current quaternion from the given rotation matrix values
  3624. * @param matrix defines the source matrix
  3625. * @returns the current updated quaternion
  3626. */
  3627. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3628. /**
  3629. * Creates a new quaternion from a rotation matrix
  3630. * @param matrix defines the source matrix
  3631. * @returns a new quaternion created from the given rotation matrix values
  3632. */
  3633. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3634. /**
  3635. * Updates the given quaternion with the given rotation matrix values
  3636. * @param matrix defines the source matrix
  3637. * @param result defines the target quaternion
  3638. */
  3639. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3640. /**
  3641. * Returns the dot product (float) between the quaternions "left" and "right"
  3642. * @param left defines the left operand
  3643. * @param right defines the right operand
  3644. * @returns the dot product
  3645. */
  3646. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3647. /**
  3648. * Checks if the two quaternions are close to each other
  3649. * @param quat0 defines the first quaternion to check
  3650. * @param quat1 defines the second quaternion to check
  3651. * @returns true if the two quaternions are close to each other
  3652. */
  3653. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3654. /**
  3655. * Creates an empty quaternion
  3656. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3657. */
  3658. static Zero(): Quaternion;
  3659. /**
  3660. * Inverse a given quaternion
  3661. * @param q defines the source quaternion
  3662. * @returns a new quaternion as the inverted current quaternion
  3663. */
  3664. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3665. /**
  3666. * Inverse a given quaternion
  3667. * @param q defines the source quaternion
  3668. * @param result the quaternion the result will be stored in
  3669. * @returns the result quaternion
  3670. */
  3671. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3672. /**
  3673. * Creates an identity quaternion
  3674. * @returns the identity quaternion
  3675. */
  3676. static Identity(): Quaternion;
  3677. /**
  3678. * Gets a boolean indicating if the given quaternion is identity
  3679. * @param quaternion defines the quaternion to check
  3680. * @returns true if the quaternion is identity
  3681. */
  3682. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3683. /**
  3684. * Creates a quaternion from a rotation around an axis
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3688. */
  3689. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3690. /**
  3691. * Creates a rotation around an axis and stores it into the given quaternion
  3692. * @param axis defines the axis to use
  3693. * @param angle defines the angle to use
  3694. * @param result defines the target quaternion
  3695. * @returns the target quaternion
  3696. */
  3697. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3698. /**
  3699. * Creates a new quaternion from data stored into an array
  3700. * @param array defines the data source
  3701. * @param offset defines the offset in the source array where the data starts
  3702. * @returns a new quaternion
  3703. */
  3704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3705. /**
  3706. * Create a quaternion from Euler rotation angles
  3707. * @param x Pitch
  3708. * @param y Yaw
  3709. * @param z Roll
  3710. * @returns the new Quaternion
  3711. */
  3712. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3713. /**
  3714. * Updates a quaternion from Euler rotation angles
  3715. * @param x Pitch
  3716. * @param y Yaw
  3717. * @param z Roll
  3718. * @param result the quaternion to store the result
  3719. * @returns the updated quaternion
  3720. */
  3721. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3722. /**
  3723. * Create a quaternion from Euler rotation vector
  3724. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3725. * @returns the new Quaternion
  3726. */
  3727. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3728. /**
  3729. * Updates a quaternion from Euler rotation vector
  3730. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3731. * @param result the quaternion to store the result
  3732. * @returns the updated quaternion
  3733. */
  3734. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3735. /**
  3736. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3737. * @param yaw defines the rotation around Y axis
  3738. * @param pitch defines the rotation around X axis
  3739. * @param roll defines the rotation around Z axis
  3740. * @returns the new quaternion
  3741. */
  3742. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3743. /**
  3744. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3745. * @param yaw defines the rotation around Y axis
  3746. * @param pitch defines the rotation around X axis
  3747. * @param roll defines the rotation around Z axis
  3748. * @param result defines the target quaternion
  3749. */
  3750. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3751. /**
  3752. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3753. * @param alpha defines the rotation around first axis
  3754. * @param beta defines the rotation around second axis
  3755. * @param gamma defines the rotation around third axis
  3756. * @returns the new quaternion
  3757. */
  3758. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3759. /**
  3760. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3761. * @param alpha defines the rotation around first axis
  3762. * @param beta defines the rotation around second axis
  3763. * @param gamma defines the rotation around third axis
  3764. * @param result defines the target quaternion
  3765. */
  3766. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3767. /**
  3768. * 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)
  3769. * @param axis1 defines the first axis
  3770. * @param axis2 defines the second axis
  3771. * @param axis3 defines the third axis
  3772. * @returns the new quaternion
  3773. */
  3774. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3775. /**
  3776. * 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
  3777. * @param axis1 defines the first axis
  3778. * @param axis2 defines the second axis
  3779. * @param axis3 defines the third axis
  3780. * @param ref defines the target quaternion
  3781. */
  3782. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3783. /**
  3784. * Interpolates between two quaternions
  3785. * @param left defines first quaternion
  3786. * @param right defines second quaternion
  3787. * @param amount defines the gradient to use
  3788. * @returns the new interpolated quaternion
  3789. */
  3790. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3791. /**
  3792. * Interpolates between two quaternions and stores it into a target quaternion
  3793. * @param left defines first quaternion
  3794. * @param right defines second quaternion
  3795. * @param amount defines the gradient to use
  3796. * @param result defines the target quaternion
  3797. */
  3798. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3799. /**
  3800. * Interpolate between two quaternions using Hermite interpolation
  3801. * @param value1 defines first quaternion
  3802. * @param tangent1 defines the incoming tangent
  3803. * @param value2 defines second quaternion
  3804. * @param tangent2 defines the outgoing tangent
  3805. * @param amount defines the target quaternion
  3806. * @returns the new interpolated quaternion
  3807. */
  3808. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3809. }
  3810. /**
  3811. * Class used to store matrix data (4x4)
  3812. */
  3813. export class Matrix {
  3814. private static _updateFlagSeed;
  3815. private static _identityReadOnly;
  3816. private _isIdentity;
  3817. private _isIdentityDirty;
  3818. private _isIdentity3x2;
  3819. private _isIdentity3x2Dirty;
  3820. /**
  3821. * Gets the update flag of the matrix which is an unique number for the matrix.
  3822. * It will be incremented every time the matrix data change.
  3823. * You can use it to speed the comparison between two versions of the same matrix.
  3824. */
  3825. updateFlag: number;
  3826. private readonly _m;
  3827. /**
  3828. * Gets the internal data of the matrix
  3829. */
  3830. get m(): DeepImmutable<Float32Array>;
  3831. /** @hidden */
  3832. _markAsUpdated(): void;
  3833. /** @hidden */
  3834. private _updateIdentityStatus;
  3835. /**
  3836. * Creates an empty matrix (filled with zeros)
  3837. */
  3838. constructor();
  3839. /**
  3840. * Check if the current matrix is identity
  3841. * @returns true is the matrix is the identity matrix
  3842. */
  3843. isIdentity(): boolean;
  3844. /**
  3845. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3846. * @returns true is the matrix is the identity matrix
  3847. */
  3848. isIdentityAs3x2(): boolean;
  3849. /**
  3850. * Gets the determinant of the matrix
  3851. * @returns the matrix determinant
  3852. */
  3853. determinant(): number;
  3854. /**
  3855. * Returns the matrix as a Float32Array
  3856. * @returns the matrix underlying array
  3857. */
  3858. toArray(): DeepImmutable<Float32Array>;
  3859. /**
  3860. * Returns the matrix as a Float32Array
  3861. * @returns the matrix underlying array.
  3862. */
  3863. asArray(): DeepImmutable<Float32Array>;
  3864. /**
  3865. * Inverts the current matrix in place
  3866. * @returns the current inverted matrix
  3867. */
  3868. invert(): Matrix;
  3869. /**
  3870. * Sets all the matrix elements to zero
  3871. * @returns the current matrix
  3872. */
  3873. reset(): Matrix;
  3874. /**
  3875. * Adds the current matrix with a second one
  3876. * @param other defines the matrix to add
  3877. * @returns a new matrix as the addition of the current matrix and the given one
  3878. */
  3879. add(other: DeepImmutable<Matrix>): Matrix;
  3880. /**
  3881. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3882. * @param other defines the matrix to add
  3883. * @param result defines the target matrix
  3884. * @returns the current matrix
  3885. */
  3886. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3887. /**
  3888. * Adds in place the given matrix to the current matrix
  3889. * @param other defines the second operand
  3890. * @returns the current updated matrix
  3891. */
  3892. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3893. /**
  3894. * Sets the given matrix to the current inverted Matrix
  3895. * @param other defines the target matrix
  3896. * @returns the unmodified current matrix
  3897. */
  3898. invertToRef(other: Matrix): Matrix;
  3899. /**
  3900. * add a value at the specified position in the current Matrix
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. addAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * mutiply the specified position in the current Matrix by a value
  3908. * @param index the index of the value within the matrix. between 0 and 15.
  3909. * @param value the value to be added
  3910. * @returns the current updated matrix
  3911. */
  3912. multiplyAtIndex(index: number, value: number): Matrix;
  3913. /**
  3914. * Inserts the translation vector (using 3 floats) in the current matrix
  3915. * @param x defines the 1st component of the translation
  3916. * @param y defines the 2nd component of the translation
  3917. * @param z defines the 3rd component of the translation
  3918. * @returns the current updated matrix
  3919. */
  3920. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3921. /**
  3922. * Adds the translation vector (using 3 floats) in the current matrix
  3923. * @param x defines the 1st component of the translation
  3924. * @param y defines the 2nd component of the translation
  3925. * @param z defines the 3rd component of the translation
  3926. * @returns the current updated matrix
  3927. */
  3928. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3929. /**
  3930. * Inserts the translation vector in the current matrix
  3931. * @param vector3 defines the translation to insert
  3932. * @returns the current updated matrix
  3933. */
  3934. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3935. /**
  3936. * Gets the translation value of the current matrix
  3937. * @returns a new Vector3 as the extracted translation from the matrix
  3938. */
  3939. getTranslation(): Vector3;
  3940. /**
  3941. * Fill a Vector3 with the extracted translation from the matrix
  3942. * @param result defines the Vector3 where to store the translation
  3943. * @returns the current matrix
  3944. */
  3945. getTranslationToRef(result: Vector3): Matrix;
  3946. /**
  3947. * Remove rotation and scaling part from the matrix
  3948. * @returns the updated matrix
  3949. */
  3950. removeRotationAndScaling(): Matrix;
  3951. /**
  3952. * Multiply two matrices
  3953. * @param other defines the second operand
  3954. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3955. */
  3956. multiply(other: DeepImmutable<Matrix>): Matrix;
  3957. /**
  3958. * Copy the current matrix from the given one
  3959. * @param other defines the source matrix
  3960. * @returns the current updated matrix
  3961. */
  3962. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3963. /**
  3964. * Populates the given array from the starting index with the current matrix values
  3965. * @param array defines the target array
  3966. * @param offset defines the offset in the target array where to start storing values
  3967. * @returns the current matrix
  3968. */
  3969. copyToArray(array: Float32Array, offset?: number): Matrix;
  3970. /**
  3971. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the matrix where to store the multiplication
  3974. * @returns the current matrix
  3975. */
  3976. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3977. /**
  3978. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3979. * @param other defines the second operand
  3980. * @param result defines the array where to store the multiplication
  3981. * @param offset defines the offset in the target array where to start storing values
  3982. * @returns the current matrix
  3983. */
  3984. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3985. /**
  3986. * Check equality between this matrix and a second one
  3987. * @param value defines the second matrix to compare
  3988. * @returns true is the current matrix and the given one values are strictly equal
  3989. */
  3990. equals(value: DeepImmutable<Matrix>): boolean;
  3991. /**
  3992. * Clone the current matrix
  3993. * @returns a new matrix from the current matrix
  3994. */
  3995. clone(): Matrix;
  3996. /**
  3997. * Returns the name of the current matrix class
  3998. * @returns the string "Matrix"
  3999. */
  4000. getClassName(): string;
  4001. /**
  4002. * Gets the hash code of the current matrix
  4003. * @returns the hash code
  4004. */
  4005. getHashCode(): number;
  4006. /**
  4007. * Decomposes the current Matrix into a translation, rotation and scaling components
  4008. * @param scale defines the scale vector3 given as a reference to update
  4009. * @param rotation defines the rotation quaternion given as a reference to update
  4010. * @param translation defines the translation vector3 given as a reference to update
  4011. * @returns true if operation was successful
  4012. */
  4013. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4014. /**
  4015. * Gets specific row of the matrix
  4016. * @param index defines the number of the row to get
  4017. * @returns the index-th row of the current matrix as a new Vector4
  4018. */
  4019. getRow(index: number): Nullable<Vector4>;
  4020. /**
  4021. * Sets the index-th row of the current matrix to the vector4 values
  4022. * @param index defines the number of the row to set
  4023. * @param row defines the target vector4
  4024. * @returns the updated current matrix
  4025. */
  4026. setRow(index: number, row: Vector4): Matrix;
  4027. /**
  4028. * Compute the transpose of the matrix
  4029. * @returns the new transposed matrix
  4030. */
  4031. transpose(): Matrix;
  4032. /**
  4033. * Compute the transpose of the matrix and store it in a given matrix
  4034. * @param result defines the target matrix
  4035. * @returns the current matrix
  4036. */
  4037. transposeToRef(result: Matrix): Matrix;
  4038. /**
  4039. * Sets the index-th row of the current matrix with the given 4 x float values
  4040. * @param index defines the row index
  4041. * @param x defines the x component to set
  4042. * @param y defines the y component to set
  4043. * @param z defines the z component to set
  4044. * @param w defines the w component to set
  4045. * @returns the updated current matrix
  4046. */
  4047. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4048. /**
  4049. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4050. * @param scale defines the scale factor
  4051. * @returns a new matrix
  4052. */
  4053. scale(scale: number): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor to a given result matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Scale the current matrix values by a factor and add the result to a given matrix
  4063. * @param scale defines the scale factor
  4064. * @param result defines the Matrix to store the result
  4065. * @returns the current matrix
  4066. */
  4067. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4068. /**
  4069. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4070. * @param ref matrix to store the result
  4071. */
  4072. toNormalMatrix(ref: Matrix): void;
  4073. /**
  4074. * Gets only rotation part of the current matrix
  4075. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4076. */
  4077. getRotationMatrix(): Matrix;
  4078. /**
  4079. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4080. * @param result defines the target matrix to store data to
  4081. * @returns the current matrix
  4082. */
  4083. getRotationMatrixToRef(result: Matrix): Matrix;
  4084. /**
  4085. * Toggles model matrix from being right handed to left handed in place and vice versa
  4086. */
  4087. toggleModelMatrixHandInPlace(): void;
  4088. /**
  4089. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4090. */
  4091. toggleProjectionMatrixHandInPlace(): void;
  4092. /**
  4093. * Creates a matrix from an array
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @returns a new Matrix set from the starting index of the given array
  4097. */
  4098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4099. /**
  4100. * Copy the content of an array into a given matrix
  4101. * @param array defines the source array
  4102. * @param offset defines an offset in the source array
  4103. * @param result defines the target matrix
  4104. */
  4105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4106. /**
  4107. * Stores an array into a matrix after having multiplied each component by a given factor
  4108. * @param array defines the source array
  4109. * @param offset defines the offset in the source array
  4110. * @param scale defines the scaling factor
  4111. * @param result defines the target matrix
  4112. */
  4113. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4114. /**
  4115. * Gets an identity matrix that must not be updated
  4116. */
  4117. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4118. /**
  4119. * Stores a list of values (16) inside a given matrix
  4120. * @param initialM11 defines 1st value of 1st row
  4121. * @param initialM12 defines 2nd value of 1st row
  4122. * @param initialM13 defines 3rd value of 1st row
  4123. * @param initialM14 defines 4th value of 1st row
  4124. * @param initialM21 defines 1st value of 2nd row
  4125. * @param initialM22 defines 2nd value of 2nd row
  4126. * @param initialM23 defines 3rd value of 2nd row
  4127. * @param initialM24 defines 4th value of 2nd row
  4128. * @param initialM31 defines 1st value of 3rd row
  4129. * @param initialM32 defines 2nd value of 3rd row
  4130. * @param initialM33 defines 3rd value of 3rd row
  4131. * @param initialM34 defines 4th value of 3rd row
  4132. * @param initialM41 defines 1st value of 4th row
  4133. * @param initialM42 defines 2nd value of 4th row
  4134. * @param initialM43 defines 3rd value of 4th row
  4135. * @param initialM44 defines 4th value of 4th row
  4136. * @param result defines the target matrix
  4137. */
  4138. 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;
  4139. /**
  4140. * Creates new matrix from a list of values (16)
  4141. * @param initialM11 defines 1st value of 1st row
  4142. * @param initialM12 defines 2nd value of 1st row
  4143. * @param initialM13 defines 3rd value of 1st row
  4144. * @param initialM14 defines 4th value of 1st row
  4145. * @param initialM21 defines 1st value of 2nd row
  4146. * @param initialM22 defines 2nd value of 2nd row
  4147. * @param initialM23 defines 3rd value of 2nd row
  4148. * @param initialM24 defines 4th value of 2nd row
  4149. * @param initialM31 defines 1st value of 3rd row
  4150. * @param initialM32 defines 2nd value of 3rd row
  4151. * @param initialM33 defines 3rd value of 3rd row
  4152. * @param initialM34 defines 4th value of 3rd row
  4153. * @param initialM41 defines 1st value of 4th row
  4154. * @param initialM42 defines 2nd value of 4th row
  4155. * @param initialM43 defines 3rd value of 4th row
  4156. * @param initialM44 defines 4th value of 4th row
  4157. * @returns the new matrix
  4158. */
  4159. 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;
  4160. /**
  4161. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4162. * @param scale defines the scale vector3
  4163. * @param rotation defines the rotation quaternion
  4164. * @param translation defines the translation vector3
  4165. * @returns a new matrix
  4166. */
  4167. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4168. /**
  4169. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4170. * @param scale defines the scale vector3
  4171. * @param rotation defines the rotation quaternion
  4172. * @param translation defines the translation vector3
  4173. * @param result defines the target matrix
  4174. */
  4175. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4176. /**
  4177. * Creates a new identity matrix
  4178. * @returns a new identity matrix
  4179. */
  4180. static Identity(): Matrix;
  4181. /**
  4182. * Creates a new identity matrix and stores the result in a given matrix
  4183. * @param result defines the target matrix
  4184. */
  4185. static IdentityToRef(result: Matrix): void;
  4186. /**
  4187. * Creates a new zero matrix
  4188. * @returns a new zero matrix
  4189. */
  4190. static Zero(): Matrix;
  4191. /**
  4192. * Creates a new rotation matrix for "angle" radians around the X axis
  4193. * @param angle defines the angle (in radians) to use
  4194. * @return the new matrix
  4195. */
  4196. static RotationX(angle: number): Matrix;
  4197. /**
  4198. * Creates a new matrix as the invert of a given matrix
  4199. * @param source defines the source matrix
  4200. * @returns the new matrix
  4201. */
  4202. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4203. /**
  4204. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4205. * @param angle defines the angle (in radians) to use
  4206. * @param result defines the target matrix
  4207. */
  4208. static RotationXToRef(angle: number, result: Matrix): void;
  4209. /**
  4210. * Creates a new rotation matrix for "angle" radians around the Y axis
  4211. * @param angle defines the angle (in radians) to use
  4212. * @return the new matrix
  4213. */
  4214. static RotationY(angle: number): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4217. * @param angle defines the angle (in radians) to use
  4218. * @param result defines the target matrix
  4219. */
  4220. static RotationYToRef(angle: number, result: Matrix): void;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the Z axis
  4223. * @param angle defines the angle (in radians) to use
  4224. * @return the new matrix
  4225. */
  4226. static RotationZ(angle: number): Matrix;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4229. * @param angle defines the angle (in radians) to use
  4230. * @param result defines the target matrix
  4231. */
  4232. static RotationZToRef(angle: number, result: Matrix): void;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @return the new matrix
  4238. */
  4239. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4240. /**
  4241. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4242. * @param axis defines the axis to use
  4243. * @param angle defines the angle (in radians) to use
  4244. * @param result defines the target matrix
  4245. */
  4246. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4247. /**
  4248. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4249. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4250. * @param from defines the vector to align
  4251. * @param to defines the vector to align to
  4252. * @param result defines the target matrix
  4253. */
  4254. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4255. /**
  4256. * Creates a rotation matrix
  4257. * @param yaw defines the yaw angle in radians (Y axis)
  4258. * @param pitch defines the pitch angle in radians (X axis)
  4259. * @param roll defines the roll angle in radians (X axis)
  4260. * @returns the new rotation matrix
  4261. */
  4262. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4263. /**
  4264. * Creates a rotation matrix and stores it in a given matrix
  4265. * @param yaw defines the yaw angle in radians (Y axis)
  4266. * @param pitch defines the pitch angle in radians (X axis)
  4267. * @param roll defines the roll angle in radians (X axis)
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4271. /**
  4272. * Creates a scaling matrix
  4273. * @param x defines the scale factor on X axis
  4274. * @param y defines the scale factor on Y axis
  4275. * @param z defines the scale factor on Z axis
  4276. * @returns the new matrix
  4277. */
  4278. static Scaling(x: number, y: number, z: number): Matrix;
  4279. /**
  4280. * Creates a scaling matrix and stores it in a given matrix
  4281. * @param x defines the scale factor on X axis
  4282. * @param y defines the scale factor on Y axis
  4283. * @param z defines the scale factor on Z axis
  4284. * @param result defines the target matrix
  4285. */
  4286. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4287. /**
  4288. * Creates a translation matrix
  4289. * @param x defines the translation on X axis
  4290. * @param y defines the translation on Y axis
  4291. * @param z defines the translationon Z axis
  4292. * @returns the new matrix
  4293. */
  4294. static Translation(x: number, y: number, z: number): Matrix;
  4295. /**
  4296. * Creates a translation matrix and stores it in a given matrix
  4297. * @param x defines the translation on X axis
  4298. * @param y defines the translation on Y axis
  4299. * @param z defines the translationon Z axis
  4300. * @param result defines the target matrix
  4301. */
  4302. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4303. /**
  4304. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4305. * @param startValue defines the start value
  4306. * @param endValue defines the end value
  4307. * @param gradient defines the gradient factor
  4308. * @returns the new matrix
  4309. */
  4310. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4311. /**
  4312. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4313. * @param startValue defines the start value
  4314. * @param endValue defines the end value
  4315. * @param gradient defines the gradient factor
  4316. * @param result defines the Matrix object where to store data
  4317. */
  4318. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4319. /**
  4320. * Builds a new matrix whose values are computed by:
  4321. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4322. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4323. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4324. * @param startValue defines the first matrix
  4325. * @param endValue defines the second matrix
  4326. * @param gradient defines the gradient between the two matrices
  4327. * @returns the new matrix
  4328. */
  4329. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4330. /**
  4331. * Update a matrix to values which are computed by:
  4332. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4333. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4334. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4335. * @param startValue defines the first matrix
  4336. * @param endValue defines the second matrix
  4337. * @param gradient defines the gradient between the two matrices
  4338. * @param result defines the target matrix
  4339. */
  4340. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4341. /**
  4342. * 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"
  4343. * This function works in left handed mode
  4344. * @param eye defines the final position of the entity
  4345. * @param target defines where the entity should look at
  4346. * @param up defines the up vector for the entity
  4347. * @returns the new matrix
  4348. */
  4349. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * 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".
  4352. * This function works in left handed mode
  4353. * @param eye defines the final position of the entity
  4354. * @param target defines where the entity should look at
  4355. * @param up defines the up vector for the entity
  4356. * @param result defines the target matrix
  4357. */
  4358. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4359. /**
  4360. * 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"
  4361. * This function works in right handed mode
  4362. * @param eye defines the final position of the entity
  4363. * @param target defines where the entity should look at
  4364. * @param up defines the up vector for the entity
  4365. * @returns the new matrix
  4366. */
  4367. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4368. /**
  4369. * 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".
  4370. * This function works in right handed mode
  4371. * @param eye defines the final position of the entity
  4372. * @param target defines where the entity should look at
  4373. * @param up defines the up vector for the entity
  4374. * @param result defines the target matrix
  4375. */
  4376. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4377. /**
  4378. * Create a left-handed orthographic projection matrix
  4379. * @param width defines the viewport width
  4380. * @param height defines the viewport height
  4381. * @param znear defines the near clip plane
  4382. * @param zfar defines the far clip plane
  4383. * @returns a new matrix as a left-handed orthographic projection matrix
  4384. */
  4385. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4386. /**
  4387. * Store a left-handed orthographic projection to a given matrix
  4388. * @param width defines the viewport width
  4389. * @param height defines the viewport height
  4390. * @param znear defines the near clip plane
  4391. * @param zfar defines the far clip plane
  4392. * @param result defines the target matrix
  4393. */
  4394. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4395. /**
  4396. * Create a left-handed orthographic projection matrix
  4397. * @param left defines the viewport left coordinate
  4398. * @param right defines the viewport right coordinate
  4399. * @param bottom defines the viewport bottom coordinate
  4400. * @param top defines the viewport top coordinate
  4401. * @param znear defines the near clip plane
  4402. * @param zfar defines the far clip plane
  4403. * @returns a new matrix as a left-handed orthographic projection matrix
  4404. */
  4405. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4406. /**
  4407. * Stores a left-handed orthographic projection into a given matrix
  4408. * @param left defines the viewport left coordinate
  4409. * @param right defines the viewport right coordinate
  4410. * @param bottom defines the viewport bottom coordinate
  4411. * @param top defines the viewport top coordinate
  4412. * @param znear defines the near clip plane
  4413. * @param zfar defines the far clip plane
  4414. * @param result defines the target matrix
  4415. */
  4416. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4417. /**
  4418. * Creates a right-handed orthographic projection matrix
  4419. * @param left defines the viewport left coordinate
  4420. * @param right defines the viewport right coordinate
  4421. * @param bottom defines the viewport bottom coordinate
  4422. * @param top defines the viewport top coordinate
  4423. * @param znear defines the near clip plane
  4424. * @param zfar defines the far clip plane
  4425. * @returns a new matrix as a right-handed orthographic projection matrix
  4426. */
  4427. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4428. /**
  4429. * Stores a right-handed orthographic projection into a given matrix
  4430. * @param left defines the viewport left coordinate
  4431. * @param right defines the viewport right coordinate
  4432. * @param bottom defines the viewport bottom coordinate
  4433. * @param top defines the viewport top coordinate
  4434. * @param znear defines the near clip plane
  4435. * @param zfar defines the far clip plane
  4436. * @param result defines the target matrix
  4437. */
  4438. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4439. /**
  4440. * Creates a left-handed perspective projection matrix
  4441. * @param width defines the viewport width
  4442. * @param height defines the viewport height
  4443. * @param znear defines the near clip plane
  4444. * @param zfar defines the far clip plane
  4445. * @returns a new matrix as a left-handed perspective projection matrix
  4446. */
  4447. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4448. /**
  4449. * Creates a left-handed perspective projection matrix
  4450. * @param fov defines the horizontal field of view
  4451. * @param aspect defines the aspect ratio
  4452. * @param znear defines the near clip plane
  4453. * @param zfar defines the far clip plane
  4454. * @returns a new matrix as a left-handed perspective projection matrix
  4455. */
  4456. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4457. /**
  4458. * Stores a left-handed perspective projection into a given matrix
  4459. * @param fov defines the horizontal field of view
  4460. * @param aspect defines the aspect ratio
  4461. * @param znear defines the near clip plane
  4462. * @param zfar defines the far clip plane
  4463. * @param result defines the target matrix
  4464. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4465. */
  4466. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4467. /**
  4468. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4469. * @param fov defines the horizontal field of view
  4470. * @param aspect defines the aspect ratio
  4471. * @param znear defines the near clip plane
  4472. * @param zfar not used as infinity is used as far clip
  4473. * @param result defines the target matrix
  4474. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4475. */
  4476. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4477. /**
  4478. * Creates a right-handed perspective projection matrix
  4479. * @param fov defines the horizontal field of view
  4480. * @param aspect defines the aspect ratio
  4481. * @param znear defines the near clip plane
  4482. * @param zfar defines the far clip plane
  4483. * @returns a new matrix as a right-handed perspective projection matrix
  4484. */
  4485. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4486. /**
  4487. * Stores a right-handed perspective projection into a given matrix
  4488. * @param fov defines the horizontal field of view
  4489. * @param aspect defines the aspect ratio
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4494. */
  4495. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4496. /**
  4497. * Stores a right-handed perspective projection into a given matrix
  4498. * @param fov defines the horizontal field of view
  4499. * @param aspect defines the aspect ratio
  4500. * @param znear defines the near clip plane
  4501. * @param zfar not used as infinity is used as far clip
  4502. * @param result defines the target matrix
  4503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4504. */
  4505. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4506. /**
  4507. * Stores a perspective projection for WebVR info a given matrix
  4508. * @param fov defines the field of view
  4509. * @param znear defines the near clip plane
  4510. * @param zfar defines the far clip plane
  4511. * @param result defines the target matrix
  4512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4513. */
  4514. static PerspectiveFovWebVRToRef(fov: {
  4515. upDegrees: number;
  4516. downDegrees: number;
  4517. leftDegrees: number;
  4518. rightDegrees: number;
  4519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4520. /**
  4521. * Computes a complete transformation matrix
  4522. * @param viewport defines the viewport to use
  4523. * @param world defines the world matrix
  4524. * @param view defines the view matrix
  4525. * @param projection defines the projection matrix
  4526. * @param zmin defines the near clip plane
  4527. * @param zmax defines the far clip plane
  4528. * @returns the transformation matrix
  4529. */
  4530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4531. /**
  4532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4533. * @param matrix defines the matrix to use
  4534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4535. */
  4536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4537. /**
  4538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4539. * @param matrix defines the matrix to use
  4540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4541. */
  4542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4543. /**
  4544. * Compute the transpose of a given matrix
  4545. * @param matrix defines the matrix to transpose
  4546. * @returns the new matrix
  4547. */
  4548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4549. /**
  4550. * Compute the transpose of a matrix and store it in a target matrix
  4551. * @param matrix defines the matrix to transpose
  4552. * @param result defines the target matrix
  4553. */
  4554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4555. /**
  4556. * Computes a reflection matrix from a plane
  4557. * @param plane defines the reflection plane
  4558. * @returns a new matrix
  4559. */
  4560. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4561. /**
  4562. * Computes a reflection matrix from a plane
  4563. * @param plane defines the reflection plane
  4564. * @param result defines the target matrix
  4565. */
  4566. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4567. /**
  4568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4569. * @param xaxis defines the value of the 1st axis
  4570. * @param yaxis defines the value of the 2nd axis
  4571. * @param zaxis defines the value of the 3rd axis
  4572. * @param result defines the target matrix
  4573. */
  4574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4575. /**
  4576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4577. * @param quat defines the quaternion to use
  4578. * @param result defines the target matrix
  4579. */
  4580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4581. }
  4582. /**
  4583. * @hidden
  4584. */
  4585. export class TmpVectors {
  4586. static Vector2: Vector2[];
  4587. static Vector3: Vector3[];
  4588. static Vector4: Vector4[];
  4589. static Quaternion: Quaternion[];
  4590. static Matrix: Matrix[];
  4591. }
  4592. }
  4593. declare module BABYLON {
  4594. /**
  4595. * Defines potential orientation for back face culling
  4596. */
  4597. export enum Orientation {
  4598. /**
  4599. * Clockwise
  4600. */
  4601. CW = 0,
  4602. /** Counter clockwise */
  4603. CCW = 1
  4604. }
  4605. /** Class used to represent a Bezier curve */
  4606. export class BezierCurve {
  4607. /**
  4608. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4609. * @param t defines the time
  4610. * @param x1 defines the left coordinate on X axis
  4611. * @param y1 defines the left coordinate on Y axis
  4612. * @param x2 defines the right coordinate on X axis
  4613. * @param y2 defines the right coordinate on Y axis
  4614. * @returns the interpolated value
  4615. */
  4616. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4617. }
  4618. /**
  4619. * Defines angle representation
  4620. */
  4621. export class Angle {
  4622. private _radians;
  4623. /**
  4624. * Creates an Angle object of "radians" radians (float).
  4625. * @param radians the angle in radians
  4626. */
  4627. constructor(radians: number);
  4628. /**
  4629. * Get value in degrees
  4630. * @returns the Angle value in degrees (float)
  4631. */
  4632. degrees(): number;
  4633. /**
  4634. * Get value in radians
  4635. * @returns the Angle value in radians (float)
  4636. */
  4637. radians(): number;
  4638. /**
  4639. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4640. * @param a defines first vector
  4641. * @param b defines second vector
  4642. * @returns a new Angle
  4643. */
  4644. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4645. /**
  4646. * Gets a new Angle object from the given float in radians
  4647. * @param radians defines the angle value in radians
  4648. * @returns a new Angle
  4649. */
  4650. static FromRadians(radians: number): Angle;
  4651. /**
  4652. * Gets a new Angle object from the given float in degrees
  4653. * @param degrees defines the angle value in degrees
  4654. * @returns a new Angle
  4655. */
  4656. static FromDegrees(degrees: number): Angle;
  4657. }
  4658. /**
  4659. * This represents an arc in a 2d space.
  4660. */
  4661. export class Arc2 {
  4662. /** Defines the start point of the arc */
  4663. startPoint: Vector2;
  4664. /** Defines the mid point of the arc */
  4665. midPoint: Vector2;
  4666. /** Defines the end point of the arc */
  4667. endPoint: Vector2;
  4668. /**
  4669. * Defines the center point of the arc.
  4670. */
  4671. centerPoint: Vector2;
  4672. /**
  4673. * Defines the radius of the arc.
  4674. */
  4675. radius: number;
  4676. /**
  4677. * Defines the angle of the arc (from mid point to end point).
  4678. */
  4679. angle: Angle;
  4680. /**
  4681. * Defines the start angle of the arc (from start point to middle point).
  4682. */
  4683. startAngle: Angle;
  4684. /**
  4685. * Defines the orientation of the arc (clock wise/counter clock wise).
  4686. */
  4687. orientation: Orientation;
  4688. /**
  4689. * Creates an Arc object from the three given points : start, middle and end.
  4690. * @param startPoint Defines the start point of the arc
  4691. * @param midPoint Defines the midlle point of the arc
  4692. * @param endPoint Defines the end point of the arc
  4693. */
  4694. constructor(
  4695. /** Defines the start point of the arc */
  4696. startPoint: Vector2,
  4697. /** Defines the mid point of the arc */
  4698. midPoint: Vector2,
  4699. /** Defines the end point of the arc */
  4700. endPoint: Vector2);
  4701. }
  4702. /**
  4703. * Represents a 2D path made up of multiple 2D points
  4704. */
  4705. export class Path2 {
  4706. private _points;
  4707. private _length;
  4708. /**
  4709. * If the path start and end point are the same
  4710. */
  4711. closed: boolean;
  4712. /**
  4713. * Creates a Path2 object from the starting 2D coordinates x and y.
  4714. * @param x the starting points x value
  4715. * @param y the starting points y value
  4716. */
  4717. constructor(x: number, y: number);
  4718. /**
  4719. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4720. * @param x the added points x value
  4721. * @param y the added points y value
  4722. * @returns the updated Path2.
  4723. */
  4724. addLineTo(x: number, y: number): Path2;
  4725. /**
  4726. * 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.
  4727. * @param midX middle point x value
  4728. * @param midY middle point y value
  4729. * @param endX end point x value
  4730. * @param endY end point y value
  4731. * @param numberOfSegments (default: 36)
  4732. * @returns the updated Path2.
  4733. */
  4734. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4735. /**
  4736. * Closes the Path2.
  4737. * @returns the Path2.
  4738. */
  4739. close(): Path2;
  4740. /**
  4741. * Gets the sum of the distance between each sequential point in the path
  4742. * @returns the Path2 total length (float).
  4743. */
  4744. length(): number;
  4745. /**
  4746. * Gets the points which construct the path
  4747. * @returns the Path2 internal array of points.
  4748. */
  4749. getPoints(): Vector2[];
  4750. /**
  4751. * Retreives the point at the distance aways from the starting point
  4752. * @param normalizedLengthPosition the length along the path to retreive the point from
  4753. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4754. */
  4755. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4756. /**
  4757. * Creates a new path starting from an x and y position
  4758. * @param x starting x value
  4759. * @param y starting y value
  4760. * @returns a new Path2 starting at the coordinates (x, y).
  4761. */
  4762. static StartingAt(x: number, y: number): Path2;
  4763. }
  4764. /**
  4765. * Represents a 3D path made up of multiple 3D points
  4766. */
  4767. export class Path3D {
  4768. /**
  4769. * an array of Vector3, the curve axis of the Path3D
  4770. */
  4771. path: Vector3[];
  4772. private _curve;
  4773. private _distances;
  4774. private _tangents;
  4775. private _normals;
  4776. private _binormals;
  4777. private _raw;
  4778. private _alignTangentsWithPath;
  4779. private readonly _pointAtData;
  4780. /**
  4781. * new Path3D(path, normal, raw)
  4782. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4783. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4784. * @param path an array of Vector3, the curve axis of the Path3D
  4785. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4786. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4787. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4788. */
  4789. constructor(
  4790. /**
  4791. * an array of Vector3, the curve axis of the Path3D
  4792. */
  4793. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4794. /**
  4795. * Returns the Path3D array of successive Vector3 designing its curve.
  4796. * @returns the Path3D array of successive Vector3 designing its curve.
  4797. */
  4798. getCurve(): Vector3[];
  4799. /**
  4800. * Returns the Path3D array of successive Vector3 designing its curve.
  4801. * @returns the Path3D array of successive Vector3 designing its curve.
  4802. */
  4803. getPoints(): Vector3[];
  4804. /**
  4805. * @returns the computed length (float) of the path.
  4806. */
  4807. length(): number;
  4808. /**
  4809. * Returns an array populated with tangent vectors on each Path3D curve point.
  4810. * @returns an array populated with tangent vectors on each Path3D curve point.
  4811. */
  4812. getTangents(): Vector3[];
  4813. /**
  4814. * Returns an array populated with normal vectors on each Path3D curve point.
  4815. * @returns an array populated with normal vectors on each Path3D curve point.
  4816. */
  4817. getNormals(): Vector3[];
  4818. /**
  4819. * Returns an array populated with binormal vectors on each Path3D curve point.
  4820. * @returns an array populated with binormal vectors on each Path3D curve point.
  4821. */
  4822. getBinormals(): Vector3[];
  4823. /**
  4824. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4825. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4826. */
  4827. getDistances(): number[];
  4828. /**
  4829. * Returns an interpolated point along this path
  4830. * @param position the position of the point along this path, from 0.0 to 1.0
  4831. * @returns a new Vector3 as the point
  4832. */
  4833. getPointAt(position: number): Vector3;
  4834. /**
  4835. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4836. * @param position the position of the point along this path, from 0.0 to 1.0
  4837. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4838. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4839. */
  4840. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4841. /**
  4842. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4843. * @param position the position of the point along this path, from 0.0 to 1.0
  4844. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4845. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4846. */
  4847. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4848. /**
  4849. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4850. * @param position the position of the point along this path, from 0.0 to 1.0
  4851. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4852. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4853. */
  4854. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4855. /**
  4856. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4857. * @param position the position of the point along this path, from 0.0 to 1.0
  4858. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4859. */
  4860. getDistanceAt(position: number): number;
  4861. /**
  4862. * Returns the array index of the previous point of an interpolated point along this path
  4863. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4864. * @returns the array index
  4865. */
  4866. getPreviousPointIndexAt(position: number): number;
  4867. /**
  4868. * 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)
  4869. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4870. * @returns the sub position
  4871. */
  4872. getSubPositionAt(position: number): number;
  4873. /**
  4874. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4875. * @param target the vector of which to get the closest position to
  4876. * @returns the position of the closest virtual point on this path to the target vector
  4877. */
  4878. getClosestPositionTo(target: Vector3): number;
  4879. /**
  4880. * Returns a sub path (slice) of this path
  4881. * @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
  4882. * @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
  4883. * @returns a sub path (slice) of this path
  4884. */
  4885. slice(start?: number, end?: number): Path3D;
  4886. /**
  4887. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4888. * @param path path which all values are copied into the curves points
  4889. * @param firstNormal which should be projected onto the curve
  4890. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4891. * @returns the same object updated.
  4892. */
  4893. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4894. private _compute;
  4895. private _getFirstNonNullVector;
  4896. private _getLastNonNullVector;
  4897. private _normalVector;
  4898. /**
  4899. * Updates the point at data for an interpolated point along this curve
  4900. * @param position the position of the point along this curve, from 0.0 to 1.0
  4901. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4902. * @returns the (updated) point at data
  4903. */
  4904. private _updatePointAtData;
  4905. /**
  4906. * Updates the point at data from the specified parameters
  4907. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4908. * @param point the interpolated point
  4909. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4910. */
  4911. private _setPointAtData;
  4912. /**
  4913. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4914. */
  4915. private _updateInterpolationMatrix;
  4916. }
  4917. /**
  4918. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4919. * A Curve3 is designed from a series of successive Vector3.
  4920. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4921. */
  4922. export class Curve3 {
  4923. private _points;
  4924. private _length;
  4925. /**
  4926. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4927. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4928. * @param v1 (Vector3) the control point
  4929. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4930. * @param nbPoints (integer) the wanted number of points in the curve
  4931. * @returns the created Curve3
  4932. */
  4933. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4934. /**
  4935. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4936. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4937. * @param v1 (Vector3) the first control point
  4938. * @param v2 (Vector3) the second control point
  4939. * @param v3 (Vector3) the end point of the Cubic Bezier
  4940. * @param nbPoints (integer) the wanted number of points in the curve
  4941. * @returns the created Curve3
  4942. */
  4943. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4944. /**
  4945. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4946. * @param p1 (Vector3) the origin point of the Hermite Spline
  4947. * @param t1 (Vector3) the tangent vector at the origin point
  4948. * @param p2 (Vector3) the end point of the Hermite Spline
  4949. * @param t2 (Vector3) the tangent vector at the end point
  4950. * @param nbPoints (integer) the wanted number of points in the curve
  4951. * @returns the created Curve3
  4952. */
  4953. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4954. /**
  4955. * Returns a Curve3 object along a CatmullRom Spline curve :
  4956. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4957. * @param nbPoints (integer) the wanted number of points between each curve control points
  4958. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4959. * @returns the created Curve3
  4960. */
  4961. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  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. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4966. * @param points points which make up the curve
  4967. */
  4968. constructor(points: Vector3[]);
  4969. /**
  4970. * @returns the Curve3 stored array of successive Vector3
  4971. */
  4972. getPoints(): Vector3[];
  4973. /**
  4974. * @returns the computed length (float) of the curve.
  4975. */
  4976. length(): number;
  4977. /**
  4978. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4979. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4980. * curveA and curveB keep unchanged.
  4981. * @param curve the curve to continue from this curve
  4982. * @returns the newly constructed curve
  4983. */
  4984. continue(curve: DeepImmutable<Curve3>): Curve3;
  4985. private _computeLength;
  4986. }
  4987. }
  4988. declare module BABYLON {
  4989. /**
  4990. * This represents the main contract an easing function should follow.
  4991. * Easing functions are used throughout the animation system.
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export interface IEasingFunction {
  4995. /**
  4996. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4997. * of the easing function.
  4998. * The link below provides some of the most common examples of easing functions.
  4999. * @see https://easings.net/
  5000. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5001. * @returns the corresponding value on the curve defined by the easing function
  5002. */
  5003. ease(gradient: number): number;
  5004. }
  5005. /**
  5006. * Base class used for every default easing function.
  5007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5008. */
  5009. export class EasingFunction implements IEasingFunction {
  5010. /**
  5011. * Interpolation follows the mathematical formula associated with the easing function.
  5012. */
  5013. static readonly EASINGMODE_EASEIN: number;
  5014. /**
  5015. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5016. */
  5017. static readonly EASINGMODE_EASEOUT: number;
  5018. /**
  5019. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5020. */
  5021. static readonly EASINGMODE_EASEINOUT: number;
  5022. private _easingMode;
  5023. /**
  5024. * Sets the easing mode of the current function.
  5025. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5026. */
  5027. setEasingMode(easingMode: number): void;
  5028. /**
  5029. * Gets the current easing mode.
  5030. * @returns the easing mode
  5031. */
  5032. getEasingMode(): number;
  5033. /**
  5034. * @hidden
  5035. */
  5036. easeInCore(gradient: number): number;
  5037. /**
  5038. * Given an input gradient between 0 and 1, this returns the corresponding value
  5039. * of the easing function.
  5040. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5041. * @returns the corresponding value on the curve defined by the easing function
  5042. */
  5043. ease(gradient: number): number;
  5044. }
  5045. /**
  5046. * Easing function with a circle shape (see link below).
  5047. * @see https://easings.net/#easeInCirc
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class CircleEase extends EasingFunction implements IEasingFunction {
  5051. /** @hidden */
  5052. easeInCore(gradient: number): number;
  5053. }
  5054. /**
  5055. * Easing function with a ease back shape (see link below).
  5056. * @see https://easings.net/#easeInBack
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class BackEase extends EasingFunction implements IEasingFunction {
  5060. /** Defines the amplitude of the function */
  5061. amplitude: number;
  5062. /**
  5063. * Instantiates a back ease easing
  5064. * @see https://easings.net/#easeInBack
  5065. * @param amplitude Defines the amplitude of the function
  5066. */
  5067. constructor(
  5068. /** Defines the amplitude of the function */
  5069. amplitude?: number);
  5070. /** @hidden */
  5071. easeInCore(gradient: number): number;
  5072. }
  5073. /**
  5074. * Easing function with a bouncing shape (see link below).
  5075. * @see https://easings.net/#easeInBounce
  5076. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5077. */
  5078. export class BounceEase extends EasingFunction implements IEasingFunction {
  5079. /** Defines the number of bounces */
  5080. bounces: number;
  5081. /** Defines the amplitude of the bounce */
  5082. bounciness: number;
  5083. /**
  5084. * Instantiates a bounce easing
  5085. * @see https://easings.net/#easeInBounce
  5086. * @param bounces Defines the number of bounces
  5087. * @param bounciness Defines the amplitude of the bounce
  5088. */
  5089. constructor(
  5090. /** Defines the number of bounces */
  5091. bounces?: number,
  5092. /** Defines the amplitude of the bounce */
  5093. bounciness?: number);
  5094. /** @hidden */
  5095. easeInCore(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a power of 3 shape (see link below).
  5099. * @see https://easings.net/#easeInCubic
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class CubicEase extends EasingFunction implements IEasingFunction {
  5103. /** @hidden */
  5104. easeInCore(gradient: number): number;
  5105. }
  5106. /**
  5107. * Easing function with an elastic shape (see link below).
  5108. * @see https://easings.net/#easeInElastic
  5109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5110. */
  5111. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5112. /** Defines the number of oscillations*/
  5113. oscillations: number;
  5114. /** Defines the amplitude of the oscillations*/
  5115. springiness: number;
  5116. /**
  5117. * Instantiates an elastic easing function
  5118. * @see https://easings.net/#easeInElastic
  5119. * @param oscillations Defines the number of oscillations
  5120. * @param springiness Defines the amplitude of the oscillations
  5121. */
  5122. constructor(
  5123. /** Defines the number of oscillations*/
  5124. oscillations?: number,
  5125. /** Defines the amplitude of the oscillations*/
  5126. springiness?: number);
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with an exponential shape (see link below).
  5132. * @see https://easings.net/#easeInExpo
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the exponent of the function */
  5137. exponent: number;
  5138. /**
  5139. * Instantiates an exponential easing function
  5140. * @see https://easings.net/#easeInExpo
  5141. * @param exponent Defines the exponent of the function
  5142. */
  5143. constructor(
  5144. /** Defines the exponent of the function */
  5145. exponent?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a power shape (see link below).
  5151. * @see https://easings.net/#easeInQuad
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class PowerEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the power of the function */
  5156. power: number;
  5157. /**
  5158. * Instantiates an power base easing function
  5159. * @see https://easings.net/#easeInQuad
  5160. * @param power Defines the power of the function
  5161. */
  5162. constructor(
  5163. /** Defines the power of the function */
  5164. power?: number);
  5165. /** @hidden */
  5166. easeInCore(gradient: number): number;
  5167. }
  5168. /**
  5169. * Easing function with a power of 2 shape (see link below).
  5170. * @see https://easings.net/#easeInQuad
  5171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5172. */
  5173. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5174. /** @hidden */
  5175. easeInCore(gradient: number): number;
  5176. }
  5177. /**
  5178. * Easing function with a power of 4 shape (see link below).
  5179. * @see https://easings.net/#easeInQuart
  5180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5181. */
  5182. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5183. /** @hidden */
  5184. easeInCore(gradient: number): number;
  5185. }
  5186. /**
  5187. * Easing function with a power of 5 shape (see link below).
  5188. * @see https://easings.net/#easeInQuint
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5192. /** @hidden */
  5193. easeInCore(gradient: number): number;
  5194. }
  5195. /**
  5196. * Easing function with a sin shape (see link below).
  5197. * @see https://easings.net/#easeInSine
  5198. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5199. */
  5200. export class SineEase extends EasingFunction implements IEasingFunction {
  5201. /** @hidden */
  5202. easeInCore(gradient: number): number;
  5203. }
  5204. /**
  5205. * Easing function with a bezier shape (see link below).
  5206. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5208. */
  5209. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5210. /** Defines the x component of the start tangent in the bezier curve */
  5211. x1: number;
  5212. /** Defines the y component of the start tangent in the bezier curve */
  5213. y1: number;
  5214. /** Defines the x component of the end tangent in the bezier curve */
  5215. x2: number;
  5216. /** Defines the y component of the end tangent in the bezier curve */
  5217. y2: number;
  5218. /**
  5219. * Instantiates a bezier function
  5220. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5221. * @param x1 Defines the x component of the start tangent in the bezier curve
  5222. * @param y1 Defines the y component of the start tangent in the bezier curve
  5223. * @param x2 Defines the x component of the end tangent in the bezier curve
  5224. * @param y2 Defines the y component of the end tangent in the bezier curve
  5225. */
  5226. constructor(
  5227. /** Defines the x component of the start tangent in the bezier curve */
  5228. x1?: number,
  5229. /** Defines the y component of the start tangent in the bezier curve */
  5230. y1?: number,
  5231. /** Defines the x component of the end tangent in the bezier curve */
  5232. x2?: number,
  5233. /** Defines the y component of the end tangent in the bezier curve */
  5234. y2?: number);
  5235. /** @hidden */
  5236. easeInCore(gradient: number): number;
  5237. }
  5238. }
  5239. declare module BABYLON {
  5240. /**
  5241. * Class used to hold a RBG color
  5242. */
  5243. export class Color3 {
  5244. /**
  5245. * Defines the red component (between 0 and 1, default is 0)
  5246. */
  5247. r: number;
  5248. /**
  5249. * Defines the green component (between 0 and 1, default is 0)
  5250. */
  5251. g: number;
  5252. /**
  5253. * Defines the blue component (between 0 and 1, default is 0)
  5254. */
  5255. b: number;
  5256. /**
  5257. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5258. * @param r defines the red component (between 0 and 1, default is 0)
  5259. * @param g defines the green component (between 0 and 1, default is 0)
  5260. * @param b defines the blue component (between 0 and 1, default is 0)
  5261. */
  5262. constructor(
  5263. /**
  5264. * Defines the red component (between 0 and 1, default is 0)
  5265. */
  5266. r?: number,
  5267. /**
  5268. * Defines the green component (between 0 and 1, default is 0)
  5269. */
  5270. g?: number,
  5271. /**
  5272. * Defines the blue component (between 0 and 1, default is 0)
  5273. */
  5274. b?: number);
  5275. /**
  5276. * Creates a string with the Color3 current values
  5277. * @returns the string representation of the Color3 object
  5278. */
  5279. toString(): string;
  5280. /**
  5281. * Returns the string "Color3"
  5282. * @returns "Color3"
  5283. */
  5284. getClassName(): string;
  5285. /**
  5286. * Compute the Color3 hash code
  5287. * @returns an unique number that can be used to hash Color3 objects
  5288. */
  5289. getHashCode(): number;
  5290. /**
  5291. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5292. * @param array defines the array where to store the r,g,b components
  5293. * @param index defines an optional index in the target array to define where to start storing values
  5294. * @returns the current Color3 object
  5295. */
  5296. toArray(array: FloatArray, index?: number): Color3;
  5297. /**
  5298. * Returns a new Color4 object from the current Color3 and the given alpha
  5299. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5300. * @returns a new Color4 object
  5301. */
  5302. toColor4(alpha?: number): Color4;
  5303. /**
  5304. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5305. * @returns the new array
  5306. */
  5307. asArray(): number[];
  5308. /**
  5309. * Returns the luminance value
  5310. * @returns a float value
  5311. */
  5312. toLuminance(): number;
  5313. /**
  5314. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5315. * @param otherColor defines the second operand
  5316. * @returns the new Color3 object
  5317. */
  5318. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5319. /**
  5320. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5321. * @param otherColor defines the second operand
  5322. * @param result defines the Color3 object where to store the result
  5323. * @returns the current Color3
  5324. */
  5325. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5326. /**
  5327. * Determines equality between Color3 objects
  5328. * @param otherColor defines the second operand
  5329. * @returns true if the rgb values are equal to the given ones
  5330. */
  5331. equals(otherColor: DeepImmutable<Color3>): boolean;
  5332. /**
  5333. * Determines equality between the current Color3 object and a set of r,b,g values
  5334. * @param r defines the red component to check
  5335. * @param g defines the green component to check
  5336. * @param b defines the blue component to check
  5337. * @returns true if the rgb values are equal to the given ones
  5338. */
  5339. equalsFloats(r: number, g: number, b: number): boolean;
  5340. /**
  5341. * Multiplies in place each rgb value by scale
  5342. * @param scale defines the scaling factor
  5343. * @returns the updated Color3
  5344. */
  5345. scale(scale: number): Color3;
  5346. /**
  5347. * Multiplies the rgb values by scale and stores the result into "result"
  5348. * @param scale defines the scaling factor
  5349. * @param result defines the Color3 object where to store the result
  5350. * @returns the unmodified current Color3
  5351. */
  5352. scaleToRef(scale: number, result: Color3): Color3;
  5353. /**
  5354. * Scale the current Color3 values by a factor and add the result to a given Color3
  5355. * @param scale defines the scale factor
  5356. * @param result defines color to store the result into
  5357. * @returns the unmodified current Color3
  5358. */
  5359. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5360. /**
  5361. * Clamps the rgb values by the min and max values and stores the result into "result"
  5362. * @param min defines minimum clamping value (default is 0)
  5363. * @param max defines maximum clamping value (default is 1)
  5364. * @param result defines color to store the result into
  5365. * @returns the original Color3
  5366. */
  5367. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5368. /**
  5369. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5370. * @param otherColor defines the second operand
  5371. * @returns the new Color3
  5372. */
  5373. add(otherColor: DeepImmutable<Color3>): Color3;
  5374. /**
  5375. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5376. * @param otherColor defines the second operand
  5377. * @param result defines Color3 object to store the result into
  5378. * @returns the unmodified current Color3
  5379. */
  5380. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5381. /**
  5382. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5383. * @param otherColor defines the second operand
  5384. * @returns the new Color3
  5385. */
  5386. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5387. /**
  5388. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5389. * @param otherColor defines the second operand
  5390. * @param result defines Color3 object to store the result into
  5391. * @returns the unmodified current Color3
  5392. */
  5393. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5394. /**
  5395. * Copy the current object
  5396. * @returns a new Color3 copied the current one
  5397. */
  5398. clone(): Color3;
  5399. /**
  5400. * Copies the rgb values from the source in the current Color3
  5401. * @param source defines the source Color3 object
  5402. * @returns the updated Color3 object
  5403. */
  5404. copyFrom(source: DeepImmutable<Color3>): Color3;
  5405. /**
  5406. * Updates the Color3 rgb values from the given floats
  5407. * @param r defines the red component to read from
  5408. * @param g defines the green component to read from
  5409. * @param b defines the blue component to read from
  5410. * @returns the current Color3 object
  5411. */
  5412. copyFromFloats(r: number, g: number, b: number): Color3;
  5413. /**
  5414. * Updates the Color3 rgb values from the given floats
  5415. * @param r defines the red component to read from
  5416. * @param g defines the green component to read from
  5417. * @param b defines the blue component to read from
  5418. * @returns the current Color3 object
  5419. */
  5420. set(r: number, g: number, b: number): Color3;
  5421. /**
  5422. * Compute the Color3 hexadecimal code as a string
  5423. * @returns a string containing the hexadecimal representation of the Color3 object
  5424. */
  5425. toHexString(): string;
  5426. /**
  5427. * Computes a new Color3 converted from the current one to linear space
  5428. * @returns a new Color3 object
  5429. */
  5430. toLinearSpace(): Color3;
  5431. /**
  5432. * Converts current color in rgb space to HSV values
  5433. * @returns a new color3 representing the HSV values
  5434. */
  5435. toHSV(): Color3;
  5436. /**
  5437. * Converts current color in rgb space to HSV values
  5438. * @param result defines the Color3 where to store the HSV values
  5439. */
  5440. toHSVToRef(result: Color3): void;
  5441. /**
  5442. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5443. * @param convertedColor defines the Color3 object where to store the linear space version
  5444. * @returns the unmodified Color3
  5445. */
  5446. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5447. /**
  5448. * Computes a new Color3 converted from the current one to gamma space
  5449. * @returns a new Color3 object
  5450. */
  5451. toGammaSpace(): Color3;
  5452. /**
  5453. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5454. * @param convertedColor defines the Color3 object where to store the gamma space version
  5455. * @returns the unmodified Color3
  5456. */
  5457. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5458. private static _BlackReadOnly;
  5459. /**
  5460. * Convert Hue, saturation and value to a Color3 (RGB)
  5461. * @param hue defines the hue
  5462. * @param saturation defines the saturation
  5463. * @param value defines the value
  5464. * @param result defines the Color3 where to store the RGB values
  5465. */
  5466. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5467. /**
  5468. * Creates a new Color3 from the string containing valid hexadecimal values
  5469. * @param hex defines a string containing valid hexadecimal values
  5470. * @returns a new Color3 object
  5471. */
  5472. static FromHexString(hex: string): Color3;
  5473. /**
  5474. * Creates a new Color3 from the starting index of the given array
  5475. * @param array defines the source array
  5476. * @param offset defines an offset in the source array
  5477. * @returns a new Color3 object
  5478. */
  5479. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5480. /**
  5481. * Creates a new Color3 from integer values (< 256)
  5482. * @param r defines the red component to read from (value between 0 and 255)
  5483. * @param g defines the green component to read from (value between 0 and 255)
  5484. * @param b defines the blue component to read from (value between 0 and 255)
  5485. * @returns a new Color3 object
  5486. */
  5487. static FromInts(r: number, g: number, b: number): Color3;
  5488. /**
  5489. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5490. * @param start defines the start Color3 value
  5491. * @param end defines the end Color3 value
  5492. * @param amount defines the gradient value between start and end
  5493. * @returns a new Color3 object
  5494. */
  5495. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5496. /**
  5497. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5498. * @param left defines the start value
  5499. * @param right defines the end value
  5500. * @param amount defines the gradient factor
  5501. * @param result defines the Color3 object where to store the result
  5502. */
  5503. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5504. /**
  5505. * Returns a Color3 value containing a red color
  5506. * @returns a new Color3 object
  5507. */
  5508. static Red(): Color3;
  5509. /**
  5510. * Returns a Color3 value containing a green color
  5511. * @returns a new Color3 object
  5512. */
  5513. static Green(): Color3;
  5514. /**
  5515. * Returns a Color3 value containing a blue color
  5516. * @returns a new Color3 object
  5517. */
  5518. static Blue(): Color3;
  5519. /**
  5520. * Returns a Color3 value containing a black color
  5521. * @returns a new Color3 object
  5522. */
  5523. static Black(): Color3;
  5524. /**
  5525. * Gets a Color3 value containing a black color that must not be updated
  5526. */
  5527. static get BlackReadOnly(): DeepImmutable<Color3>;
  5528. /**
  5529. * Returns a Color3 value containing a white color
  5530. * @returns a new Color3 object
  5531. */
  5532. static White(): Color3;
  5533. /**
  5534. * Returns a Color3 value containing a purple color
  5535. * @returns a new Color3 object
  5536. */
  5537. static Purple(): Color3;
  5538. /**
  5539. * Returns a Color3 value containing a magenta color
  5540. * @returns a new Color3 object
  5541. */
  5542. static Magenta(): Color3;
  5543. /**
  5544. * Returns a Color3 value containing a yellow color
  5545. * @returns a new Color3 object
  5546. */
  5547. static Yellow(): Color3;
  5548. /**
  5549. * Returns a Color3 value containing a gray color
  5550. * @returns a new Color3 object
  5551. */
  5552. static Gray(): Color3;
  5553. /**
  5554. * Returns a Color3 value containing a teal color
  5555. * @returns a new Color3 object
  5556. */
  5557. static Teal(): Color3;
  5558. /**
  5559. * Returns a Color3 value containing a random color
  5560. * @returns a new Color3 object
  5561. */
  5562. static Random(): Color3;
  5563. }
  5564. /**
  5565. * Class used to hold a RBGA color
  5566. */
  5567. export class Color4 {
  5568. /**
  5569. * Defines the red component (between 0 and 1, default is 0)
  5570. */
  5571. r: number;
  5572. /**
  5573. * Defines the green component (between 0 and 1, default is 0)
  5574. */
  5575. g: number;
  5576. /**
  5577. * Defines the blue component (between 0 and 1, default is 0)
  5578. */
  5579. b: number;
  5580. /**
  5581. * Defines the alpha component (between 0 and 1, default is 1)
  5582. */
  5583. a: number;
  5584. /**
  5585. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5586. * @param r defines the red component (between 0 and 1, default is 0)
  5587. * @param g defines the green component (between 0 and 1, default is 0)
  5588. * @param b defines the blue component (between 0 and 1, default is 0)
  5589. * @param a defines the alpha component (between 0 and 1, default is 1)
  5590. */
  5591. constructor(
  5592. /**
  5593. * Defines the red component (between 0 and 1, default is 0)
  5594. */
  5595. r?: number,
  5596. /**
  5597. * Defines the green component (between 0 and 1, default is 0)
  5598. */
  5599. g?: number,
  5600. /**
  5601. * Defines the blue component (between 0 and 1, default is 0)
  5602. */
  5603. b?: number,
  5604. /**
  5605. * Defines the alpha component (between 0 and 1, default is 1)
  5606. */
  5607. a?: number);
  5608. /**
  5609. * Adds in place the given Color4 values to the current Color4 object
  5610. * @param right defines the second operand
  5611. * @returns the current updated Color4 object
  5612. */
  5613. addInPlace(right: DeepImmutable<Color4>): Color4;
  5614. /**
  5615. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5616. * @returns the new array
  5617. */
  5618. asArray(): number[];
  5619. /**
  5620. * Stores from the starting index in the given array the Color4 successive values
  5621. * @param array defines the array where to store the r,g,b components
  5622. * @param index defines an optional index in the target array to define where to start storing values
  5623. * @returns the current Color4 object
  5624. */
  5625. toArray(array: number[], index?: number): Color4;
  5626. /**
  5627. * Determines equality between Color4 objects
  5628. * @param otherColor defines the second operand
  5629. * @returns true if the rgba values are equal to the given ones
  5630. */
  5631. equals(otherColor: DeepImmutable<Color4>): boolean;
  5632. /**
  5633. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5634. * @param right defines the second operand
  5635. * @returns a new Color4 object
  5636. */
  5637. add(right: DeepImmutable<Color4>): Color4;
  5638. /**
  5639. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5640. * @param right defines the second operand
  5641. * @returns a new Color4 object
  5642. */
  5643. subtract(right: DeepImmutable<Color4>): Color4;
  5644. /**
  5645. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5646. * @param right defines the second operand
  5647. * @param result defines the Color4 object where to store the result
  5648. * @returns the current Color4 object
  5649. */
  5650. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5651. /**
  5652. * Creates a new Color4 with the current Color4 values multiplied by scale
  5653. * @param scale defines the scaling factor to apply
  5654. * @returns a new Color4 object
  5655. */
  5656. scale(scale: number): Color4;
  5657. /**
  5658. * Multiplies the current Color4 values by scale and stores the result in "result"
  5659. * @param scale defines the scaling factor to apply
  5660. * @param result defines the Color4 object where to store the result
  5661. * @returns the current unmodified Color4
  5662. */
  5663. scaleToRef(scale: number, result: Color4): Color4;
  5664. /**
  5665. * Scale the current Color4 values by a factor and add the result to a given Color4
  5666. * @param scale defines the scale factor
  5667. * @param result defines the Color4 object where to store the result
  5668. * @returns the unmodified current Color4
  5669. */
  5670. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5671. /**
  5672. * Clamps the rgb values by the min and max values and stores the result into "result"
  5673. * @param min defines minimum clamping value (default is 0)
  5674. * @param max defines maximum clamping value (default is 1)
  5675. * @param result defines color to store the result into.
  5676. * @returns the cuurent Color4
  5677. */
  5678. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5679. /**
  5680. * Multipy an Color4 value by another and return a new Color4 object
  5681. * @param color defines the Color4 value to multiply by
  5682. * @returns a new Color4 object
  5683. */
  5684. multiply(color: Color4): Color4;
  5685. /**
  5686. * Multipy a Color4 value by another and push the result in a reference value
  5687. * @param color defines the Color4 value to multiply by
  5688. * @param result defines the Color4 to fill the result in
  5689. * @returns the result Color4
  5690. */
  5691. multiplyToRef(color: Color4, result: Color4): Color4;
  5692. /**
  5693. * Creates a string with the Color4 current values
  5694. * @returns the string representation of the Color4 object
  5695. */
  5696. toString(): string;
  5697. /**
  5698. * Returns the string "Color4"
  5699. * @returns "Color4"
  5700. */
  5701. getClassName(): string;
  5702. /**
  5703. * Compute the Color4 hash code
  5704. * @returns an unique number that can be used to hash Color4 objects
  5705. */
  5706. getHashCode(): number;
  5707. /**
  5708. * Creates a new Color4 copied from the current one
  5709. * @returns a new Color4 object
  5710. */
  5711. clone(): Color4;
  5712. /**
  5713. * Copies the given Color4 values into the current one
  5714. * @param source defines the source Color4 object
  5715. * @returns the current updated Color4 object
  5716. */
  5717. copyFrom(source: Color4): Color4;
  5718. /**
  5719. * Copies the given float values into the current one
  5720. * @param r defines the red component to read from
  5721. * @param g defines the green component to read from
  5722. * @param b defines the blue component to read from
  5723. * @param a defines the alpha component to read from
  5724. * @returns the current updated Color4 object
  5725. */
  5726. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5727. /**
  5728. * Copies the given float values into the current one
  5729. * @param r defines the red component to read from
  5730. * @param g defines the green component to read from
  5731. * @param b defines the blue component to read from
  5732. * @param a defines the alpha component to read from
  5733. * @returns the current updated Color4 object
  5734. */
  5735. set(r: number, g: number, b: number, a: number): Color4;
  5736. /**
  5737. * Compute the Color4 hexadecimal code as a string
  5738. * @returns a string containing the hexadecimal representation of the Color4 object
  5739. */
  5740. toHexString(): string;
  5741. /**
  5742. * Computes a new Color4 converted from the current one to linear space
  5743. * @returns a new Color4 object
  5744. */
  5745. toLinearSpace(): Color4;
  5746. /**
  5747. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5748. * @param convertedColor defines the Color4 object where to store the linear space version
  5749. * @returns the unmodified Color4
  5750. */
  5751. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5752. /**
  5753. * Computes a new Color4 converted from the current one to gamma space
  5754. * @returns a new Color4 object
  5755. */
  5756. toGammaSpace(): Color4;
  5757. /**
  5758. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5759. * @param convertedColor defines the Color4 object where to store the gamma space version
  5760. * @returns the unmodified Color4
  5761. */
  5762. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5763. /**
  5764. * Creates a new Color4 from the string containing valid hexadecimal values
  5765. * @param hex defines a string containing valid hexadecimal values
  5766. * @returns a new Color4 object
  5767. */
  5768. static FromHexString(hex: string): Color4;
  5769. /**
  5770. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5771. * @param left defines the start value
  5772. * @param right defines the end value
  5773. * @param amount defines the gradient factor
  5774. * @returns a new Color4 object
  5775. */
  5776. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5777. /**
  5778. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5779. * @param left defines the start value
  5780. * @param right defines the end value
  5781. * @param amount defines the gradient factor
  5782. * @param result defines the Color4 object where to store data
  5783. */
  5784. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5785. /**
  5786. * Creates a new Color4 from a Color3 and an alpha value
  5787. * @param color3 defines the source Color3 to read from
  5788. * @param alpha defines the alpha component (1.0 by default)
  5789. * @returns a new Color4 object
  5790. */
  5791. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5792. /**
  5793. * Creates a new Color4 from the starting index element of the given array
  5794. * @param array defines the source array to read from
  5795. * @param offset defines the offset in the source array
  5796. * @returns a new Color4 object
  5797. */
  5798. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5799. /**
  5800. * Creates a new Color3 from integer values (< 256)
  5801. * @param r defines the red component to read from (value between 0 and 255)
  5802. * @param g defines the green component to read from (value between 0 and 255)
  5803. * @param b defines the blue component to read from (value between 0 and 255)
  5804. * @param a defines the alpha component to read from (value between 0 and 255)
  5805. * @returns a new Color3 object
  5806. */
  5807. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5808. /**
  5809. * Check the content of a given array and convert it to an array containing RGBA data
  5810. * If the original array was already containing count * 4 values then it is returned directly
  5811. * @param colors defines the array to check
  5812. * @param count defines the number of RGBA data to expect
  5813. * @returns an array containing count * 4 values (RGBA)
  5814. */
  5815. static CheckColors4(colors: number[], count: number): number[];
  5816. }
  5817. /**
  5818. * @hidden
  5819. */
  5820. export class TmpColors {
  5821. static Color3: Color3[];
  5822. static Color4: Color4[];
  5823. }
  5824. }
  5825. declare module BABYLON {
  5826. /**
  5827. * Defines an interface which represents an animation key frame
  5828. */
  5829. export interface IAnimationKey {
  5830. /**
  5831. * Frame of the key frame
  5832. */
  5833. frame: number;
  5834. /**
  5835. * Value at the specifies key frame
  5836. */
  5837. value: any;
  5838. /**
  5839. * The input tangent for the cubic hermite spline
  5840. */
  5841. inTangent?: any;
  5842. /**
  5843. * The output tangent for the cubic hermite spline
  5844. */
  5845. outTangent?: any;
  5846. /**
  5847. * The animation interpolation type
  5848. */
  5849. interpolation?: AnimationKeyInterpolation;
  5850. }
  5851. /**
  5852. * Enum for the animation key frame interpolation type
  5853. */
  5854. export enum AnimationKeyInterpolation {
  5855. /**
  5856. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5857. */
  5858. STEP = 1
  5859. }
  5860. }
  5861. declare module BABYLON {
  5862. /**
  5863. * Represents the range of an animation
  5864. */
  5865. export class AnimationRange {
  5866. /**The name of the animation range**/
  5867. name: string;
  5868. /**The starting frame of the animation */
  5869. from: number;
  5870. /**The ending frame of the animation*/
  5871. to: number;
  5872. /**
  5873. * Initializes the range of an animation
  5874. * @param name The name of the animation range
  5875. * @param from The starting frame of the animation
  5876. * @param to The ending frame of the animation
  5877. */
  5878. constructor(
  5879. /**The name of the animation range**/
  5880. name: string,
  5881. /**The starting frame of the animation */
  5882. from: number,
  5883. /**The ending frame of the animation*/
  5884. to: number);
  5885. /**
  5886. * Makes a copy of the animation range
  5887. * @returns A copy of the animation range
  5888. */
  5889. clone(): AnimationRange;
  5890. }
  5891. }
  5892. declare module BABYLON {
  5893. /**
  5894. * Composed of a frame, and an action function
  5895. */
  5896. export class AnimationEvent {
  5897. /** The frame for which the event is triggered **/
  5898. frame: number;
  5899. /** The event to perform when triggered **/
  5900. action: (currentFrame: number) => void;
  5901. /** Specifies if the event should be triggered only once**/
  5902. onlyOnce?: boolean | undefined;
  5903. /**
  5904. * Specifies if the animation event is done
  5905. */
  5906. isDone: boolean;
  5907. /**
  5908. * Initializes the animation event
  5909. * @param frame The frame for which the event is triggered
  5910. * @param action The event to perform when triggered
  5911. * @param onlyOnce Specifies if the event should be triggered only once
  5912. */
  5913. constructor(
  5914. /** The frame for which the event is triggered **/
  5915. frame: number,
  5916. /** The event to perform when triggered **/
  5917. action: (currentFrame: number) => void,
  5918. /** Specifies if the event should be triggered only once**/
  5919. onlyOnce?: boolean | undefined);
  5920. /** @hidden */
  5921. _clone(): AnimationEvent;
  5922. }
  5923. }
  5924. declare module BABYLON {
  5925. /**
  5926. * Interface used to define a behavior
  5927. */
  5928. export interface Behavior<T> {
  5929. /** gets or sets behavior's name */
  5930. name: string;
  5931. /**
  5932. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5933. */
  5934. init(): void;
  5935. /**
  5936. * Called when the behavior is attached to a target
  5937. * @param target defines the target where the behavior is attached to
  5938. */
  5939. attach(target: T): void;
  5940. /**
  5941. * Called when the behavior is detached from its target
  5942. */
  5943. detach(): void;
  5944. }
  5945. /**
  5946. * Interface implemented by classes supporting behaviors
  5947. */
  5948. export interface IBehaviorAware<T> {
  5949. /**
  5950. * Attach a behavior
  5951. * @param behavior defines the behavior to attach
  5952. * @returns the current host
  5953. */
  5954. addBehavior(behavior: Behavior<T>): T;
  5955. /**
  5956. * Remove a behavior from the current object
  5957. * @param behavior defines the behavior to detach
  5958. * @returns the current host
  5959. */
  5960. removeBehavior(behavior: Behavior<T>): T;
  5961. /**
  5962. * Gets a behavior using its name to search
  5963. * @param name defines the name to search
  5964. * @returns the behavior or null if not found
  5965. */
  5966. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5967. }
  5968. }
  5969. declare module BABYLON {
  5970. /**
  5971. * Defines an array and its length.
  5972. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5973. */
  5974. export interface ISmartArrayLike<T> {
  5975. /**
  5976. * The data of the array.
  5977. */
  5978. data: Array<T>;
  5979. /**
  5980. * The active length of the array.
  5981. */
  5982. length: number;
  5983. }
  5984. /**
  5985. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5986. */
  5987. export class SmartArray<T> implements ISmartArrayLike<T> {
  5988. /**
  5989. * The full set of data from the array.
  5990. */
  5991. data: Array<T>;
  5992. /**
  5993. * The active length of the array.
  5994. */
  5995. length: number;
  5996. protected _id: number;
  5997. /**
  5998. * Instantiates a Smart Array.
  5999. * @param capacity defines the default capacity of the array.
  6000. */
  6001. constructor(capacity: number);
  6002. /**
  6003. * Pushes a value at the end of the active data.
  6004. * @param value defines the object to push in the array.
  6005. */
  6006. push(value: T): void;
  6007. /**
  6008. * Iterates over the active data and apply the lambda to them.
  6009. * @param func defines the action to apply on each value.
  6010. */
  6011. forEach(func: (content: T) => void): void;
  6012. /**
  6013. * Sorts the full sets of data.
  6014. * @param compareFn defines the comparison function to apply.
  6015. */
  6016. sort(compareFn: (a: T, b: T) => number): void;
  6017. /**
  6018. * Resets the active data to an empty array.
  6019. */
  6020. reset(): void;
  6021. /**
  6022. * Releases all the data from the array as well as the array.
  6023. */
  6024. dispose(): void;
  6025. /**
  6026. * Concats the active data with a given array.
  6027. * @param array defines the data to concatenate with.
  6028. */
  6029. concat(array: any): void;
  6030. /**
  6031. * Returns the position of a value in the active data.
  6032. * @param value defines the value to find the index for
  6033. * @returns the index if found in the active data otherwise -1
  6034. */
  6035. indexOf(value: T): number;
  6036. /**
  6037. * Returns whether an element is part of the active data.
  6038. * @param value defines the value to look for
  6039. * @returns true if found in the active data otherwise false
  6040. */
  6041. contains(value: T): boolean;
  6042. private static _GlobalId;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. * The data in this array can only be present once
  6047. */
  6048. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6049. private _duplicateId;
  6050. /**
  6051. * Pushes a value at the end of the active data.
  6052. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6053. * @param value defines the object to push in the array.
  6054. */
  6055. push(value: T): void;
  6056. /**
  6057. * Pushes a value at the end of the active data.
  6058. * If the data is already present, it won t be added again
  6059. * @param value defines the object to push in the array.
  6060. * @returns true if added false if it was already present
  6061. */
  6062. pushNoDuplicate(value: T): boolean;
  6063. /**
  6064. * Resets the active data to an empty array.
  6065. */
  6066. reset(): void;
  6067. /**
  6068. * Concats the active data with a given array.
  6069. * This ensures no dupplicate will be present in the result.
  6070. * @param array defines the data to concatenate with.
  6071. */
  6072. concatWithNoDuplicate(array: any): void;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * @ignore
  6078. * This is a list of all the different input types that are available in the application.
  6079. * Fo instance: ArcRotateCameraGamepadInput...
  6080. */
  6081. export var CameraInputTypes: {};
  6082. /**
  6083. * This is the contract to implement in order to create a new input class.
  6084. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6085. */
  6086. export interface ICameraInput<TCamera extends Camera> {
  6087. /**
  6088. * Defines the camera the input is attached to.
  6089. */
  6090. camera: Nullable<TCamera>;
  6091. /**
  6092. * Gets the class name of the current intput.
  6093. * @returns the class name
  6094. */
  6095. getClassName(): string;
  6096. /**
  6097. * Get the friendly name associated with the input class.
  6098. * @returns the input friendly name
  6099. */
  6100. getSimpleName(): string;
  6101. /**
  6102. * Attach the input controls to a specific dom element to get the input from.
  6103. * @param element Defines the element the controls should be listened from
  6104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6105. */
  6106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6107. /**
  6108. * Detach the current controls from the specified dom element.
  6109. * @param element Defines the element to stop listening the inputs from
  6110. */
  6111. detachControl(element: Nullable<HTMLElement>): void;
  6112. /**
  6113. * Update the current camera state depending on the inputs that have been used this frame.
  6114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6115. */
  6116. checkInputs?: () => void;
  6117. }
  6118. /**
  6119. * Represents a map of input types to input instance or input index to input instance.
  6120. */
  6121. export interface CameraInputsMap<TCamera extends Camera> {
  6122. /**
  6123. * Accessor to the input by input type.
  6124. */
  6125. [name: string]: ICameraInput<TCamera>;
  6126. /**
  6127. * Accessor to the input by input index.
  6128. */
  6129. [idx: number]: ICameraInput<TCamera>;
  6130. }
  6131. /**
  6132. * This represents the input manager used within a camera.
  6133. * It helps dealing with all the different kind of input attached to a camera.
  6134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6135. */
  6136. export class CameraInputsManager<TCamera extends Camera> {
  6137. /**
  6138. * Defines the list of inputs attahed to the camera.
  6139. */
  6140. attached: CameraInputsMap<TCamera>;
  6141. /**
  6142. * Defines the dom element the camera is collecting inputs from.
  6143. * This is null if the controls have not been attached.
  6144. */
  6145. attachedElement: Nullable<HTMLElement>;
  6146. /**
  6147. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6148. */
  6149. noPreventDefault: boolean;
  6150. /**
  6151. * Defined the camera the input manager belongs to.
  6152. */
  6153. camera: TCamera;
  6154. /**
  6155. * Update the current camera state depending on the inputs that have been used this frame.
  6156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6157. */
  6158. checkInputs: () => void;
  6159. /**
  6160. * Instantiate a new Camera Input Manager.
  6161. * @param camera Defines the camera the input manager blongs to
  6162. */
  6163. constructor(camera: TCamera);
  6164. /**
  6165. * Add an input method to a camera
  6166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6167. * @param input camera input method
  6168. */
  6169. add(input: ICameraInput<TCamera>): void;
  6170. /**
  6171. * Remove a specific input method from a camera
  6172. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6173. * @param inputToRemove camera input method
  6174. */
  6175. remove(inputToRemove: ICameraInput<TCamera>): void;
  6176. /**
  6177. * Remove a specific input type from a camera
  6178. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6179. * @param inputType the type of the input to remove
  6180. */
  6181. removeByType(inputType: string): void;
  6182. private _addCheckInputs;
  6183. /**
  6184. * Attach the input controls to the currently attached dom element to listen the events from.
  6185. * @param input Defines the input to attach
  6186. */
  6187. attachInput(input: ICameraInput<TCamera>): void;
  6188. /**
  6189. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6190. * @param element Defines the dom element to collect the events from
  6191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6192. */
  6193. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6194. /**
  6195. * Detach the current manager inputs controls from a specific dom element.
  6196. * @param element Defines the dom element to collect the events from
  6197. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6198. */
  6199. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6200. /**
  6201. * Rebuild the dynamic inputCheck function from the current list of
  6202. * defined inputs in the manager.
  6203. */
  6204. rebuildInputCheck(): void;
  6205. /**
  6206. * Remove all attached input methods from a camera
  6207. */
  6208. clear(): void;
  6209. /**
  6210. * Serialize the current input manager attached to a camera.
  6211. * This ensures than once parsed,
  6212. * the input associated to the camera will be identical to the current ones
  6213. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6214. */
  6215. serialize(serializedCamera: any): void;
  6216. /**
  6217. * Parses an input manager serialized JSON to restore the previous list of inputs
  6218. * and states associated to a camera.
  6219. * @param parsedCamera Defines the JSON to parse
  6220. */
  6221. parse(parsedCamera: any): void;
  6222. }
  6223. }
  6224. declare module BABYLON {
  6225. /**
  6226. * Class used to store data that will be store in GPU memory
  6227. */
  6228. export class Buffer {
  6229. private _engine;
  6230. private _buffer;
  6231. /** @hidden */
  6232. _data: Nullable<DataArray>;
  6233. private _updatable;
  6234. private _instanced;
  6235. private _divisor;
  6236. /**
  6237. * Gets the byte stride.
  6238. */
  6239. readonly byteStride: number;
  6240. /**
  6241. * Constructor
  6242. * @param engine the engine
  6243. * @param data the data to use for this buffer
  6244. * @param updatable whether the data is updatable
  6245. * @param stride the stride (optional)
  6246. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6247. * @param instanced whether the buffer is instanced (optional)
  6248. * @param useBytes set to true if the stride in in bytes (optional)
  6249. * @param divisor sets an optional divisor for instances (1 by default)
  6250. */
  6251. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6252. /**
  6253. * Create a new VertexBuffer based on the current buffer
  6254. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6255. * @param offset defines offset in the buffer (0 by default)
  6256. * @param size defines the size in floats of attributes (position is 3 for instance)
  6257. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6258. * @param instanced defines if the vertex buffer contains indexed data
  6259. * @param useBytes defines if the offset and stride are in bytes *
  6260. * @param divisor sets an optional divisor for instances (1 by default)
  6261. * @returns the new vertex buffer
  6262. */
  6263. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6264. /**
  6265. * Gets a boolean indicating if the Buffer is updatable?
  6266. * @returns true if the buffer is updatable
  6267. */
  6268. isUpdatable(): boolean;
  6269. /**
  6270. * Gets current buffer's data
  6271. * @returns a DataArray or null
  6272. */
  6273. getData(): Nullable<DataArray>;
  6274. /**
  6275. * Gets underlying native buffer
  6276. * @returns underlying native buffer
  6277. */
  6278. getBuffer(): Nullable<DataBuffer>;
  6279. /**
  6280. * Gets the stride in float32 units (i.e. byte stride / 4).
  6281. * May not be an integer if the byte stride is not divisible by 4.
  6282. * @returns the stride in float32 units
  6283. * @deprecated Please use byteStride instead.
  6284. */
  6285. getStrideSize(): number;
  6286. /**
  6287. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6288. * @param data defines the data to store
  6289. */
  6290. create(data?: Nullable<DataArray>): void;
  6291. /** @hidden */
  6292. _rebuild(): void;
  6293. /**
  6294. * Update current buffer data
  6295. * @param data defines the data to store
  6296. */
  6297. update(data: DataArray): void;
  6298. /**
  6299. * Updates the data directly.
  6300. * @param data the new data
  6301. * @param offset the new offset
  6302. * @param vertexCount the vertex count (optional)
  6303. * @param useBytes set to true if the offset is in bytes
  6304. */
  6305. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6306. /**
  6307. * Release all resources
  6308. */
  6309. dispose(): void;
  6310. }
  6311. /**
  6312. * Specialized buffer used to store vertex data
  6313. */
  6314. export class VertexBuffer {
  6315. /** @hidden */
  6316. _buffer: Buffer;
  6317. private _kind;
  6318. private _size;
  6319. private _ownsBuffer;
  6320. private _instanced;
  6321. private _instanceDivisor;
  6322. /**
  6323. * The byte type.
  6324. */
  6325. static readonly BYTE: number;
  6326. /**
  6327. * The unsigned byte type.
  6328. */
  6329. static readonly UNSIGNED_BYTE: number;
  6330. /**
  6331. * The short type.
  6332. */
  6333. static readonly SHORT: number;
  6334. /**
  6335. * The unsigned short type.
  6336. */
  6337. static readonly UNSIGNED_SHORT: number;
  6338. /**
  6339. * The integer type.
  6340. */
  6341. static readonly INT: number;
  6342. /**
  6343. * The unsigned integer type.
  6344. */
  6345. static readonly UNSIGNED_INT: number;
  6346. /**
  6347. * The float type.
  6348. */
  6349. static readonly FLOAT: number;
  6350. /**
  6351. * Gets or sets the instance divisor when in instanced mode
  6352. */
  6353. get instanceDivisor(): number;
  6354. set instanceDivisor(value: number);
  6355. /**
  6356. * Gets the byte stride.
  6357. */
  6358. readonly byteStride: number;
  6359. /**
  6360. * Gets the byte offset.
  6361. */
  6362. readonly byteOffset: number;
  6363. /**
  6364. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6365. */
  6366. readonly normalized: boolean;
  6367. /**
  6368. * Gets the data type of each component in the array.
  6369. */
  6370. readonly type: number;
  6371. /**
  6372. * Constructor
  6373. * @param engine the engine
  6374. * @param data the data to use for this vertex buffer
  6375. * @param kind the vertex buffer kind
  6376. * @param updatable whether the data is updatable
  6377. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6378. * @param stride the stride (optional)
  6379. * @param instanced whether the buffer is instanced (optional)
  6380. * @param offset the offset of the data (optional)
  6381. * @param size the number of components (optional)
  6382. * @param type the type of the component (optional)
  6383. * @param normalized whether the data contains normalized data (optional)
  6384. * @param useBytes set to true if stride and offset are in bytes (optional)
  6385. * @param divisor defines the instance divisor to use (1 by default)
  6386. */
  6387. 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);
  6388. /** @hidden */
  6389. _rebuild(): void;
  6390. /**
  6391. * Returns the kind of the VertexBuffer (string)
  6392. * @returns a string
  6393. */
  6394. getKind(): string;
  6395. /**
  6396. * Gets a boolean indicating if the VertexBuffer is updatable?
  6397. * @returns true if the buffer is updatable
  6398. */
  6399. isUpdatable(): boolean;
  6400. /**
  6401. * Gets current buffer's data
  6402. * @returns a DataArray or null
  6403. */
  6404. getData(): Nullable<DataArray>;
  6405. /**
  6406. * Gets underlying native buffer
  6407. * @returns underlying native buffer
  6408. */
  6409. getBuffer(): Nullable<DataBuffer>;
  6410. /**
  6411. * Gets the stride in float32 units (i.e. byte stride / 4).
  6412. * May not be an integer if the byte stride is not divisible by 4.
  6413. * @returns the stride in float32 units
  6414. * @deprecated Please use byteStride instead.
  6415. */
  6416. getStrideSize(): number;
  6417. /**
  6418. * Returns the offset as a multiple of the type byte length.
  6419. * @returns the offset in bytes
  6420. * @deprecated Please use byteOffset instead.
  6421. */
  6422. getOffset(): number;
  6423. /**
  6424. * Returns the number of components per vertex attribute (integer)
  6425. * @returns the size in float
  6426. */
  6427. getSize(): number;
  6428. /**
  6429. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6430. * @returns true if this buffer is instanced
  6431. */
  6432. getIsInstanced(): boolean;
  6433. /**
  6434. * Returns the instancing divisor, zero for non-instanced (integer).
  6435. * @returns a number
  6436. */
  6437. getInstanceDivisor(): number;
  6438. /**
  6439. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6440. * @param data defines the data to store
  6441. */
  6442. create(data?: DataArray): void;
  6443. /**
  6444. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6445. * This function will create a new buffer if the current one is not updatable
  6446. * @param data defines the data to store
  6447. */
  6448. update(data: DataArray): void;
  6449. /**
  6450. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6451. * Returns the directly updated WebGLBuffer.
  6452. * @param data the new data
  6453. * @param offset the new offset
  6454. * @param useBytes set to true if the offset is in bytes
  6455. */
  6456. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6457. /**
  6458. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6459. */
  6460. dispose(): void;
  6461. /**
  6462. * Enumerates each value of this vertex buffer as numbers.
  6463. * @param count the number of values to enumerate
  6464. * @param callback the callback function called for each value
  6465. */
  6466. forEach(count: number, callback: (value: number, index: number) => void): void;
  6467. /**
  6468. * Positions
  6469. */
  6470. static readonly PositionKind: string;
  6471. /**
  6472. * Normals
  6473. */
  6474. static readonly NormalKind: string;
  6475. /**
  6476. * Tangents
  6477. */
  6478. static readonly TangentKind: string;
  6479. /**
  6480. * Texture coordinates
  6481. */
  6482. static readonly UVKind: string;
  6483. /**
  6484. * Texture coordinates 2
  6485. */
  6486. static readonly UV2Kind: string;
  6487. /**
  6488. * Texture coordinates 3
  6489. */
  6490. static readonly UV3Kind: string;
  6491. /**
  6492. * Texture coordinates 4
  6493. */
  6494. static readonly UV4Kind: string;
  6495. /**
  6496. * Texture coordinates 5
  6497. */
  6498. static readonly UV5Kind: string;
  6499. /**
  6500. * Texture coordinates 6
  6501. */
  6502. static readonly UV6Kind: string;
  6503. /**
  6504. * Colors
  6505. */
  6506. static readonly ColorKind: string;
  6507. /**
  6508. * Matrix indices (for bones)
  6509. */
  6510. static readonly MatricesIndicesKind: string;
  6511. /**
  6512. * Matrix weights (for bones)
  6513. */
  6514. static readonly MatricesWeightsKind: string;
  6515. /**
  6516. * Additional matrix indices (for bones)
  6517. */
  6518. static readonly MatricesIndicesExtraKind: string;
  6519. /**
  6520. * Additional matrix weights (for bones)
  6521. */
  6522. static readonly MatricesWeightsExtraKind: string;
  6523. /**
  6524. * Deduces the stride given a kind.
  6525. * @param kind The kind string to deduce
  6526. * @returns The deduced stride
  6527. */
  6528. static DeduceStride(kind: string): number;
  6529. /**
  6530. * Gets the byte length of the given type.
  6531. * @param type the type
  6532. * @returns the number of bytes
  6533. */
  6534. static GetTypeByteLength(type: number): number;
  6535. /**
  6536. * Enumerates each value of the given parameters as numbers.
  6537. * @param data the data to enumerate
  6538. * @param byteOffset the byte offset of the data
  6539. * @param byteStride the byte stride of the data
  6540. * @param componentCount the number of components per element
  6541. * @param componentType the type of the component
  6542. * @param count the number of values to enumerate
  6543. * @param normalized whether the data is normalized
  6544. * @param callback the callback function called for each value
  6545. */
  6546. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6547. private static _GetFloatValue;
  6548. }
  6549. }
  6550. declare module BABYLON {
  6551. /**
  6552. * @hidden
  6553. */
  6554. export class IntersectionInfo {
  6555. bu: Nullable<number>;
  6556. bv: Nullable<number>;
  6557. distance: number;
  6558. faceId: number;
  6559. subMeshId: number;
  6560. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6561. }
  6562. }
  6563. declare module BABYLON {
  6564. /**
  6565. * Represens a plane by the equation ax + by + cz + d = 0
  6566. */
  6567. export class Plane {
  6568. private static _TmpMatrix;
  6569. /**
  6570. * Normal of the plane (a,b,c)
  6571. */
  6572. normal: Vector3;
  6573. /**
  6574. * d component of the plane
  6575. */
  6576. d: number;
  6577. /**
  6578. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6579. * @param a a component of the plane
  6580. * @param b b component of the plane
  6581. * @param c c component of the plane
  6582. * @param d d component of the plane
  6583. */
  6584. constructor(a: number, b: number, c: number, d: number);
  6585. /**
  6586. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6587. */
  6588. asArray(): number[];
  6589. /**
  6590. * @returns a new plane copied from the current Plane.
  6591. */
  6592. clone(): Plane;
  6593. /**
  6594. * @returns the string "Plane".
  6595. */
  6596. getClassName(): string;
  6597. /**
  6598. * @returns the Plane hash code.
  6599. */
  6600. getHashCode(): number;
  6601. /**
  6602. * Normalize the current Plane in place.
  6603. * @returns the updated Plane.
  6604. */
  6605. normalize(): Plane;
  6606. /**
  6607. * Applies a transformation the plane and returns the result
  6608. * @param transformation the transformation matrix to be applied to the plane
  6609. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6610. */
  6611. transform(transformation: DeepImmutable<Matrix>): Plane;
  6612. /**
  6613. * Calcualtte the dot product between the point and the plane normal
  6614. * @param point point to calculate the dot product with
  6615. * @returns the dot product (float) of the point coordinates and the plane normal.
  6616. */
  6617. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6618. /**
  6619. * Updates the current Plane from the plane defined by the three given points.
  6620. * @param point1 one of the points used to contruct the plane
  6621. * @param point2 one of the points used to contruct the plane
  6622. * @param point3 one of the points used to contruct the plane
  6623. * @returns the updated Plane.
  6624. */
  6625. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6626. /**
  6627. * Checks if the plane is facing a given direction
  6628. * @param direction the direction to check if the plane is facing
  6629. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6630. * @returns True is the vector "direction" is the same side than the plane normal.
  6631. */
  6632. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6633. /**
  6634. * Calculates the distance to a point
  6635. * @param point point to calculate distance to
  6636. * @returns the signed distance (float) from the given point to the Plane.
  6637. */
  6638. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6639. /**
  6640. * Creates a plane from an array
  6641. * @param array the array to create a plane from
  6642. * @returns a new Plane from the given array.
  6643. */
  6644. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6645. /**
  6646. * Creates a plane from three points
  6647. * @param point1 point used to create the plane
  6648. * @param point2 point used to create the plane
  6649. * @param point3 point used to create the plane
  6650. * @returns a new Plane defined by the three given points.
  6651. */
  6652. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6653. /**
  6654. * Creates a plane from an origin point and a normal
  6655. * @param origin origin of the plane to be constructed
  6656. * @param normal normal of the plane to be constructed
  6657. * @returns a new Plane the normal vector to this plane at the given origin point.
  6658. * Note : the vector "normal" is updated because normalized.
  6659. */
  6660. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6661. /**
  6662. * Calculates the distance from a plane and a point
  6663. * @param origin origin of the plane to be constructed
  6664. * @param normal normal of the plane to be constructed
  6665. * @param point point to calculate distance to
  6666. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6667. */
  6668. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6669. }
  6670. }
  6671. declare module BABYLON {
  6672. /**
  6673. * Class used to store bounding sphere information
  6674. */
  6675. export class BoundingSphere {
  6676. /**
  6677. * Gets the center of the bounding sphere in local space
  6678. */
  6679. readonly center: Vector3;
  6680. /**
  6681. * Radius of the bounding sphere in local space
  6682. */
  6683. radius: number;
  6684. /**
  6685. * Gets the center of the bounding sphere in world space
  6686. */
  6687. readonly centerWorld: Vector3;
  6688. /**
  6689. * Radius of the bounding sphere in world space
  6690. */
  6691. radiusWorld: number;
  6692. /**
  6693. * Gets the minimum vector in local space
  6694. */
  6695. readonly minimum: Vector3;
  6696. /**
  6697. * Gets the maximum vector in local space
  6698. */
  6699. readonly maximum: Vector3;
  6700. private _worldMatrix;
  6701. private static readonly TmpVector3;
  6702. /**
  6703. * Creates a new bounding sphere
  6704. * @param min defines the minimum vector (in local space)
  6705. * @param max defines the maximum vector (in local space)
  6706. * @param worldMatrix defines the new world matrix
  6707. */
  6708. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6709. /**
  6710. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6711. * @param min defines the new minimum vector (in local space)
  6712. * @param max defines the new maximum vector (in local space)
  6713. * @param worldMatrix defines the new world matrix
  6714. */
  6715. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6716. /**
  6717. * Scale the current bounding sphere by applying a scale factor
  6718. * @param factor defines the scale factor to apply
  6719. * @returns the current bounding box
  6720. */
  6721. scale(factor: number): BoundingSphere;
  6722. /**
  6723. * Gets the world matrix of the bounding box
  6724. * @returns a matrix
  6725. */
  6726. getWorldMatrix(): DeepImmutable<Matrix>;
  6727. /** @hidden */
  6728. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6729. /**
  6730. * Tests if the bounding sphere is intersecting the frustum planes
  6731. * @param frustumPlanes defines the frustum planes to test
  6732. * @returns true if there is an intersection
  6733. */
  6734. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6735. /**
  6736. * Tests if the bounding sphere center is in between the frustum planes.
  6737. * Used for optimistic fast inclusion.
  6738. * @param frustumPlanes defines the frustum planes to test
  6739. * @returns true if the sphere center is in between the frustum planes
  6740. */
  6741. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6742. /**
  6743. * Tests if a point is inside the bounding sphere
  6744. * @param point defines the point to test
  6745. * @returns true if the point is inside the bounding sphere
  6746. */
  6747. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6748. /**
  6749. * Checks if two sphere intersct
  6750. * @param sphere0 sphere 0
  6751. * @param sphere1 sphere 1
  6752. * @returns true if the speres intersect
  6753. */
  6754. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6755. }
  6756. }
  6757. declare module BABYLON {
  6758. /**
  6759. * Class used to store bounding box information
  6760. */
  6761. export class BoundingBox implements ICullable {
  6762. /**
  6763. * Gets the 8 vectors representing the bounding box in local space
  6764. */
  6765. readonly vectors: Vector3[];
  6766. /**
  6767. * Gets the center of the bounding box in local space
  6768. */
  6769. readonly center: Vector3;
  6770. /**
  6771. * Gets the center of the bounding box in world space
  6772. */
  6773. readonly centerWorld: Vector3;
  6774. /**
  6775. * Gets the extend size in local space
  6776. */
  6777. readonly extendSize: Vector3;
  6778. /**
  6779. * Gets the extend size in world space
  6780. */
  6781. readonly extendSizeWorld: Vector3;
  6782. /**
  6783. * Gets the OBB (object bounding box) directions
  6784. */
  6785. readonly directions: Vector3[];
  6786. /**
  6787. * Gets the 8 vectors representing the bounding box in world space
  6788. */
  6789. readonly vectorsWorld: Vector3[];
  6790. /**
  6791. * Gets the minimum vector in world space
  6792. */
  6793. readonly minimumWorld: Vector3;
  6794. /**
  6795. * Gets the maximum vector in world space
  6796. */
  6797. readonly maximumWorld: Vector3;
  6798. /**
  6799. * Gets the minimum vector in local space
  6800. */
  6801. readonly minimum: Vector3;
  6802. /**
  6803. * Gets the maximum vector in local space
  6804. */
  6805. readonly maximum: Vector3;
  6806. private _worldMatrix;
  6807. private static readonly TmpVector3;
  6808. /**
  6809. * @hidden
  6810. */
  6811. _tag: number;
  6812. /**
  6813. * Creates a new bounding box
  6814. * @param min defines the minimum vector (in local space)
  6815. * @param max defines the maximum vector (in local space)
  6816. * @param worldMatrix defines the new world matrix
  6817. */
  6818. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6819. /**
  6820. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6821. * @param min defines the new minimum vector (in local space)
  6822. * @param max defines the new maximum vector (in local space)
  6823. * @param worldMatrix defines the new world matrix
  6824. */
  6825. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6826. /**
  6827. * Scale the current bounding box by applying a scale factor
  6828. * @param factor defines the scale factor to apply
  6829. * @returns the current bounding box
  6830. */
  6831. scale(factor: number): BoundingBox;
  6832. /**
  6833. * Gets the world matrix of the bounding box
  6834. * @returns a matrix
  6835. */
  6836. getWorldMatrix(): DeepImmutable<Matrix>;
  6837. /** @hidden */
  6838. _update(world: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Tests if the bounding box is intersecting the frustum planes
  6841. * @param frustumPlanes defines the frustum planes to test
  6842. * @returns true if there is an intersection
  6843. */
  6844. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6845. /**
  6846. * Tests if the bounding box is entirely inside the frustum planes
  6847. * @param frustumPlanes defines the frustum planes to test
  6848. * @returns true if there is an inclusion
  6849. */
  6850. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6851. /**
  6852. * Tests if a point is inside the bounding box
  6853. * @param point defines the point to test
  6854. * @returns true if the point is inside the bounding box
  6855. */
  6856. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6857. /**
  6858. * Tests if the bounding box intersects with a bounding sphere
  6859. * @param sphere defines the sphere to test
  6860. * @returns true if there is an intersection
  6861. */
  6862. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6863. /**
  6864. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6865. * @param min defines the min vector to use
  6866. * @param max defines the max vector to use
  6867. * @returns true if there is an intersection
  6868. */
  6869. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6870. /**
  6871. * Tests if two bounding boxes are intersections
  6872. * @param box0 defines the first box to test
  6873. * @param box1 defines the second box to test
  6874. * @returns true if there is an intersection
  6875. */
  6876. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6877. /**
  6878. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6879. * @param minPoint defines the minimum vector of the bounding box
  6880. * @param maxPoint defines the maximum vector of the bounding box
  6881. * @param sphereCenter defines the sphere center
  6882. * @param sphereRadius defines the sphere radius
  6883. * @returns true if there is an intersection
  6884. */
  6885. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6886. /**
  6887. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6888. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @return true if there is an inclusion
  6891. */
  6892. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6895. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @return true if there is an intersection
  6898. */
  6899. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /** @hidden */
  6904. export class Collider {
  6905. /** Define if a collision was found */
  6906. collisionFound: boolean;
  6907. /**
  6908. * Define last intersection point in local space
  6909. */
  6910. intersectionPoint: Vector3;
  6911. /**
  6912. * Define last collided mesh
  6913. */
  6914. collidedMesh: Nullable<AbstractMesh>;
  6915. private _collisionPoint;
  6916. private _planeIntersectionPoint;
  6917. private _tempVector;
  6918. private _tempVector2;
  6919. private _tempVector3;
  6920. private _tempVector4;
  6921. private _edge;
  6922. private _baseToVertex;
  6923. private _destinationPoint;
  6924. private _slidePlaneNormal;
  6925. private _displacementVector;
  6926. /** @hidden */
  6927. _radius: Vector3;
  6928. /** @hidden */
  6929. _retry: number;
  6930. private _velocity;
  6931. private _basePoint;
  6932. private _epsilon;
  6933. /** @hidden */
  6934. _velocityWorldLength: number;
  6935. /** @hidden */
  6936. _basePointWorld: Vector3;
  6937. private _velocityWorld;
  6938. private _normalizedVelocity;
  6939. /** @hidden */
  6940. _initialVelocity: Vector3;
  6941. /** @hidden */
  6942. _initialPosition: Vector3;
  6943. private _nearestDistance;
  6944. private _collisionMask;
  6945. get collisionMask(): number;
  6946. set collisionMask(mask: number);
  6947. /**
  6948. * Gets the plane normal used to compute the sliding response (in local space)
  6949. */
  6950. get slidePlaneNormal(): Vector3;
  6951. /** @hidden */
  6952. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6953. /** @hidden */
  6954. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6955. /** @hidden */
  6956. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6957. /** @hidden */
  6958. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6959. /** @hidden */
  6960. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6961. /** @hidden */
  6962. _getResponse(pos: Vector3, vel: Vector3): void;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Interface for cullable objects
  6968. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6969. */
  6970. export interface ICullable {
  6971. /**
  6972. * Checks if the object or part of the object is in the frustum
  6973. * @param frustumPlanes Camera near/planes
  6974. * @returns true if the object is in frustum otherwise false
  6975. */
  6976. isInFrustum(frustumPlanes: Plane[]): boolean;
  6977. /**
  6978. * Checks if a cullable object (mesh...) is in the camera frustum
  6979. * Unlike isInFrustum this cheks the full bounding box
  6980. * @param frustumPlanes Camera near/planes
  6981. * @returns true if the object is in frustum otherwise false
  6982. */
  6983. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6984. }
  6985. /**
  6986. * Info for a bounding data of a mesh
  6987. */
  6988. export class BoundingInfo implements ICullable {
  6989. /**
  6990. * Bounding box for the mesh
  6991. */
  6992. readonly boundingBox: BoundingBox;
  6993. /**
  6994. * Bounding sphere for the mesh
  6995. */
  6996. readonly boundingSphere: BoundingSphere;
  6997. private _isLocked;
  6998. private static readonly TmpVector3;
  6999. /**
  7000. * Constructs bounding info
  7001. * @param minimum min vector of the bounding box/sphere
  7002. * @param maximum max vector of the bounding box/sphere
  7003. * @param worldMatrix defines the new world matrix
  7004. */
  7005. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7006. /**
  7007. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7008. * @param min defines the new minimum vector (in local space)
  7009. * @param max defines the new maximum vector (in local space)
  7010. * @param worldMatrix defines the new world matrix
  7011. */
  7012. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7013. /**
  7014. * min vector of the bounding box/sphere
  7015. */
  7016. get minimum(): Vector3;
  7017. /**
  7018. * max vector of the bounding box/sphere
  7019. */
  7020. get maximum(): Vector3;
  7021. /**
  7022. * If the info is locked and won't be updated to avoid perf overhead
  7023. */
  7024. get isLocked(): boolean;
  7025. set isLocked(value: boolean);
  7026. /**
  7027. * Updates the bounding sphere and box
  7028. * @param world world matrix to be used to update
  7029. */
  7030. update(world: DeepImmutable<Matrix>): void;
  7031. /**
  7032. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7033. * @param center New center of the bounding info
  7034. * @param extend New extend of the bounding info
  7035. * @returns the current bounding info
  7036. */
  7037. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7038. /**
  7039. * Scale the current bounding info by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding info
  7042. */
  7043. scale(factor: number): BoundingInfo;
  7044. /**
  7045. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7046. * @param frustumPlanes defines the frustum to test
  7047. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7048. * @returns true if the bounding info is in the frustum planes
  7049. */
  7050. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7051. /**
  7052. * Gets the world distance between the min and max points of the bounding box
  7053. */
  7054. get diagonalLength(): number;
  7055. /**
  7056. * Checks if a cullable object (mesh...) is in the camera frustum
  7057. * Unlike isInFrustum this cheks the full bounding box
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7062. /** @hidden */
  7063. _checkCollision(collider: Collider): boolean;
  7064. /**
  7065. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7066. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7067. * @param point the point to check intersection with
  7068. * @returns if the point intersects
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7073. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7074. * @param boundingInfo the bounding info to check intersection with
  7075. * @param precise if the intersection should be done using OBB
  7076. * @returns if the bounding info intersects
  7077. */
  7078. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7079. }
  7080. }
  7081. declare module BABYLON {
  7082. /**
  7083. * Extracts minimum and maximum values from a list of indexed positions
  7084. * @param positions defines the positions to use
  7085. * @param indices defines the indices to the positions
  7086. * @param indexStart defines the start index
  7087. * @param indexCount defines the end index
  7088. * @param bias defines bias value to add to the result
  7089. * @return minimum and maximum values
  7090. */
  7091. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7092. minimum: Vector3;
  7093. maximum: Vector3;
  7094. };
  7095. /**
  7096. * Extracts minimum and maximum values from a list of positions
  7097. * @param positions defines the positions to use
  7098. * @param start defines the start index in the positions array
  7099. * @param count defines the number of positions to handle
  7100. * @param bias defines bias value to add to the result
  7101. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7102. * @return minimum and maximum values
  7103. */
  7104. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7105. minimum: Vector3;
  7106. maximum: Vector3;
  7107. };
  7108. }
  7109. declare module BABYLON {
  7110. /** @hidden */
  7111. export class WebGLDataBuffer extends DataBuffer {
  7112. private _buffer;
  7113. constructor(resource: WebGLBuffer);
  7114. get underlyingResource(): any;
  7115. }
  7116. }
  7117. declare module BABYLON {
  7118. /** @hidden */
  7119. export class WebGLPipelineContext implements IPipelineContext {
  7120. engine: ThinEngine;
  7121. program: Nullable<WebGLProgram>;
  7122. context?: WebGLRenderingContext;
  7123. vertexShader?: WebGLShader;
  7124. fragmentShader?: WebGLShader;
  7125. isParallelCompiled: boolean;
  7126. onCompiled?: () => void;
  7127. transformFeedback?: WebGLTransformFeedback | null;
  7128. vertexCompilationError: Nullable<string>;
  7129. fragmentCompilationError: Nullable<string>;
  7130. programLinkError: Nullable<string>;
  7131. programValidationError: Nullable<string>;
  7132. get isAsync(): boolean;
  7133. get isReady(): boolean;
  7134. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7135. }
  7136. }
  7137. declare module BABYLON {
  7138. interface ThinEngine {
  7139. /**
  7140. * Create an uniform buffer
  7141. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7142. * @param elements defines the content of the uniform buffer
  7143. * @returns the webGL uniform buffer
  7144. */
  7145. createUniformBuffer(elements: FloatArray): DataBuffer;
  7146. /**
  7147. * Create a dynamic uniform buffer
  7148. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7149. * @param elements defines the content of the uniform buffer
  7150. * @returns the webGL uniform buffer
  7151. */
  7152. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7153. /**
  7154. * Update an existing uniform buffer
  7155. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7156. * @param uniformBuffer defines the target uniform buffer
  7157. * @param elements defines the content to update
  7158. * @param offset defines the offset in the uniform buffer where update should start
  7159. * @param count defines the size of the data to update
  7160. */
  7161. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7162. /**
  7163. * Bind an uniform buffer to the current webGL context
  7164. * @param buffer defines the buffer to bind
  7165. */
  7166. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7167. /**
  7168. * Bind a buffer to the current webGL context at a given location
  7169. * @param buffer defines the buffer to bind
  7170. * @param location defines the index where to bind the buffer
  7171. */
  7172. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7173. /**
  7174. * Bind a specific block at a given index in a specific shader program
  7175. * @param pipelineContext defines the pipeline context to use
  7176. * @param blockName defines the block name
  7177. * @param index defines the index where to bind the block
  7178. */
  7179. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7180. }
  7181. }
  7182. declare module BABYLON {
  7183. /**
  7184. * Uniform buffer objects.
  7185. *
  7186. * Handles blocks of uniform on the GPU.
  7187. *
  7188. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7189. *
  7190. * For more information, please refer to :
  7191. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7192. */
  7193. export class UniformBuffer {
  7194. private _engine;
  7195. private _buffer;
  7196. private _data;
  7197. private _bufferData;
  7198. private _dynamic?;
  7199. private _uniformLocations;
  7200. private _uniformSizes;
  7201. private _uniformLocationPointer;
  7202. private _needSync;
  7203. private _noUBO;
  7204. private _currentEffect;
  7205. /** @hidden */
  7206. _alreadyBound: boolean;
  7207. private static _MAX_UNIFORM_SIZE;
  7208. private static _tempBuffer;
  7209. /**
  7210. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7211. * This is dynamic to allow compat with webgl 1 and 2.
  7212. * You will need to pass the name of the uniform as well as the value.
  7213. */
  7214. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7215. /**
  7216. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7217. * This is dynamic to allow compat with webgl 1 and 2.
  7218. * You will need to pass the name of the uniform as well as the value.
  7219. */
  7220. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7221. /**
  7222. * Lambda to Update a single float in a uniform buffer.
  7223. * This is dynamic to allow compat with webgl 1 and 2.
  7224. * You will need to pass the name of the uniform as well as the value.
  7225. */
  7226. updateFloat: (name: string, x: number) => void;
  7227. /**
  7228. * Lambda to Update a vec2 of float in a uniform buffer.
  7229. * This is dynamic to allow compat with webgl 1 and 2.
  7230. * You will need to pass the name of the uniform as well as the value.
  7231. */
  7232. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7233. /**
  7234. * Lambda to Update a vec3 of float in a uniform buffer.
  7235. * This is dynamic to allow compat with webgl 1 and 2.
  7236. * You will need to pass the name of the uniform as well as the value.
  7237. */
  7238. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7239. /**
  7240. * Lambda to Update a vec4 of float in a uniform buffer.
  7241. * This is dynamic to allow compat with webgl 1 and 2.
  7242. * You will need to pass the name of the uniform as well as the value.
  7243. */
  7244. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7245. /**
  7246. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7247. * This is dynamic to allow compat with webgl 1 and 2.
  7248. * You will need to pass the name of the uniform as well as the value.
  7249. */
  7250. updateMatrix: (name: string, mat: Matrix) => void;
  7251. /**
  7252. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7253. * This is dynamic to allow compat with webgl 1 and 2.
  7254. * You will need to pass the name of the uniform as well as the value.
  7255. */
  7256. updateVector3: (name: string, vector: Vector3) => void;
  7257. /**
  7258. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7263. /**
  7264. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7269. /**
  7270. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7275. /**
  7276. * Instantiates a new Uniform buffer objects.
  7277. *
  7278. * Handles blocks of uniform on the GPU.
  7279. *
  7280. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7281. *
  7282. * For more information, please refer to :
  7283. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7284. * @param engine Define the engine the buffer is associated with
  7285. * @param data Define the data contained in the buffer
  7286. * @param dynamic Define if the buffer is updatable
  7287. */
  7288. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7289. /**
  7290. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7291. * or just falling back on setUniformXXX calls.
  7292. */
  7293. get useUbo(): boolean;
  7294. /**
  7295. * Indicates if the WebGL underlying uniform buffer is in sync
  7296. * with the javascript cache data.
  7297. */
  7298. get isSync(): boolean;
  7299. /**
  7300. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7301. * Also, a dynamic UniformBuffer will disable cache verification and always
  7302. * update the underlying WebGL uniform buffer to the GPU.
  7303. * @returns if Dynamic, otherwise false
  7304. */
  7305. isDynamic(): boolean;
  7306. /**
  7307. * The data cache on JS side.
  7308. * @returns the underlying data as a float array
  7309. */
  7310. getData(): Float32Array;
  7311. /**
  7312. * The underlying WebGL Uniform buffer.
  7313. * @returns the webgl buffer
  7314. */
  7315. getBuffer(): Nullable<DataBuffer>;
  7316. /**
  7317. * std140 layout specifies how to align data within an UBO structure.
  7318. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7319. * for specs.
  7320. */
  7321. private _fillAlignment;
  7322. /**
  7323. * Adds an uniform in the buffer.
  7324. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7325. * for the layout to be correct !
  7326. * @param name Name of the uniform, as used in the uniform block in the shader.
  7327. * @param size Data size, or data directly.
  7328. */
  7329. addUniform(name: string, size: number | number[]): void;
  7330. /**
  7331. * Adds a Matrix 4x4 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. * @param mat A 4x4 matrix.
  7334. */
  7335. addMatrix(name: string, mat: Matrix): void;
  7336. /**
  7337. * Adds a vec2 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. * @param x Define the x component value of the vec2
  7340. * @param y Define the y component value of the vec2
  7341. */
  7342. addFloat2(name: string, x: number, y: number): void;
  7343. /**
  7344. * Adds a vec3 to the uniform buffer.
  7345. * @param name Name of the uniform, as used in the uniform block in the shader.
  7346. * @param x Define the x component value of the vec3
  7347. * @param y Define the y component value of the vec3
  7348. * @param z Define the z component value of the vec3
  7349. */
  7350. addFloat3(name: string, x: number, y: number, z: number): void;
  7351. /**
  7352. * Adds a vec3 to the uniform buffer.
  7353. * @param name Name of the uniform, as used in the uniform block in the shader.
  7354. * @param color Define the vec3 from a Color
  7355. */
  7356. addColor3(name: string, color: Color3): void;
  7357. /**
  7358. * Adds a vec4 to the uniform buffer.
  7359. * @param name Name of the uniform, as used in the uniform block in the shader.
  7360. * @param color Define the rgb components from a Color
  7361. * @param alpha Define the a component of the vec4
  7362. */
  7363. addColor4(name: string, color: Color3, alpha: number): void;
  7364. /**
  7365. * Adds a vec3 to the uniform buffer.
  7366. * @param name Name of the uniform, as used in the uniform block in the shader.
  7367. * @param vector Define the vec3 components from a Vector
  7368. */
  7369. addVector3(name: string, vector: Vector3): void;
  7370. /**
  7371. * Adds a Matrix 3x3 to the uniform buffer.
  7372. * @param name Name of the uniform, as used in the uniform block in the shader.
  7373. */
  7374. addMatrix3x3(name: string): void;
  7375. /**
  7376. * Adds a Matrix 2x2 to the uniform buffer.
  7377. * @param name Name of the uniform, as used in the uniform block in the shader.
  7378. */
  7379. addMatrix2x2(name: string): void;
  7380. /**
  7381. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7382. */
  7383. create(): void;
  7384. /** @hidden */
  7385. _rebuild(): void;
  7386. /**
  7387. * Updates the WebGL Uniform Buffer on the GPU.
  7388. * If the `dynamic` flag is set to true, no cache comparison is done.
  7389. * Otherwise, the buffer will be updated only if the cache differs.
  7390. */
  7391. update(): void;
  7392. /**
  7393. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7394. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7395. * @param data Define the flattened data
  7396. * @param size Define the size of the data.
  7397. */
  7398. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7399. private _valueCache;
  7400. private _cacheMatrix;
  7401. private _updateMatrix3x3ForUniform;
  7402. private _updateMatrix3x3ForEffect;
  7403. private _updateMatrix2x2ForEffect;
  7404. private _updateMatrix2x2ForUniform;
  7405. private _updateFloatForEffect;
  7406. private _updateFloatForUniform;
  7407. private _updateFloat2ForEffect;
  7408. private _updateFloat2ForUniform;
  7409. private _updateFloat3ForEffect;
  7410. private _updateFloat3ForUniform;
  7411. private _updateFloat4ForEffect;
  7412. private _updateFloat4ForUniform;
  7413. private _updateMatrixForEffect;
  7414. private _updateMatrixForUniform;
  7415. private _updateVector3ForEffect;
  7416. private _updateVector3ForUniform;
  7417. private _updateVector4ForEffect;
  7418. private _updateVector4ForUniform;
  7419. private _updateColor3ForEffect;
  7420. private _updateColor3ForUniform;
  7421. private _updateColor4ForEffect;
  7422. private _updateColor4ForUniform;
  7423. /**
  7424. * Sets a sampler uniform on the effect.
  7425. * @param name Define the name of the sampler.
  7426. * @param texture Define the texture to set in the sampler
  7427. */
  7428. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7429. /**
  7430. * Directly updates the value of the uniform in the cache AND on the GPU.
  7431. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7432. * @param data Define the flattened data
  7433. */
  7434. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7435. /**
  7436. * Binds this uniform buffer to an effect.
  7437. * @param effect Define the effect to bind the buffer to
  7438. * @param name Name of the uniform block in the shader.
  7439. */
  7440. bindToEffect(effect: Effect, name: string): void;
  7441. /**
  7442. * Disposes the uniform buffer.
  7443. */
  7444. dispose(): void;
  7445. }
  7446. }
  7447. declare module BABYLON {
  7448. /**
  7449. * Enum that determines the text-wrapping mode to use.
  7450. */
  7451. export enum InspectableType {
  7452. /**
  7453. * Checkbox for booleans
  7454. */
  7455. Checkbox = 0,
  7456. /**
  7457. * Sliders for numbers
  7458. */
  7459. Slider = 1,
  7460. /**
  7461. * Vector3
  7462. */
  7463. Vector3 = 2,
  7464. /**
  7465. * Quaternions
  7466. */
  7467. Quaternion = 3,
  7468. /**
  7469. * Color3
  7470. */
  7471. Color3 = 4,
  7472. /**
  7473. * String
  7474. */
  7475. String = 5
  7476. }
  7477. /**
  7478. * Interface used to define custom inspectable properties.
  7479. * This interface is used by the inspector to display custom property grids
  7480. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7481. */
  7482. export interface IInspectable {
  7483. /**
  7484. * Gets the label to display
  7485. */
  7486. label: string;
  7487. /**
  7488. * Gets the name of the property to edit
  7489. */
  7490. propertyName: string;
  7491. /**
  7492. * Gets the type of the editor to use
  7493. */
  7494. type: InspectableType;
  7495. /**
  7496. * Gets the minimum value of the property when using in "slider" mode
  7497. */
  7498. min?: number;
  7499. /**
  7500. * Gets the maximum value of the property when using in "slider" mode
  7501. */
  7502. max?: number;
  7503. /**
  7504. * Gets the setp to use when using in "slider" mode
  7505. */
  7506. step?: number;
  7507. }
  7508. }
  7509. declare module BABYLON {
  7510. /**
  7511. * Class used to provide helper for timing
  7512. */
  7513. export class TimingTools {
  7514. /**
  7515. * Polyfill for setImmediate
  7516. * @param action defines the action to execute after the current execution block
  7517. */
  7518. static SetImmediate(action: () => void): void;
  7519. }
  7520. }
  7521. declare module BABYLON {
  7522. /**
  7523. * Class used to enable instatition of objects by class name
  7524. */
  7525. export class InstantiationTools {
  7526. /**
  7527. * Use this object to register external classes like custom textures or material
  7528. * to allow the laoders to instantiate them
  7529. */
  7530. static RegisteredExternalClasses: {
  7531. [key: string]: Object;
  7532. };
  7533. /**
  7534. * Tries to instantiate a new object from a given class name
  7535. * @param className defines the class name to instantiate
  7536. * @returns the new object or null if the system was not able to do the instantiation
  7537. */
  7538. static Instantiate(className: string): any;
  7539. }
  7540. }
  7541. declare module BABYLON {
  7542. /**
  7543. * Define options used to create a depth texture
  7544. */
  7545. export class DepthTextureCreationOptions {
  7546. /** Specifies whether or not a stencil should be allocated in the texture */
  7547. generateStencil?: boolean;
  7548. /** Specifies whether or not bilinear filtering is enable on the texture */
  7549. bilinearFiltering?: boolean;
  7550. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7551. comparisonFunction?: number;
  7552. /** Specifies if the created texture is a cube texture */
  7553. isCube?: boolean;
  7554. }
  7555. }
  7556. declare module BABYLON {
  7557. interface ThinEngine {
  7558. /**
  7559. * Creates a depth stencil cube texture.
  7560. * This is only available in WebGL 2.
  7561. * @param size The size of face edge in the cube texture.
  7562. * @param options The options defining the cube texture.
  7563. * @returns The cube texture
  7564. */
  7565. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7566. /**
  7567. * Creates a cube texture
  7568. * @param rootUrl defines the url where the files to load is located
  7569. * @param scene defines the current scene
  7570. * @param files defines the list of files to load (1 per face)
  7571. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7572. * @param onLoad defines an optional callback raised when the texture is loaded
  7573. * @param onError defines an optional callback raised if there is an issue to load the texture
  7574. * @param format defines the format of the data
  7575. * @param forcedExtension defines the extension to use to pick the right loader
  7576. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7577. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7578. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7579. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7580. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7581. * @returns the cube texture as an InternalTexture
  7582. */
  7583. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7584. /**
  7585. * Creates a cube texture
  7586. * @param rootUrl defines the url where the files to load is located
  7587. * @param scene defines the current scene
  7588. * @param files defines the list of files to load (1 per face)
  7589. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7590. * @param onLoad defines an optional callback raised when the texture is loaded
  7591. * @param onError defines an optional callback raised if there is an issue to load the texture
  7592. * @param format defines the format of the data
  7593. * @param forcedExtension defines the extension to use to pick the right loader
  7594. * @returns the cube texture as an InternalTexture
  7595. */
  7596. 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;
  7597. /**
  7598. * Creates a cube texture
  7599. * @param rootUrl defines the url where the files to load is located
  7600. * @param scene defines the current scene
  7601. * @param files defines the list of files to load (1 per face)
  7602. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7603. * @param onLoad defines an optional callback raised when the texture is loaded
  7604. * @param onError defines an optional callback raised if there is an issue to load the texture
  7605. * @param format defines the format of the data
  7606. * @param forcedExtension defines the extension to use to pick the right loader
  7607. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7608. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7609. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7610. * @returns the cube texture as an InternalTexture
  7611. */
  7612. 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;
  7613. /** @hidden */
  7614. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7615. /** @hidden */
  7616. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7617. /** @hidden */
  7618. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7619. /** @hidden */
  7620. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7621. /**
  7622. * @hidden
  7623. */
  7624. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7625. }
  7626. }
  7627. declare module BABYLON {
  7628. /**
  7629. * Class for creating a cube texture
  7630. */
  7631. export class CubeTexture extends BaseTexture {
  7632. private _delayedOnLoad;
  7633. /**
  7634. * The url of the texture
  7635. */
  7636. url: string;
  7637. /**
  7638. * Gets or sets the center of the bounding box associated with the cube texture.
  7639. * It must define where the camera used to render the texture was set
  7640. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7641. */
  7642. boundingBoxPosition: Vector3;
  7643. private _boundingBoxSize;
  7644. /**
  7645. * Gets or sets the size of the bounding box associated with the cube texture
  7646. * When defined, the cubemap will switch to local mode
  7647. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7648. * @example https://www.babylonjs-playground.com/#RNASML
  7649. */
  7650. set boundingBoxSize(value: Vector3);
  7651. /**
  7652. * Returns the bounding box size
  7653. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7654. */
  7655. get boundingBoxSize(): Vector3;
  7656. protected _rotationY: number;
  7657. /**
  7658. * Sets texture matrix rotation angle around Y axis in radians.
  7659. */
  7660. set rotationY(value: number);
  7661. /**
  7662. * Gets texture matrix rotation angle around Y axis radians.
  7663. */
  7664. get rotationY(): number;
  7665. /**
  7666. * Are mip maps generated for this texture or not.
  7667. */
  7668. get noMipmap(): boolean;
  7669. private _noMipmap;
  7670. private _files;
  7671. protected _forcedExtension: Nullable<string>;
  7672. private _extensions;
  7673. private _textureMatrix;
  7674. private _format;
  7675. private _createPolynomials;
  7676. /** @hidden */
  7677. _prefiltered: boolean;
  7678. /**
  7679. * Creates a cube texture from an array of image urls
  7680. * @param files defines an array of image urls
  7681. * @param scene defines the hosting scene
  7682. * @param noMipmap specifies if mip maps are not used
  7683. * @returns a cube texture
  7684. */
  7685. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7686. /**
  7687. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7688. * @param url defines the url of the prefiltered texture
  7689. * @param scene defines the scene the texture is attached to
  7690. * @param forcedExtension defines the extension of the file if different from the url
  7691. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7692. * @return the prefiltered texture
  7693. */
  7694. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7695. /**
  7696. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7697. * as prefiltered data.
  7698. * @param rootUrl defines the url of the texture or the root name of the six images
  7699. * @param scene defines the scene the texture is attached to
  7700. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7701. * @param noMipmap defines if mipmaps should be created or not
  7702. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7703. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7704. * @param onError defines a callback triggered in case of error during load
  7705. * @param format defines the internal format to use for the texture once loaded
  7706. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7707. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7708. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7709. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7710. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7711. * @return the cube texture
  7712. */
  7713. 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);
  7714. /**
  7715. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7716. */
  7717. get isPrefiltered(): boolean;
  7718. /**
  7719. * Get the current class name of the texture useful for serialization or dynamic coding.
  7720. * @returns "CubeTexture"
  7721. */
  7722. getClassName(): string;
  7723. /**
  7724. * Update the url (and optional buffer) of this texture if url was null during construction.
  7725. * @param url the url of the texture
  7726. * @param forcedExtension defines the extension to use
  7727. * @param onLoad callback called when the texture is loaded (defaults to null)
  7728. */
  7729. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7730. /**
  7731. * Delays loading of the cube texture
  7732. * @param forcedExtension defines the extension to use
  7733. */
  7734. delayLoad(forcedExtension?: string): void;
  7735. /**
  7736. * Returns the reflection texture matrix
  7737. * @returns the reflection texture matrix
  7738. */
  7739. getReflectionTextureMatrix(): Matrix;
  7740. /**
  7741. * Sets the reflection texture matrix
  7742. * @param value Reflection texture matrix
  7743. */
  7744. setReflectionTextureMatrix(value: Matrix): void;
  7745. /**
  7746. * Parses text to create a cube texture
  7747. * @param parsedTexture define the serialized text to read from
  7748. * @param scene defines the hosting scene
  7749. * @param rootUrl defines the root url of the cube texture
  7750. * @returns a cube texture
  7751. */
  7752. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7753. /**
  7754. * Makes a clone, or deep copy, of the cube texture
  7755. * @returns a new cube texture
  7756. */
  7757. clone(): CubeTexture;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Manages the defines for the Material
  7763. */
  7764. export class MaterialDefines {
  7765. /** @hidden */
  7766. protected _keys: string[];
  7767. private _isDirty;
  7768. /** @hidden */
  7769. _renderId: number;
  7770. /** @hidden */
  7771. _areLightsDirty: boolean;
  7772. /** @hidden */
  7773. _areLightsDisposed: boolean;
  7774. /** @hidden */
  7775. _areAttributesDirty: boolean;
  7776. /** @hidden */
  7777. _areTexturesDirty: boolean;
  7778. /** @hidden */
  7779. _areFresnelDirty: boolean;
  7780. /** @hidden */
  7781. _areMiscDirty: boolean;
  7782. /** @hidden */
  7783. _areImageProcessingDirty: boolean;
  7784. /** @hidden */
  7785. _normals: boolean;
  7786. /** @hidden */
  7787. _uvs: boolean;
  7788. /** @hidden */
  7789. _needNormals: boolean;
  7790. /** @hidden */
  7791. _needUVs: boolean;
  7792. [id: string]: any;
  7793. /**
  7794. * Specifies if the material needs to be re-calculated
  7795. */
  7796. get isDirty(): boolean;
  7797. /**
  7798. * Marks the material to indicate that it has been re-calculated
  7799. */
  7800. markAsProcessed(): void;
  7801. /**
  7802. * Marks the material to indicate that it needs to be re-calculated
  7803. */
  7804. markAsUnprocessed(): void;
  7805. /**
  7806. * Marks the material to indicate all of its defines need to be re-calculated
  7807. */
  7808. markAllAsDirty(): void;
  7809. /**
  7810. * Marks the material to indicate that image processing needs to be re-calculated
  7811. */
  7812. markAsImageProcessingDirty(): void;
  7813. /**
  7814. * Marks the material to indicate the lights need to be re-calculated
  7815. * @param disposed Defines whether the light is dirty due to dispose or not
  7816. */
  7817. markAsLightDirty(disposed?: boolean): void;
  7818. /**
  7819. * Marks the attribute state as changed
  7820. */
  7821. markAsAttributesDirty(): void;
  7822. /**
  7823. * Marks the texture state as changed
  7824. */
  7825. markAsTexturesDirty(): void;
  7826. /**
  7827. * Marks the fresnel state as changed
  7828. */
  7829. markAsFresnelDirty(): void;
  7830. /**
  7831. * Marks the misc state as changed
  7832. */
  7833. markAsMiscDirty(): void;
  7834. /**
  7835. * Rebuilds the material defines
  7836. */
  7837. rebuild(): void;
  7838. /**
  7839. * Specifies if two material defines are equal
  7840. * @param other - A material define instance to compare to
  7841. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7842. */
  7843. isEqual(other: MaterialDefines): boolean;
  7844. /**
  7845. * Clones this instance's defines to another instance
  7846. * @param other - material defines to clone values to
  7847. */
  7848. cloneTo(other: MaterialDefines): void;
  7849. /**
  7850. * Resets the material define values
  7851. */
  7852. reset(): void;
  7853. /**
  7854. * Converts the material define values to a string
  7855. * @returns - String of material define information
  7856. */
  7857. toString(): string;
  7858. }
  7859. }
  7860. declare module BABYLON {
  7861. /**
  7862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7864. * 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;
  7865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7866. */
  7867. export class ColorCurves {
  7868. private _dirty;
  7869. private _tempColor;
  7870. private _globalCurve;
  7871. private _highlightsCurve;
  7872. private _midtonesCurve;
  7873. private _shadowsCurve;
  7874. private _positiveCurve;
  7875. private _negativeCurve;
  7876. private _globalHue;
  7877. private _globalDensity;
  7878. private _globalSaturation;
  7879. private _globalExposure;
  7880. /**
  7881. * Gets the global Hue value.
  7882. * 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).
  7883. */
  7884. get globalHue(): number;
  7885. /**
  7886. * Sets the global Hue value.
  7887. * 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).
  7888. */
  7889. set globalHue(value: number);
  7890. /**
  7891. * Gets the global Density value.
  7892. * 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.
  7893. * Values less than zero provide a filter of opposite hue.
  7894. */
  7895. get globalDensity(): number;
  7896. /**
  7897. * Sets the global Density value.
  7898. * 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.
  7899. * Values less than zero provide a filter of opposite hue.
  7900. */
  7901. set globalDensity(value: number);
  7902. /**
  7903. * Gets the global Saturation value.
  7904. * 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.
  7905. */
  7906. get globalSaturation(): number;
  7907. /**
  7908. * Sets the global Saturation value.
  7909. * 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.
  7910. */
  7911. set globalSaturation(value: number);
  7912. /**
  7913. * Gets the global Exposure value.
  7914. * 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.
  7915. */
  7916. get globalExposure(): number;
  7917. /**
  7918. * Sets the global Exposure value.
  7919. * 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.
  7920. */
  7921. set globalExposure(value: number);
  7922. private _highlightsHue;
  7923. private _highlightsDensity;
  7924. private _highlightsSaturation;
  7925. private _highlightsExposure;
  7926. /**
  7927. * Gets the highlights Hue value.
  7928. * 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).
  7929. */
  7930. get highlightsHue(): number;
  7931. /**
  7932. * Sets the highlights Hue value.
  7933. * 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).
  7934. */
  7935. set highlightsHue(value: number);
  7936. /**
  7937. * Gets the highlights Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. get highlightsDensity(): number;
  7942. /**
  7943. * Sets the highlights 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. set highlightsDensity(value: number);
  7948. /**
  7949. * Gets the highlights Saturation value.
  7950. * 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.
  7951. */
  7952. get highlightsSaturation(): number;
  7953. /**
  7954. * Sets the highlights Saturation value.
  7955. * 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.
  7956. */
  7957. set highlightsSaturation(value: number);
  7958. /**
  7959. * Gets the highlights Exposure value.
  7960. * 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.
  7961. */
  7962. get highlightsExposure(): number;
  7963. /**
  7964. * Sets the highlights Exposure value.
  7965. * 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.
  7966. */
  7967. set highlightsExposure(value: number);
  7968. private _midtonesHue;
  7969. private _midtonesDensity;
  7970. private _midtonesSaturation;
  7971. private _midtonesExposure;
  7972. /**
  7973. * Gets the midtones Hue value.
  7974. * 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).
  7975. */
  7976. get midtonesHue(): number;
  7977. /**
  7978. * Sets the midtones Hue value.
  7979. * 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).
  7980. */
  7981. set midtonesHue(value: number);
  7982. /**
  7983. * Gets the midtones Density value.
  7984. * 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.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. get midtonesDensity(): number;
  7988. /**
  7989. * Sets the midtones 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. set midtonesDensity(value: number);
  7994. /**
  7995. * Gets the midtones Saturation value.
  7996. * 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.
  7997. */
  7998. get midtonesSaturation(): number;
  7999. /**
  8000. * Sets the midtones Saturation value.
  8001. * 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.
  8002. */
  8003. set midtonesSaturation(value: number);
  8004. /**
  8005. * Gets the midtones Exposure value.
  8006. * 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.
  8007. */
  8008. get midtonesExposure(): number;
  8009. /**
  8010. * Sets the midtones Exposure value.
  8011. * 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.
  8012. */
  8013. set midtonesExposure(value: number);
  8014. private _shadowsHue;
  8015. private _shadowsDensity;
  8016. private _shadowsSaturation;
  8017. private _shadowsExposure;
  8018. /**
  8019. * Gets the shadows Hue value.
  8020. * 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).
  8021. */
  8022. get shadowsHue(): number;
  8023. /**
  8024. * Sets the shadows Hue value.
  8025. * 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).
  8026. */
  8027. set shadowsHue(value: number);
  8028. /**
  8029. * Gets the shadows Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. get shadowsDensity(): number;
  8034. /**
  8035. * Sets the shadows 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. set shadowsDensity(value: number);
  8040. /**
  8041. * Gets the shadows Saturation value.
  8042. * 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.
  8043. */
  8044. get shadowsSaturation(): number;
  8045. /**
  8046. * Sets the shadows Saturation value.
  8047. * 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.
  8048. */
  8049. set shadowsSaturation(value: number);
  8050. /**
  8051. * Gets the shadows Exposure value.
  8052. * 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.
  8053. */
  8054. get shadowsExposure(): number;
  8055. /**
  8056. * Sets the shadows Exposure value.
  8057. * 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.
  8058. */
  8059. set shadowsExposure(value: number);
  8060. /**
  8061. * Returns the class name
  8062. * @returns The class name
  8063. */
  8064. getClassName(): string;
  8065. /**
  8066. * Binds the color curves to the shader.
  8067. * @param colorCurves The color curve to bind
  8068. * @param effect The effect to bind to
  8069. * @param positiveUniform The positive uniform shader parameter
  8070. * @param neutralUniform The neutral uniform shader parameter
  8071. * @param negativeUniform The negative uniform shader parameter
  8072. */
  8073. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8074. /**
  8075. * Prepare the list of uniforms associated with the ColorCurves effects.
  8076. * @param uniformsList The list of uniforms used in the effect
  8077. */
  8078. static PrepareUniforms(uniformsList: string[]): void;
  8079. /**
  8080. * Returns color grading data based on a hue, density, saturation and exposure value.
  8081. * @param filterHue The hue of the color filter.
  8082. * @param filterDensity The density of the color filter.
  8083. * @param saturation The saturation.
  8084. * @param exposure The exposure.
  8085. * @param result The result data container.
  8086. */
  8087. private getColorGradingDataToRef;
  8088. /**
  8089. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8090. * @param value The input slider value in range [-100,100].
  8091. * @returns Adjusted value.
  8092. */
  8093. private static applyColorGradingSliderNonlinear;
  8094. /**
  8095. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8096. * @param hue The hue (H) input.
  8097. * @param saturation The saturation (S) input.
  8098. * @param brightness The brightness (B) input.
  8099. * @result An RGBA color represented as Vector4.
  8100. */
  8101. private static fromHSBToRef;
  8102. /**
  8103. * Returns a value clamped between min and max
  8104. * @param value The value to clamp
  8105. * @param min The minimum of value
  8106. * @param max The maximum of value
  8107. * @returns The clamped value.
  8108. */
  8109. private static clamp;
  8110. /**
  8111. * Clones the current color curve instance.
  8112. * @return The cloned curves
  8113. */
  8114. clone(): ColorCurves;
  8115. /**
  8116. * Serializes the current color curve instance to a json representation.
  8117. * @return a JSON representation
  8118. */
  8119. serialize(): any;
  8120. /**
  8121. * Parses the color curve from a json representation.
  8122. * @param source the JSON source to parse
  8123. * @return The parsed curves
  8124. */
  8125. static Parse(source: any): ColorCurves;
  8126. }
  8127. }
  8128. declare module BABYLON {
  8129. /**
  8130. * Interface to follow in your material defines to integrate easily the
  8131. * Image proccessing functions.
  8132. * @hidden
  8133. */
  8134. export interface IImageProcessingConfigurationDefines {
  8135. IMAGEPROCESSING: boolean;
  8136. VIGNETTE: boolean;
  8137. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8138. VIGNETTEBLENDMODEOPAQUE: boolean;
  8139. TONEMAPPING: boolean;
  8140. TONEMAPPING_ACES: boolean;
  8141. CONTRAST: boolean;
  8142. EXPOSURE: boolean;
  8143. COLORCURVES: boolean;
  8144. COLORGRADING: boolean;
  8145. COLORGRADING3D: boolean;
  8146. SAMPLER3DGREENDEPTH: boolean;
  8147. SAMPLER3DBGRMAP: boolean;
  8148. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8149. }
  8150. /**
  8151. * @hidden
  8152. */
  8153. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8154. IMAGEPROCESSING: boolean;
  8155. VIGNETTE: boolean;
  8156. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8157. VIGNETTEBLENDMODEOPAQUE: boolean;
  8158. TONEMAPPING: boolean;
  8159. TONEMAPPING_ACES: boolean;
  8160. CONTRAST: boolean;
  8161. COLORCURVES: boolean;
  8162. COLORGRADING: boolean;
  8163. COLORGRADING3D: boolean;
  8164. SAMPLER3DGREENDEPTH: boolean;
  8165. SAMPLER3DBGRMAP: boolean;
  8166. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8167. EXPOSURE: boolean;
  8168. constructor();
  8169. }
  8170. /**
  8171. * This groups together the common properties used for image processing either in direct forward pass
  8172. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8173. * or not.
  8174. */
  8175. export class ImageProcessingConfiguration {
  8176. /**
  8177. * Default tone mapping applied in BabylonJS.
  8178. */
  8179. static readonly TONEMAPPING_STANDARD: number;
  8180. /**
  8181. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8182. * to other engines rendering to increase portability.
  8183. */
  8184. static readonly TONEMAPPING_ACES: number;
  8185. /**
  8186. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8187. */
  8188. colorCurves: Nullable<ColorCurves>;
  8189. private _colorCurvesEnabled;
  8190. /**
  8191. * Gets wether the color curves effect is enabled.
  8192. */
  8193. get colorCurvesEnabled(): boolean;
  8194. /**
  8195. * Sets wether the color curves effect is enabled.
  8196. */
  8197. set colorCurvesEnabled(value: boolean);
  8198. private _colorGradingTexture;
  8199. /**
  8200. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8201. */
  8202. get colorGradingTexture(): Nullable<BaseTexture>;
  8203. /**
  8204. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8205. */
  8206. set colorGradingTexture(value: Nullable<BaseTexture>);
  8207. private _colorGradingEnabled;
  8208. /**
  8209. * Gets wether the color grading effect is enabled.
  8210. */
  8211. get colorGradingEnabled(): boolean;
  8212. /**
  8213. * Sets wether the color grading effect is enabled.
  8214. */
  8215. set colorGradingEnabled(value: boolean);
  8216. private _colorGradingWithGreenDepth;
  8217. /**
  8218. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8219. */
  8220. get colorGradingWithGreenDepth(): boolean;
  8221. /**
  8222. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8223. */
  8224. set colorGradingWithGreenDepth(value: boolean);
  8225. private _colorGradingBGR;
  8226. /**
  8227. * Gets wether the color grading texture contains BGR values.
  8228. */
  8229. get colorGradingBGR(): boolean;
  8230. /**
  8231. * Sets wether the color grading texture contains BGR values.
  8232. */
  8233. set colorGradingBGR(value: boolean);
  8234. /** @hidden */
  8235. _exposure: number;
  8236. /**
  8237. * Gets the Exposure used in the effect.
  8238. */
  8239. get exposure(): number;
  8240. /**
  8241. * Sets the Exposure used in the effect.
  8242. */
  8243. set exposure(value: number);
  8244. private _toneMappingEnabled;
  8245. /**
  8246. * Gets wether the tone mapping effect is enabled.
  8247. */
  8248. get toneMappingEnabled(): boolean;
  8249. /**
  8250. * Sets wether the tone mapping effect is enabled.
  8251. */
  8252. set toneMappingEnabled(value: boolean);
  8253. private _toneMappingType;
  8254. /**
  8255. * Gets the type of tone mapping effect.
  8256. */
  8257. get toneMappingType(): number;
  8258. /**
  8259. * Sets the type of tone mapping effect used in BabylonJS.
  8260. */
  8261. set toneMappingType(value: number);
  8262. protected _contrast: number;
  8263. /**
  8264. * Gets the contrast used in the effect.
  8265. */
  8266. get contrast(): number;
  8267. /**
  8268. * Sets the contrast used in the effect.
  8269. */
  8270. set contrast(value: number);
  8271. /**
  8272. * Vignette stretch size.
  8273. */
  8274. vignetteStretch: number;
  8275. /**
  8276. * Vignette centre X Offset.
  8277. */
  8278. vignetteCentreX: number;
  8279. /**
  8280. * Vignette centre Y Offset.
  8281. */
  8282. vignetteCentreY: number;
  8283. /**
  8284. * Vignette weight or intensity of the vignette effect.
  8285. */
  8286. vignetteWeight: number;
  8287. /**
  8288. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8289. * if vignetteEnabled is set to true.
  8290. */
  8291. vignetteColor: Color4;
  8292. /**
  8293. * Camera field of view used by the Vignette effect.
  8294. */
  8295. vignetteCameraFov: number;
  8296. private _vignetteBlendMode;
  8297. /**
  8298. * Gets the vignette blend mode allowing different kind of effect.
  8299. */
  8300. get vignetteBlendMode(): number;
  8301. /**
  8302. * Sets the vignette blend mode allowing different kind of effect.
  8303. */
  8304. set vignetteBlendMode(value: number);
  8305. private _vignetteEnabled;
  8306. /**
  8307. * Gets wether the vignette effect is enabled.
  8308. */
  8309. get vignetteEnabled(): boolean;
  8310. /**
  8311. * Sets wether the vignette effect is enabled.
  8312. */
  8313. set vignetteEnabled(value: boolean);
  8314. private _applyByPostProcess;
  8315. /**
  8316. * Gets wether the image processing is applied through a post process or not.
  8317. */
  8318. get applyByPostProcess(): boolean;
  8319. /**
  8320. * Sets wether the image processing is applied through a post process or not.
  8321. */
  8322. set applyByPostProcess(value: boolean);
  8323. private _isEnabled;
  8324. /**
  8325. * Gets wether the image processing is enabled or not.
  8326. */
  8327. get isEnabled(): boolean;
  8328. /**
  8329. * Sets wether the image processing is enabled or not.
  8330. */
  8331. set isEnabled(value: boolean);
  8332. /**
  8333. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8334. */
  8335. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8336. /**
  8337. * Method called each time the image processing information changes requires to recompile the effect.
  8338. */
  8339. protected _updateParameters(): void;
  8340. /**
  8341. * Gets the current class name.
  8342. * @return "ImageProcessingConfiguration"
  8343. */
  8344. getClassName(): string;
  8345. /**
  8346. * Prepare the list of uniforms associated with the Image Processing effects.
  8347. * @param uniforms The list of uniforms used in the effect
  8348. * @param defines the list of defines currently in use
  8349. */
  8350. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8351. /**
  8352. * Prepare the list of samplers associated with the Image Processing effects.
  8353. * @param samplersList The list of uniforms used in the effect
  8354. * @param defines the list of defines currently in use
  8355. */
  8356. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8357. /**
  8358. * Prepare the list of defines associated to the shader.
  8359. * @param defines the list of defines to complete
  8360. * @param forPostProcess Define if we are currently in post process mode or not
  8361. */
  8362. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8363. /**
  8364. * Returns true if all the image processing information are ready.
  8365. * @returns True if ready, otherwise, false
  8366. */
  8367. isReady(): boolean;
  8368. /**
  8369. * Binds the image processing to the shader.
  8370. * @param effect The effect to bind to
  8371. * @param overrideAspectRatio Override the aspect ratio of the effect
  8372. */
  8373. bind(effect: Effect, overrideAspectRatio?: number): void;
  8374. /**
  8375. * Clones the current image processing instance.
  8376. * @return The cloned image processing
  8377. */
  8378. clone(): ImageProcessingConfiguration;
  8379. /**
  8380. * Serializes the current image processing instance to a json representation.
  8381. * @return a JSON representation
  8382. */
  8383. serialize(): any;
  8384. /**
  8385. * Parses the image processing from a json representation.
  8386. * @param source the JSON source to parse
  8387. * @return The parsed image processing
  8388. */
  8389. static Parse(source: any): ImageProcessingConfiguration;
  8390. private static _VIGNETTEMODE_MULTIPLY;
  8391. private static _VIGNETTEMODE_OPAQUE;
  8392. /**
  8393. * Used to apply the vignette as a mix with the pixel color.
  8394. */
  8395. static get VIGNETTEMODE_MULTIPLY(): number;
  8396. /**
  8397. * Used to apply the vignette as a replacement of the pixel color.
  8398. */
  8399. static get VIGNETTEMODE_OPAQUE(): number;
  8400. }
  8401. }
  8402. declare module BABYLON {
  8403. /** @hidden */
  8404. export var postprocessVertexShader: {
  8405. name: string;
  8406. shader: string;
  8407. };
  8408. }
  8409. declare module BABYLON {
  8410. interface ThinEngine {
  8411. /**
  8412. * Creates a new render target texture
  8413. * @param size defines the size of the texture
  8414. * @param options defines the options used to create the texture
  8415. * @returns a new render target texture stored in an InternalTexture
  8416. */
  8417. createRenderTargetTexture(size: number | {
  8418. width: number;
  8419. height: number;
  8420. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8421. /**
  8422. * Creates a depth stencil texture.
  8423. * This is only available in WebGL 2 or with the depth texture extension available.
  8424. * @param size The size of face edge in the texture.
  8425. * @param options The options defining the texture.
  8426. * @returns The texture
  8427. */
  8428. createDepthStencilTexture(size: number | {
  8429. width: number;
  8430. height: number;
  8431. }, options: DepthTextureCreationOptions): InternalTexture;
  8432. /** @hidden */
  8433. _createDepthStencilTexture(size: number | {
  8434. width: number;
  8435. height: number;
  8436. }, options: DepthTextureCreationOptions): InternalTexture;
  8437. }
  8438. }
  8439. declare module BABYLON {
  8440. /** Defines supported spaces */
  8441. export enum Space {
  8442. /** Local (object) space */
  8443. LOCAL = 0,
  8444. /** World space */
  8445. WORLD = 1,
  8446. /** Bone space */
  8447. BONE = 2
  8448. }
  8449. /** Defines the 3 main axes */
  8450. export class Axis {
  8451. /** X axis */
  8452. static X: Vector3;
  8453. /** Y axis */
  8454. static Y: Vector3;
  8455. /** Z axis */
  8456. static Z: Vector3;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /**
  8461. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8462. * This is the base of the follow, arc rotate cameras and Free camera
  8463. * @see http://doc.babylonjs.com/features/cameras
  8464. */
  8465. export class TargetCamera extends Camera {
  8466. private static _RigCamTransformMatrix;
  8467. private static _TargetTransformMatrix;
  8468. private static _TargetFocalPoint;
  8469. /**
  8470. * Define the current direction the camera is moving to
  8471. */
  8472. cameraDirection: Vector3;
  8473. /**
  8474. * Define the current rotation the camera is rotating to
  8475. */
  8476. cameraRotation: Vector2;
  8477. /**
  8478. * When set, the up vector of the camera will be updated by the rotation of the camera
  8479. */
  8480. updateUpVectorFromRotation: boolean;
  8481. private _tmpQuaternion;
  8482. /**
  8483. * Define the current rotation of the camera
  8484. */
  8485. rotation: Vector3;
  8486. /**
  8487. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8488. */
  8489. rotationQuaternion: Quaternion;
  8490. /**
  8491. * Define the current speed of the camera
  8492. */
  8493. speed: number;
  8494. /**
  8495. * Add constraint to the camera to prevent it to move freely in all directions and
  8496. * around all axis.
  8497. */
  8498. noRotationConstraint: boolean;
  8499. /**
  8500. * Define the current target of the camera as an object or a position.
  8501. */
  8502. lockedTarget: any;
  8503. /** @hidden */
  8504. _currentTarget: Vector3;
  8505. /** @hidden */
  8506. _initialFocalDistance: number;
  8507. /** @hidden */
  8508. _viewMatrix: Matrix;
  8509. /** @hidden */
  8510. _camMatrix: Matrix;
  8511. /** @hidden */
  8512. _cameraTransformMatrix: Matrix;
  8513. /** @hidden */
  8514. _cameraRotationMatrix: Matrix;
  8515. /** @hidden */
  8516. _referencePoint: Vector3;
  8517. /** @hidden */
  8518. _transformedReferencePoint: Vector3;
  8519. protected _globalCurrentTarget: Vector3;
  8520. protected _globalCurrentUpVector: Vector3;
  8521. /** @hidden */
  8522. _reset: () => void;
  8523. private _defaultUp;
  8524. /**
  8525. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8526. * This is the base of the follow, arc rotate cameras and Free camera
  8527. * @see http://doc.babylonjs.com/features/cameras
  8528. * @param name Defines the name of the camera in the scene
  8529. * @param position Defines the start position of the camera in the scene
  8530. * @param scene Defines the scene the camera belongs to
  8531. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8532. */
  8533. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8534. /**
  8535. * Gets the position in front of the camera at a given distance.
  8536. * @param distance The distance from the camera we want the position to be
  8537. * @returns the position
  8538. */
  8539. getFrontPosition(distance: number): Vector3;
  8540. /** @hidden */
  8541. _getLockedTargetPosition(): Nullable<Vector3>;
  8542. private _storedPosition;
  8543. private _storedRotation;
  8544. private _storedRotationQuaternion;
  8545. /**
  8546. * Store current camera state of the camera (fov, position, rotation, etc..)
  8547. * @returns the camera
  8548. */
  8549. storeState(): Camera;
  8550. /**
  8551. * Restored camera state. You must call storeState() first
  8552. * @returns whether it was successful or not
  8553. * @hidden
  8554. */
  8555. _restoreStateValues(): boolean;
  8556. /** @hidden */
  8557. _initCache(): void;
  8558. /** @hidden */
  8559. _updateCache(ignoreParentClass?: boolean): void;
  8560. /** @hidden */
  8561. _isSynchronizedViewMatrix(): boolean;
  8562. /** @hidden */
  8563. _computeLocalCameraSpeed(): number;
  8564. /**
  8565. * Defines the target the camera should look at.
  8566. * @param target Defines the new target as a Vector or a mesh
  8567. */
  8568. setTarget(target: Vector3): void;
  8569. /**
  8570. * Return the current target position of the camera. This value is expressed in local space.
  8571. * @returns the target position
  8572. */
  8573. getTarget(): Vector3;
  8574. /** @hidden */
  8575. _decideIfNeedsToMove(): boolean;
  8576. /** @hidden */
  8577. _updatePosition(): void;
  8578. /** @hidden */
  8579. _checkInputs(): void;
  8580. protected _updateCameraRotationMatrix(): void;
  8581. /**
  8582. * 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)
  8583. * @returns the current camera
  8584. */
  8585. private _rotateUpVectorWithCameraRotationMatrix;
  8586. private _cachedRotationZ;
  8587. private _cachedQuaternionRotationZ;
  8588. /** @hidden */
  8589. _getViewMatrix(): Matrix;
  8590. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8591. /**
  8592. * @hidden
  8593. */
  8594. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8595. /**
  8596. * @hidden
  8597. */
  8598. _updateRigCameras(): void;
  8599. private _getRigCamPositionAndTarget;
  8600. /**
  8601. * Gets the current object class name.
  8602. * @return the class name
  8603. */
  8604. getClassName(): string;
  8605. }
  8606. }
  8607. declare module BABYLON {
  8608. /**
  8609. * Gather the list of keyboard event types as constants.
  8610. */
  8611. export class KeyboardEventTypes {
  8612. /**
  8613. * The keydown event is fired when a key becomes active (pressed).
  8614. */
  8615. static readonly KEYDOWN: number;
  8616. /**
  8617. * The keyup event is fired when a key has been released.
  8618. */
  8619. static readonly KEYUP: number;
  8620. }
  8621. /**
  8622. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8623. */
  8624. export class KeyboardInfo {
  8625. /**
  8626. * Defines the type of event (KeyboardEventTypes)
  8627. */
  8628. type: number;
  8629. /**
  8630. * Defines the related dom event
  8631. */
  8632. event: KeyboardEvent;
  8633. /**
  8634. * Instantiates a new keyboard info.
  8635. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8636. * @param type Defines the type of event (KeyboardEventTypes)
  8637. * @param event Defines the related dom event
  8638. */
  8639. constructor(
  8640. /**
  8641. * Defines the type of event (KeyboardEventTypes)
  8642. */
  8643. type: number,
  8644. /**
  8645. * Defines the related dom event
  8646. */
  8647. event: KeyboardEvent);
  8648. }
  8649. /**
  8650. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8651. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8652. */
  8653. export class KeyboardInfoPre extends KeyboardInfo {
  8654. /**
  8655. * Defines the type of event (KeyboardEventTypes)
  8656. */
  8657. type: number;
  8658. /**
  8659. * Defines the related dom event
  8660. */
  8661. event: KeyboardEvent;
  8662. /**
  8663. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8664. */
  8665. skipOnPointerObservable: boolean;
  8666. /**
  8667. * Instantiates a new keyboard pre info.
  8668. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8669. * @param type Defines the type of event (KeyboardEventTypes)
  8670. * @param event Defines the related dom event
  8671. */
  8672. constructor(
  8673. /**
  8674. * Defines the type of event (KeyboardEventTypes)
  8675. */
  8676. type: number,
  8677. /**
  8678. * Defines the related dom event
  8679. */
  8680. event: KeyboardEvent);
  8681. }
  8682. }
  8683. declare module BABYLON {
  8684. /**
  8685. * Manage the keyboard inputs to control the movement of a free camera.
  8686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8687. */
  8688. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8689. /**
  8690. * Defines the camera the input is attached to.
  8691. */
  8692. camera: FreeCamera;
  8693. /**
  8694. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8695. */
  8696. keysUp: number[];
  8697. /**
  8698. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8699. */
  8700. keysDown: number[];
  8701. /**
  8702. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8703. */
  8704. keysLeft: number[];
  8705. /**
  8706. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8707. */
  8708. keysRight: number[];
  8709. private _keys;
  8710. private _onCanvasBlurObserver;
  8711. private _onKeyboardObserver;
  8712. private _engine;
  8713. private _scene;
  8714. /**
  8715. * Attach the input controls to a specific dom element to get the input from.
  8716. * @param element Defines the element the controls should be listened from
  8717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8718. */
  8719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8720. /**
  8721. * Detach the current controls from the specified dom element.
  8722. * @param element Defines the element to stop listening the inputs from
  8723. */
  8724. detachControl(element: Nullable<HTMLElement>): void;
  8725. /**
  8726. * Update the current camera state depending on the inputs that have been used this frame.
  8727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8728. */
  8729. checkInputs(): void;
  8730. /**
  8731. * Gets the class name of the current intput.
  8732. * @returns the class name
  8733. */
  8734. getClassName(): string;
  8735. /** @hidden */
  8736. _onLostFocus(): void;
  8737. /**
  8738. * Get the friendly name associated with the input class.
  8739. * @returns the input friendly name
  8740. */
  8741. getSimpleName(): string;
  8742. }
  8743. }
  8744. declare module BABYLON {
  8745. /**
  8746. * Interface describing all the common properties and methods a shadow light needs to implement.
  8747. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8748. * as well as binding the different shadow properties to the effects.
  8749. */
  8750. export interface IShadowLight extends Light {
  8751. /**
  8752. * The light id in the scene (used in scene.findLighById for instance)
  8753. */
  8754. id: string;
  8755. /**
  8756. * The position the shdow will be casted from.
  8757. */
  8758. position: Vector3;
  8759. /**
  8760. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8761. */
  8762. direction: Vector3;
  8763. /**
  8764. * The transformed position. Position of the light in world space taking parenting in account.
  8765. */
  8766. transformedPosition: Vector3;
  8767. /**
  8768. * The transformed direction. Direction of the light in world space taking parenting in account.
  8769. */
  8770. transformedDirection: Vector3;
  8771. /**
  8772. * The friendly name of the light in the scene.
  8773. */
  8774. name: string;
  8775. /**
  8776. * Defines the shadow projection clipping minimum z value.
  8777. */
  8778. shadowMinZ: number;
  8779. /**
  8780. * Defines the shadow projection clipping maximum z value.
  8781. */
  8782. shadowMaxZ: number;
  8783. /**
  8784. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8785. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8786. */
  8787. computeTransformedInformation(): boolean;
  8788. /**
  8789. * Gets the scene the light belongs to.
  8790. * @returns The scene
  8791. */
  8792. getScene(): Scene;
  8793. /**
  8794. * Callback defining a custom Projection Matrix Builder.
  8795. * This can be used to override the default projection matrix computation.
  8796. */
  8797. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8798. /**
  8799. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8800. * @param matrix The materix to updated with the projection information
  8801. * @param viewMatrix The transform matrix of the light
  8802. * @param renderList The list of mesh to render in the map
  8803. * @returns The current light
  8804. */
  8805. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8806. /**
  8807. * Gets the current depth scale used in ESM.
  8808. * @returns The scale
  8809. */
  8810. getDepthScale(): number;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /**
  8826. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8827. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8828. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8829. */
  8830. getShadowDirection(faceIndex?: number): Vector3;
  8831. /**
  8832. * Gets the minZ used for shadow according to both the scene and the light.
  8833. * @param activeCamera The camera we are returning the min for
  8834. * @returns the depth min z
  8835. */
  8836. getDepthMinZ(activeCamera: Camera): number;
  8837. /**
  8838. * Gets the maxZ used for shadow according to both the scene and the light.
  8839. * @param activeCamera The camera we are returning the max for
  8840. * @returns the depth max z
  8841. */
  8842. getDepthMaxZ(activeCamera: Camera): number;
  8843. }
  8844. /**
  8845. * Base implementation IShadowLight
  8846. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8847. */
  8848. export abstract class ShadowLight extends Light implements IShadowLight {
  8849. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8850. protected _position: Vector3;
  8851. protected _setPosition(value: Vector3): void;
  8852. /**
  8853. * Sets the position the shadow will be casted from. Also use as the light position for both
  8854. * point and spot lights.
  8855. */
  8856. get position(): Vector3;
  8857. /**
  8858. * Sets the position the shadow will be casted from. Also use as the light position for both
  8859. * point and spot lights.
  8860. */
  8861. set position(value: Vector3);
  8862. protected _direction: Vector3;
  8863. protected _setDirection(value: Vector3): void;
  8864. /**
  8865. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8866. * Also use as the light direction on spot and directional lights.
  8867. */
  8868. get direction(): Vector3;
  8869. /**
  8870. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8871. * Also use as the light direction on spot and directional lights.
  8872. */
  8873. set direction(value: Vector3);
  8874. private _shadowMinZ;
  8875. /**
  8876. * Gets the shadow projection clipping minimum z value.
  8877. */
  8878. get shadowMinZ(): number;
  8879. /**
  8880. * Sets the shadow projection clipping minimum z value.
  8881. */
  8882. set shadowMinZ(value: number);
  8883. private _shadowMaxZ;
  8884. /**
  8885. * Sets the shadow projection clipping maximum z value.
  8886. */
  8887. get shadowMaxZ(): number;
  8888. /**
  8889. * Gets the shadow projection clipping maximum z value.
  8890. */
  8891. set shadowMaxZ(value: number);
  8892. /**
  8893. * Callback defining a custom Projection Matrix Builder.
  8894. * This can be used to override the default projection matrix computation.
  8895. */
  8896. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8897. /**
  8898. * The transformed position. Position of the light in world space taking parenting in account.
  8899. */
  8900. transformedPosition: Vector3;
  8901. /**
  8902. * The transformed direction. Direction of the light in world space taking parenting in account.
  8903. */
  8904. transformedDirection: Vector3;
  8905. private _needProjectionMatrixCompute;
  8906. /**
  8907. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8908. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8909. */
  8910. computeTransformedInformation(): boolean;
  8911. /**
  8912. * Return the depth scale used for the shadow map.
  8913. * @returns the depth scale.
  8914. */
  8915. getDepthScale(): number;
  8916. /**
  8917. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8918. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8919. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8920. */
  8921. getShadowDirection(faceIndex?: number): Vector3;
  8922. /**
  8923. * Returns the ShadowLight absolute position in the World.
  8924. * @returns the position vector in world space
  8925. */
  8926. getAbsolutePosition(): Vector3;
  8927. /**
  8928. * Sets the ShadowLight direction toward the passed target.
  8929. * @param target The point to target in local space
  8930. * @returns the updated ShadowLight direction
  8931. */
  8932. setDirectionToTarget(target: Vector3): Vector3;
  8933. /**
  8934. * Returns the light rotation in euler definition.
  8935. * @returns the x y z rotation in local space.
  8936. */
  8937. getRotation(): Vector3;
  8938. /**
  8939. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8940. * @returns true if a cube texture needs to be use
  8941. */
  8942. needCube(): boolean;
  8943. /**
  8944. * Detects if the projection matrix requires to be recomputed this frame.
  8945. * @returns true if it requires to be recomputed otherwise, false.
  8946. */
  8947. needProjectionMatrixCompute(): boolean;
  8948. /**
  8949. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8950. */
  8951. forceProjectionMatrixCompute(): void;
  8952. /** @hidden */
  8953. _initCache(): void;
  8954. /** @hidden */
  8955. _isSynchronized(): boolean;
  8956. /**
  8957. * Computes the world matrix of the node
  8958. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8959. * @returns the world matrix
  8960. */
  8961. computeWorldMatrix(force?: boolean): Matrix;
  8962. /**
  8963. * Gets the minZ used for shadow according to both the scene and the light.
  8964. * @param activeCamera The camera we are returning the min for
  8965. * @returns the depth min z
  8966. */
  8967. getDepthMinZ(activeCamera: Camera): number;
  8968. /**
  8969. * Gets the maxZ used for shadow according to both the scene and the light.
  8970. * @param activeCamera The camera we are returning the max for
  8971. * @returns the depth max z
  8972. */
  8973. getDepthMaxZ(activeCamera: Camera): number;
  8974. /**
  8975. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8976. * @param matrix The materix to updated with the projection information
  8977. * @param viewMatrix The transform matrix of the light
  8978. * @param renderList The list of mesh to render in the map
  8979. * @returns The current light
  8980. */
  8981. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8987. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8988. */
  8989. export class EffectFallbacks implements IEffectFallbacks {
  8990. private _defines;
  8991. private _currentRank;
  8992. private _maxRank;
  8993. private _mesh;
  8994. /**
  8995. * Removes the fallback from the bound mesh.
  8996. */
  8997. unBindMesh(): void;
  8998. /**
  8999. * Adds a fallback on the specified property.
  9000. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9001. * @param define The name of the define in the shader
  9002. */
  9003. addFallback(rank: number, define: string): void;
  9004. /**
  9005. * Sets the mesh to use CPU skinning when needing to fallback.
  9006. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9007. * @param mesh The mesh to use the fallbacks.
  9008. */
  9009. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9010. /**
  9011. * Checks to see if more fallbacks are still availible.
  9012. */
  9013. get hasMoreFallbacks(): boolean;
  9014. /**
  9015. * Removes the defines that should be removed when falling back.
  9016. * @param currentDefines defines the current define statements for the shader.
  9017. * @param effect defines the current effect we try to compile
  9018. * @returns The resulting defines with defines of the current rank removed.
  9019. */
  9020. reduce(currentDefines: string, effect: Effect): string;
  9021. }
  9022. }
  9023. declare module BABYLON {
  9024. /**
  9025. * "Static Class" containing the most commonly used helper while dealing with material for
  9026. * rendering purpose.
  9027. *
  9028. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9029. *
  9030. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9031. */
  9032. export class MaterialHelper {
  9033. /**
  9034. * Bind the current view position to an effect.
  9035. * @param effect The effect to be bound
  9036. * @param scene The scene the eyes position is used from
  9037. */
  9038. static BindEyePosition(effect: Effect, scene: Scene): void;
  9039. /**
  9040. * Helps preparing the defines values about the UVs in used in the effect.
  9041. * UVs are shared as much as we can accross channels in the shaders.
  9042. * @param texture The texture we are preparing the UVs for
  9043. * @param defines The defines to update
  9044. * @param key The channel key "diffuse", "specular"... used in the shader
  9045. */
  9046. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9047. /**
  9048. * Binds a texture matrix value to its corrsponding uniform
  9049. * @param texture The texture to bind the matrix for
  9050. * @param uniformBuffer The uniform buffer receivin the data
  9051. * @param key The channel key "diffuse", "specular"... used in the shader
  9052. */
  9053. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9054. /**
  9055. * Gets the current status of the fog (should it be enabled?)
  9056. * @param mesh defines the mesh to evaluate for fog support
  9057. * @param scene defines the hosting scene
  9058. * @returns true if fog must be enabled
  9059. */
  9060. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9061. /**
  9062. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9063. * @param mesh defines the current mesh
  9064. * @param scene defines the current scene
  9065. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9066. * @param pointsCloud defines if point cloud rendering has to be turned on
  9067. * @param fogEnabled defines if fog has to be turned on
  9068. * @param alphaTest defines if alpha testing has to be turned on
  9069. * @param defines defines the current list of defines
  9070. */
  9071. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9072. /**
  9073. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9074. * @param scene defines the current scene
  9075. * @param engine defines the current engine
  9076. * @param defines specifies the list of active defines
  9077. * @param useInstances defines if instances have to be turned on
  9078. * @param useClipPlane defines if clip plane have to be turned on
  9079. */
  9080. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9081. /**
  9082. * Prepares the defines for bones
  9083. * @param mesh The mesh containing the geometry data we will draw
  9084. * @param defines The defines to update
  9085. */
  9086. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9087. /**
  9088. * Prepares the defines for morph targets
  9089. * @param mesh The mesh containing the geometry data we will draw
  9090. * @param defines The defines to update
  9091. */
  9092. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9093. /**
  9094. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9095. * @param mesh The mesh containing the geometry data we will draw
  9096. * @param defines The defines to update
  9097. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9098. * @param useBones Precise whether bones should be used or not (override mesh info)
  9099. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9100. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9101. * @returns false if defines are considered not dirty and have not been checked
  9102. */
  9103. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9104. /**
  9105. * Prepares the defines related to multiview
  9106. * @param scene The scene we are intending to draw
  9107. * @param defines The defines to update
  9108. */
  9109. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9110. /**
  9111. * Prepares the defines related to the light information passed in parameter
  9112. * @param scene The scene we are intending to draw
  9113. * @param mesh The mesh the effect is compiling for
  9114. * @param light The light the effect is compiling for
  9115. * @param lightIndex The index of the light
  9116. * @param defines The defines to update
  9117. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9118. * @param state Defines the current state regarding what is needed (normals, etc...)
  9119. */
  9120. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9121. needNormals: boolean;
  9122. needRebuild: boolean;
  9123. shadowEnabled: boolean;
  9124. specularEnabled: boolean;
  9125. lightmapMode: boolean;
  9126. }): void;
  9127. /**
  9128. * Prepares the defines related to the light information passed in parameter
  9129. * @param scene The scene we are intending to draw
  9130. * @param mesh The mesh the effect is compiling for
  9131. * @param defines The defines to update
  9132. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9133. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9134. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9135. * @returns true if normals will be required for the rest of the effect
  9136. */
  9137. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9138. /**
  9139. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9140. * @param lightIndex defines the light index
  9141. * @param uniformsList The uniform list
  9142. * @param samplersList The sampler list
  9143. * @param projectedLightTexture defines if projected texture must be used
  9144. * @param uniformBuffersList defines an optional list of uniform buffers
  9145. */
  9146. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9147. /**
  9148. * Prepares the uniforms and samplers list to be used in the effect
  9149. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9150. * @param samplersList The sampler list
  9151. * @param defines The defines helping in the list generation
  9152. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9153. */
  9154. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9155. /**
  9156. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9157. * @param defines The defines to update while falling back
  9158. * @param fallbacks The authorized effect fallbacks
  9159. * @param maxSimultaneousLights The maximum number of lights allowed
  9160. * @param rank the current rank of the Effect
  9161. * @returns The newly affected rank
  9162. */
  9163. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9164. private static _TmpMorphInfluencers;
  9165. /**
  9166. * Prepares the list of attributes required for morph targets according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param mesh The mesh to prepare the morph targets attributes for
  9169. * @param influencers The number of influencers
  9170. */
  9171. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9172. /**
  9173. * Prepares the list of attributes required for morph targets according to the effect defines.
  9174. * @param attribs The current list of supported attribs
  9175. * @param mesh The mesh to prepare the morph targets attributes for
  9176. * @param defines The current Defines of the effect
  9177. */
  9178. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9179. /**
  9180. * Prepares the list of attributes required for bones according to the effect defines.
  9181. * @param attribs The current list of supported attribs
  9182. * @param mesh The mesh to prepare the bones attributes for
  9183. * @param defines The current Defines of the effect
  9184. * @param fallbacks The current efffect fallback strategy
  9185. */
  9186. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9187. /**
  9188. * Check and prepare the list of attributes required for instances according to the effect defines.
  9189. * @param attribs The current list of supported attribs
  9190. * @param defines The current MaterialDefines of the effect
  9191. */
  9192. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9193. /**
  9194. * Add the list of attributes required for instances to the attribs array.
  9195. * @param attribs The current list of supported attribs
  9196. */
  9197. static PushAttributesForInstances(attribs: string[]): void;
  9198. /**
  9199. * Binds the light information to the effect.
  9200. * @param light The light containing the generator
  9201. * @param effect The effect we are binding the data to
  9202. * @param lightIndex The light index in the effect used to render
  9203. */
  9204. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9205. /**
  9206. * Binds the lights information from the scene to the effect for the given mesh.
  9207. * @param light Light to bind
  9208. * @param lightIndex Light index
  9209. * @param scene The scene where the light belongs to
  9210. * @param effect The effect we are binding the data to
  9211. * @param useSpecular Defines if specular is supported
  9212. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9213. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9214. */
  9215. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9216. /**
  9217. * Binds the lights information from the scene to the effect for the given mesh.
  9218. * @param scene The scene the lights belongs to
  9219. * @param mesh The mesh we are binding the information to render
  9220. * @param effect The effect we are binding the data to
  9221. * @param defines The generated defines for the effect
  9222. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9223. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9224. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9225. */
  9226. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9227. private static _tempFogColor;
  9228. /**
  9229. * Binds the fog information from the scene to the effect for the given mesh.
  9230. * @param scene The scene the lights belongs to
  9231. * @param mesh The mesh we are binding the information to render
  9232. * @param effect The effect we are binding the data to
  9233. * @param linearSpace Defines if the fog effect is applied in linear space
  9234. */
  9235. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9236. /**
  9237. * Binds the bones information from the mesh to the effect.
  9238. * @param mesh The mesh we are binding the information to render
  9239. * @param effect The effect we are binding the data to
  9240. */
  9241. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9242. /**
  9243. * Binds the morph targets information from the mesh to the effect.
  9244. * @param abstractMesh The mesh we are binding the information to render
  9245. * @param effect The effect we are binding the data to
  9246. */
  9247. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9248. /**
  9249. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9250. * @param defines The generated defines used in the effect
  9251. * @param effect The effect we are binding the data to
  9252. * @param scene The scene we are willing to render with logarithmic scale for
  9253. */
  9254. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9255. /**
  9256. * Binds the clip plane information from the scene to the effect.
  9257. * @param scene The scene the clip plane information are extracted from
  9258. * @param effect The effect we are binding the data to
  9259. */
  9260. static BindClipPlane(effect: Effect, scene: Scene): void;
  9261. }
  9262. }
  9263. declare module BABYLON {
  9264. /** @hidden */
  9265. export var packingFunctions: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module BABYLON {
  9271. /** @hidden */
  9272. export var shadowMapPixelShader: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var bonesDeclaration: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var morphTargetsVertexGlobalDeclaration: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var morphTargetsVertexDeclaration: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var instancesDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var helperFunctions: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var morphTargetsVertex: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var instancesVertex: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var bonesVertex: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var shadowMapVertexShader: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var depthBoxBlurPixelShader: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /**
  9349. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9350. */
  9351. export interface ICustomShaderOptions {
  9352. /**
  9353. * Gets or sets the custom shader name to use
  9354. */
  9355. shaderName: string;
  9356. /**
  9357. * The list of attribute names used in the shader
  9358. */
  9359. attributes?: string[];
  9360. /**
  9361. * The list of unifrom names used in the shader
  9362. */
  9363. uniforms?: string[];
  9364. /**
  9365. * The list of sampler names used in the shader
  9366. */
  9367. samplers?: string[];
  9368. /**
  9369. * The list of defines used in the shader
  9370. */
  9371. defines?: string[];
  9372. }
  9373. /**
  9374. * Interface to implement to create a shadow generator compatible with BJS.
  9375. */
  9376. export interface IShadowGenerator {
  9377. /**
  9378. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9379. * @returns The render target texture if present otherwise, null
  9380. */
  9381. getShadowMap(): Nullable<RenderTargetTexture>;
  9382. /**
  9383. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9384. * @returns The render target texture if the shadow map is present otherwise, null
  9385. */
  9386. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9387. /**
  9388. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9389. * @param subMesh The submesh we want to render in the shadow map
  9390. * @param useInstances Defines wether will draw in the map using instances
  9391. * @returns true if ready otherwise, false
  9392. */
  9393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9394. /**
  9395. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9396. * @param defines Defines of the material we want to update
  9397. * @param lightIndex Index of the light in the enabled light list of the material
  9398. */
  9399. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9400. /**
  9401. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9402. * defined in the generator but impacting the effect).
  9403. * It implies the unifroms available on the materials are the standard BJS ones.
  9404. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9405. * @param effect The effect we are binfing the information for
  9406. */
  9407. bindShadowLight(lightIndex: string, effect: Effect): void;
  9408. /**
  9409. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9410. * (eq to shadow prjection matrix * light transform matrix)
  9411. * @returns The transform matrix used to create the shadow map
  9412. */
  9413. getTransformMatrix(): Matrix;
  9414. /**
  9415. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9416. * Cube and 2D textures for instance.
  9417. */
  9418. recreateShadowMap(): void;
  9419. /**
  9420. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9421. * @param onCompiled Callback triggered at the and of the effects compilation
  9422. * @param options Sets of optional options forcing the compilation with different modes
  9423. */
  9424. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9425. useInstances: boolean;
  9426. }>): void;
  9427. /**
  9428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9429. * @param options Sets of optional options forcing the compilation with different modes
  9430. * @returns A promise that resolves when the compilation completes
  9431. */
  9432. forceCompilationAsync(options?: Partial<{
  9433. useInstances: boolean;
  9434. }>): Promise<void>;
  9435. /**
  9436. * Serializes the shadow generator setup to a json object.
  9437. * @returns The serialized JSON object
  9438. */
  9439. serialize(): any;
  9440. /**
  9441. * Disposes the Shadow map and related Textures and effects.
  9442. */
  9443. dispose(): void;
  9444. }
  9445. /**
  9446. * Default implementation IShadowGenerator.
  9447. * This is the main object responsible of generating shadows in the framework.
  9448. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9449. */
  9450. export class ShadowGenerator implements IShadowGenerator {
  9451. /**
  9452. * Shadow generator mode None: no filtering applied.
  9453. */
  9454. static readonly FILTER_NONE: number;
  9455. /**
  9456. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9457. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9458. */
  9459. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9460. /**
  9461. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9462. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9463. */
  9464. static readonly FILTER_POISSONSAMPLING: number;
  9465. /**
  9466. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9478. * edge artifacts on steep falloff.
  9479. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9480. */
  9481. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9482. /**
  9483. * Shadow generator mode PCF: Percentage Closer Filtering
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9486. */
  9487. static readonly FILTER_PCF: number;
  9488. /**
  9489. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9490. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9491. * Contact Hardening
  9492. */
  9493. static readonly FILTER_PCSS: number;
  9494. /**
  9495. * Reserved for PCF and PCSS
  9496. * Highest Quality.
  9497. *
  9498. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9499. *
  9500. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9501. */
  9502. static readonly QUALITY_HIGH: number;
  9503. /**
  9504. * Reserved for PCF and PCSS
  9505. * Good tradeoff for quality/perf cross devices
  9506. *
  9507. * Execute PCF on a 3*3 kernel.
  9508. *
  9509. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9510. */
  9511. static readonly QUALITY_MEDIUM: number;
  9512. /**
  9513. * Reserved for PCF and PCSS
  9514. * The lowest quality but the fastest.
  9515. *
  9516. * Execute PCF on a 1*1 kernel.
  9517. *
  9518. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9519. */
  9520. static readonly QUALITY_LOW: number;
  9521. /** Gets or sets the custom shader name to use */
  9522. customShaderOptions: ICustomShaderOptions;
  9523. /**
  9524. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9525. */
  9526. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9527. /**
  9528. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9529. */
  9530. onAfterShadowMapRenderObservable: Observable<Effect>;
  9531. /**
  9532. * Observable triggered before a mesh is rendered in the shadow map.
  9533. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9534. */
  9535. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9536. /**
  9537. * Observable triggered after a mesh is rendered in the shadow map.
  9538. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9539. */
  9540. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9541. private _bias;
  9542. /**
  9543. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9544. */
  9545. get bias(): number;
  9546. /**
  9547. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9548. */
  9549. set bias(bias: number);
  9550. private _normalBias;
  9551. /**
  9552. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9553. */
  9554. get normalBias(): number;
  9555. /**
  9556. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9557. */
  9558. set normalBias(normalBias: number);
  9559. private _blurBoxOffset;
  9560. /**
  9561. * Gets the blur box offset: offset applied during the blur pass.
  9562. * Only useful if useKernelBlur = false
  9563. */
  9564. get blurBoxOffset(): number;
  9565. /**
  9566. * Sets the blur box offset: offset applied during the blur pass.
  9567. * Only useful if useKernelBlur = false
  9568. */
  9569. set blurBoxOffset(value: number);
  9570. private _blurScale;
  9571. /**
  9572. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9573. * 2 means half of the size.
  9574. */
  9575. get blurScale(): number;
  9576. /**
  9577. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9578. * 2 means half of the size.
  9579. */
  9580. set blurScale(value: number);
  9581. private _blurKernel;
  9582. /**
  9583. * Gets the blur kernel: kernel size of the blur pass.
  9584. * Only useful if useKernelBlur = true
  9585. */
  9586. get blurKernel(): number;
  9587. /**
  9588. * Sets the blur kernel: kernel size of the blur pass.
  9589. * Only useful if useKernelBlur = true
  9590. */
  9591. set blurKernel(value: number);
  9592. private _useKernelBlur;
  9593. /**
  9594. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9595. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9596. */
  9597. get useKernelBlur(): boolean;
  9598. /**
  9599. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9600. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9601. */
  9602. set useKernelBlur(value: boolean);
  9603. private _depthScale;
  9604. /**
  9605. * Gets the depth scale used in ESM mode.
  9606. */
  9607. get depthScale(): number;
  9608. /**
  9609. * Sets the depth scale used in ESM mode.
  9610. * This can override the scale stored on the light.
  9611. */
  9612. set depthScale(value: number);
  9613. private _filter;
  9614. /**
  9615. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9616. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9617. */
  9618. get filter(): number;
  9619. /**
  9620. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9621. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9622. */
  9623. set filter(value: number);
  9624. /**
  9625. * Gets if the current filter is set to Poisson Sampling.
  9626. */
  9627. get usePoissonSampling(): boolean;
  9628. /**
  9629. * Sets the current filter to Poisson Sampling.
  9630. */
  9631. set usePoissonSampling(value: boolean);
  9632. /**
  9633. * Gets if the current filter is set to ESM.
  9634. */
  9635. get useExponentialShadowMap(): boolean;
  9636. /**
  9637. * Sets the current filter is to ESM.
  9638. */
  9639. set useExponentialShadowMap(value: boolean);
  9640. /**
  9641. * Gets if the current filter is set to filtered ESM.
  9642. */
  9643. get useBlurExponentialShadowMap(): boolean;
  9644. /**
  9645. * Gets if the current filter is set to filtered ESM.
  9646. */
  9647. set useBlurExponentialShadowMap(value: boolean);
  9648. /**
  9649. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9650. * exponential to prevent steep falloff artifacts).
  9651. */
  9652. get useCloseExponentialShadowMap(): boolean;
  9653. /**
  9654. * Sets the current filter to "close ESM" (using the inverse of the
  9655. * exponential to prevent steep falloff artifacts).
  9656. */
  9657. set useCloseExponentialShadowMap(value: boolean);
  9658. /**
  9659. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9660. * exponential to prevent steep falloff artifacts).
  9661. */
  9662. get useBlurCloseExponentialShadowMap(): boolean;
  9663. /**
  9664. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9665. * exponential to prevent steep falloff artifacts).
  9666. */
  9667. set useBlurCloseExponentialShadowMap(value: boolean);
  9668. /**
  9669. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9670. */
  9671. get usePercentageCloserFiltering(): boolean;
  9672. /**
  9673. * Sets the current filter to "PCF" (percentage closer filtering).
  9674. */
  9675. set usePercentageCloserFiltering(value: boolean);
  9676. private _filteringQuality;
  9677. /**
  9678. * Gets the PCF or PCSS Quality.
  9679. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9680. */
  9681. get filteringQuality(): number;
  9682. /**
  9683. * Sets the PCF or PCSS Quality.
  9684. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9685. */
  9686. set filteringQuality(filteringQuality: number);
  9687. /**
  9688. * Gets if the current filter is set to "PCSS" (contact hardening).
  9689. */
  9690. get useContactHardeningShadow(): boolean;
  9691. /**
  9692. * Sets the current filter to "PCSS" (contact hardening).
  9693. */
  9694. set useContactHardeningShadow(value: boolean);
  9695. private _contactHardeningLightSizeUVRatio;
  9696. /**
  9697. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9698. * Using a ratio helps keeping shape stability independently of the map size.
  9699. *
  9700. * It does not account for the light projection as it was having too much
  9701. * instability during the light setup or during light position changes.
  9702. *
  9703. * Only valid if useContactHardeningShadow is true.
  9704. */
  9705. get contactHardeningLightSizeUVRatio(): number;
  9706. /**
  9707. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9708. * Using a ratio helps keeping shape stability independently of the map size.
  9709. *
  9710. * It does not account for the light projection as it was having too much
  9711. * instability during the light setup or during light position changes.
  9712. *
  9713. * Only valid if useContactHardeningShadow is true.
  9714. */
  9715. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9716. private _darkness;
  9717. /** Gets or sets the actual darkness of a shadow */
  9718. get darkness(): number;
  9719. set darkness(value: number);
  9720. /**
  9721. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9722. * 0 means strongest and 1 would means no shadow.
  9723. * @returns the darkness.
  9724. */
  9725. getDarkness(): number;
  9726. /**
  9727. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9728. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9729. * @returns the shadow generator allowing fluent coding.
  9730. */
  9731. setDarkness(darkness: number): ShadowGenerator;
  9732. private _transparencyShadow;
  9733. /** Gets or sets the ability to have transparent shadow */
  9734. get transparencyShadow(): boolean;
  9735. set transparencyShadow(value: boolean);
  9736. /**
  9737. * Sets the ability to have transparent shadow (boolean).
  9738. * @param transparent True if transparent else False
  9739. * @returns the shadow generator allowing fluent coding
  9740. */
  9741. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9742. private _shadowMap;
  9743. private _shadowMap2;
  9744. /**
  9745. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9746. * @returns The render target texture if present otherwise, null
  9747. */
  9748. getShadowMap(): Nullable<RenderTargetTexture>;
  9749. /**
  9750. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9751. * @returns The render target texture if the shadow map is present otherwise, null
  9752. */
  9753. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9754. /**
  9755. * Gets the class name of that object
  9756. * @returns "ShadowGenerator"
  9757. */
  9758. getClassName(): string;
  9759. /**
  9760. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9761. * @param mesh Mesh to add
  9762. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9763. * @returns the Shadow Generator itself
  9764. */
  9765. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9766. /**
  9767. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9768. * @param mesh Mesh to remove
  9769. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9770. * @returns the Shadow Generator itself
  9771. */
  9772. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9773. /**
  9774. * Controls the extent to which the shadows fade out at the edge of the frustum
  9775. * Used only by directionals and spots
  9776. */
  9777. frustumEdgeFalloff: number;
  9778. private _light;
  9779. /**
  9780. * Returns the associated light object.
  9781. * @returns the light generating the shadow
  9782. */
  9783. getLight(): IShadowLight;
  9784. /**
  9785. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9786. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9787. * It might on the other hand introduce peter panning.
  9788. */
  9789. forceBackFacesOnly: boolean;
  9790. private _scene;
  9791. private _lightDirection;
  9792. private _effect;
  9793. private _viewMatrix;
  9794. private _projectionMatrix;
  9795. private _transformMatrix;
  9796. private _cachedPosition;
  9797. private _cachedDirection;
  9798. private _cachedDefines;
  9799. private _currentRenderID;
  9800. private _boxBlurPostprocess;
  9801. private _kernelBlurXPostprocess;
  9802. private _kernelBlurYPostprocess;
  9803. private _blurPostProcesses;
  9804. private _mapSize;
  9805. private _currentFaceIndex;
  9806. private _currentFaceIndexCache;
  9807. private _textureType;
  9808. private _defaultTextureMatrix;
  9809. private _storedUniqueId;
  9810. /** @hidden */
  9811. static _SceneComponentInitialization: (scene: Scene) => void;
  9812. /**
  9813. * Creates a ShadowGenerator object.
  9814. * A ShadowGenerator is the required tool to use the shadows.
  9815. * Each light casting shadows needs to use its own ShadowGenerator.
  9816. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9817. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9818. * @param light The light object generating the shadows.
  9819. * @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.
  9820. */
  9821. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9822. private _initializeGenerator;
  9823. private _initializeShadowMap;
  9824. private _initializeBlurRTTAndPostProcesses;
  9825. private _renderForShadowMap;
  9826. private _renderSubMeshForShadowMap;
  9827. private _applyFilterValues;
  9828. /**
  9829. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9830. * @param onCompiled Callback triggered at the and of the effects compilation
  9831. * @param options Sets of optional options forcing the compilation with different modes
  9832. */
  9833. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9834. useInstances: boolean;
  9835. }>): void;
  9836. /**
  9837. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9838. * @param options Sets of optional options forcing the compilation with different modes
  9839. * @returns A promise that resolves when the compilation completes
  9840. */
  9841. forceCompilationAsync(options?: Partial<{
  9842. useInstances: boolean;
  9843. }>): Promise<void>;
  9844. /**
  9845. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9846. * @param subMesh The submesh we want to render in the shadow map
  9847. * @param useInstances Defines wether will draw in the map using instances
  9848. * @returns true if ready otherwise, false
  9849. */
  9850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9851. /**
  9852. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9853. * @param defines Defines of the material we want to update
  9854. * @param lightIndex Index of the light in the enabled light list of the material
  9855. */
  9856. prepareDefines(defines: any, lightIndex: number): void;
  9857. /**
  9858. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9859. * defined in the generator but impacting the effect).
  9860. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9861. * @param effect The effect we are binfing the information for
  9862. */
  9863. bindShadowLight(lightIndex: string, effect: Effect): void;
  9864. /**
  9865. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9866. * (eq to shadow prjection matrix * light transform matrix)
  9867. * @returns The transform matrix used to create the shadow map
  9868. */
  9869. getTransformMatrix(): Matrix;
  9870. /**
  9871. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9872. * Cube and 2D textures for instance.
  9873. */
  9874. recreateShadowMap(): void;
  9875. private _disposeBlurPostProcesses;
  9876. private _disposeRTTandPostProcesses;
  9877. /**
  9878. * Disposes the ShadowGenerator.
  9879. * Returns nothing.
  9880. */
  9881. dispose(): void;
  9882. /**
  9883. * Serializes the shadow generator setup to a json object.
  9884. * @returns The serialized JSON object
  9885. */
  9886. serialize(): any;
  9887. /**
  9888. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9889. * @param parsedShadowGenerator The JSON object to parse
  9890. * @param scene The scene to create the shadow map for
  9891. * @returns The parsed shadow generator
  9892. */
  9893. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9894. }
  9895. }
  9896. declare module BABYLON {
  9897. /**
  9898. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9899. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9900. * 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.
  9901. */
  9902. export abstract class Light extends Node {
  9903. /**
  9904. * Falloff Default: light is falling off following the material specification:
  9905. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9906. */
  9907. static readonly FALLOFF_DEFAULT: number;
  9908. /**
  9909. * Falloff Physical: light is falling off following the inverse squared distance law.
  9910. */
  9911. static readonly FALLOFF_PHYSICAL: number;
  9912. /**
  9913. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9914. * to enhance interoperability with other engines.
  9915. */
  9916. static readonly FALLOFF_GLTF: number;
  9917. /**
  9918. * Falloff Standard: light is falling off like in the standard material
  9919. * to enhance interoperability with other materials.
  9920. */
  9921. static readonly FALLOFF_STANDARD: number;
  9922. /**
  9923. * If every light affecting the material is in this lightmapMode,
  9924. * material.lightmapTexture adds or multiplies
  9925. * (depends on material.useLightmapAsShadowmap)
  9926. * after every other light calculations.
  9927. */
  9928. static readonly LIGHTMAP_DEFAULT: number;
  9929. /**
  9930. * material.lightmapTexture as only diffuse lighting from this light
  9931. * adds only specular lighting from this light
  9932. * adds dynamic shadows
  9933. */
  9934. static readonly LIGHTMAP_SPECULAR: number;
  9935. /**
  9936. * material.lightmapTexture as only lighting
  9937. * no light calculation from this light
  9938. * only adds dynamic shadows from this light
  9939. */
  9940. static readonly LIGHTMAP_SHADOWSONLY: number;
  9941. /**
  9942. * Each light type uses the default quantity according to its type:
  9943. * point/spot lights use luminous intensity
  9944. * directional lights use illuminance
  9945. */
  9946. static readonly INTENSITYMODE_AUTOMATIC: number;
  9947. /**
  9948. * lumen (lm)
  9949. */
  9950. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9951. /**
  9952. * candela (lm/sr)
  9953. */
  9954. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9955. /**
  9956. * lux (lm/m^2)
  9957. */
  9958. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9959. /**
  9960. * nit (cd/m^2)
  9961. */
  9962. static readonly INTENSITYMODE_LUMINANCE: number;
  9963. /**
  9964. * Light type const id of the point light.
  9965. */
  9966. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9967. /**
  9968. * Light type const id of the directional light.
  9969. */
  9970. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9971. /**
  9972. * Light type const id of the spot light.
  9973. */
  9974. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9975. /**
  9976. * Light type const id of the hemispheric light.
  9977. */
  9978. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9979. /**
  9980. * Diffuse gives the basic color to an object.
  9981. */
  9982. diffuse: Color3;
  9983. /**
  9984. * Specular produces a highlight color on an object.
  9985. * Note: This is note affecting PBR materials.
  9986. */
  9987. specular: Color3;
  9988. /**
  9989. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9990. * falling off base on range or angle.
  9991. * This can be set to any values in Light.FALLOFF_x.
  9992. *
  9993. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9994. * other types of materials.
  9995. */
  9996. falloffType: number;
  9997. /**
  9998. * Strength of the light.
  9999. * Note: By default it is define in the framework own unit.
  10000. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10001. */
  10002. intensity: number;
  10003. private _range;
  10004. protected _inverseSquaredRange: number;
  10005. /**
  10006. * Defines how far from the source the light is impacting in scene units.
  10007. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10008. */
  10009. get range(): number;
  10010. /**
  10011. * Defines how far from the source the light is impacting in scene units.
  10012. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10013. */
  10014. set range(value: number);
  10015. /**
  10016. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10017. * of light.
  10018. */
  10019. private _photometricScale;
  10020. private _intensityMode;
  10021. /**
  10022. * Gets the photometric scale used to interpret the intensity.
  10023. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10024. */
  10025. get intensityMode(): number;
  10026. /**
  10027. * Sets the photometric scale used to interpret the intensity.
  10028. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10029. */
  10030. set intensityMode(value: number);
  10031. private _radius;
  10032. /**
  10033. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10034. */
  10035. get radius(): number;
  10036. /**
  10037. * sets the light radius used by PBR Materials to simulate soft area lights.
  10038. */
  10039. set radius(value: number);
  10040. private _renderPriority;
  10041. /**
  10042. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10043. * exceeding the number allowed of the materials.
  10044. */
  10045. renderPriority: number;
  10046. private _shadowEnabled;
  10047. /**
  10048. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10049. * the current shadow generator.
  10050. */
  10051. get shadowEnabled(): boolean;
  10052. /**
  10053. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10054. * the current shadow generator.
  10055. */
  10056. set shadowEnabled(value: boolean);
  10057. private _includedOnlyMeshes;
  10058. /**
  10059. * Gets the only meshes impacted by this light.
  10060. */
  10061. get includedOnlyMeshes(): AbstractMesh[];
  10062. /**
  10063. * Sets the only meshes impacted by this light.
  10064. */
  10065. set includedOnlyMeshes(value: AbstractMesh[]);
  10066. private _excludedMeshes;
  10067. /**
  10068. * Gets the meshes not impacted by this light.
  10069. */
  10070. get excludedMeshes(): AbstractMesh[];
  10071. /**
  10072. * Sets the meshes not impacted by this light.
  10073. */
  10074. set excludedMeshes(value: AbstractMesh[]);
  10075. private _excludeWithLayerMask;
  10076. /**
  10077. * Gets the layer id use to find what meshes are not impacted by the light.
  10078. * Inactive if 0
  10079. */
  10080. get excludeWithLayerMask(): number;
  10081. /**
  10082. * Sets the layer id use to find what meshes are not impacted by the light.
  10083. * Inactive if 0
  10084. */
  10085. set excludeWithLayerMask(value: number);
  10086. private _includeOnlyWithLayerMask;
  10087. /**
  10088. * Gets the layer id use to find what meshes are impacted by the light.
  10089. * Inactive if 0
  10090. */
  10091. get includeOnlyWithLayerMask(): number;
  10092. /**
  10093. * Sets the layer id use to find what meshes are impacted by the light.
  10094. * Inactive if 0
  10095. */
  10096. set includeOnlyWithLayerMask(value: number);
  10097. private _lightmapMode;
  10098. /**
  10099. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10100. */
  10101. get lightmapMode(): number;
  10102. /**
  10103. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10104. */
  10105. set lightmapMode(value: number);
  10106. /**
  10107. * Shadow generator associted to the light.
  10108. * @hidden Internal use only.
  10109. */
  10110. _shadowGenerator: Nullable<IShadowGenerator>;
  10111. /**
  10112. * @hidden Internal use only.
  10113. */
  10114. _excludedMeshesIds: string[];
  10115. /**
  10116. * @hidden Internal use only.
  10117. */
  10118. _includedOnlyMeshesIds: string[];
  10119. /**
  10120. * The current light unifom buffer.
  10121. * @hidden Internal use only.
  10122. */
  10123. _uniformBuffer: UniformBuffer;
  10124. /** @hidden */
  10125. _renderId: number;
  10126. /**
  10127. * Creates a Light object in the scene.
  10128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10129. * @param name The firendly name of the light
  10130. * @param scene The scene the light belongs too
  10131. */
  10132. constructor(name: string, scene: Scene);
  10133. protected abstract _buildUniformLayout(): void;
  10134. /**
  10135. * Sets the passed Effect "effect" with the Light information.
  10136. * @param effect The effect to update
  10137. * @param lightIndex The index of the light in the effect to update
  10138. * @returns The light
  10139. */
  10140. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10141. /**
  10142. * Sets the passed Effect "effect" with the Light textures.
  10143. * @param effect The effect to update
  10144. * @param lightIndex The index of the light in the effect to update
  10145. * @returns The light
  10146. */
  10147. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10148. /**
  10149. * Binds the lights information from the scene to the effect for the given mesh.
  10150. * @param lightIndex Light index
  10151. * @param scene The scene where the light belongs to
  10152. * @param effect The effect we are binding the data to
  10153. * @param useSpecular Defines if specular is supported
  10154. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10155. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10156. */
  10157. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10158. /**
  10159. * Sets the passed Effect "effect" with the Light information.
  10160. * @param effect The effect to update
  10161. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10162. * @returns The light
  10163. */
  10164. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10165. /**
  10166. * Returns the string "Light".
  10167. * @returns the class name
  10168. */
  10169. getClassName(): string;
  10170. /** @hidden */
  10171. readonly _isLight: boolean;
  10172. /**
  10173. * Converts the light information to a readable string for debug purpose.
  10174. * @param fullDetails Supports for multiple levels of logging within scene loading
  10175. * @returns the human readable light info
  10176. */
  10177. toString(fullDetails?: boolean): string;
  10178. /** @hidden */
  10179. protected _syncParentEnabledState(): void;
  10180. /**
  10181. * Set the enabled state of this node.
  10182. * @param value - the new enabled state
  10183. */
  10184. setEnabled(value: boolean): void;
  10185. /**
  10186. * Returns the Light associated shadow generator if any.
  10187. * @return the associated shadow generator.
  10188. */
  10189. getShadowGenerator(): Nullable<IShadowGenerator>;
  10190. /**
  10191. * Returns a Vector3, the absolute light position in the World.
  10192. * @returns the world space position of the light
  10193. */
  10194. getAbsolutePosition(): Vector3;
  10195. /**
  10196. * Specifies if the light will affect the passed mesh.
  10197. * @param mesh The mesh to test against the light
  10198. * @return true the mesh is affected otherwise, false.
  10199. */
  10200. canAffectMesh(mesh: AbstractMesh): boolean;
  10201. /**
  10202. * Sort function to order lights for rendering.
  10203. * @param a First Light object to compare to second.
  10204. * @param b Second Light object to compare first.
  10205. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10206. */
  10207. static CompareLightsPriority(a: Light, b: Light): number;
  10208. /**
  10209. * Releases resources associated with this node.
  10210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10212. */
  10213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10214. /**
  10215. * Returns the light type ID (integer).
  10216. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10217. */
  10218. getTypeID(): number;
  10219. /**
  10220. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10221. * @returns the scaled intensity in intensity mode unit
  10222. */
  10223. getScaledIntensity(): number;
  10224. /**
  10225. * Returns a new Light object, named "name", from the current one.
  10226. * @param name The name of the cloned light
  10227. * @returns the new created light
  10228. */
  10229. clone(name: string): Nullable<Light>;
  10230. /**
  10231. * Serializes the current light into a Serialization object.
  10232. * @returns the serialized object.
  10233. */
  10234. serialize(): any;
  10235. /**
  10236. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10237. * This new light is named "name" and added to the passed scene.
  10238. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10239. * @param name The friendly name of the light
  10240. * @param scene The scene the new light will belong to
  10241. * @returns the constructor function
  10242. */
  10243. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10244. /**
  10245. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10246. * @param parsedLight The JSON representation of the light
  10247. * @param scene The scene to create the parsed light in
  10248. * @returns the created light after parsing
  10249. */
  10250. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10251. private _hookArrayForExcluded;
  10252. private _hookArrayForIncludedOnly;
  10253. private _resyncMeshes;
  10254. /**
  10255. * Forces the meshes to update their light related information in their rendering used effects
  10256. * @hidden Internal Use Only
  10257. */
  10258. _markMeshesAsLightDirty(): void;
  10259. /**
  10260. * Recomputes the cached photometric scale if needed.
  10261. */
  10262. private _computePhotometricScale;
  10263. /**
  10264. * Returns the Photometric Scale according to the light type and intensity mode.
  10265. */
  10266. private _getPhotometricScale;
  10267. /**
  10268. * Reorder the light in the scene according to their defined priority.
  10269. * @hidden Internal Use Only
  10270. */
  10271. _reorderLightsInScene(): void;
  10272. /**
  10273. * Prepares the list of defines specific to the light type.
  10274. * @param defines the list of defines
  10275. * @param lightIndex defines the index of the light for the effect
  10276. */
  10277. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Interface used to define Action
  10283. */
  10284. export interface IAction {
  10285. /**
  10286. * Trigger for the action
  10287. */
  10288. trigger: number;
  10289. /** Options of the trigger */
  10290. triggerOptions: any;
  10291. /**
  10292. * Gets the trigger parameters
  10293. * @returns the trigger parameters
  10294. */
  10295. getTriggerParameter(): any;
  10296. /**
  10297. * Internal only - executes current action event
  10298. * @hidden
  10299. */
  10300. _executeCurrent(evt?: ActionEvent): void;
  10301. /**
  10302. * Serialize placeholder for child classes
  10303. * @param parent of child
  10304. * @returns the serialized object
  10305. */
  10306. serialize(parent: any): any;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. _prepare(): void;
  10312. /**
  10313. * Internal only - manager for action
  10314. * @hidden
  10315. */
  10316. _actionManager: AbstractActionManager;
  10317. /**
  10318. * Adds action to chain of actions, may be a DoNothingAction
  10319. * @param action defines the next action to execute
  10320. * @returns The action passed in
  10321. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10322. */
  10323. then(action: IAction): IAction;
  10324. }
  10325. /**
  10326. * The action to be carried out following a trigger
  10327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10328. */
  10329. export class Action implements IAction {
  10330. /** the trigger, with or without parameters, for the action */
  10331. triggerOptions: any;
  10332. /**
  10333. * Trigger for the action
  10334. */
  10335. trigger: number;
  10336. /**
  10337. * Internal only - manager for action
  10338. * @hidden
  10339. */
  10340. _actionManager: ActionManager;
  10341. private _nextActiveAction;
  10342. private _child;
  10343. private _condition?;
  10344. private _triggerParameter;
  10345. /**
  10346. * An event triggered prior to action being executed.
  10347. */
  10348. onBeforeExecuteObservable: Observable<Action>;
  10349. /**
  10350. * Creates a new Action
  10351. * @param triggerOptions the trigger, with or without parameters, for the action
  10352. * @param condition an optional determinant of action
  10353. */
  10354. constructor(
  10355. /** the trigger, with or without parameters, for the action */
  10356. triggerOptions: any, condition?: Condition);
  10357. /**
  10358. * Internal only
  10359. * @hidden
  10360. */
  10361. _prepare(): void;
  10362. /**
  10363. * Gets the trigger parameters
  10364. * @returns the trigger parameters
  10365. */
  10366. getTriggerParameter(): any;
  10367. /**
  10368. * Internal only - executes current action event
  10369. * @hidden
  10370. */
  10371. _executeCurrent(evt?: ActionEvent): void;
  10372. /**
  10373. * Execute placeholder for child classes
  10374. * @param evt optional action event
  10375. */
  10376. execute(evt?: ActionEvent): void;
  10377. /**
  10378. * Skips to next active action
  10379. */
  10380. skipToNextActiveAction(): void;
  10381. /**
  10382. * Adds action to chain of actions, may be a DoNothingAction
  10383. * @param action defines the next action to execute
  10384. * @returns The action passed in
  10385. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10386. */
  10387. then(action: Action): Action;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. _getProperty(propertyPath: string): string;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. _getEffectiveTarget(target: any, propertyPath: string): any;
  10398. /**
  10399. * Serialize placeholder for child classes
  10400. * @param parent of child
  10401. * @returns the serialized object
  10402. */
  10403. serialize(parent: any): any;
  10404. /**
  10405. * Internal only called by serialize
  10406. * @hidden
  10407. */
  10408. protected _serialize(serializedAction: any, parent?: any): any;
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. static _SerializeValueAsString: (value: any) => string;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. static _GetTargetProperty: (target: Node | Scene) => {
  10419. name: string;
  10420. targetType: string;
  10421. value: string;
  10422. };
  10423. }
  10424. }
  10425. declare module BABYLON {
  10426. /**
  10427. * A Condition applied to an Action
  10428. */
  10429. export class Condition {
  10430. /**
  10431. * Internal only - manager for action
  10432. * @hidden
  10433. */
  10434. _actionManager: ActionManager;
  10435. /**
  10436. * Internal only
  10437. * @hidden
  10438. */
  10439. _evaluationId: number;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. _currentResult: boolean;
  10445. /**
  10446. * Creates a new Condition
  10447. * @param actionManager the manager of the action the condition is applied to
  10448. */
  10449. constructor(actionManager: ActionManager);
  10450. /**
  10451. * Check if the current condition is valid
  10452. * @returns a boolean
  10453. */
  10454. isValid(): boolean;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _getProperty(propertyPath: string): string;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getEffectiveTarget(target: any, propertyPath: string): any;
  10465. /**
  10466. * Serialize placeholder for child classes
  10467. * @returns the serialized object
  10468. */
  10469. serialize(): any;
  10470. /**
  10471. * Internal only
  10472. * @hidden
  10473. */
  10474. protected _serialize(serializedCondition: any): any;
  10475. }
  10476. /**
  10477. * Defines specific conditional operators as extensions of Condition
  10478. */
  10479. export class ValueCondition extends Condition {
  10480. /** path to specify the property of the target the conditional operator uses */
  10481. propertyPath: string;
  10482. /** the value compared by the conditional operator against the current value of the property */
  10483. value: any;
  10484. /** the conditional operator, default ValueCondition.IsEqual */
  10485. operator: number;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. private static _IsEqual;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private static _IsDifferent;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private static _IsGreater;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private static _IsLesser;
  10506. /**
  10507. * returns the number for IsEqual
  10508. */
  10509. static get IsEqual(): number;
  10510. /**
  10511. * Returns the number for IsDifferent
  10512. */
  10513. static get IsDifferent(): number;
  10514. /**
  10515. * Returns the number for IsGreater
  10516. */
  10517. static get IsGreater(): number;
  10518. /**
  10519. * Returns the number for IsLesser
  10520. */
  10521. static get IsLesser(): number;
  10522. /**
  10523. * Internal only The action manager for the condition
  10524. * @hidden
  10525. */
  10526. _actionManager: ActionManager;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. private _target;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private _effectiveTarget;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private _property;
  10542. /**
  10543. * Creates a new ValueCondition
  10544. * @param actionManager manager for the action the condition applies to
  10545. * @param target for the action
  10546. * @param propertyPath path to specify the property of the target the conditional operator uses
  10547. * @param value the value compared by the conditional operator against the current value of the property
  10548. * @param operator the conditional operator, default ValueCondition.IsEqual
  10549. */
  10550. constructor(actionManager: ActionManager, target: any,
  10551. /** path to specify the property of the target the conditional operator uses */
  10552. propertyPath: string,
  10553. /** the value compared by the conditional operator against the current value of the property */
  10554. value: any,
  10555. /** the conditional operator, default ValueCondition.IsEqual */
  10556. operator?: number);
  10557. /**
  10558. * Compares the given value with the property value for the specified conditional operator
  10559. * @returns the result of the comparison
  10560. */
  10561. isValid(): boolean;
  10562. /**
  10563. * Serialize the ValueCondition into a JSON compatible object
  10564. * @returns serialization object
  10565. */
  10566. serialize(): any;
  10567. /**
  10568. * Gets the name of the conditional operator for the ValueCondition
  10569. * @param operator the conditional operator
  10570. * @returns the name
  10571. */
  10572. static GetOperatorName(operator: number): string;
  10573. }
  10574. /**
  10575. * Defines a predicate condition as an extension of Condition
  10576. */
  10577. export class PredicateCondition extends Condition {
  10578. /** defines the predicate function used to validate the condition */
  10579. predicate: () => boolean;
  10580. /**
  10581. * Internal only - manager for action
  10582. * @hidden
  10583. */
  10584. _actionManager: ActionManager;
  10585. /**
  10586. * Creates a new PredicateCondition
  10587. * @param actionManager manager for the action the condition applies to
  10588. * @param predicate defines the predicate function used to validate the condition
  10589. */
  10590. constructor(actionManager: ActionManager,
  10591. /** defines the predicate function used to validate the condition */
  10592. predicate: () => boolean);
  10593. /**
  10594. * @returns the validity of the predicate condition
  10595. */
  10596. isValid(): boolean;
  10597. }
  10598. /**
  10599. * Defines a state condition as an extension of Condition
  10600. */
  10601. export class StateCondition extends Condition {
  10602. /** Value to compare with target state */
  10603. value: string;
  10604. /**
  10605. * Internal only - manager for action
  10606. * @hidden
  10607. */
  10608. _actionManager: ActionManager;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. private _target;
  10614. /**
  10615. * Creates a new StateCondition
  10616. * @param actionManager manager for the action the condition applies to
  10617. * @param target of the condition
  10618. * @param value to compare with target state
  10619. */
  10620. constructor(actionManager: ActionManager, target: any,
  10621. /** Value to compare with target state */
  10622. value: string);
  10623. /**
  10624. * Gets a boolean indicating if the current condition is met
  10625. * @returns the validity of the state
  10626. */
  10627. isValid(): boolean;
  10628. /**
  10629. * Serialize the StateCondition into a JSON compatible object
  10630. * @returns serialization object
  10631. */
  10632. serialize(): any;
  10633. }
  10634. }
  10635. declare module BABYLON {
  10636. /**
  10637. * This defines an action responsible to toggle a boolean once triggered.
  10638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10639. */
  10640. export class SwitchBooleanAction extends Action {
  10641. /**
  10642. * The path to the boolean property in the target object
  10643. */
  10644. propertyPath: string;
  10645. private _target;
  10646. private _effectiveTarget;
  10647. private _property;
  10648. /**
  10649. * Instantiate the action
  10650. * @param triggerOptions defines the trigger options
  10651. * @param target defines the object containing the boolean
  10652. * @param propertyPath defines the path to the boolean property in the target object
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action toggle the boolean value.
  10660. */
  10661. execute(): void;
  10662. /**
  10663. * Serializes the actions and its related information.
  10664. * @param parent defines the object to serialize in
  10665. * @returns the serialized object
  10666. */
  10667. serialize(parent: any): any;
  10668. }
  10669. /**
  10670. * This defines an action responsible to set a the state field of the target
  10671. * to a desired value once triggered.
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10673. */
  10674. export class SetStateAction extends Action {
  10675. /**
  10676. * The value to store in the state field.
  10677. */
  10678. value: string;
  10679. private _target;
  10680. /**
  10681. * Instantiate the action
  10682. * @param triggerOptions defines the trigger options
  10683. * @param target defines the object containing the state property
  10684. * @param value defines the value to store in the state field
  10685. * @param condition defines the trigger related conditions
  10686. */
  10687. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10688. /**
  10689. * Execute the action and store the value on the target state property.
  10690. */
  10691. execute(): void;
  10692. /**
  10693. * Serializes the actions and its related information.
  10694. * @param parent defines the object to serialize in
  10695. * @returns the serialized object
  10696. */
  10697. serialize(parent: any): any;
  10698. }
  10699. /**
  10700. * This defines an action responsible to set a property of the target
  10701. * to a desired value once triggered.
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10703. */
  10704. export class SetValueAction extends Action {
  10705. /**
  10706. * The path of the property to set in the target.
  10707. */
  10708. propertyPath: string;
  10709. /**
  10710. * The value to set in the property
  10711. */
  10712. value: any;
  10713. private _target;
  10714. private _effectiveTarget;
  10715. private _property;
  10716. /**
  10717. * Instantiate the action
  10718. * @param triggerOptions defines the trigger options
  10719. * @param target defines the object containing the property
  10720. * @param propertyPath defines the path of the property to set in the target
  10721. * @param value defines the value to set in the property
  10722. * @param condition defines the trigger related conditions
  10723. */
  10724. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10725. /** @hidden */
  10726. _prepare(): void;
  10727. /**
  10728. * Execute the action and set the targetted property to the desired value.
  10729. */
  10730. execute(): void;
  10731. /**
  10732. * Serializes the actions and its related information.
  10733. * @param parent defines the object to serialize in
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. }
  10738. /**
  10739. * This defines an action responsible to increment the target value
  10740. * to a desired value once triggered.
  10741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10742. */
  10743. export class IncrementValueAction extends Action {
  10744. /**
  10745. * The path of the property to increment in the target.
  10746. */
  10747. propertyPath: string;
  10748. /**
  10749. * The value we should increment the property by.
  10750. */
  10751. value: any;
  10752. private _target;
  10753. private _effectiveTarget;
  10754. private _property;
  10755. /**
  10756. * Instantiate the action
  10757. * @param triggerOptions defines the trigger options
  10758. * @param target defines the object containing the property
  10759. * @param propertyPath defines the path of the property to increment in the target
  10760. * @param value defines the value value we should increment the property by
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10764. /** @hidden */
  10765. _prepare(): void;
  10766. /**
  10767. * Execute the action and increment the target of the value amount.
  10768. */
  10769. execute(): void;
  10770. /**
  10771. * Serializes the actions and its related information.
  10772. * @param parent defines the object to serialize in
  10773. * @returns the serialized object
  10774. */
  10775. serialize(parent: any): any;
  10776. }
  10777. /**
  10778. * This defines an action responsible to start an animation once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class PlayAnimationAction extends Action {
  10782. /**
  10783. * Where the animation should start (animation frame)
  10784. */
  10785. from: number;
  10786. /**
  10787. * Where the animation should stop (animation frame)
  10788. */
  10789. to: number;
  10790. /**
  10791. * Define if the animation should loop or stop after the first play.
  10792. */
  10793. loop?: boolean;
  10794. private _target;
  10795. /**
  10796. * Instantiate the action
  10797. * @param triggerOptions defines the trigger options
  10798. * @param target defines the target animation or animation name
  10799. * @param from defines from where the animation should start (animation frame)
  10800. * @param end defines where the animation should stop (animation frame)
  10801. * @param loop defines if the animation should loop or stop after the first play
  10802. * @param condition defines the trigger related conditions
  10803. */
  10804. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10805. /** @hidden */
  10806. _prepare(): void;
  10807. /**
  10808. * Execute the action and play the animation.
  10809. */
  10810. execute(): void;
  10811. /**
  10812. * Serializes the actions and its related information.
  10813. * @param parent defines the object to serialize in
  10814. * @returns the serialized object
  10815. */
  10816. serialize(parent: any): any;
  10817. }
  10818. /**
  10819. * This defines an action responsible to stop an animation once triggered.
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10821. */
  10822. export class StopAnimationAction extends Action {
  10823. private _target;
  10824. /**
  10825. * Instantiate the action
  10826. * @param triggerOptions defines the trigger options
  10827. * @param target defines the target animation or animation name
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, condition?: Condition);
  10831. /** @hidden */
  10832. _prepare(): void;
  10833. /**
  10834. * Execute the action and stop the animation.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. /**
  10845. * This defines an action responsible that does nothing once triggered.
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10847. */
  10848. export class DoNothingAction extends Action {
  10849. /**
  10850. * Instantiate the action
  10851. * @param triggerOptions defines the trigger options
  10852. * @param condition defines the trigger related conditions
  10853. */
  10854. constructor(triggerOptions?: any, condition?: Condition);
  10855. /**
  10856. * Execute the action and do nothing.
  10857. */
  10858. execute(): void;
  10859. /**
  10860. * Serializes the actions and its related information.
  10861. * @param parent defines the object to serialize in
  10862. * @returns the serialized object
  10863. */
  10864. serialize(parent: any): any;
  10865. }
  10866. /**
  10867. * This defines an action responsible to trigger several actions once triggered.
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10869. */
  10870. export class CombineAction extends Action {
  10871. /**
  10872. * The list of aggregated animations to run.
  10873. */
  10874. children: Action[];
  10875. /**
  10876. * Instantiate the action
  10877. * @param triggerOptions defines the trigger options
  10878. * @param children defines the list of aggregated animations to run
  10879. * @param condition defines the trigger related conditions
  10880. */
  10881. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10882. /** @hidden */
  10883. _prepare(): void;
  10884. /**
  10885. * Execute the action and executes all the aggregated actions.
  10886. */
  10887. execute(evt: ActionEvent): void;
  10888. /**
  10889. * Serializes the actions and its related information.
  10890. * @param parent defines the object to serialize in
  10891. * @returns the serialized object
  10892. */
  10893. serialize(parent: any): any;
  10894. }
  10895. /**
  10896. * This defines an action responsible to run code (external event) once triggered.
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10898. */
  10899. export class ExecuteCodeAction extends Action {
  10900. /**
  10901. * The callback function to run.
  10902. */
  10903. func: (evt: ActionEvent) => void;
  10904. /**
  10905. * Instantiate the action
  10906. * @param triggerOptions defines the trigger options
  10907. * @param func defines the callback function to run
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10911. /**
  10912. * Execute the action and run the attached code.
  10913. */
  10914. execute(evt: ActionEvent): void;
  10915. }
  10916. /**
  10917. * This defines an action responsible to set the parent property of the target once triggered.
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10919. */
  10920. export class SetParentAction extends Action {
  10921. private _parent;
  10922. private _target;
  10923. /**
  10924. * Instantiate the action
  10925. * @param triggerOptions defines the trigger options
  10926. * @param target defines the target containing the parent property
  10927. * @param parent defines from where the animation should start (animation frame)
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10931. /** @hidden */
  10932. _prepare(): void;
  10933. /**
  10934. * Execute the action and set the parent property.
  10935. */
  10936. execute(): void;
  10937. /**
  10938. * Serializes the actions and its related information.
  10939. * @param parent defines the object to serialize in
  10940. * @returns the serialized object
  10941. */
  10942. serialize(parent: any): any;
  10943. }
  10944. }
  10945. declare module BABYLON {
  10946. /**
  10947. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10948. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class ActionManager extends AbstractActionManager {
  10952. /**
  10953. * Nothing
  10954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10955. */
  10956. static readonly NothingTrigger: number;
  10957. /**
  10958. * On pick
  10959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10960. */
  10961. static readonly OnPickTrigger: number;
  10962. /**
  10963. * On left pick
  10964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10965. */
  10966. static readonly OnLeftPickTrigger: number;
  10967. /**
  10968. * On right pick
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10970. */
  10971. static readonly OnRightPickTrigger: number;
  10972. /**
  10973. * On center pick
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10975. */
  10976. static readonly OnCenterPickTrigger: number;
  10977. /**
  10978. * On pick down
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10980. */
  10981. static readonly OnPickDownTrigger: number;
  10982. /**
  10983. * On double pick
  10984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10985. */
  10986. static readonly OnDoublePickTrigger: number;
  10987. /**
  10988. * On pick up
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10990. */
  10991. static readonly OnPickUpTrigger: number;
  10992. /**
  10993. * On pick out.
  10994. * This trigger will only be raised if you also declared a OnPickDown
  10995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10996. */
  10997. static readonly OnPickOutTrigger: number;
  10998. /**
  10999. * On long press
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11001. */
  11002. static readonly OnLongPressTrigger: number;
  11003. /**
  11004. * On pointer over
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11006. */
  11007. static readonly OnPointerOverTrigger: number;
  11008. /**
  11009. * On pointer out
  11010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11011. */
  11012. static readonly OnPointerOutTrigger: number;
  11013. /**
  11014. * On every frame
  11015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11016. */
  11017. static readonly OnEveryFrameTrigger: number;
  11018. /**
  11019. * On intersection enter
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnIntersectionEnterTrigger: number;
  11023. /**
  11024. * On intersection exit
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly OnIntersectionExitTrigger: number;
  11028. /**
  11029. * On key down
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnKeyDownTrigger: number;
  11033. /**
  11034. * On key up
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnKeyUpTrigger: number;
  11038. private _scene;
  11039. /**
  11040. * Creates a new action manager
  11041. * @param scene defines the hosting scene
  11042. */
  11043. constructor(scene: Scene);
  11044. /**
  11045. * Releases all associated resources
  11046. */
  11047. dispose(): void;
  11048. /**
  11049. * Gets hosting scene
  11050. * @returns the hosting scene
  11051. */
  11052. getScene(): Scene;
  11053. /**
  11054. * Does this action manager handles actions of any of the given triggers
  11055. * @param triggers defines the triggers to be tested
  11056. * @return a boolean indicating whether one (or more) of the triggers is handled
  11057. */
  11058. hasSpecificTriggers(triggers: number[]): boolean;
  11059. /**
  11060. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11061. * speed.
  11062. * @param triggerA defines the trigger to be tested
  11063. * @param triggerB defines the trigger to be tested
  11064. * @return a boolean indicating whether one (or more) of the triggers is handled
  11065. */
  11066. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11067. /**
  11068. * Does this action manager handles actions of a given trigger
  11069. * @param trigger defines the trigger to be tested
  11070. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11071. * @return whether the trigger is handled
  11072. */
  11073. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11074. /**
  11075. * Does this action manager has pointer triggers
  11076. */
  11077. get hasPointerTriggers(): boolean;
  11078. /**
  11079. * Does this action manager has pick triggers
  11080. */
  11081. get hasPickTriggers(): boolean;
  11082. /**
  11083. * Registers an action to this action manager
  11084. * @param action defines the action to be registered
  11085. * @return the action amended (prepared) after registration
  11086. */
  11087. registerAction(action: IAction): Nullable<IAction>;
  11088. /**
  11089. * Unregisters an action to this action manager
  11090. * @param action defines the action to be unregistered
  11091. * @return a boolean indicating whether the action has been unregistered
  11092. */
  11093. unregisterAction(action: IAction): Boolean;
  11094. /**
  11095. * Process a specific trigger
  11096. * @param trigger defines the trigger to process
  11097. * @param evt defines the event details to be processed
  11098. */
  11099. processTrigger(trigger: number, evt?: IActionEvent): void;
  11100. /** @hidden */
  11101. _getEffectiveTarget(target: any, propertyPath: string): any;
  11102. /** @hidden */
  11103. _getProperty(propertyPath: string): string;
  11104. /**
  11105. * Serialize this manager to a JSON object
  11106. * @param name defines the property name to store this manager
  11107. * @returns a JSON representation of this manager
  11108. */
  11109. serialize(name: string): any;
  11110. /**
  11111. * Creates a new ActionManager from a JSON data
  11112. * @param parsedActions defines the JSON data to read from
  11113. * @param object defines the hosting mesh
  11114. * @param scene defines the hosting scene
  11115. */
  11116. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11117. /**
  11118. * Get a trigger name by index
  11119. * @param trigger defines the trigger index
  11120. * @returns a trigger name
  11121. */
  11122. static GetTriggerName(trigger: number): string;
  11123. }
  11124. }
  11125. declare module BABYLON {
  11126. /**
  11127. * Class representing a ray with position and direction
  11128. */
  11129. export class Ray {
  11130. /** origin point */
  11131. origin: Vector3;
  11132. /** direction */
  11133. direction: Vector3;
  11134. /** length of the ray */
  11135. length: number;
  11136. private static readonly TmpVector3;
  11137. private _tmpRay;
  11138. /**
  11139. * Creates a new ray
  11140. * @param origin origin point
  11141. * @param direction direction
  11142. * @param length length of the ray
  11143. */
  11144. constructor(
  11145. /** origin point */
  11146. origin: Vector3,
  11147. /** direction */
  11148. direction: Vector3,
  11149. /** length of the ray */
  11150. length?: number);
  11151. /**
  11152. * Checks if the ray intersects a box
  11153. * @param minimum bound of the box
  11154. * @param maximum bound of the box
  11155. * @param intersectionTreshold extra extend to be added to the box in all direction
  11156. * @returns if the box was hit
  11157. */
  11158. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11159. /**
  11160. * Checks if the ray intersects a box
  11161. * @param box the bounding box to check
  11162. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11163. * @returns if the box was hit
  11164. */
  11165. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11166. /**
  11167. * If the ray hits a sphere
  11168. * @param sphere the bounding sphere to check
  11169. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11170. * @returns true if it hits the sphere
  11171. */
  11172. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11173. /**
  11174. * If the ray hits a triange
  11175. * @param vertex0 triangle vertex
  11176. * @param vertex1 triangle vertex
  11177. * @param vertex2 triangle vertex
  11178. * @returns intersection information if hit
  11179. */
  11180. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11181. /**
  11182. * Checks if ray intersects a plane
  11183. * @param plane the plane to check
  11184. * @returns the distance away it was hit
  11185. */
  11186. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11187. /**
  11188. * Calculate the intercept of a ray on a given axis
  11189. * @param axis to check 'x' | 'y' | 'z'
  11190. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11191. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11192. */
  11193. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11194. /**
  11195. * Checks if ray intersects a mesh
  11196. * @param mesh the mesh to check
  11197. * @param fastCheck if only the bounding box should checked
  11198. * @returns picking info of the intersecton
  11199. */
  11200. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11201. /**
  11202. * Checks if ray intersects a mesh
  11203. * @param meshes the meshes to check
  11204. * @param fastCheck if only the bounding box should checked
  11205. * @param results array to store result in
  11206. * @returns Array of picking infos
  11207. */
  11208. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11209. private _comparePickingInfo;
  11210. private static smallnum;
  11211. private static rayl;
  11212. /**
  11213. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11214. * @param sega the first point of the segment to test the intersection against
  11215. * @param segb the second point of the segment to test the intersection against
  11216. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11217. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11218. */
  11219. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11220. /**
  11221. * Update the ray from viewport position
  11222. * @param x position
  11223. * @param y y position
  11224. * @param viewportWidth viewport width
  11225. * @param viewportHeight viewport height
  11226. * @param world world matrix
  11227. * @param view view matrix
  11228. * @param projection projection matrix
  11229. * @returns this ray updated
  11230. */
  11231. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11232. /**
  11233. * Creates a ray with origin and direction of 0,0,0
  11234. * @returns the new ray
  11235. */
  11236. static Zero(): Ray;
  11237. /**
  11238. * Creates a new ray from screen space and viewport
  11239. * @param x position
  11240. * @param y y position
  11241. * @param viewportWidth viewport width
  11242. * @param viewportHeight viewport height
  11243. * @param world world matrix
  11244. * @param view view matrix
  11245. * @param projection projection matrix
  11246. * @returns new ray
  11247. */
  11248. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11249. /**
  11250. * 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
  11251. * transformed to the given world matrix.
  11252. * @param origin The origin point
  11253. * @param end The end point
  11254. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11255. * @returns the new ray
  11256. */
  11257. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11258. /**
  11259. * Transforms a ray by a matrix
  11260. * @param ray ray to transform
  11261. * @param matrix matrix to apply
  11262. * @returns the resulting new ray
  11263. */
  11264. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11265. /**
  11266. * Transforms a ray by a matrix
  11267. * @param ray ray to transform
  11268. * @param matrix matrix to apply
  11269. * @param result ray to store result in
  11270. */
  11271. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11272. /**
  11273. * Unproject a ray from screen space to object space
  11274. * @param sourceX defines the screen space x coordinate to use
  11275. * @param sourceY defines the screen space y coordinate to use
  11276. * @param viewportWidth defines the current width of the viewport
  11277. * @param viewportHeight defines the current height of the viewport
  11278. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11279. * @param view defines the view matrix to use
  11280. * @param projection defines the projection matrix to use
  11281. */
  11282. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11283. }
  11284. /**
  11285. * Type used to define predicate used to select faces when a mesh intersection is detected
  11286. */
  11287. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11288. interface Scene {
  11289. /** @hidden */
  11290. _tempPickingRay: Nullable<Ray>;
  11291. /** @hidden */
  11292. _cachedRayForTransform: Ray;
  11293. /** @hidden */
  11294. _pickWithRayInverseMatrix: Matrix;
  11295. /** @hidden */
  11296. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11297. /** @hidden */
  11298. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11299. }
  11300. }
  11301. declare module BABYLON {
  11302. /**
  11303. * Groups all the scene component constants in one place to ease maintenance.
  11304. * @hidden
  11305. */
  11306. export class SceneComponentConstants {
  11307. static readonly NAME_EFFECTLAYER: string;
  11308. static readonly NAME_LAYER: string;
  11309. static readonly NAME_LENSFLARESYSTEM: string;
  11310. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11311. static readonly NAME_PARTICLESYSTEM: string;
  11312. static readonly NAME_GAMEPAD: string;
  11313. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11314. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11315. static readonly NAME_DEPTHRENDERER: string;
  11316. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11317. static readonly NAME_SPRITE: string;
  11318. static readonly NAME_OUTLINERENDERER: string;
  11319. static readonly NAME_PROCEDURALTEXTURE: string;
  11320. static readonly NAME_SHADOWGENERATOR: string;
  11321. static readonly NAME_OCTREE: string;
  11322. static readonly NAME_PHYSICSENGINE: string;
  11323. static readonly NAME_AUDIO: string;
  11324. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11325. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11326. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11327. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11328. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11329. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11330. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11331. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11332. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11333. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11334. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11335. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11336. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11337. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11338. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11339. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11340. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11341. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11342. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11343. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11344. static readonly STEP_AFTERRENDER_AUDIO: number;
  11345. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11346. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11347. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11348. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11349. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11350. static readonly STEP_POINTERMOVE_SPRITE: number;
  11351. static readonly STEP_POINTERDOWN_SPRITE: number;
  11352. static readonly STEP_POINTERUP_SPRITE: number;
  11353. }
  11354. /**
  11355. * This represents a scene component.
  11356. *
  11357. * This is used to decouple the dependency the scene is having on the different workloads like
  11358. * layers, post processes...
  11359. */
  11360. export interface ISceneComponent {
  11361. /**
  11362. * The name of the component. Each component must have a unique name.
  11363. */
  11364. name: string;
  11365. /**
  11366. * The scene the component belongs to.
  11367. */
  11368. scene: Scene;
  11369. /**
  11370. * Register the component to one instance of a scene.
  11371. */
  11372. register(): void;
  11373. /**
  11374. * Rebuilds the elements related to this component in case of
  11375. * context lost for instance.
  11376. */
  11377. rebuild(): void;
  11378. /**
  11379. * Disposes the component and the associated ressources.
  11380. */
  11381. dispose(): void;
  11382. }
  11383. /**
  11384. * This represents a SERIALIZABLE scene component.
  11385. *
  11386. * This extends Scene Component to add Serialization methods on top.
  11387. */
  11388. export interface ISceneSerializableComponent extends ISceneComponent {
  11389. /**
  11390. * Adds all the elements from the container to the scene
  11391. * @param container the container holding the elements
  11392. */
  11393. addFromContainer(container: AbstractScene): void;
  11394. /**
  11395. * Removes all the elements in the container from the scene
  11396. * @param container contains the elements to remove
  11397. * @param dispose if the removed element should be disposed (default: false)
  11398. */
  11399. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11400. /**
  11401. * Serializes the component data to the specified json object
  11402. * @param serializationObject The object to serialize to
  11403. */
  11404. serialize(serializationObject: any): void;
  11405. }
  11406. /**
  11407. * Strong typing of a Mesh related stage step action
  11408. */
  11409. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11410. /**
  11411. * Strong typing of a Evaluate Sub Mesh related stage step action
  11412. */
  11413. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11414. /**
  11415. * Strong typing of a Active Mesh related stage step action
  11416. */
  11417. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11418. /**
  11419. * Strong typing of a Camera related stage step action
  11420. */
  11421. export type CameraStageAction = (camera: Camera) => void;
  11422. /**
  11423. * Strong typing of a Camera Frame buffer related stage step action
  11424. */
  11425. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11426. /**
  11427. * Strong typing of a Render Target related stage step action
  11428. */
  11429. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11430. /**
  11431. * Strong typing of a RenderingGroup related stage step action
  11432. */
  11433. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11434. /**
  11435. * Strong typing of a Mesh Render related stage step action
  11436. */
  11437. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11438. /**
  11439. * Strong typing of a simple stage step action
  11440. */
  11441. export type SimpleStageAction = () => void;
  11442. /**
  11443. * Strong typing of a render target action.
  11444. */
  11445. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11446. /**
  11447. * Strong typing of a pointer move action.
  11448. */
  11449. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11450. /**
  11451. * Strong typing of a pointer up/down action.
  11452. */
  11453. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11454. /**
  11455. * Representation of a stage in the scene (Basically a list of ordered steps)
  11456. * @hidden
  11457. */
  11458. export class Stage<T extends Function> extends Array<{
  11459. index: number;
  11460. component: ISceneComponent;
  11461. action: T;
  11462. }> {
  11463. /**
  11464. * Hide ctor from the rest of the world.
  11465. * @param items The items to add.
  11466. */
  11467. private constructor();
  11468. /**
  11469. * Creates a new Stage.
  11470. * @returns A new instance of a Stage
  11471. */
  11472. static Create<T extends Function>(): Stage<T>;
  11473. /**
  11474. * Registers a step in an ordered way in the targeted stage.
  11475. * @param index Defines the position to register the step in
  11476. * @param component Defines the component attached to the step
  11477. * @param action Defines the action to launch during the step
  11478. */
  11479. registerStep(index: number, component: ISceneComponent, action: T): void;
  11480. /**
  11481. * Clears all the steps from the stage.
  11482. */
  11483. clear(): void;
  11484. }
  11485. }
  11486. declare module BABYLON {
  11487. interface Scene {
  11488. /** @hidden */
  11489. _pointerOverSprite: Nullable<Sprite>;
  11490. /** @hidden */
  11491. _pickedDownSprite: Nullable<Sprite>;
  11492. /** @hidden */
  11493. _tempSpritePickingRay: Nullable<Ray>;
  11494. /**
  11495. * All of the sprite managers added to this scene
  11496. * @see http://doc.babylonjs.com/babylon101/sprites
  11497. */
  11498. spriteManagers: Array<ISpriteManager>;
  11499. /**
  11500. * An event triggered when sprites rendering is about to start
  11501. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11502. */
  11503. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11504. /**
  11505. * An event triggered when sprites rendering is done
  11506. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11507. */
  11508. onAfterSpritesRenderingObservable: Observable<Scene>;
  11509. /** @hidden */
  11510. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11511. /** Launch a ray to try to pick a sprite in the scene
  11512. * @param x position on screen
  11513. * @param y position on screen
  11514. * @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
  11515. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11516. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11517. * @returns a PickingInfo
  11518. */
  11519. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11520. /** Use the given ray to pick a sprite in the scene
  11521. * @param ray The ray (in world space) to use to pick meshes
  11522. * @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
  11523. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11524. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11525. * @returns a PickingInfo
  11526. */
  11527. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11528. /** @hidden */
  11529. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11530. /** Launch a ray to try to pick sprites in the scene
  11531. * @param x position on screen
  11532. * @param y position on screen
  11533. * @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
  11534. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11535. * @returns a PickingInfo array
  11536. */
  11537. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11538. /** Use the given ray to pick sprites in the scene
  11539. * @param ray The ray (in world space) to use to pick meshes
  11540. * @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
  11541. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11542. * @returns a PickingInfo array
  11543. */
  11544. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11545. /**
  11546. * Force the sprite under the pointer
  11547. * @param sprite defines the sprite to use
  11548. */
  11549. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11550. /**
  11551. * Gets the sprite under the pointer
  11552. * @returns a Sprite or null if no sprite is under the pointer
  11553. */
  11554. getPointerOverSprite(): Nullable<Sprite>;
  11555. }
  11556. /**
  11557. * Defines the sprite scene component responsible to manage sprites
  11558. * in a given scene.
  11559. */
  11560. export class SpriteSceneComponent implements ISceneComponent {
  11561. /**
  11562. * The component name helpfull to identify the component in the list of scene components.
  11563. */
  11564. readonly name: string;
  11565. /**
  11566. * The scene the component belongs to.
  11567. */
  11568. scene: Scene;
  11569. /** @hidden */
  11570. private _spritePredicate;
  11571. /**
  11572. * Creates a new instance of the component for the given scene
  11573. * @param scene Defines the scene to register the component in
  11574. */
  11575. constructor(scene: Scene);
  11576. /**
  11577. * Registers the component in a given scene
  11578. */
  11579. register(): void;
  11580. /**
  11581. * Rebuilds the elements related to this component in case of
  11582. * context lost for instance.
  11583. */
  11584. rebuild(): void;
  11585. /**
  11586. * Disposes the component and the associated ressources.
  11587. */
  11588. dispose(): void;
  11589. private _pickSpriteButKeepRay;
  11590. private _pointerMove;
  11591. private _pointerDown;
  11592. private _pointerUp;
  11593. }
  11594. }
  11595. declare module BABYLON {
  11596. /** @hidden */
  11597. export var fogFragmentDeclaration: {
  11598. name: string;
  11599. shader: string;
  11600. };
  11601. }
  11602. declare module BABYLON {
  11603. /** @hidden */
  11604. export var fogFragment: {
  11605. name: string;
  11606. shader: string;
  11607. };
  11608. }
  11609. declare module BABYLON {
  11610. /** @hidden */
  11611. export var spritesPixelShader: {
  11612. name: string;
  11613. shader: string;
  11614. };
  11615. }
  11616. declare module BABYLON {
  11617. /** @hidden */
  11618. export var fogVertexDeclaration: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module BABYLON {
  11624. /** @hidden */
  11625. export var spritesVertexShader: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module BABYLON {
  11631. /**
  11632. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11633. */
  11634. export interface ISpriteManager extends IDisposable {
  11635. /**
  11636. * Restricts the camera to viewing objects with the same layerMask.
  11637. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11638. */
  11639. layerMask: number;
  11640. /**
  11641. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11642. */
  11643. isPickable: boolean;
  11644. /**
  11645. * Specifies the rendering group id for this mesh (0 by default)
  11646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11647. */
  11648. renderingGroupId: number;
  11649. /**
  11650. * Defines the list of sprites managed by the manager.
  11651. */
  11652. sprites: Array<Sprite>;
  11653. /**
  11654. * Tests the intersection of a sprite with a specific ray.
  11655. * @param ray The ray we are sending to test the collision
  11656. * @param camera The camera space we are sending rays in
  11657. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11658. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11659. * @returns picking info or null.
  11660. */
  11661. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11662. /**
  11663. * Intersects the sprites with a ray
  11664. * @param ray defines the ray to intersect with
  11665. * @param camera defines the current active camera
  11666. * @param predicate defines a predicate used to select candidate sprites
  11667. * @returns null if no hit or a PickingInfo array
  11668. */
  11669. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11670. /**
  11671. * Renders the list of sprites on screen.
  11672. */
  11673. render(): void;
  11674. }
  11675. /**
  11676. * Class used to manage multiple sprites on the same spritesheet
  11677. * @see http://doc.babylonjs.com/babylon101/sprites
  11678. */
  11679. export class SpriteManager implements ISpriteManager {
  11680. /** defines the manager's name */
  11681. name: string;
  11682. /** Gets the list of sprites */
  11683. sprites: Sprite[];
  11684. /** Gets or sets the rendering group id (0 by default) */
  11685. renderingGroupId: number;
  11686. /** Gets or sets camera layer mask */
  11687. layerMask: number;
  11688. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11689. fogEnabled: boolean;
  11690. /** Gets or sets a boolean indicating if the sprites are pickable */
  11691. isPickable: boolean;
  11692. /** Defines the default width of a cell in the spritesheet */
  11693. cellWidth: number;
  11694. /** Defines the default height of a cell in the spritesheet */
  11695. cellHeight: number;
  11696. /** Associative array from JSON sprite data file */
  11697. private _cellData;
  11698. /** Array of sprite names from JSON sprite data file */
  11699. private _spriteMap;
  11700. /** True when packed cell data from JSON file is ready*/
  11701. private _packedAndReady;
  11702. /**
  11703. * An event triggered when the manager is disposed.
  11704. */
  11705. onDisposeObservable: Observable<SpriteManager>;
  11706. private _onDisposeObserver;
  11707. /**
  11708. * Callback called when the manager is disposed
  11709. */
  11710. set onDispose(callback: () => void);
  11711. private _capacity;
  11712. private _fromPacked;
  11713. private _spriteTexture;
  11714. private _epsilon;
  11715. private _scene;
  11716. private _vertexData;
  11717. private _buffer;
  11718. private _vertexBuffers;
  11719. private _indexBuffer;
  11720. private _effectBase;
  11721. private _effectFog;
  11722. /**
  11723. * Gets or sets the spritesheet texture
  11724. */
  11725. get texture(): Texture;
  11726. set texture(value: Texture);
  11727. /**
  11728. * Creates a new sprite manager
  11729. * @param name defines the manager's name
  11730. * @param imgUrl defines the sprite sheet url
  11731. * @param capacity defines the maximum allowed number of sprites
  11732. * @param cellSize defines the size of a sprite cell
  11733. * @param scene defines the hosting scene
  11734. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11735. * @param samplingMode defines the smapling mode to use with spritesheet
  11736. * @param fromPacked set to false; do not alter
  11737. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11738. */
  11739. constructor(
  11740. /** defines the manager's name */
  11741. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11742. private _makePacked;
  11743. private _appendSpriteVertex;
  11744. /**
  11745. * Intersects the sprites with a ray
  11746. * @param ray defines the ray to intersect with
  11747. * @param camera defines the current active camera
  11748. * @param predicate defines a predicate used to select candidate sprites
  11749. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11750. * @returns null if no hit or a PickingInfo
  11751. */
  11752. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11753. /**
  11754. * Intersects the sprites with a ray
  11755. * @param ray defines the ray to intersect with
  11756. * @param camera defines the current active camera
  11757. * @param predicate defines a predicate used to select candidate sprites
  11758. * @returns null if no hit or a PickingInfo array
  11759. */
  11760. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11761. /**
  11762. * Render all child sprites
  11763. */
  11764. render(): void;
  11765. /**
  11766. * Release associated resources
  11767. */
  11768. dispose(): void;
  11769. }
  11770. }
  11771. declare module BABYLON {
  11772. /**
  11773. * Class used to represent a sprite
  11774. * @see http://doc.babylonjs.com/babylon101/sprites
  11775. */
  11776. export class Sprite {
  11777. /** defines the name */
  11778. name: string;
  11779. /** Gets or sets the current world position */
  11780. position: Vector3;
  11781. /** Gets or sets the main color */
  11782. color: Color4;
  11783. /** Gets or sets the width */
  11784. width: number;
  11785. /** Gets or sets the height */
  11786. height: number;
  11787. /** Gets or sets rotation angle */
  11788. angle: number;
  11789. /** Gets or sets the cell index in the sprite sheet */
  11790. cellIndex: number;
  11791. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11792. cellRef: string;
  11793. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11794. invertU: number;
  11795. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11796. invertV: number;
  11797. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11798. disposeWhenFinishedAnimating: boolean;
  11799. /** Gets the list of attached animations */
  11800. animations: Animation[];
  11801. /** Gets or sets a boolean indicating if the sprite can be picked */
  11802. isPickable: boolean;
  11803. /**
  11804. * Gets or sets the associated action manager
  11805. */
  11806. actionManager: Nullable<ActionManager>;
  11807. private _animationStarted;
  11808. private _loopAnimation;
  11809. private _fromIndex;
  11810. private _toIndex;
  11811. private _delay;
  11812. private _direction;
  11813. private _manager;
  11814. private _time;
  11815. private _onAnimationEnd;
  11816. /**
  11817. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11818. */
  11819. isVisible: boolean;
  11820. /**
  11821. * Gets or sets the sprite size
  11822. */
  11823. get size(): number;
  11824. set size(value: number);
  11825. /**
  11826. * Creates a new Sprite
  11827. * @param name defines the name
  11828. * @param manager defines the manager
  11829. */
  11830. constructor(
  11831. /** defines the name */
  11832. name: string, manager: ISpriteManager);
  11833. /**
  11834. * Starts an animation
  11835. * @param from defines the initial key
  11836. * @param to defines the end key
  11837. * @param loop defines if the animation must loop
  11838. * @param delay defines the start delay (in ms)
  11839. * @param onAnimationEnd defines a callback to call when animation ends
  11840. */
  11841. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11842. /** Stops current animation (if any) */
  11843. stopAnimation(): void;
  11844. /** @hidden */
  11845. _animate(deltaTime: number): void;
  11846. /** Release associated resources */
  11847. dispose(): void;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * Information about the result of picking within a scene
  11853. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11854. */
  11855. export class PickingInfo {
  11856. /** @hidden */
  11857. _pickingUnavailable: boolean;
  11858. /**
  11859. * If the pick collided with an object
  11860. */
  11861. hit: boolean;
  11862. /**
  11863. * Distance away where the pick collided
  11864. */
  11865. distance: number;
  11866. /**
  11867. * The location of pick collision
  11868. */
  11869. pickedPoint: Nullable<Vector3>;
  11870. /**
  11871. * The mesh corresponding the the pick collision
  11872. */
  11873. pickedMesh: Nullable<AbstractMesh>;
  11874. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11875. bu: number;
  11876. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11877. bv: number;
  11878. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11879. faceId: number;
  11880. /** Id of the the submesh that was picked */
  11881. subMeshId: number;
  11882. /** If a sprite was picked, this will be the sprite the pick collided with */
  11883. pickedSprite: Nullable<Sprite>;
  11884. /**
  11885. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11886. */
  11887. originMesh: Nullable<AbstractMesh>;
  11888. /**
  11889. * The ray that was used to perform the picking.
  11890. */
  11891. ray: Nullable<Ray>;
  11892. /**
  11893. * Gets the normal correspodning to the face the pick collided with
  11894. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11895. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11896. * @returns The normal correspodning to the face the pick collided with
  11897. */
  11898. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11899. /**
  11900. * Gets the texture coordinates of where the pick occured
  11901. * @returns the vector containing the coordnates of the texture
  11902. */
  11903. getTextureCoordinates(): Nullable<Vector2>;
  11904. }
  11905. }
  11906. declare module BABYLON {
  11907. /**
  11908. * Gather the list of pointer event types as constants.
  11909. */
  11910. export class PointerEventTypes {
  11911. /**
  11912. * 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.
  11913. */
  11914. static readonly POINTERDOWN: number;
  11915. /**
  11916. * The pointerup event is fired when a pointer is no longer active.
  11917. */
  11918. static readonly POINTERUP: number;
  11919. /**
  11920. * The pointermove event is fired when a pointer changes coordinates.
  11921. */
  11922. static readonly POINTERMOVE: number;
  11923. /**
  11924. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11925. */
  11926. static readonly POINTERWHEEL: number;
  11927. /**
  11928. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11929. */
  11930. static readonly POINTERPICK: number;
  11931. /**
  11932. * The pointertap event is fired when a the object has been touched and released without drag.
  11933. */
  11934. static readonly POINTERTAP: number;
  11935. /**
  11936. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11937. */
  11938. static readonly POINTERDOUBLETAP: number;
  11939. }
  11940. /**
  11941. * Base class of pointer info types.
  11942. */
  11943. export class PointerInfoBase {
  11944. /**
  11945. * Defines the type of event (PointerEventTypes)
  11946. */
  11947. type: number;
  11948. /**
  11949. * Defines the related dom event
  11950. */
  11951. event: PointerEvent | MouseWheelEvent;
  11952. /**
  11953. * Instantiates the base class of pointers info.
  11954. * @param type Defines the type of event (PointerEventTypes)
  11955. * @param event Defines the related dom event
  11956. */
  11957. constructor(
  11958. /**
  11959. * Defines the type of event (PointerEventTypes)
  11960. */
  11961. type: number,
  11962. /**
  11963. * Defines the related dom event
  11964. */
  11965. event: PointerEvent | MouseWheelEvent);
  11966. }
  11967. /**
  11968. * This class is used to store pointer related info for the onPrePointerObservable event.
  11969. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11970. */
  11971. export class PointerInfoPre extends PointerInfoBase {
  11972. /**
  11973. * Ray from a pointer if availible (eg. 6dof controller)
  11974. */
  11975. ray: Nullable<Ray>;
  11976. /**
  11977. * Defines the local position of the pointer on the canvas.
  11978. */
  11979. localPosition: Vector2;
  11980. /**
  11981. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11982. */
  11983. skipOnPointerObservable: boolean;
  11984. /**
  11985. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11986. * @param type Defines the type of event (PointerEventTypes)
  11987. * @param event Defines the related dom event
  11988. * @param localX Defines the local x coordinates of the pointer when the event occured
  11989. * @param localY Defines the local y coordinates of the pointer when the event occured
  11990. */
  11991. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11992. }
  11993. /**
  11994. * This type contains all the data related to a pointer event in Babylon.js.
  11995. * 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.
  11996. */
  11997. export class PointerInfo extends PointerInfoBase {
  11998. /**
  11999. * Defines the picking info associated to the info (if any)\
  12000. */
  12001. pickInfo: Nullable<PickingInfo>;
  12002. /**
  12003. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12004. * @param type Defines the type of event (PointerEventTypes)
  12005. * @param event Defines the related dom event
  12006. * @param pickInfo Defines the picking info associated to the info (if any)\
  12007. */
  12008. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12009. /**
  12010. * Defines the picking info associated to the info (if any)\
  12011. */
  12012. pickInfo: Nullable<PickingInfo>);
  12013. }
  12014. /**
  12015. * Data relating to a touch event on the screen.
  12016. */
  12017. export interface PointerTouch {
  12018. /**
  12019. * X coordinate of touch.
  12020. */
  12021. x: number;
  12022. /**
  12023. * Y coordinate of touch.
  12024. */
  12025. y: number;
  12026. /**
  12027. * Id of touch. Unique for each finger.
  12028. */
  12029. pointerId: number;
  12030. /**
  12031. * Event type passed from DOM.
  12032. */
  12033. type: any;
  12034. }
  12035. }
  12036. declare module BABYLON {
  12037. /**
  12038. * Manage the mouse inputs to control the movement of a free camera.
  12039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12040. */
  12041. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12042. /**
  12043. * Define if touch is enabled in the mouse input
  12044. */
  12045. touchEnabled: boolean;
  12046. /**
  12047. * Defines the camera the input is attached to.
  12048. */
  12049. camera: FreeCamera;
  12050. /**
  12051. * Defines the buttons associated with the input to handle camera move.
  12052. */
  12053. buttons: number[];
  12054. /**
  12055. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12056. */
  12057. angularSensibility: number;
  12058. private _pointerInput;
  12059. private _onMouseMove;
  12060. private _observer;
  12061. private previousPosition;
  12062. /**
  12063. * Observable for when a pointer move event occurs containing the move offset
  12064. */
  12065. onPointerMovedObservable: Observable<{
  12066. offsetX: number;
  12067. offsetY: number;
  12068. }>;
  12069. /**
  12070. * @hidden
  12071. * If the camera should be rotated automatically based on pointer movement
  12072. */
  12073. _allowCameraRotation: boolean;
  12074. /**
  12075. * Manage the mouse inputs to control the movement of a free camera.
  12076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12077. * @param touchEnabled Defines if touch is enabled or not
  12078. */
  12079. constructor(
  12080. /**
  12081. * Define if touch is enabled in the mouse input
  12082. */
  12083. touchEnabled?: boolean);
  12084. /**
  12085. * Attach the input controls to a specific dom element to get the input from.
  12086. * @param element Defines the element the controls should be listened from
  12087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12088. */
  12089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12090. /**
  12091. * Called on JS contextmenu event.
  12092. * Override this method to provide functionality.
  12093. */
  12094. protected onContextMenu(evt: PointerEvent): void;
  12095. /**
  12096. * Detach the current controls from the specified dom element.
  12097. * @param element Defines the element to stop listening the inputs from
  12098. */
  12099. detachControl(element: Nullable<HTMLElement>): void;
  12100. /**
  12101. * Gets the class name of the current intput.
  12102. * @returns the class name
  12103. */
  12104. getClassName(): string;
  12105. /**
  12106. * Get the friendly name associated with the input class.
  12107. * @returns the input friendly name
  12108. */
  12109. getSimpleName(): string;
  12110. }
  12111. }
  12112. declare module BABYLON {
  12113. /**
  12114. * Manage the touch inputs to control the movement of a free camera.
  12115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12116. */
  12117. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12118. /**
  12119. * Defines the camera the input is attached to.
  12120. */
  12121. camera: FreeCamera;
  12122. /**
  12123. * Defines the touch sensibility for rotation.
  12124. * The higher the faster.
  12125. */
  12126. touchAngularSensibility: number;
  12127. /**
  12128. * Defines the touch sensibility for move.
  12129. * The higher the faster.
  12130. */
  12131. touchMoveSensibility: number;
  12132. private _offsetX;
  12133. private _offsetY;
  12134. private _pointerPressed;
  12135. private _pointerInput;
  12136. private _observer;
  12137. private _onLostFocus;
  12138. /**
  12139. * Attach the input controls to a specific dom element to get the input from.
  12140. * @param element Defines the element the controls should be listened from
  12141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12142. */
  12143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12144. /**
  12145. * Detach the current controls from the specified dom element.
  12146. * @param element Defines the element to stop listening the inputs from
  12147. */
  12148. detachControl(element: Nullable<HTMLElement>): void;
  12149. /**
  12150. * Update the current camera state depending on the inputs that have been used this frame.
  12151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12152. */
  12153. checkInputs(): void;
  12154. /**
  12155. * Gets the class name of the current intput.
  12156. * @returns the class name
  12157. */
  12158. getClassName(): string;
  12159. /**
  12160. * Get the friendly name associated with the input class.
  12161. * @returns the input friendly name
  12162. */
  12163. getSimpleName(): string;
  12164. }
  12165. }
  12166. declare module BABYLON {
  12167. /**
  12168. * Default Inputs manager for the FreeCamera.
  12169. * It groups all the default supported inputs for ease of use.
  12170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12171. */
  12172. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12173. /**
  12174. * @hidden
  12175. */
  12176. _mouseInput: Nullable<FreeCameraMouseInput>;
  12177. /**
  12178. * Instantiates a new FreeCameraInputsManager.
  12179. * @param camera Defines the camera the inputs belong to
  12180. */
  12181. constructor(camera: FreeCamera);
  12182. /**
  12183. * Add keyboard input support to the input manager.
  12184. * @returns the current input manager
  12185. */
  12186. addKeyboard(): FreeCameraInputsManager;
  12187. /**
  12188. * Add mouse input support to the input manager.
  12189. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12190. * @returns the current input manager
  12191. */
  12192. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12193. /**
  12194. * Removes the mouse input support from the manager
  12195. * @returns the current input manager
  12196. */
  12197. removeMouse(): FreeCameraInputsManager;
  12198. /**
  12199. * Add touch input support to the input manager.
  12200. * @returns the current input manager
  12201. */
  12202. addTouch(): FreeCameraInputsManager;
  12203. /**
  12204. * Remove all attached input methods from a camera
  12205. */
  12206. clear(): void;
  12207. }
  12208. }
  12209. declare module BABYLON {
  12210. /**
  12211. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12212. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12214. */
  12215. export class FreeCamera extends TargetCamera {
  12216. /**
  12217. * Define the collision ellipsoid of the camera.
  12218. * This is helpful to simulate a camera body like the player body around the camera
  12219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12220. */
  12221. ellipsoid: Vector3;
  12222. /**
  12223. * Define an offset for the position of the ellipsoid around the camera.
  12224. * This can be helpful to determine the center of the body near the gravity center of the body
  12225. * instead of its head.
  12226. */
  12227. ellipsoidOffset: Vector3;
  12228. /**
  12229. * Enable or disable collisions of the camera with the rest of the scene objects.
  12230. */
  12231. checkCollisions: boolean;
  12232. /**
  12233. * Enable or disable gravity on the camera.
  12234. */
  12235. applyGravity: boolean;
  12236. /**
  12237. * Define the input manager associated to the camera.
  12238. */
  12239. inputs: FreeCameraInputsManager;
  12240. /**
  12241. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12242. * Higher values reduce sensitivity.
  12243. */
  12244. get angularSensibility(): number;
  12245. /**
  12246. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12247. * Higher values reduce sensitivity.
  12248. */
  12249. set angularSensibility(value: number);
  12250. /**
  12251. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12252. */
  12253. get keysUp(): number[];
  12254. set keysUp(value: number[]);
  12255. /**
  12256. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12257. */
  12258. get keysDown(): number[];
  12259. set keysDown(value: number[]);
  12260. /**
  12261. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12262. */
  12263. get keysLeft(): number[];
  12264. set keysLeft(value: number[]);
  12265. /**
  12266. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12267. */
  12268. get keysRight(): number[];
  12269. set keysRight(value: number[]);
  12270. /**
  12271. * Event raised when the camera collide with a mesh in the scene.
  12272. */
  12273. onCollide: (collidedMesh: AbstractMesh) => void;
  12274. private _collider;
  12275. private _needMoveForGravity;
  12276. private _oldPosition;
  12277. private _diffPosition;
  12278. private _newPosition;
  12279. /** @hidden */
  12280. _localDirection: Vector3;
  12281. /** @hidden */
  12282. _transformedDirection: Vector3;
  12283. /**
  12284. * Instantiates a Free Camera.
  12285. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12286. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12287. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12288. * @param name Define the name of the camera in the scene
  12289. * @param position Define the start position of the camera in the scene
  12290. * @param scene Define the scene the camera belongs to
  12291. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12292. */
  12293. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12294. /**
  12295. * Attached controls to the current camera.
  12296. * @param element Defines the element the controls should be listened from
  12297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12298. */
  12299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12300. /**
  12301. * Detach the current controls from the camera.
  12302. * The camera will stop reacting to inputs.
  12303. * @param element Defines the element to stop listening the inputs from
  12304. */
  12305. detachControl(element: HTMLElement): void;
  12306. private _collisionMask;
  12307. /**
  12308. * Define a collision mask to limit the list of object the camera can collide with
  12309. */
  12310. get collisionMask(): number;
  12311. set collisionMask(mask: number);
  12312. /** @hidden */
  12313. _collideWithWorld(displacement: Vector3): void;
  12314. private _onCollisionPositionChange;
  12315. /** @hidden */
  12316. _checkInputs(): void;
  12317. /** @hidden */
  12318. _decideIfNeedsToMove(): boolean;
  12319. /** @hidden */
  12320. _updatePosition(): void;
  12321. /**
  12322. * Destroy the camera and release the current resources hold by it.
  12323. */
  12324. dispose(): void;
  12325. /**
  12326. * Gets the current object class name.
  12327. * @return the class name
  12328. */
  12329. getClassName(): string;
  12330. }
  12331. }
  12332. declare module BABYLON {
  12333. /**
  12334. * Represents a gamepad control stick position
  12335. */
  12336. export class StickValues {
  12337. /**
  12338. * The x component of the control stick
  12339. */
  12340. x: number;
  12341. /**
  12342. * The y component of the control stick
  12343. */
  12344. y: number;
  12345. /**
  12346. * Initializes the gamepad x and y control stick values
  12347. * @param x The x component of the gamepad control stick value
  12348. * @param y The y component of the gamepad control stick value
  12349. */
  12350. constructor(
  12351. /**
  12352. * The x component of the control stick
  12353. */
  12354. x: number,
  12355. /**
  12356. * The y component of the control stick
  12357. */
  12358. y: number);
  12359. }
  12360. /**
  12361. * An interface which manages callbacks for gamepad button changes
  12362. */
  12363. export interface GamepadButtonChanges {
  12364. /**
  12365. * Called when a gamepad has been changed
  12366. */
  12367. changed: boolean;
  12368. /**
  12369. * Called when a gamepad press event has been triggered
  12370. */
  12371. pressChanged: boolean;
  12372. /**
  12373. * Called when a touch event has been triggered
  12374. */
  12375. touchChanged: boolean;
  12376. /**
  12377. * Called when a value has changed
  12378. */
  12379. valueChanged: boolean;
  12380. }
  12381. /**
  12382. * Represents a gamepad
  12383. */
  12384. export class Gamepad {
  12385. /**
  12386. * The id of the gamepad
  12387. */
  12388. id: string;
  12389. /**
  12390. * The index of the gamepad
  12391. */
  12392. index: number;
  12393. /**
  12394. * The browser gamepad
  12395. */
  12396. browserGamepad: any;
  12397. /**
  12398. * Specifies what type of gamepad this represents
  12399. */
  12400. type: number;
  12401. private _leftStick;
  12402. private _rightStick;
  12403. /** @hidden */
  12404. _isConnected: boolean;
  12405. private _leftStickAxisX;
  12406. private _leftStickAxisY;
  12407. private _rightStickAxisX;
  12408. private _rightStickAxisY;
  12409. /**
  12410. * Triggered when the left control stick has been changed
  12411. */
  12412. private _onleftstickchanged;
  12413. /**
  12414. * Triggered when the right control stick has been changed
  12415. */
  12416. private _onrightstickchanged;
  12417. /**
  12418. * Represents a gamepad controller
  12419. */
  12420. static GAMEPAD: number;
  12421. /**
  12422. * Represents a generic controller
  12423. */
  12424. static GENERIC: number;
  12425. /**
  12426. * Represents an XBox controller
  12427. */
  12428. static XBOX: number;
  12429. /**
  12430. * Represents a pose-enabled controller
  12431. */
  12432. static POSE_ENABLED: number;
  12433. /**
  12434. * Represents an Dual Shock controller
  12435. */
  12436. static DUALSHOCK: number;
  12437. /**
  12438. * Specifies whether the left control stick should be Y-inverted
  12439. */
  12440. protected _invertLeftStickY: boolean;
  12441. /**
  12442. * Specifies if the gamepad has been connected
  12443. */
  12444. get isConnected(): boolean;
  12445. /**
  12446. * Initializes the gamepad
  12447. * @param id The id of the gamepad
  12448. * @param index The index of the gamepad
  12449. * @param browserGamepad The browser gamepad
  12450. * @param leftStickX The x component of the left joystick
  12451. * @param leftStickY The y component of the left joystick
  12452. * @param rightStickX The x component of the right joystick
  12453. * @param rightStickY The y component of the right joystick
  12454. */
  12455. constructor(
  12456. /**
  12457. * The id of the gamepad
  12458. */
  12459. id: string,
  12460. /**
  12461. * The index of the gamepad
  12462. */
  12463. index: number,
  12464. /**
  12465. * The browser gamepad
  12466. */
  12467. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12468. /**
  12469. * Callback triggered when the left joystick has changed
  12470. * @param callback
  12471. */
  12472. onleftstickchanged(callback: (values: StickValues) => void): void;
  12473. /**
  12474. * Callback triggered when the right joystick has changed
  12475. * @param callback
  12476. */
  12477. onrightstickchanged(callback: (values: StickValues) => void): void;
  12478. /**
  12479. * Gets the left joystick
  12480. */
  12481. get leftStick(): StickValues;
  12482. /**
  12483. * Sets the left joystick values
  12484. */
  12485. set leftStick(newValues: StickValues);
  12486. /**
  12487. * Gets the right joystick
  12488. */
  12489. get rightStick(): StickValues;
  12490. /**
  12491. * Sets the right joystick value
  12492. */
  12493. set rightStick(newValues: StickValues);
  12494. /**
  12495. * Updates the gamepad joystick positions
  12496. */
  12497. update(): void;
  12498. /**
  12499. * Disposes the gamepad
  12500. */
  12501. dispose(): void;
  12502. }
  12503. /**
  12504. * Represents a generic gamepad
  12505. */
  12506. export class GenericPad extends Gamepad {
  12507. private _buttons;
  12508. private _onbuttondown;
  12509. private _onbuttonup;
  12510. /**
  12511. * Observable triggered when a button has been pressed
  12512. */
  12513. onButtonDownObservable: Observable<number>;
  12514. /**
  12515. * Observable triggered when a button has been released
  12516. */
  12517. onButtonUpObservable: Observable<number>;
  12518. /**
  12519. * Callback triggered when a button has been pressed
  12520. * @param callback Called when a button has been pressed
  12521. */
  12522. onbuttondown(callback: (buttonPressed: number) => void): void;
  12523. /**
  12524. * Callback triggered when a button has been released
  12525. * @param callback Called when a button has been released
  12526. */
  12527. onbuttonup(callback: (buttonReleased: number) => void): void;
  12528. /**
  12529. * Initializes the generic gamepad
  12530. * @param id The id of the generic gamepad
  12531. * @param index The index of the generic gamepad
  12532. * @param browserGamepad The browser gamepad
  12533. */
  12534. constructor(id: string, index: number, browserGamepad: any);
  12535. private _setButtonValue;
  12536. /**
  12537. * Updates the generic gamepad
  12538. */
  12539. update(): void;
  12540. /**
  12541. * Disposes the generic gamepad
  12542. */
  12543. dispose(): void;
  12544. }
  12545. }
  12546. declare module BABYLON {
  12547. interface Engine {
  12548. /**
  12549. * Creates a raw texture
  12550. * @param data defines the data to store in the texture
  12551. * @param width defines the width of the texture
  12552. * @param height defines the height of the texture
  12553. * @param format defines the format of the data
  12554. * @param generateMipMaps defines if the engine should generate the mip levels
  12555. * @param invertY defines if data must be stored with Y axis inverted
  12556. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12557. * @param compression defines the compression used (null by default)
  12558. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12559. * @returns the raw texture inside an InternalTexture
  12560. */
  12561. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12562. /**
  12563. * Update a raw texture
  12564. * @param texture defines the texture to update
  12565. * @param data defines the data to store in the texture
  12566. * @param format defines the format of the data
  12567. * @param invertY defines if data must be stored with Y axis inverted
  12568. */
  12569. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12570. /**
  12571. * Update a raw texture
  12572. * @param texture defines the texture to update
  12573. * @param data defines the data to store in the texture
  12574. * @param format defines the format of the data
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param compression defines the compression used (null by default)
  12577. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12578. */
  12579. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12580. /**
  12581. * Creates a new raw cube texture
  12582. * @param data defines the array of data to use to create each face
  12583. * @param size defines the size of the textures
  12584. * @param format defines the format of the data
  12585. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12586. * @param generateMipMaps defines if the engine should generate the mip levels
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12589. * @param compression defines the compression used (null by default)
  12590. * @returns the cube texture as an InternalTexture
  12591. */
  12592. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12593. /**
  12594. * Update a raw cube texture
  12595. * @param texture defines the texture to udpdate
  12596. * @param data defines the data to store
  12597. * @param format defines the data format
  12598. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. */
  12601. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12602. /**
  12603. * Update a raw cube texture
  12604. * @param texture defines the texture to udpdate
  12605. * @param data defines the data to store
  12606. * @param format defines the data format
  12607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12608. * @param invertY defines if data must be stored with Y axis inverted
  12609. * @param compression defines the compression used (null by default)
  12610. */
  12611. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12612. /**
  12613. * Update a raw cube texture
  12614. * @param texture defines the texture to udpdate
  12615. * @param data defines the data to store
  12616. * @param format defines the data format
  12617. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param level defines which level of the texture to update
  12621. */
  12622. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12623. /**
  12624. * Creates a new raw cube texture from a specified url
  12625. * @param url defines the url where the data is located
  12626. * @param scene defines the current scene
  12627. * @param size defines the size of the textures
  12628. * @param format defines the format of the data
  12629. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12630. * @param noMipmap defines if the engine should avoid generating the mip levels
  12631. * @param callback defines a callback used to extract texture data from loaded data
  12632. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12633. * @param onLoad defines a callback called when texture is loaded
  12634. * @param onError defines a callback called if there is an error
  12635. * @returns the cube texture as an InternalTexture
  12636. */
  12637. 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;
  12638. /**
  12639. * Creates a new raw cube texture from a specified url
  12640. * @param url defines the url where the data is located
  12641. * @param scene defines the current scene
  12642. * @param size defines the size of the textures
  12643. * @param format defines the format of the data
  12644. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12645. * @param noMipmap defines if the engine should avoid generating the mip levels
  12646. * @param callback defines a callback used to extract texture data from loaded data
  12647. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12648. * @param onLoad defines a callback called when texture is loaded
  12649. * @param onError defines a callback called if there is an error
  12650. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @returns the cube texture as an InternalTexture
  12653. */
  12654. 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;
  12655. /**
  12656. * Creates a new raw 3D texture
  12657. * @param data defines the data used to create the texture
  12658. * @param width defines the width of the texture
  12659. * @param height defines the height of the texture
  12660. * @param depth defines the depth of the texture
  12661. * @param format defines the format of the texture
  12662. * @param generateMipMaps defines if the engine must generate mip levels
  12663. * @param invertY defines if data must be stored with Y axis inverted
  12664. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12665. * @param compression defines the compressed used (can be null)
  12666. * @param textureType defines the compressed used (can be null)
  12667. * @returns a new raw 3D texture (stored in an InternalTexture)
  12668. */
  12669. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12670. /**
  12671. * Update a raw 3D texture
  12672. * @param texture defines the texture to update
  12673. * @param data defines the data to store
  12674. * @param format defines the data format
  12675. * @param invertY defines if data must be stored with Y axis inverted
  12676. */
  12677. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12678. /**
  12679. * Update a raw 3D texture
  12680. * @param texture defines the texture to update
  12681. * @param data defines the data to store
  12682. * @param format defines the data format
  12683. * @param invertY defines if data must be stored with Y axis inverted
  12684. * @param compression defines the used compression (can be null)
  12685. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12686. */
  12687. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12688. /**
  12689. * Creates a new raw 2D array texture
  12690. * @param data defines the data used to create the texture
  12691. * @param width defines the width of the texture
  12692. * @param height defines the height of the texture
  12693. * @param depth defines the number of layers of the texture
  12694. * @param format defines the format of the texture
  12695. * @param generateMipMaps defines if the engine must generate mip levels
  12696. * @param invertY defines if data must be stored with Y axis inverted
  12697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12698. * @param compression defines the compressed used (can be null)
  12699. * @param textureType defines the compressed used (can be null)
  12700. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12701. */
  12702. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12703. /**
  12704. * Update a raw 2D array texture
  12705. * @param texture defines the texture to update
  12706. * @param data defines the data to store
  12707. * @param format defines the data format
  12708. * @param invertY defines if data must be stored with Y axis inverted
  12709. */
  12710. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12711. /**
  12712. * Update a raw 2D array texture
  12713. * @param texture defines the texture to update
  12714. * @param data defines the data to store
  12715. * @param format defines the data format
  12716. * @param invertY defines if data must be stored with Y axis inverted
  12717. * @param compression defines the used compression (can be null)
  12718. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12719. */
  12720. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12721. }
  12722. }
  12723. declare module BABYLON {
  12724. /**
  12725. * Raw texture can help creating a texture directly from an array of data.
  12726. * This can be super useful if you either get the data from an uncompressed source or
  12727. * if you wish to create your texture pixel by pixel.
  12728. */
  12729. export class RawTexture extends Texture {
  12730. /**
  12731. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12732. */
  12733. format: number;
  12734. private _engine;
  12735. /**
  12736. * Instantiates a new RawTexture.
  12737. * Raw texture can help creating a texture directly from an array of data.
  12738. * This can be super useful if you either get the data from an uncompressed source or
  12739. * if you wish to create your texture pixel by pixel.
  12740. * @param data define the array of data to use to create the texture
  12741. * @param width define the width of the texture
  12742. * @param height define the height of the texture
  12743. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12744. * @param scene define the scene the texture belongs to
  12745. * @param generateMipMaps define whether mip maps should be generated or not
  12746. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12747. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12748. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12749. */
  12750. constructor(data: ArrayBufferView, width: number, height: number,
  12751. /**
  12752. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12753. */
  12754. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12755. /**
  12756. * Updates the texture underlying data.
  12757. * @param data Define the new data of the texture
  12758. */
  12759. update(data: ArrayBufferView): void;
  12760. /**
  12761. * Creates a luminance texture from some data.
  12762. * @param data Define the texture data
  12763. * @param width Define the width of the texture
  12764. * @param height Define the height of the texture
  12765. * @param scene Define the scene the texture belongs to
  12766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12769. * @returns the luminance texture
  12770. */
  12771. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12772. /**
  12773. * Creates a luminance alpha texture from some data.
  12774. * @param data Define the texture data
  12775. * @param width Define the width of the texture
  12776. * @param height Define the height of the texture
  12777. * @param scene Define the scene the texture belongs to
  12778. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12779. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12780. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12781. * @returns the luminance alpha texture
  12782. */
  12783. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12784. /**
  12785. * Creates an alpha texture from some data.
  12786. * @param data Define the texture data
  12787. * @param width Define the width of the texture
  12788. * @param height Define the height of the texture
  12789. * @param scene Define the scene the texture belongs to
  12790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12793. * @returns the alpha texture
  12794. */
  12795. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12796. /**
  12797. * Creates a RGB texture from some data.
  12798. * @param data Define the texture data
  12799. * @param width Define the width of the texture
  12800. * @param height Define the height of the texture
  12801. * @param scene Define the scene the texture belongs to
  12802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12805. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12806. * @returns the RGB alpha texture
  12807. */
  12808. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12809. /**
  12810. * Creates a RGBA texture from some data.
  12811. * @param data Define the texture data
  12812. * @param width Define the width of the texture
  12813. * @param height Define the height of the texture
  12814. * @param scene Define the scene the texture belongs to
  12815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12818. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12819. * @returns the RGBA texture
  12820. */
  12821. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12822. /**
  12823. * Creates a R texture from some data.
  12824. * @param data Define the texture data
  12825. * @param width Define the width of the texture
  12826. * @param height Define the height of the texture
  12827. * @param scene Define the scene the texture belongs to
  12828. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12829. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12830. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12831. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12832. * @returns the R texture
  12833. */
  12834. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12835. }
  12836. }
  12837. declare module BABYLON {
  12838. /**
  12839. * Interface for the size containing width and height
  12840. */
  12841. export interface ISize {
  12842. /**
  12843. * Width
  12844. */
  12845. width: number;
  12846. /**
  12847. * Heighht
  12848. */
  12849. height: number;
  12850. }
  12851. /**
  12852. * Size containing widht and height
  12853. */
  12854. export class Size implements ISize {
  12855. /**
  12856. * Width
  12857. */
  12858. width: number;
  12859. /**
  12860. * Height
  12861. */
  12862. height: number;
  12863. /**
  12864. * Creates a Size object from the given width and height (floats).
  12865. * @param width width of the new size
  12866. * @param height height of the new size
  12867. */
  12868. constructor(width: number, height: number);
  12869. /**
  12870. * Returns a string with the Size width and height
  12871. * @returns a string with the Size width and height
  12872. */
  12873. toString(): string;
  12874. /**
  12875. * "Size"
  12876. * @returns the string "Size"
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * Returns the Size hash code.
  12881. * @returns a hash code for a unique width and height
  12882. */
  12883. getHashCode(): number;
  12884. /**
  12885. * Updates the current size from the given one.
  12886. * @param src the given size
  12887. */
  12888. copyFrom(src: Size): void;
  12889. /**
  12890. * Updates in place the current Size from the given floats.
  12891. * @param width width of the new size
  12892. * @param height height of the new size
  12893. * @returns the updated Size.
  12894. */
  12895. copyFromFloats(width: number, height: number): Size;
  12896. /**
  12897. * Updates in place the current Size from the given floats.
  12898. * @param width width to set
  12899. * @param height height to set
  12900. * @returns the updated Size.
  12901. */
  12902. set(width: number, height: number): Size;
  12903. /**
  12904. * Multiplies the width and height by numbers
  12905. * @param w factor to multiple the width by
  12906. * @param h factor to multiple the height by
  12907. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12908. */
  12909. multiplyByFloats(w: number, h: number): Size;
  12910. /**
  12911. * Clones the size
  12912. * @returns a new Size copied from the given one.
  12913. */
  12914. clone(): Size;
  12915. /**
  12916. * True if the current Size and the given one width and height are strictly equal.
  12917. * @param other the other size to compare against
  12918. * @returns True if the current Size and the given one width and height are strictly equal.
  12919. */
  12920. equals(other: Size): boolean;
  12921. /**
  12922. * The surface of the Size : width * height (float).
  12923. */
  12924. get surface(): number;
  12925. /**
  12926. * Create a new size of zero
  12927. * @returns a new Size set to (0.0, 0.0)
  12928. */
  12929. static Zero(): Size;
  12930. /**
  12931. * Sums the width and height of two sizes
  12932. * @param otherSize size to add to this size
  12933. * @returns a new Size set as the addition result of the current Size and the given one.
  12934. */
  12935. add(otherSize: Size): Size;
  12936. /**
  12937. * Subtracts the width and height of two
  12938. * @param otherSize size to subtract to this size
  12939. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12940. */
  12941. subtract(otherSize: Size): Size;
  12942. /**
  12943. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12944. * @param start starting size to lerp between
  12945. * @param end end size to lerp between
  12946. * @param amount amount to lerp between the start and end values
  12947. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12948. */
  12949. static Lerp(start: Size, end: Size, amount: number): Size;
  12950. }
  12951. }
  12952. declare module BABYLON {
  12953. /**
  12954. * Defines a runtime animation
  12955. */
  12956. export class RuntimeAnimation {
  12957. private _events;
  12958. /**
  12959. * The current frame of the runtime animation
  12960. */
  12961. private _currentFrame;
  12962. /**
  12963. * The animation used by the runtime animation
  12964. */
  12965. private _animation;
  12966. /**
  12967. * The target of the runtime animation
  12968. */
  12969. private _target;
  12970. /**
  12971. * The initiating animatable
  12972. */
  12973. private _host;
  12974. /**
  12975. * The original value of the runtime animation
  12976. */
  12977. private _originalValue;
  12978. /**
  12979. * The original blend value of the runtime animation
  12980. */
  12981. private _originalBlendValue;
  12982. /**
  12983. * The offsets cache of the runtime animation
  12984. */
  12985. private _offsetsCache;
  12986. /**
  12987. * The high limits cache of the runtime animation
  12988. */
  12989. private _highLimitsCache;
  12990. /**
  12991. * Specifies if the runtime animation has been stopped
  12992. */
  12993. private _stopped;
  12994. /**
  12995. * The blending factor of the runtime animation
  12996. */
  12997. private _blendingFactor;
  12998. /**
  12999. * The BabylonJS scene
  13000. */
  13001. private _scene;
  13002. /**
  13003. * The current value of the runtime animation
  13004. */
  13005. private _currentValue;
  13006. /** @hidden */
  13007. _animationState: _IAnimationState;
  13008. /**
  13009. * The active target of the runtime animation
  13010. */
  13011. private _activeTargets;
  13012. private _currentActiveTarget;
  13013. private _directTarget;
  13014. /**
  13015. * The target path of the runtime animation
  13016. */
  13017. private _targetPath;
  13018. /**
  13019. * The weight of the runtime animation
  13020. */
  13021. private _weight;
  13022. /**
  13023. * The ratio offset of the runtime animation
  13024. */
  13025. private _ratioOffset;
  13026. /**
  13027. * The previous delay of the runtime animation
  13028. */
  13029. private _previousDelay;
  13030. /**
  13031. * The previous ratio of the runtime animation
  13032. */
  13033. private _previousRatio;
  13034. private _enableBlending;
  13035. private _keys;
  13036. private _minFrame;
  13037. private _maxFrame;
  13038. private _minValue;
  13039. private _maxValue;
  13040. private _targetIsArray;
  13041. /**
  13042. * Gets the current frame of the runtime animation
  13043. */
  13044. get currentFrame(): number;
  13045. /**
  13046. * Gets the weight of the runtime animation
  13047. */
  13048. get weight(): number;
  13049. /**
  13050. * Gets the current value of the runtime animation
  13051. */
  13052. get currentValue(): any;
  13053. /**
  13054. * Gets the target path of the runtime animation
  13055. */
  13056. get targetPath(): string;
  13057. /**
  13058. * Gets the actual target of the runtime animation
  13059. */
  13060. get target(): any;
  13061. /** @hidden */
  13062. _onLoop: () => void;
  13063. /**
  13064. * Create a new RuntimeAnimation object
  13065. * @param target defines the target of the animation
  13066. * @param animation defines the source animation object
  13067. * @param scene defines the hosting scene
  13068. * @param host defines the initiating Animatable
  13069. */
  13070. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13071. private _preparePath;
  13072. /**
  13073. * Gets the animation from the runtime animation
  13074. */
  13075. get animation(): Animation;
  13076. /**
  13077. * Resets the runtime animation to the beginning
  13078. * @param restoreOriginal defines whether to restore the target property to the original value
  13079. */
  13080. reset(restoreOriginal?: boolean): void;
  13081. /**
  13082. * Specifies if the runtime animation is stopped
  13083. * @returns Boolean specifying if the runtime animation is stopped
  13084. */
  13085. isStopped(): boolean;
  13086. /**
  13087. * Disposes of the runtime animation
  13088. */
  13089. dispose(): void;
  13090. /**
  13091. * Apply the interpolated value to the target
  13092. * @param currentValue defines the value computed by the animation
  13093. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13094. */
  13095. setValue(currentValue: any, weight: number): void;
  13096. private _getOriginalValues;
  13097. private _setValue;
  13098. /**
  13099. * Gets the loop pmode of the runtime animation
  13100. * @returns Loop Mode
  13101. */
  13102. private _getCorrectLoopMode;
  13103. /**
  13104. * Move the current animation to a given frame
  13105. * @param frame defines the frame to move to
  13106. */
  13107. goToFrame(frame: number): void;
  13108. /**
  13109. * @hidden Internal use only
  13110. */
  13111. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13112. /**
  13113. * Execute the current animation
  13114. * @param delay defines the delay to add to the current frame
  13115. * @param from defines the lower bound of the animation range
  13116. * @param to defines the upper bound of the animation range
  13117. * @param loop defines if the current animation must loop
  13118. * @param speedRatio defines the current speed ratio
  13119. * @param weight defines the weight of the animation (default is -1 so no weight)
  13120. * @param onLoop optional callback called when animation loops
  13121. * @returns a boolean indicating if the animation is running
  13122. */
  13123. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13124. }
  13125. }
  13126. declare module BABYLON {
  13127. /**
  13128. * Class used to store an actual running animation
  13129. */
  13130. export class Animatable {
  13131. /** defines the target object */
  13132. target: any;
  13133. /** defines the starting frame number (default is 0) */
  13134. fromFrame: number;
  13135. /** defines the ending frame number (default is 100) */
  13136. toFrame: number;
  13137. /** defines if the animation must loop (default is false) */
  13138. loopAnimation: boolean;
  13139. /** defines a callback to call when animation ends if it is not looping */
  13140. onAnimationEnd?: (() => void) | null | undefined;
  13141. /** defines a callback to call when animation loops */
  13142. onAnimationLoop?: (() => void) | null | undefined;
  13143. private _localDelayOffset;
  13144. private _pausedDelay;
  13145. private _runtimeAnimations;
  13146. private _paused;
  13147. private _scene;
  13148. private _speedRatio;
  13149. private _weight;
  13150. private _syncRoot;
  13151. /**
  13152. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13153. * This will only apply for non looping animation (default is true)
  13154. */
  13155. disposeOnEnd: boolean;
  13156. /**
  13157. * Gets a boolean indicating if the animation has started
  13158. */
  13159. animationStarted: boolean;
  13160. /**
  13161. * Observer raised when the animation ends
  13162. */
  13163. onAnimationEndObservable: Observable<Animatable>;
  13164. /**
  13165. * Observer raised when the animation loops
  13166. */
  13167. onAnimationLoopObservable: Observable<Animatable>;
  13168. /**
  13169. * Gets the root Animatable used to synchronize and normalize animations
  13170. */
  13171. get syncRoot(): Nullable<Animatable>;
  13172. /**
  13173. * Gets the current frame of the first RuntimeAnimation
  13174. * Used to synchronize Animatables
  13175. */
  13176. get masterFrame(): number;
  13177. /**
  13178. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13179. */
  13180. get weight(): number;
  13181. set weight(value: number);
  13182. /**
  13183. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13184. */
  13185. get speedRatio(): number;
  13186. set speedRatio(value: number);
  13187. /**
  13188. * Creates a new Animatable
  13189. * @param scene defines the hosting scene
  13190. * @param target defines the target object
  13191. * @param fromFrame defines the starting frame number (default is 0)
  13192. * @param toFrame defines the ending frame number (default is 100)
  13193. * @param loopAnimation defines if the animation must loop (default is false)
  13194. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13195. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13196. * @param animations defines a group of animation to add to the new Animatable
  13197. * @param onAnimationLoop defines a callback to call when animation loops
  13198. */
  13199. constructor(scene: Scene,
  13200. /** defines the target object */
  13201. target: any,
  13202. /** defines the starting frame number (default is 0) */
  13203. fromFrame?: number,
  13204. /** defines the ending frame number (default is 100) */
  13205. toFrame?: number,
  13206. /** defines if the animation must loop (default is false) */
  13207. loopAnimation?: boolean, speedRatio?: number,
  13208. /** defines a callback to call when animation ends if it is not looping */
  13209. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13210. /** defines a callback to call when animation loops */
  13211. onAnimationLoop?: (() => void) | null | undefined);
  13212. /**
  13213. * Synchronize and normalize current Animatable with a source Animatable
  13214. * This is useful when using animation weights and when animations are not of the same length
  13215. * @param root defines the root Animatable to synchronize with
  13216. * @returns the current Animatable
  13217. */
  13218. syncWith(root: Animatable): Animatable;
  13219. /**
  13220. * Gets the list of runtime animations
  13221. * @returns an array of RuntimeAnimation
  13222. */
  13223. getAnimations(): RuntimeAnimation[];
  13224. /**
  13225. * Adds more animations to the current animatable
  13226. * @param target defines the target of the animations
  13227. * @param animations defines the new animations to add
  13228. */
  13229. appendAnimations(target: any, animations: Animation[]): void;
  13230. /**
  13231. * Gets the source animation for a specific property
  13232. * @param property defines the propertyu to look for
  13233. * @returns null or the source animation for the given property
  13234. */
  13235. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13236. /**
  13237. * Gets the runtime animation for a specific property
  13238. * @param property defines the propertyu to look for
  13239. * @returns null or the runtime animation for the given property
  13240. */
  13241. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13242. /**
  13243. * Resets the animatable to its original state
  13244. */
  13245. reset(): void;
  13246. /**
  13247. * Allows the animatable to blend with current running animations
  13248. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13249. * @param blendingSpeed defines the blending speed to use
  13250. */
  13251. enableBlending(blendingSpeed: number): void;
  13252. /**
  13253. * Disable animation blending
  13254. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13255. */
  13256. disableBlending(): void;
  13257. /**
  13258. * Jump directly to a given frame
  13259. * @param frame defines the frame to jump to
  13260. */
  13261. goToFrame(frame: number): void;
  13262. /**
  13263. * Pause the animation
  13264. */
  13265. pause(): void;
  13266. /**
  13267. * Restart the animation
  13268. */
  13269. restart(): void;
  13270. private _raiseOnAnimationEnd;
  13271. /**
  13272. * Stop and delete the current animation
  13273. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13274. * @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)
  13275. */
  13276. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13277. /**
  13278. * Wait asynchronously for the animation to end
  13279. * @returns a promise which will be fullfilled when the animation ends
  13280. */
  13281. waitAsync(): Promise<Animatable>;
  13282. /** @hidden */
  13283. _animate(delay: number): boolean;
  13284. }
  13285. interface Scene {
  13286. /** @hidden */
  13287. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13288. /** @hidden */
  13289. _processLateAnimationBindingsForMatrices(holder: {
  13290. totalWeight: number;
  13291. animations: RuntimeAnimation[];
  13292. originalValue: Matrix;
  13293. }): any;
  13294. /** @hidden */
  13295. _processLateAnimationBindingsForQuaternions(holder: {
  13296. totalWeight: number;
  13297. animations: RuntimeAnimation[];
  13298. originalValue: Quaternion;
  13299. }, refQuaternion: Quaternion): Quaternion;
  13300. /** @hidden */
  13301. _processLateAnimationBindings(): void;
  13302. /**
  13303. * Will start the animation sequence of a given target
  13304. * @param target defines the target
  13305. * @param from defines from which frame should animation start
  13306. * @param to defines until which frame should animation run.
  13307. * @param weight defines the weight to apply to the animation (1.0 by default)
  13308. * @param loop defines if the animation loops
  13309. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13310. * @param onAnimationEnd defines the function to be executed when the animation ends
  13311. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13312. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13313. * @param onAnimationLoop defines the callback to call when an animation loops
  13314. * @returns the animatable object created for this animation
  13315. */
  13316. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13317. /**
  13318. * Will start the animation sequence of a given target
  13319. * @param target defines the target
  13320. * @param from defines from which frame should animation start
  13321. * @param to defines until which frame should animation run.
  13322. * @param loop defines if the animation loops
  13323. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13324. * @param onAnimationEnd defines the function to be executed when the animation ends
  13325. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13326. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13327. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13328. * @param onAnimationLoop defines the callback to call when an animation loops
  13329. * @returns the animatable object created for this animation
  13330. */
  13331. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13332. /**
  13333. * Will start the animation sequence of a given target and its hierarchy
  13334. * @param target defines the target
  13335. * @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.
  13336. * @param from defines from which frame should animation start
  13337. * @param to defines until which frame should animation run.
  13338. * @param loop defines if the animation loops
  13339. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13340. * @param onAnimationEnd defines the function to be executed when the animation ends
  13341. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13342. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13343. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13344. * @param onAnimationLoop defines the callback to call when an animation loops
  13345. * @returns the list of created animatables
  13346. */
  13347. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13348. /**
  13349. * Begin a new animation on a given node
  13350. * @param target defines the target where the animation will take place
  13351. * @param animations defines the list of animations to start
  13352. * @param from defines the initial value
  13353. * @param to defines the final value
  13354. * @param loop defines if you want animation to loop (off by default)
  13355. * @param speedRatio defines the speed ratio to apply to all animations
  13356. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13357. * @param onAnimationLoop defines the callback to call when an animation loops
  13358. * @returns the list of created animatables
  13359. */
  13360. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13361. /**
  13362. * Begin a new animation on a given node and its hierarchy
  13363. * @param target defines the root node where the animation will take place
  13364. * @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.
  13365. * @param animations defines the list of animations to start
  13366. * @param from defines the initial value
  13367. * @param to defines the final value
  13368. * @param loop defines if you want animation to loop (off by default)
  13369. * @param speedRatio defines the speed ratio to apply to all animations
  13370. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13371. * @param onAnimationLoop defines the callback to call when an animation loops
  13372. * @returns the list of animatables created for all nodes
  13373. */
  13374. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13375. /**
  13376. * Gets the animatable associated with a specific target
  13377. * @param target defines the target of the animatable
  13378. * @returns the required animatable if found
  13379. */
  13380. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13381. /**
  13382. * Gets all animatables associated with a given target
  13383. * @param target defines the target to look animatables for
  13384. * @returns an array of Animatables
  13385. */
  13386. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13387. /**
  13388. * Stops and removes all animations that have been applied to the scene
  13389. */
  13390. stopAllAnimations(): void;
  13391. /**
  13392. * Gets the current delta time used by animation engine
  13393. */
  13394. deltaTime: number;
  13395. }
  13396. interface Bone {
  13397. /**
  13398. * Copy an animation range from another bone
  13399. * @param source defines the source bone
  13400. * @param rangeName defines the range name to copy
  13401. * @param frameOffset defines the frame offset
  13402. * @param rescaleAsRequired defines if rescaling must be applied if required
  13403. * @param skelDimensionsRatio defines the scaling ratio
  13404. * @returns true if operation was successful
  13405. */
  13406. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13407. }
  13408. }
  13409. declare module BABYLON {
  13410. /**
  13411. * Class used to override all child animations of a given target
  13412. */
  13413. export class AnimationPropertiesOverride {
  13414. /**
  13415. * Gets or sets a value indicating if animation blending must be used
  13416. */
  13417. enableBlending: boolean;
  13418. /**
  13419. * Gets or sets the blending speed to use when enableBlending is true
  13420. */
  13421. blendingSpeed: number;
  13422. /**
  13423. * Gets or sets the default loop mode to use
  13424. */
  13425. loopMode: number;
  13426. }
  13427. }
  13428. declare module BABYLON {
  13429. /**
  13430. * Class used to handle skinning animations
  13431. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13432. */
  13433. export class Skeleton implements IAnimatable {
  13434. /** defines the skeleton name */
  13435. name: string;
  13436. /** defines the skeleton Id */
  13437. id: string;
  13438. /**
  13439. * Defines the list of child bones
  13440. */
  13441. bones: Bone[];
  13442. /**
  13443. * Defines an estimate of the dimension of the skeleton at rest
  13444. */
  13445. dimensionsAtRest: Vector3;
  13446. /**
  13447. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13448. */
  13449. needInitialSkinMatrix: boolean;
  13450. /**
  13451. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13452. */
  13453. overrideMesh: Nullable<AbstractMesh>;
  13454. /**
  13455. * Gets the list of animations attached to this skeleton
  13456. */
  13457. animations: Array<Animation>;
  13458. private _scene;
  13459. private _isDirty;
  13460. private _transformMatrices;
  13461. private _transformMatrixTexture;
  13462. private _meshesWithPoseMatrix;
  13463. private _animatables;
  13464. private _identity;
  13465. private _synchronizedWithMesh;
  13466. private _ranges;
  13467. private _lastAbsoluteTransformsUpdateId;
  13468. private _canUseTextureForBones;
  13469. private _uniqueId;
  13470. /** @hidden */
  13471. _numBonesWithLinkedTransformNode: number;
  13472. /** @hidden */
  13473. _hasWaitingData: Nullable<boolean>;
  13474. /**
  13475. * Specifies if the skeleton should be serialized
  13476. */
  13477. doNotSerialize: boolean;
  13478. private _useTextureToStoreBoneMatrices;
  13479. /**
  13480. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13481. * Please note that this option is not available if the hardware does not support it
  13482. */
  13483. get useTextureToStoreBoneMatrices(): boolean;
  13484. set useTextureToStoreBoneMatrices(value: boolean);
  13485. private _animationPropertiesOverride;
  13486. /**
  13487. * Gets or sets the animation properties override
  13488. */
  13489. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13490. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13491. /**
  13492. * List of inspectable custom properties (used by the Inspector)
  13493. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13494. */
  13495. inspectableCustomProperties: IInspectable[];
  13496. /**
  13497. * An observable triggered before computing the skeleton's matrices
  13498. */
  13499. onBeforeComputeObservable: Observable<Skeleton>;
  13500. /**
  13501. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13502. */
  13503. get isUsingTextureForMatrices(): boolean;
  13504. /**
  13505. * Gets the unique ID of this skeleton
  13506. */
  13507. get uniqueId(): number;
  13508. /**
  13509. * Creates a new skeleton
  13510. * @param name defines the skeleton name
  13511. * @param id defines the skeleton Id
  13512. * @param scene defines the hosting scene
  13513. */
  13514. constructor(
  13515. /** defines the skeleton name */
  13516. name: string,
  13517. /** defines the skeleton Id */
  13518. id: string, scene: Scene);
  13519. /**
  13520. * Gets the current object class name.
  13521. * @return the class name
  13522. */
  13523. getClassName(): string;
  13524. /**
  13525. * Returns an array containing the root bones
  13526. * @returns an array containing the root bones
  13527. */
  13528. getChildren(): Array<Bone>;
  13529. /**
  13530. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13531. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13532. * @returns a Float32Array containing matrices data
  13533. */
  13534. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13535. /**
  13536. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13537. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13538. * @returns a raw texture containing the data
  13539. */
  13540. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13541. /**
  13542. * Gets the current hosting scene
  13543. * @returns a scene object
  13544. */
  13545. getScene(): Scene;
  13546. /**
  13547. * Gets a string representing the current skeleton data
  13548. * @param fullDetails defines a boolean indicating if we want a verbose version
  13549. * @returns a string representing the current skeleton data
  13550. */
  13551. toString(fullDetails?: boolean): string;
  13552. /**
  13553. * Get bone's index searching by name
  13554. * @param name defines bone's name to search for
  13555. * @return the indice of the bone. Returns -1 if not found
  13556. */
  13557. getBoneIndexByName(name: string): number;
  13558. /**
  13559. * Creater a new animation range
  13560. * @param name defines the name of the range
  13561. * @param from defines the start key
  13562. * @param to defines the end key
  13563. */
  13564. createAnimationRange(name: string, from: number, to: number): void;
  13565. /**
  13566. * Delete a specific animation range
  13567. * @param name defines the name of the range
  13568. * @param deleteFrames defines if frames must be removed as well
  13569. */
  13570. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13571. /**
  13572. * Gets a specific animation range
  13573. * @param name defines the name of the range to look for
  13574. * @returns the requested animation range or null if not found
  13575. */
  13576. getAnimationRange(name: string): Nullable<AnimationRange>;
  13577. /**
  13578. * Gets the list of all animation ranges defined on this skeleton
  13579. * @returns an array
  13580. */
  13581. getAnimationRanges(): Nullable<AnimationRange>[];
  13582. /**
  13583. * Copy animation range from a source skeleton.
  13584. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13585. * @param source defines the source skeleton
  13586. * @param name defines the name of the range to copy
  13587. * @param rescaleAsRequired defines if rescaling must be applied if required
  13588. * @returns true if operation was successful
  13589. */
  13590. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13591. /**
  13592. * Forces the skeleton to go to rest pose
  13593. */
  13594. returnToRest(): void;
  13595. private _getHighestAnimationFrame;
  13596. /**
  13597. * Begin a specific animation range
  13598. * @param name defines the name of the range to start
  13599. * @param loop defines if looping must be turned on (false by default)
  13600. * @param speedRatio defines the speed ratio to apply (1 by default)
  13601. * @param onAnimationEnd defines a callback which will be called when animation will end
  13602. * @returns a new animatable
  13603. */
  13604. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13605. /** @hidden */
  13606. _markAsDirty(): void;
  13607. /** @hidden */
  13608. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13609. /** @hidden */
  13610. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13611. private _computeTransformMatrices;
  13612. /**
  13613. * Build all resources required to render a skeleton
  13614. */
  13615. prepare(): void;
  13616. /**
  13617. * Gets the list of animatables currently running for this skeleton
  13618. * @returns an array of animatables
  13619. */
  13620. getAnimatables(): IAnimatable[];
  13621. /**
  13622. * Clone the current skeleton
  13623. * @param name defines the name of the new skeleton
  13624. * @param id defines the id of the new skeleton
  13625. * @returns the new skeleton
  13626. */
  13627. clone(name: string, id?: string): Skeleton;
  13628. /**
  13629. * Enable animation blending for this skeleton
  13630. * @param blendingSpeed defines the blending speed to apply
  13631. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13632. */
  13633. enableBlending(blendingSpeed?: number): void;
  13634. /**
  13635. * Releases all resources associated with the current skeleton
  13636. */
  13637. dispose(): void;
  13638. /**
  13639. * Serialize the skeleton in a JSON object
  13640. * @returns a JSON object
  13641. */
  13642. serialize(): any;
  13643. /**
  13644. * Creates a new skeleton from serialized data
  13645. * @param parsedSkeleton defines the serialized data
  13646. * @param scene defines the hosting scene
  13647. * @returns a new skeleton
  13648. */
  13649. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13650. /**
  13651. * Compute all node absolute transforms
  13652. * @param forceUpdate defines if computation must be done even if cache is up to date
  13653. */
  13654. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13655. /**
  13656. * Gets the root pose matrix
  13657. * @returns a matrix
  13658. */
  13659. getPoseMatrix(): Nullable<Matrix>;
  13660. /**
  13661. * Sorts bones per internal index
  13662. */
  13663. sortBones(): void;
  13664. private _sortBones;
  13665. }
  13666. }
  13667. declare module BABYLON {
  13668. /**
  13669. * Class used to store bone information
  13670. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13671. */
  13672. export class Bone extends Node {
  13673. /**
  13674. * defines the bone name
  13675. */
  13676. name: string;
  13677. private static _tmpVecs;
  13678. private static _tmpQuat;
  13679. private static _tmpMats;
  13680. /**
  13681. * Gets the list of child bones
  13682. */
  13683. children: Bone[];
  13684. /** Gets the animations associated with this bone */
  13685. animations: Animation[];
  13686. /**
  13687. * Gets or sets bone length
  13688. */
  13689. length: number;
  13690. /**
  13691. * @hidden Internal only
  13692. * Set this value to map this bone to a different index in the transform matrices
  13693. * Set this value to -1 to exclude the bone from the transform matrices
  13694. */
  13695. _index: Nullable<number>;
  13696. private _skeleton;
  13697. private _localMatrix;
  13698. private _restPose;
  13699. private _baseMatrix;
  13700. private _absoluteTransform;
  13701. private _invertedAbsoluteTransform;
  13702. private _parent;
  13703. private _scalingDeterminant;
  13704. private _worldTransform;
  13705. private _localScaling;
  13706. private _localRotation;
  13707. private _localPosition;
  13708. private _needToDecompose;
  13709. private _needToCompose;
  13710. /** @hidden */
  13711. _linkedTransformNode: Nullable<TransformNode>;
  13712. /** @hidden */
  13713. _waitingTransformNodeId: Nullable<string>;
  13714. /** @hidden */
  13715. get _matrix(): Matrix;
  13716. /** @hidden */
  13717. set _matrix(value: Matrix);
  13718. /**
  13719. * Create a new bone
  13720. * @param name defines the bone name
  13721. * @param skeleton defines the parent skeleton
  13722. * @param parentBone defines the parent (can be null if the bone is the root)
  13723. * @param localMatrix defines the local matrix
  13724. * @param restPose defines the rest pose matrix
  13725. * @param baseMatrix defines the base matrix
  13726. * @param index defines index of the bone in the hiearchy
  13727. */
  13728. constructor(
  13729. /**
  13730. * defines the bone name
  13731. */
  13732. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13733. /**
  13734. * Gets the current object class name.
  13735. * @return the class name
  13736. */
  13737. getClassName(): string;
  13738. /**
  13739. * Gets the parent skeleton
  13740. * @returns a skeleton
  13741. */
  13742. getSkeleton(): Skeleton;
  13743. /**
  13744. * Gets parent bone
  13745. * @returns a bone or null if the bone is the root of the bone hierarchy
  13746. */
  13747. getParent(): Nullable<Bone>;
  13748. /**
  13749. * Returns an array containing the root bones
  13750. * @returns an array containing the root bones
  13751. */
  13752. getChildren(): Array<Bone>;
  13753. /**
  13754. * Gets the node index in matrix array generated for rendering
  13755. * @returns the node index
  13756. */
  13757. getIndex(): number;
  13758. /**
  13759. * Sets the parent bone
  13760. * @param parent defines the parent (can be null if the bone is the root)
  13761. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13762. */
  13763. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13764. /**
  13765. * Gets the local matrix
  13766. * @returns a matrix
  13767. */
  13768. getLocalMatrix(): Matrix;
  13769. /**
  13770. * Gets the base matrix (initial matrix which remains unchanged)
  13771. * @returns a matrix
  13772. */
  13773. getBaseMatrix(): Matrix;
  13774. /**
  13775. * Gets the rest pose matrix
  13776. * @returns a matrix
  13777. */
  13778. getRestPose(): Matrix;
  13779. /**
  13780. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13781. */
  13782. getWorldMatrix(): Matrix;
  13783. /**
  13784. * Sets the local matrix to rest pose matrix
  13785. */
  13786. returnToRest(): void;
  13787. /**
  13788. * Gets the inverse of the absolute transform matrix.
  13789. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13790. * @returns a matrix
  13791. */
  13792. getInvertedAbsoluteTransform(): Matrix;
  13793. /**
  13794. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13795. * @returns a matrix
  13796. */
  13797. getAbsoluteTransform(): Matrix;
  13798. /**
  13799. * Links with the given transform node.
  13800. * The local matrix of this bone is copied from the transform node every frame.
  13801. * @param transformNode defines the transform node to link to
  13802. */
  13803. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13804. /**
  13805. * Gets the node used to drive the bone's transformation
  13806. * @returns a transform node or null
  13807. */
  13808. getTransformNode(): Nullable<TransformNode>;
  13809. /** Gets or sets current position (in local space) */
  13810. get position(): Vector3;
  13811. set position(newPosition: Vector3);
  13812. /** Gets or sets current rotation (in local space) */
  13813. get rotation(): Vector3;
  13814. set rotation(newRotation: Vector3);
  13815. /** Gets or sets current rotation quaternion (in local space) */
  13816. get rotationQuaternion(): Quaternion;
  13817. set rotationQuaternion(newRotation: Quaternion);
  13818. /** Gets or sets current scaling (in local space) */
  13819. get scaling(): Vector3;
  13820. set scaling(newScaling: Vector3);
  13821. /**
  13822. * Gets the animation properties override
  13823. */
  13824. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13825. private _decompose;
  13826. private _compose;
  13827. /**
  13828. * Update the base and local matrices
  13829. * @param matrix defines the new base or local matrix
  13830. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13831. * @param updateLocalMatrix defines if the local matrix should be updated
  13832. */
  13833. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13834. /** @hidden */
  13835. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13836. /**
  13837. * Flag the bone as dirty (Forcing it to update everything)
  13838. */
  13839. markAsDirty(): void;
  13840. /** @hidden */
  13841. _markAsDirtyAndCompose(): void;
  13842. private _markAsDirtyAndDecompose;
  13843. /**
  13844. * Translate the bone in local or world space
  13845. * @param vec The amount to translate the bone
  13846. * @param space The space that the translation is in
  13847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13848. */
  13849. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13850. /**
  13851. * Set the postion of the bone in local or world space
  13852. * @param position The position to set the bone
  13853. * @param space The space that the position is in
  13854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13855. */
  13856. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13857. /**
  13858. * Set the absolute position of the bone (world space)
  13859. * @param position The position to set the bone
  13860. * @param mesh The mesh that this bone is attached to
  13861. */
  13862. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13863. /**
  13864. * Scale the bone on the x, y and z axes (in local space)
  13865. * @param x The amount to scale the bone on the x axis
  13866. * @param y The amount to scale the bone on the y axis
  13867. * @param z The amount to scale the bone on the z axis
  13868. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13869. */
  13870. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13871. /**
  13872. * Set the bone scaling in local space
  13873. * @param scale defines the scaling vector
  13874. */
  13875. setScale(scale: Vector3): void;
  13876. /**
  13877. * Gets the current scaling in local space
  13878. * @returns the current scaling vector
  13879. */
  13880. getScale(): Vector3;
  13881. /**
  13882. * Gets the current scaling in local space and stores it in a target vector
  13883. * @param result defines the target vector
  13884. */
  13885. getScaleToRef(result: Vector3): void;
  13886. /**
  13887. * Set the yaw, pitch, and roll of the bone in local or world space
  13888. * @param yaw The rotation of the bone on the y axis
  13889. * @param pitch The rotation of the bone on the x axis
  13890. * @param roll The rotation of the bone on the z axis
  13891. * @param space The space that the axes of rotation are in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. */
  13894. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13895. /**
  13896. * Add a rotation to the bone on an axis in local or world space
  13897. * @param axis The axis to rotate the bone on
  13898. * @param amount The amount to rotate the bone
  13899. * @param space The space that the axis is in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. */
  13902. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13903. /**
  13904. * Set the rotation of the bone to a particular axis angle in local or world space
  13905. * @param axis The axis to rotate the bone on
  13906. * @param angle The angle that the bone should be rotated to
  13907. * @param space The space that the axis is in
  13908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13909. */
  13910. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13911. /**
  13912. * Set the euler rotation of the bone in local of world space
  13913. * @param rotation The euler rotation that the bone should be set to
  13914. * @param space The space that the rotation is in
  13915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13916. */
  13917. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13918. /**
  13919. * Set the quaternion rotation of the bone in local of world space
  13920. * @param quat The quaternion rotation that the bone should be set to
  13921. * @param space The space that the rotation is in
  13922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13923. */
  13924. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13925. /**
  13926. * Set the rotation matrix of the bone in local of world space
  13927. * @param rotMat The rotation matrix that the bone should be set to
  13928. * @param space The space that the rotation is in
  13929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13930. */
  13931. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13932. private _rotateWithMatrix;
  13933. private _getNegativeRotationToRef;
  13934. /**
  13935. * Get the position of the bone in local or world space
  13936. * @param space The space that the returned position is in
  13937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13938. * @returns The position of the bone
  13939. */
  13940. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13941. /**
  13942. * Copy the position of the bone to a vector3 in local or world space
  13943. * @param space The space that the returned position is in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. * @param result The vector3 to copy the position to
  13946. */
  13947. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13948. /**
  13949. * Get the absolute position of the bone (world space)
  13950. * @param mesh The mesh that this bone is attached to
  13951. * @returns The absolute position of the bone
  13952. */
  13953. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13954. /**
  13955. * Copy the absolute position of the bone (world space) to the result param
  13956. * @param mesh The mesh that this bone is attached to
  13957. * @param result The vector3 to copy the absolute position to
  13958. */
  13959. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13960. /**
  13961. * Compute the absolute transforms of this bone and its children
  13962. */
  13963. computeAbsoluteTransforms(): void;
  13964. /**
  13965. * Get the world direction from an axis that is in the local space of the bone
  13966. * @param localAxis The local direction that is used to compute the world direction
  13967. * @param mesh The mesh that this bone is attached to
  13968. * @returns The world direction
  13969. */
  13970. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13971. /**
  13972. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13973. * @param localAxis The local direction that is used to compute the world direction
  13974. * @param mesh The mesh that this bone is attached to
  13975. * @param result The vector3 that the world direction will be copied to
  13976. */
  13977. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13978. /**
  13979. * Get the euler rotation of the bone in local or world space
  13980. * @param space The space that the rotation should be in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. * @returns The euler rotation
  13983. */
  13984. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13985. /**
  13986. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13987. * @param space The space that the rotation should be in
  13988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13989. * @param result The vector3 that the rotation should be copied to
  13990. */
  13991. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13992. /**
  13993. * Get the quaternion rotation of the bone in either local or world space
  13994. * @param space The space that the rotation should be in
  13995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13996. * @returns The quaternion rotation
  13997. */
  13998. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13999. /**
  14000. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14001. * @param space The space that the rotation should be in
  14002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14003. * @param result The quaternion that the rotation should be copied to
  14004. */
  14005. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14006. /**
  14007. * Get the rotation matrix of the bone in local or world space
  14008. * @param space The space that the rotation should be in
  14009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14010. * @returns The rotation matrix
  14011. */
  14012. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14013. /**
  14014. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14015. * @param space The space that the rotation should be in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. * @param result The quaternion that the rotation should be copied to
  14018. */
  14019. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14020. /**
  14021. * Get the world position of a point that is in the local space of the bone
  14022. * @param position The local position
  14023. * @param mesh The mesh that this bone is attached to
  14024. * @returns The world position
  14025. */
  14026. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14029. * @param position The local position
  14030. * @param mesh The mesh that this bone is attached to
  14031. * @param result The vector3 that the world position should be copied to
  14032. */
  14033. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14034. /**
  14035. * Get the local position of a point that is in world space
  14036. * @param position The world position
  14037. * @param mesh The mesh that this bone is attached to
  14038. * @returns The local position
  14039. */
  14040. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14041. /**
  14042. * Get the local position of a point that is in world space and copy it to the result param
  14043. * @param position The world position
  14044. * @param mesh The mesh that this bone is attached to
  14045. * @param result The vector3 that the local position should be copied to
  14046. */
  14047. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14048. }
  14049. }
  14050. declare module BABYLON {
  14051. /**
  14052. * 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.
  14053. * @see https://doc.babylonjs.com/how_to/transformnode
  14054. */
  14055. export class TransformNode extends Node {
  14056. /**
  14057. * Object will not rotate to face the camera
  14058. */
  14059. static BILLBOARDMODE_NONE: number;
  14060. /**
  14061. * Object will rotate to face the camera but only on the x axis
  14062. */
  14063. static BILLBOARDMODE_X: number;
  14064. /**
  14065. * Object will rotate to face the camera but only on the y axis
  14066. */
  14067. static BILLBOARDMODE_Y: number;
  14068. /**
  14069. * Object will rotate to face the camera but only on the z axis
  14070. */
  14071. static BILLBOARDMODE_Z: number;
  14072. /**
  14073. * Object will rotate to face the camera
  14074. */
  14075. static BILLBOARDMODE_ALL: number;
  14076. /**
  14077. * Object will rotate to face the camera's position instead of orientation
  14078. */
  14079. static BILLBOARDMODE_USE_POSITION: number;
  14080. private _forward;
  14081. private _forwardInverted;
  14082. private _up;
  14083. private _right;
  14084. private _rightInverted;
  14085. private _position;
  14086. private _rotation;
  14087. private _rotationQuaternion;
  14088. protected _scaling: Vector3;
  14089. protected _isDirty: boolean;
  14090. private _transformToBoneReferal;
  14091. private _isAbsoluteSynced;
  14092. private _billboardMode;
  14093. /**
  14094. * Gets or sets the billboard mode. Default is 0.
  14095. *
  14096. * | Value | Type | Description |
  14097. * | --- | --- | --- |
  14098. * | 0 | BILLBOARDMODE_NONE | |
  14099. * | 1 | BILLBOARDMODE_X | |
  14100. * | 2 | BILLBOARDMODE_Y | |
  14101. * | 4 | BILLBOARDMODE_Z | |
  14102. * | 7 | BILLBOARDMODE_ALL | |
  14103. *
  14104. */
  14105. get billboardMode(): number;
  14106. set billboardMode(value: number);
  14107. private _preserveParentRotationForBillboard;
  14108. /**
  14109. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14110. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14111. */
  14112. get preserveParentRotationForBillboard(): boolean;
  14113. set preserveParentRotationForBillboard(value: boolean);
  14114. /**
  14115. * 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
  14116. */
  14117. scalingDeterminant: number;
  14118. private _infiniteDistance;
  14119. /**
  14120. * Gets or sets the distance of the object to max, often used by skybox
  14121. */
  14122. get infiniteDistance(): boolean;
  14123. set infiniteDistance(value: boolean);
  14124. /**
  14125. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14126. * By default the system will update normals to compensate
  14127. */
  14128. ignoreNonUniformScaling: boolean;
  14129. /**
  14130. * 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
  14131. */
  14132. reIntegrateRotationIntoRotationQuaternion: boolean;
  14133. /** @hidden */
  14134. _poseMatrix: Nullable<Matrix>;
  14135. /** @hidden */
  14136. _localMatrix: Matrix;
  14137. private _usePivotMatrix;
  14138. private _absolutePosition;
  14139. private _absoluteScaling;
  14140. private _absoluteRotationQuaternion;
  14141. private _pivotMatrix;
  14142. private _pivotMatrixInverse;
  14143. protected _postMultiplyPivotMatrix: boolean;
  14144. protected _isWorldMatrixFrozen: boolean;
  14145. /** @hidden */
  14146. _indexInSceneTransformNodesArray: number;
  14147. /**
  14148. * An event triggered after the world matrix is updated
  14149. */
  14150. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14151. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14152. /**
  14153. * Gets a string identifying the name of the class
  14154. * @returns "TransformNode" string
  14155. */
  14156. getClassName(): string;
  14157. /**
  14158. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14159. */
  14160. get position(): Vector3;
  14161. set position(newPosition: Vector3);
  14162. /**
  14163. * 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)).
  14164. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14165. */
  14166. get rotation(): Vector3;
  14167. set rotation(newRotation: Vector3);
  14168. /**
  14169. * 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)).
  14170. */
  14171. get scaling(): Vector3;
  14172. set scaling(newScaling: Vector3);
  14173. /**
  14174. * 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).
  14175. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14176. */
  14177. get rotationQuaternion(): Nullable<Quaternion>;
  14178. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14179. /**
  14180. * The forward direction of that transform in world space.
  14181. */
  14182. get forward(): Vector3;
  14183. /**
  14184. * The up direction of that transform in world space.
  14185. */
  14186. get up(): Vector3;
  14187. /**
  14188. * The right direction of that transform in world space.
  14189. */
  14190. get right(): Vector3;
  14191. /**
  14192. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14193. * @param matrix the matrix to copy the pose from
  14194. * @returns this TransformNode.
  14195. */
  14196. updatePoseMatrix(matrix: Matrix): TransformNode;
  14197. /**
  14198. * Returns the mesh Pose matrix.
  14199. * @returns the pose matrix
  14200. */
  14201. getPoseMatrix(): Matrix;
  14202. /** @hidden */
  14203. _isSynchronized(): boolean;
  14204. /** @hidden */
  14205. _initCache(): void;
  14206. /**
  14207. * Flag the transform node as dirty (Forcing it to update everything)
  14208. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14209. * @returns this transform node
  14210. */
  14211. markAsDirty(property: string): TransformNode;
  14212. /**
  14213. * Returns the current mesh absolute position.
  14214. * Returns a Vector3.
  14215. */
  14216. get absolutePosition(): Vector3;
  14217. /**
  14218. * Returns the current mesh absolute scaling.
  14219. * Returns a Vector3.
  14220. */
  14221. get absoluteScaling(): Vector3;
  14222. /**
  14223. * Returns the current mesh absolute rotation.
  14224. * Returns a Quaternion.
  14225. */
  14226. get absoluteRotationQuaternion(): Quaternion;
  14227. /**
  14228. * Sets a new matrix to apply before all other transformation
  14229. * @param matrix defines the transform matrix
  14230. * @returns the current TransformNode
  14231. */
  14232. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14233. /**
  14234. * Sets a new pivot matrix to the current node
  14235. * @param matrix defines the new pivot matrix to use
  14236. * @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
  14237. * @returns the current TransformNode
  14238. */
  14239. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14240. /**
  14241. * Returns the mesh pivot matrix.
  14242. * Default : Identity.
  14243. * @returns the matrix
  14244. */
  14245. getPivotMatrix(): Matrix;
  14246. /**
  14247. * Instantiate (when possible) or clone that node with its hierarchy
  14248. * @param newParent defines the new parent to use for the instance (or clone)
  14249. * @param options defines options to configure how copy is done
  14250. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14251. * @returns an instance (or a clone) of the current node with its hiearchy
  14252. */
  14253. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14254. doNotInstantiate: boolean;
  14255. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14256. /**
  14257. * Prevents the World matrix to be computed any longer
  14258. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14259. * @returns the TransformNode.
  14260. */
  14261. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14262. /**
  14263. * Allows back the World matrix computation.
  14264. * @returns the TransformNode.
  14265. */
  14266. unfreezeWorldMatrix(): this;
  14267. /**
  14268. * True if the World matrix has been frozen.
  14269. */
  14270. get isWorldMatrixFrozen(): boolean;
  14271. /**
  14272. * Retuns the mesh absolute position in the World.
  14273. * @returns a Vector3.
  14274. */
  14275. getAbsolutePosition(): Vector3;
  14276. /**
  14277. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14278. * @param absolutePosition the absolute position to set
  14279. * @returns the TransformNode.
  14280. */
  14281. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14282. /**
  14283. * Sets the mesh position in its local space.
  14284. * @param vector3 the position to set in localspace
  14285. * @returns the TransformNode.
  14286. */
  14287. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14288. /**
  14289. * Returns the mesh position in the local space from the current World matrix values.
  14290. * @returns a new Vector3.
  14291. */
  14292. getPositionExpressedInLocalSpace(): Vector3;
  14293. /**
  14294. * Translates the mesh along the passed Vector3 in its local space.
  14295. * @param vector3 the distance to translate in localspace
  14296. * @returns the TransformNode.
  14297. */
  14298. locallyTranslate(vector3: Vector3): TransformNode;
  14299. private static _lookAtVectorCache;
  14300. /**
  14301. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14302. * @param targetPoint the position (must be in same space as current mesh) to look at
  14303. * @param yawCor optional yaw (y-axis) correction in radians
  14304. * @param pitchCor optional pitch (x-axis) correction in radians
  14305. * @param rollCor optional roll (z-axis) correction in radians
  14306. * @param space the choosen space of the target
  14307. * @returns the TransformNode.
  14308. */
  14309. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14310. /**
  14311. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14312. * This Vector3 is expressed in the World space.
  14313. * @param localAxis axis to rotate
  14314. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14315. */
  14316. getDirection(localAxis: Vector3): Vector3;
  14317. /**
  14318. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14319. * localAxis is expressed in the mesh local space.
  14320. * result is computed in the Wordl space from the mesh World matrix.
  14321. * @param localAxis axis to rotate
  14322. * @param result the resulting transformnode
  14323. * @returns this TransformNode.
  14324. */
  14325. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14326. /**
  14327. * Sets this transform node rotation to the given local axis.
  14328. * @param localAxis the axis in local space
  14329. * @param yawCor optional yaw (y-axis) correction in radians
  14330. * @param pitchCor optional pitch (x-axis) correction in radians
  14331. * @param rollCor optional roll (z-axis) correction in radians
  14332. * @returns this TransformNode
  14333. */
  14334. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14335. /**
  14336. * Sets a new pivot point to the current node
  14337. * @param point defines the new pivot point to use
  14338. * @param space defines if the point is in world or local space (local by default)
  14339. * @returns the current TransformNode
  14340. */
  14341. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14342. /**
  14343. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14344. * @returns the pivot point
  14345. */
  14346. getPivotPoint(): Vector3;
  14347. /**
  14348. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14349. * @param result the vector3 to store the result
  14350. * @returns this TransformNode.
  14351. */
  14352. getPivotPointToRef(result: Vector3): TransformNode;
  14353. /**
  14354. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14355. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14356. */
  14357. getAbsolutePivotPoint(): Vector3;
  14358. /**
  14359. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14360. * @param result vector3 to store the result
  14361. * @returns this TransformNode.
  14362. */
  14363. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14364. /**
  14365. * Defines the passed node as the parent of the current node.
  14366. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14367. * @see https://doc.babylonjs.com/how_to/parenting
  14368. * @param node the node ot set as the parent
  14369. * @returns this TransformNode.
  14370. */
  14371. setParent(node: Nullable<Node>): TransformNode;
  14372. private _nonUniformScaling;
  14373. /**
  14374. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14375. */
  14376. get nonUniformScaling(): boolean;
  14377. /** @hidden */
  14378. _updateNonUniformScalingState(value: boolean): boolean;
  14379. /**
  14380. * Attach the current TransformNode to another TransformNode associated with a bone
  14381. * @param bone Bone affecting the TransformNode
  14382. * @param affectedTransformNode TransformNode associated with the bone
  14383. * @returns this object
  14384. */
  14385. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14386. /**
  14387. * Detach the transform node if its associated with a bone
  14388. * @returns this object
  14389. */
  14390. detachFromBone(): TransformNode;
  14391. private static _rotationAxisCache;
  14392. /**
  14393. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14394. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14395. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14396. * The passed axis is also normalized.
  14397. * @param axis the axis to rotate around
  14398. * @param amount the amount to rotate in radians
  14399. * @param space Space to rotate in (Default: local)
  14400. * @returns the TransformNode.
  14401. */
  14402. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14403. /**
  14404. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14405. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14406. * The passed axis is also normalized. .
  14407. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14408. * @param point the point to rotate around
  14409. * @param axis the axis to rotate around
  14410. * @param amount the amount to rotate in radians
  14411. * @returns the TransformNode
  14412. */
  14413. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14414. /**
  14415. * Translates the mesh along the axis vector for the passed distance in the given space.
  14416. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14417. * @param axis the axis to translate in
  14418. * @param distance the distance to translate
  14419. * @param space Space to rotate in (Default: local)
  14420. * @returns the TransformNode.
  14421. */
  14422. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14423. /**
  14424. * Adds a rotation step to the mesh current rotation.
  14425. * x, y, z are Euler angles expressed in radians.
  14426. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14427. * This means this rotation is made in the mesh local space only.
  14428. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14429. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14430. * ```javascript
  14431. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14432. * ```
  14433. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14434. * 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.
  14435. * @param x Rotation to add
  14436. * @param y Rotation to add
  14437. * @param z Rotation to add
  14438. * @returns the TransformNode.
  14439. */
  14440. addRotation(x: number, y: number, z: number): TransformNode;
  14441. /**
  14442. * @hidden
  14443. */
  14444. protected _getEffectiveParent(): Nullable<Node>;
  14445. /**
  14446. * Computes the world matrix of the node
  14447. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14448. * @returns the world matrix
  14449. */
  14450. computeWorldMatrix(force?: boolean): Matrix;
  14451. protected _afterComputeWorldMatrix(): void;
  14452. /**
  14453. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14454. * @param func callback function to add
  14455. *
  14456. * @returns the TransformNode.
  14457. */
  14458. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14459. /**
  14460. * Removes a registered callback function.
  14461. * @param func callback function to remove
  14462. * @returns the TransformNode.
  14463. */
  14464. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14465. /**
  14466. * Gets the position of the current mesh in camera space
  14467. * @param camera defines the camera to use
  14468. * @returns a position
  14469. */
  14470. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14471. /**
  14472. * Returns the distance from the mesh to the active camera
  14473. * @param camera defines the camera to use
  14474. * @returns the distance
  14475. */
  14476. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14477. /**
  14478. * Clone the current transform node
  14479. * @param name Name of the new clone
  14480. * @param newParent New parent for the clone
  14481. * @param doNotCloneChildren Do not clone children hierarchy
  14482. * @returns the new transform node
  14483. */
  14484. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14485. /**
  14486. * Serializes the objects information.
  14487. * @param currentSerializationObject defines the object to serialize in
  14488. * @returns the serialized object
  14489. */
  14490. serialize(currentSerializationObject?: any): any;
  14491. /**
  14492. * Returns a new TransformNode object parsed from the source provided.
  14493. * @param parsedTransformNode is the source.
  14494. * @param scene the scne the object belongs to
  14495. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14496. * @returns a new TransformNode object parsed from the source provided.
  14497. */
  14498. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14499. /**
  14500. * Get all child-transformNodes of this node
  14501. * @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
  14502. * @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
  14503. * @returns an array of TransformNode
  14504. */
  14505. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14506. /**
  14507. * Releases resources associated with this transform node.
  14508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14510. */
  14511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14512. /**
  14513. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14514. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14515. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14516. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14517. * @returns the current mesh
  14518. */
  14519. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14520. private _syncAbsoluteScalingAndRotation;
  14521. }
  14522. }
  14523. declare module BABYLON {
  14524. /**
  14525. * Defines the types of pose enabled controllers that are supported
  14526. */
  14527. export enum PoseEnabledControllerType {
  14528. /**
  14529. * HTC Vive
  14530. */
  14531. VIVE = 0,
  14532. /**
  14533. * Oculus Rift
  14534. */
  14535. OCULUS = 1,
  14536. /**
  14537. * Windows mixed reality
  14538. */
  14539. WINDOWS = 2,
  14540. /**
  14541. * Samsung gear VR
  14542. */
  14543. GEAR_VR = 3,
  14544. /**
  14545. * Google Daydream
  14546. */
  14547. DAYDREAM = 4,
  14548. /**
  14549. * Generic
  14550. */
  14551. GENERIC = 5
  14552. }
  14553. /**
  14554. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14555. */
  14556. export interface MutableGamepadButton {
  14557. /**
  14558. * Value of the button/trigger
  14559. */
  14560. value: number;
  14561. /**
  14562. * If the button/trigger is currently touched
  14563. */
  14564. touched: boolean;
  14565. /**
  14566. * If the button/trigger is currently pressed
  14567. */
  14568. pressed: boolean;
  14569. }
  14570. /**
  14571. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14572. * @hidden
  14573. */
  14574. export interface ExtendedGamepadButton extends GamepadButton {
  14575. /**
  14576. * If the button/trigger is currently pressed
  14577. */
  14578. readonly pressed: boolean;
  14579. /**
  14580. * If the button/trigger is currently touched
  14581. */
  14582. readonly touched: boolean;
  14583. /**
  14584. * Value of the button/trigger
  14585. */
  14586. readonly value: number;
  14587. }
  14588. /** @hidden */
  14589. export interface _GamePadFactory {
  14590. /**
  14591. * Returns wether or not the current gamepad can be created for this type of controller.
  14592. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14593. * @returns true if it can be created, otherwise false
  14594. */
  14595. canCreate(gamepadInfo: any): boolean;
  14596. /**
  14597. * Creates a new instance of the Gamepad.
  14598. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14599. * @returns the new gamepad instance
  14600. */
  14601. create(gamepadInfo: any): Gamepad;
  14602. }
  14603. /**
  14604. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14605. */
  14606. export class PoseEnabledControllerHelper {
  14607. /** @hidden */
  14608. static _ControllerFactories: _GamePadFactory[];
  14609. /** @hidden */
  14610. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14611. /**
  14612. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14613. * @param vrGamepad the gamepad to initialized
  14614. * @returns a vr controller of the type the gamepad identified as
  14615. */
  14616. static InitiateController(vrGamepad: any): Gamepad;
  14617. }
  14618. /**
  14619. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14620. */
  14621. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14622. /**
  14623. * If the controller is used in a webXR session
  14624. */
  14625. isXR: boolean;
  14626. private _deviceRoomPosition;
  14627. private _deviceRoomRotationQuaternion;
  14628. /**
  14629. * The device position in babylon space
  14630. */
  14631. devicePosition: Vector3;
  14632. /**
  14633. * The device rotation in babylon space
  14634. */
  14635. deviceRotationQuaternion: Quaternion;
  14636. /**
  14637. * The scale factor of the device in babylon space
  14638. */
  14639. deviceScaleFactor: number;
  14640. /**
  14641. * (Likely devicePosition should be used instead) The device position in its room space
  14642. */
  14643. position: Vector3;
  14644. /**
  14645. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14646. */
  14647. rotationQuaternion: Quaternion;
  14648. /**
  14649. * The type of controller (Eg. Windows mixed reality)
  14650. */
  14651. controllerType: PoseEnabledControllerType;
  14652. protected _calculatedPosition: Vector3;
  14653. private _calculatedRotation;
  14654. /**
  14655. * The raw pose from the device
  14656. */
  14657. rawPose: DevicePose;
  14658. private _trackPosition;
  14659. private _maxRotationDistFromHeadset;
  14660. private _draggedRoomRotation;
  14661. /**
  14662. * @hidden
  14663. */
  14664. _disableTrackPosition(fixedPosition: Vector3): void;
  14665. /**
  14666. * Internal, the mesh attached to the controller
  14667. * @hidden
  14668. */
  14669. _mesh: Nullable<AbstractMesh>;
  14670. private _poseControlledCamera;
  14671. private _leftHandSystemQuaternion;
  14672. /**
  14673. * Internal, matrix used to convert room space to babylon space
  14674. * @hidden
  14675. */
  14676. _deviceToWorld: Matrix;
  14677. /**
  14678. * Node to be used when casting a ray from the controller
  14679. * @hidden
  14680. */
  14681. _pointingPoseNode: Nullable<TransformNode>;
  14682. /**
  14683. * Name of the child mesh that can be used to cast a ray from the controller
  14684. */
  14685. static readonly POINTING_POSE: string;
  14686. /**
  14687. * Creates a new PoseEnabledController from a gamepad
  14688. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14689. */
  14690. constructor(browserGamepad: any);
  14691. private _workingMatrix;
  14692. /**
  14693. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14694. */
  14695. update(): void;
  14696. /**
  14697. * Updates only the pose device and mesh without doing any button event checking
  14698. */
  14699. protected _updatePoseAndMesh(): void;
  14700. /**
  14701. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14702. * @param poseData raw pose fromthe device
  14703. */
  14704. updateFromDevice(poseData: DevicePose): void;
  14705. /**
  14706. * @hidden
  14707. */
  14708. _meshAttachedObservable: Observable<AbstractMesh>;
  14709. /**
  14710. * Attaches a mesh to the controller
  14711. * @param mesh the mesh to be attached
  14712. */
  14713. attachToMesh(mesh: AbstractMesh): void;
  14714. /**
  14715. * Attaches the controllers mesh to a camera
  14716. * @param camera the camera the mesh should be attached to
  14717. */
  14718. attachToPoseControlledCamera(camera: TargetCamera): void;
  14719. /**
  14720. * Disposes of the controller
  14721. */
  14722. dispose(): void;
  14723. /**
  14724. * The mesh that is attached to the controller
  14725. */
  14726. get mesh(): Nullable<AbstractMesh>;
  14727. /**
  14728. * Gets the ray of the controller in the direction the controller is pointing
  14729. * @param length the length the resulting ray should be
  14730. * @returns a ray in the direction the controller is pointing
  14731. */
  14732. getForwardRay(length?: number): Ray;
  14733. }
  14734. }
  14735. declare module BABYLON {
  14736. /**
  14737. * Defines the WebVRController object that represents controllers tracked in 3D space
  14738. */
  14739. export abstract class WebVRController extends PoseEnabledController {
  14740. /**
  14741. * Internal, the default controller model for the controller
  14742. */
  14743. protected _defaultModel: Nullable<AbstractMesh>;
  14744. /**
  14745. * Fired when the trigger state has changed
  14746. */
  14747. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14748. /**
  14749. * Fired when the main button state has changed
  14750. */
  14751. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14752. /**
  14753. * Fired when the secondary button state has changed
  14754. */
  14755. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14756. /**
  14757. * Fired when the pad state has changed
  14758. */
  14759. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14760. /**
  14761. * Fired when controllers stick values have changed
  14762. */
  14763. onPadValuesChangedObservable: Observable<StickValues>;
  14764. /**
  14765. * Array of button availible on the controller
  14766. */
  14767. protected _buttons: Array<MutableGamepadButton>;
  14768. private _onButtonStateChange;
  14769. /**
  14770. * Fired when a controller button's state has changed
  14771. * @param callback the callback containing the button that was modified
  14772. */
  14773. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14774. /**
  14775. * X and Y axis corresponding to the controllers joystick
  14776. */
  14777. pad: StickValues;
  14778. /**
  14779. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14780. */
  14781. hand: string;
  14782. /**
  14783. * The default controller model for the controller
  14784. */
  14785. get defaultModel(): Nullable<AbstractMesh>;
  14786. /**
  14787. * Creates a new WebVRController from a gamepad
  14788. * @param vrGamepad the gamepad that the WebVRController should be created from
  14789. */
  14790. constructor(vrGamepad: any);
  14791. /**
  14792. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14793. */
  14794. update(): void;
  14795. /**
  14796. * Function to be called when a button is modified
  14797. */
  14798. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14799. /**
  14800. * Loads a mesh and attaches it to the controller
  14801. * @param scene the scene the mesh should be added to
  14802. * @param meshLoaded callback for when the mesh has been loaded
  14803. */
  14804. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14805. private _setButtonValue;
  14806. private _changes;
  14807. private _checkChanges;
  14808. /**
  14809. * Disposes of th webVRCOntroller
  14810. */
  14811. dispose(): void;
  14812. }
  14813. }
  14814. declare module BABYLON {
  14815. /**
  14816. * The HemisphericLight simulates the ambient environment light,
  14817. * so the passed direction is the light reflection direction, not the incoming direction.
  14818. */
  14819. export class HemisphericLight extends Light {
  14820. /**
  14821. * The groundColor is the light in the opposite direction to the one specified during creation.
  14822. * 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.
  14823. */
  14824. groundColor: Color3;
  14825. /**
  14826. * The light reflection direction, not the incoming direction.
  14827. */
  14828. direction: Vector3;
  14829. /**
  14830. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14831. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14832. * The HemisphericLight can't cast shadows.
  14833. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14834. * @param name The friendly name of the light
  14835. * @param direction The direction of the light reflection
  14836. * @param scene The scene the light belongs to
  14837. */
  14838. constructor(name: string, direction: Vector3, scene: Scene);
  14839. protected _buildUniformLayout(): void;
  14840. /**
  14841. * Returns the string "HemisphericLight".
  14842. * @return The class name
  14843. */
  14844. getClassName(): string;
  14845. /**
  14846. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14847. * Returns the updated direction.
  14848. * @param target The target the direction should point to
  14849. * @return The computed direction
  14850. */
  14851. setDirectionToTarget(target: Vector3): Vector3;
  14852. /**
  14853. * Returns the shadow generator associated to the light.
  14854. * @returns Always null for hemispheric lights because it does not support shadows.
  14855. */
  14856. getShadowGenerator(): Nullable<IShadowGenerator>;
  14857. /**
  14858. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14859. * @param effect The effect to update
  14860. * @param lightIndex The index of the light in the effect to update
  14861. * @returns The hemispheric light
  14862. */
  14863. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14864. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14865. /**
  14866. * Computes the world matrix of the node
  14867. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14868. * @param useWasUpdatedFlag defines a reserved property
  14869. * @returns the world matrix
  14870. */
  14871. computeWorldMatrix(): Matrix;
  14872. /**
  14873. * Returns the integer 3.
  14874. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14875. */
  14876. getTypeID(): number;
  14877. /**
  14878. * Prepares the list of defines specific to the light type.
  14879. * @param defines the list of defines
  14880. * @param lightIndex defines the index of the light for the effect
  14881. */
  14882. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14883. }
  14884. }
  14885. declare module BABYLON {
  14886. /** @hidden */
  14887. export var vrMultiviewToSingleviewPixelShader: {
  14888. name: string;
  14889. shader: string;
  14890. };
  14891. }
  14892. declare module BABYLON {
  14893. /**
  14894. * Renders to multiple views with a single draw call
  14895. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14896. */
  14897. export class MultiviewRenderTarget extends RenderTargetTexture {
  14898. /**
  14899. * Creates a multiview render target
  14900. * @param scene scene used with the render target
  14901. * @param size the size of the render target (used for each view)
  14902. */
  14903. constructor(scene: Scene, size?: number | {
  14904. width: number;
  14905. height: number;
  14906. } | {
  14907. ratio: number;
  14908. });
  14909. /**
  14910. * @hidden
  14911. * @param faceIndex the face index, if its a cube texture
  14912. */
  14913. _bindFrameBuffer(faceIndex?: number): void;
  14914. /**
  14915. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14916. * @returns the view count
  14917. */
  14918. getViewCount(): number;
  14919. }
  14920. }
  14921. declare module BABYLON {
  14922. /**
  14923. * Represents a camera frustum
  14924. */
  14925. export class Frustum {
  14926. /**
  14927. * Gets the planes representing the frustum
  14928. * @param transform matrix to be applied to the returned planes
  14929. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14930. */
  14931. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14932. /**
  14933. * Gets the near frustum plane transformed by the transform matrix
  14934. * @param transform transformation matrix to be applied to the resulting frustum plane
  14935. * @param frustumPlane the resuling frustum plane
  14936. */
  14937. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14938. /**
  14939. * Gets the far frustum plane transformed by the transform matrix
  14940. * @param transform transformation matrix to be applied to the resulting frustum plane
  14941. * @param frustumPlane the resuling frustum plane
  14942. */
  14943. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14944. /**
  14945. * Gets the left frustum plane transformed by the transform matrix
  14946. * @param transform transformation matrix to be applied to the resulting frustum plane
  14947. * @param frustumPlane the resuling frustum plane
  14948. */
  14949. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14950. /**
  14951. * Gets the right frustum plane transformed by the transform matrix
  14952. * @param transform transformation matrix to be applied to the resulting frustum plane
  14953. * @param frustumPlane the resuling frustum plane
  14954. */
  14955. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14956. /**
  14957. * Gets the top frustum plane transformed by the transform matrix
  14958. * @param transform transformation matrix to be applied to the resulting frustum plane
  14959. * @param frustumPlane the resuling frustum plane
  14960. */
  14961. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14962. /**
  14963. * Gets the bottom frustum plane transformed by the transform matrix
  14964. * @param transform transformation matrix to be applied to the resulting frustum plane
  14965. * @param frustumPlane the resuling frustum plane
  14966. */
  14967. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14968. /**
  14969. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14970. * @param transform transformation matrix to be applied to the resulting frustum planes
  14971. * @param frustumPlanes the resuling frustum planes
  14972. */
  14973. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14974. }
  14975. }
  14976. declare module BABYLON {
  14977. interface Engine {
  14978. /**
  14979. * Creates a new multiview render target
  14980. * @param width defines the width of the texture
  14981. * @param height defines the height of the texture
  14982. * @returns the created multiview texture
  14983. */
  14984. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14985. /**
  14986. * Binds a multiview framebuffer to be drawn to
  14987. * @param multiviewTexture texture to bind
  14988. */
  14989. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14990. }
  14991. interface Camera {
  14992. /**
  14993. * @hidden
  14994. * 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)
  14995. */
  14996. _useMultiviewToSingleView: boolean;
  14997. /**
  14998. * @hidden
  14999. * 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)
  15000. */
  15001. _multiviewTexture: Nullable<RenderTargetTexture>;
  15002. /**
  15003. * @hidden
  15004. * ensures the multiview texture of the camera exists and has the specified width/height
  15005. * @param width height to set on the multiview texture
  15006. * @param height width to set on the multiview texture
  15007. */
  15008. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15009. }
  15010. interface Scene {
  15011. /** @hidden */
  15012. _transformMatrixR: Matrix;
  15013. /** @hidden */
  15014. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15015. /** @hidden */
  15016. _createMultiviewUbo(): void;
  15017. /** @hidden */
  15018. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15019. /** @hidden */
  15020. _renderMultiviewToSingleView(camera: Camera): void;
  15021. }
  15022. }
  15023. declare module BABYLON {
  15024. /**
  15025. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15026. * This will not be used for webXR as it supports displaying texture arrays directly
  15027. */
  15028. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15029. /**
  15030. * Initializes a VRMultiviewToSingleview
  15031. * @param name name of the post process
  15032. * @param camera camera to be applied to
  15033. * @param scaleFactor scaling factor to the size of the output texture
  15034. */
  15035. constructor(name: string, camera: Camera, scaleFactor: number);
  15036. }
  15037. }
  15038. declare module BABYLON {
  15039. /**
  15040. * Interface used to define additional presentation attributes
  15041. */
  15042. export interface IVRPresentationAttributes {
  15043. /**
  15044. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15045. */
  15046. highRefreshRate: boolean;
  15047. /**
  15048. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15049. */
  15050. foveationLevel: number;
  15051. }
  15052. interface Engine {
  15053. /** @hidden */
  15054. _vrDisplay: any;
  15055. /** @hidden */
  15056. _vrSupported: boolean;
  15057. /** @hidden */
  15058. _oldSize: Size;
  15059. /** @hidden */
  15060. _oldHardwareScaleFactor: number;
  15061. /** @hidden */
  15062. _vrExclusivePointerMode: boolean;
  15063. /** @hidden */
  15064. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15065. /** @hidden */
  15066. _onVRDisplayPointerRestricted: () => void;
  15067. /** @hidden */
  15068. _onVRDisplayPointerUnrestricted: () => void;
  15069. /** @hidden */
  15070. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15071. /** @hidden */
  15072. _onVrDisplayDisconnect: Nullable<() => void>;
  15073. /** @hidden */
  15074. _onVrDisplayPresentChange: Nullable<() => void>;
  15075. /**
  15076. * Observable signaled when VR display mode changes
  15077. */
  15078. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15079. /**
  15080. * Observable signaled when VR request present is complete
  15081. */
  15082. onVRRequestPresentComplete: Observable<boolean>;
  15083. /**
  15084. * Observable signaled when VR request present starts
  15085. */
  15086. onVRRequestPresentStart: Observable<Engine>;
  15087. /**
  15088. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15089. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15090. */
  15091. isInVRExclusivePointerMode: boolean;
  15092. /**
  15093. * Gets a boolean indicating if a webVR device was detected
  15094. * @returns true if a webVR device was detected
  15095. */
  15096. isVRDevicePresent(): boolean;
  15097. /**
  15098. * Gets the current webVR device
  15099. * @returns the current webVR device (or null)
  15100. */
  15101. getVRDevice(): any;
  15102. /**
  15103. * Initializes a webVR display and starts listening to display change events
  15104. * The onVRDisplayChangedObservable will be notified upon these changes
  15105. * @returns A promise containing a VRDisplay and if vr is supported
  15106. */
  15107. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15108. /** @hidden */
  15109. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15110. /**
  15111. * Gets or sets the presentation attributes used to configure VR rendering
  15112. */
  15113. vrPresentationAttributes?: IVRPresentationAttributes;
  15114. /**
  15115. * Call this function to switch to webVR mode
  15116. * Will do nothing if webVR is not supported or if there is no webVR device
  15117. * @param options the webvr options provided to the camera. mainly used for multiview
  15118. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15119. */
  15120. enableVR(options: WebVROptions): void;
  15121. /** @hidden */
  15122. _onVRFullScreenTriggered(): void;
  15123. }
  15124. }
  15125. declare module BABYLON {
  15126. /**
  15127. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15128. * IMPORTANT!! The data is right-hand data.
  15129. * @export
  15130. * @interface DevicePose
  15131. */
  15132. export interface DevicePose {
  15133. /**
  15134. * The position of the device, values in array are [x,y,z].
  15135. */
  15136. readonly position: Nullable<Float32Array>;
  15137. /**
  15138. * The linearVelocity of the device, values in array are [x,y,z].
  15139. */
  15140. readonly linearVelocity: Nullable<Float32Array>;
  15141. /**
  15142. * The linearAcceleration of the device, values in array are [x,y,z].
  15143. */
  15144. readonly linearAcceleration: Nullable<Float32Array>;
  15145. /**
  15146. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15147. */
  15148. readonly orientation: Nullable<Float32Array>;
  15149. /**
  15150. * The angularVelocity of the device, values in array are [x,y,z].
  15151. */
  15152. readonly angularVelocity: Nullable<Float32Array>;
  15153. /**
  15154. * The angularAcceleration of the device, values in array are [x,y,z].
  15155. */
  15156. readonly angularAcceleration: Nullable<Float32Array>;
  15157. }
  15158. /**
  15159. * Interface representing a pose controlled object in Babylon.
  15160. * A pose controlled object has both regular pose values as well as pose values
  15161. * from an external device such as a VR head mounted display
  15162. */
  15163. export interface PoseControlled {
  15164. /**
  15165. * The position of the object in babylon space.
  15166. */
  15167. position: Vector3;
  15168. /**
  15169. * The rotation quaternion of the object in babylon space.
  15170. */
  15171. rotationQuaternion: Quaternion;
  15172. /**
  15173. * The position of the device in babylon space.
  15174. */
  15175. devicePosition?: Vector3;
  15176. /**
  15177. * The rotation quaternion of the device in babylon space.
  15178. */
  15179. deviceRotationQuaternion: Quaternion;
  15180. /**
  15181. * The raw pose coming from the device.
  15182. */
  15183. rawPose: Nullable<DevicePose>;
  15184. /**
  15185. * The scale of the device to be used when translating from device space to babylon space.
  15186. */
  15187. deviceScaleFactor: number;
  15188. /**
  15189. * Updates the poseControlled values based on the input device pose.
  15190. * @param poseData the pose data to update the object with
  15191. */
  15192. updateFromDevice(poseData: DevicePose): void;
  15193. }
  15194. /**
  15195. * Set of options to customize the webVRCamera
  15196. */
  15197. export interface WebVROptions {
  15198. /**
  15199. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15200. */
  15201. trackPosition?: boolean;
  15202. /**
  15203. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15204. */
  15205. positionScale?: number;
  15206. /**
  15207. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15208. */
  15209. displayName?: string;
  15210. /**
  15211. * Should the native controller meshes be initialized. (default: true)
  15212. */
  15213. controllerMeshes?: boolean;
  15214. /**
  15215. * Creating a default HemiLight only on controllers. (default: true)
  15216. */
  15217. defaultLightingOnControllers?: boolean;
  15218. /**
  15219. * If you don't want to use the default VR button of the helper. (default: false)
  15220. */
  15221. useCustomVRButton?: boolean;
  15222. /**
  15223. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15224. */
  15225. customVRButton?: HTMLButtonElement;
  15226. /**
  15227. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15228. */
  15229. rayLength?: number;
  15230. /**
  15231. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15232. */
  15233. defaultHeight?: number;
  15234. /**
  15235. * If multiview should be used if availible (default: false)
  15236. */
  15237. useMultiview?: boolean;
  15238. }
  15239. /**
  15240. * This represents a WebVR camera.
  15241. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15242. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15243. */
  15244. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15245. private webVROptions;
  15246. /**
  15247. * @hidden
  15248. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15249. */
  15250. _vrDevice: any;
  15251. /**
  15252. * The rawPose of the vrDevice.
  15253. */
  15254. rawPose: Nullable<DevicePose>;
  15255. private _onVREnabled;
  15256. private _specsVersion;
  15257. private _attached;
  15258. private _frameData;
  15259. protected _descendants: Array<Node>;
  15260. private _deviceRoomPosition;
  15261. /** @hidden */
  15262. _deviceRoomRotationQuaternion: Quaternion;
  15263. private _standingMatrix;
  15264. /**
  15265. * Represents device position in babylon space.
  15266. */
  15267. devicePosition: Vector3;
  15268. /**
  15269. * Represents device rotation in babylon space.
  15270. */
  15271. deviceRotationQuaternion: Quaternion;
  15272. /**
  15273. * The scale of the device to be used when translating from device space to babylon space.
  15274. */
  15275. deviceScaleFactor: number;
  15276. private _deviceToWorld;
  15277. private _worldToDevice;
  15278. /**
  15279. * References to the webVR controllers for the vrDevice.
  15280. */
  15281. controllers: Array<WebVRController>;
  15282. /**
  15283. * Emits an event when a controller is attached.
  15284. */
  15285. onControllersAttachedObservable: Observable<WebVRController[]>;
  15286. /**
  15287. * Emits an event when a controller's mesh has been loaded;
  15288. */
  15289. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15290. /**
  15291. * Emits an event when the HMD's pose has been updated.
  15292. */
  15293. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15294. private _poseSet;
  15295. /**
  15296. * If the rig cameras be used as parent instead of this camera.
  15297. */
  15298. rigParenting: boolean;
  15299. private _lightOnControllers;
  15300. private _defaultHeight?;
  15301. /**
  15302. * Instantiates a WebVRFreeCamera.
  15303. * @param name The name of the WebVRFreeCamera
  15304. * @param position The starting anchor position for the camera
  15305. * @param scene The scene the camera belongs to
  15306. * @param webVROptions a set of customizable options for the webVRCamera
  15307. */
  15308. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15309. /**
  15310. * Gets the device distance from the ground in meters.
  15311. * @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.
  15312. */
  15313. deviceDistanceToRoomGround(): number;
  15314. /**
  15315. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15316. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15317. */
  15318. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15319. /**
  15320. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15321. * @returns A promise with a boolean set to if the standing matrix is supported.
  15322. */
  15323. useStandingMatrixAsync(): Promise<boolean>;
  15324. /**
  15325. * Disposes the camera
  15326. */
  15327. dispose(): void;
  15328. /**
  15329. * Gets a vrController by name.
  15330. * @param name The name of the controller to retreive
  15331. * @returns the controller matching the name specified or null if not found
  15332. */
  15333. getControllerByName(name: string): Nullable<WebVRController>;
  15334. private _leftController;
  15335. /**
  15336. * The controller corresponding to the users left hand.
  15337. */
  15338. get leftController(): Nullable<WebVRController>;
  15339. private _rightController;
  15340. /**
  15341. * The controller corresponding to the users right hand.
  15342. */
  15343. get rightController(): Nullable<WebVRController>;
  15344. /**
  15345. * Casts a ray forward from the vrCamera's gaze.
  15346. * @param length Length of the ray (default: 100)
  15347. * @returns the ray corresponding to the gaze
  15348. */
  15349. getForwardRay(length?: number): Ray;
  15350. /**
  15351. * @hidden
  15352. * Updates the camera based on device's frame data
  15353. */
  15354. _checkInputs(): void;
  15355. /**
  15356. * Updates the poseControlled values based on the input device pose.
  15357. * @param poseData Pose coming from the device
  15358. */
  15359. updateFromDevice(poseData: DevicePose): void;
  15360. private _htmlElementAttached;
  15361. private _detachIfAttached;
  15362. /**
  15363. * WebVR's attach control will start broadcasting frames to the device.
  15364. * Note that in certain browsers (chrome for example) this function must be called
  15365. * within a user-interaction callback. Example:
  15366. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15367. *
  15368. * @param element html element to attach the vrDevice to
  15369. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15370. */
  15371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15372. /**
  15373. * Detaches the camera from the html element and disables VR
  15374. *
  15375. * @param element html element to detach from
  15376. */
  15377. detachControl(element: HTMLElement): void;
  15378. /**
  15379. * @returns the name of this class
  15380. */
  15381. getClassName(): string;
  15382. /**
  15383. * Calls resetPose on the vrDisplay
  15384. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15385. */
  15386. resetToCurrentRotation(): void;
  15387. /**
  15388. * @hidden
  15389. * Updates the rig cameras (left and right eye)
  15390. */
  15391. _updateRigCameras(): void;
  15392. private _workingVector;
  15393. private _oneVector;
  15394. private _workingMatrix;
  15395. private updateCacheCalled;
  15396. private _correctPositionIfNotTrackPosition;
  15397. /**
  15398. * @hidden
  15399. * Updates the cached values of the camera
  15400. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15401. */
  15402. _updateCache(ignoreParentClass?: boolean): void;
  15403. /**
  15404. * @hidden
  15405. * Get current device position in babylon world
  15406. */
  15407. _computeDevicePosition(): void;
  15408. /**
  15409. * Updates the current device position and rotation in the babylon world
  15410. */
  15411. update(): void;
  15412. /**
  15413. * @hidden
  15414. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15415. * @returns an identity matrix
  15416. */
  15417. _getViewMatrix(): Matrix;
  15418. private _tmpMatrix;
  15419. /**
  15420. * This function is called by the two RIG cameras.
  15421. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15422. * @hidden
  15423. */
  15424. _getWebVRViewMatrix(): Matrix;
  15425. /** @hidden */
  15426. _getWebVRProjectionMatrix(): Matrix;
  15427. private _onGamepadConnectedObserver;
  15428. private _onGamepadDisconnectedObserver;
  15429. private _updateCacheWhenTrackingDisabledObserver;
  15430. /**
  15431. * Initializes the controllers and their meshes
  15432. */
  15433. initControllers(): void;
  15434. }
  15435. }
  15436. declare module BABYLON {
  15437. /**
  15438. * Size options for a post process
  15439. */
  15440. export type PostProcessOptions = {
  15441. width: number;
  15442. height: number;
  15443. };
  15444. /**
  15445. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15446. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15447. */
  15448. export class PostProcess {
  15449. /** Name of the PostProcess. */
  15450. name: string;
  15451. /**
  15452. * Gets or sets the unique id of the post process
  15453. */
  15454. uniqueId: number;
  15455. /**
  15456. * Width of the texture to apply the post process on
  15457. */
  15458. width: number;
  15459. /**
  15460. * Height of the texture to apply the post process on
  15461. */
  15462. height: number;
  15463. /**
  15464. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15465. * @hidden
  15466. */
  15467. _outputTexture: Nullable<InternalTexture>;
  15468. /**
  15469. * Sampling mode used by the shader
  15470. * See https://doc.babylonjs.com/classes/3.1/texture
  15471. */
  15472. renderTargetSamplingMode: number;
  15473. /**
  15474. * Clear color to use when screen clearing
  15475. */
  15476. clearColor: Color4;
  15477. /**
  15478. * If the buffer needs to be cleared before applying the post process. (default: true)
  15479. * Should be set to false if shader will overwrite all previous pixels.
  15480. */
  15481. autoClear: boolean;
  15482. /**
  15483. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15484. */
  15485. alphaMode: number;
  15486. /**
  15487. * Sets the setAlphaBlendConstants of the babylon engine
  15488. */
  15489. alphaConstants: Color4;
  15490. /**
  15491. * Animations to be used for the post processing
  15492. */
  15493. animations: Animation[];
  15494. /**
  15495. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15496. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15497. */
  15498. enablePixelPerfectMode: boolean;
  15499. /**
  15500. * Force the postprocess to be applied without taking in account viewport
  15501. */
  15502. forceFullscreenViewport: boolean;
  15503. /**
  15504. * List of inspectable custom properties (used by the Inspector)
  15505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15506. */
  15507. inspectableCustomProperties: IInspectable[];
  15508. /**
  15509. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15510. *
  15511. * | Value | Type | Description |
  15512. * | ----- | ----------------------------------- | ----------- |
  15513. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15514. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15515. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15516. *
  15517. */
  15518. scaleMode: number;
  15519. /**
  15520. * Force textures to be a power of two (default: false)
  15521. */
  15522. alwaysForcePOT: boolean;
  15523. private _samples;
  15524. /**
  15525. * Number of sample textures (default: 1)
  15526. */
  15527. get samples(): number;
  15528. set samples(n: number);
  15529. /**
  15530. * Modify the scale of the post process to be the same as the viewport (default: false)
  15531. */
  15532. adaptScaleToCurrentViewport: boolean;
  15533. private _camera;
  15534. private _scene;
  15535. private _engine;
  15536. private _options;
  15537. private _reusable;
  15538. private _textureType;
  15539. /**
  15540. * Smart array of input and output textures for the post process.
  15541. * @hidden
  15542. */
  15543. _textures: SmartArray<InternalTexture>;
  15544. /**
  15545. * The index in _textures that corresponds to the output texture.
  15546. * @hidden
  15547. */
  15548. _currentRenderTextureInd: number;
  15549. private _effect;
  15550. private _samplers;
  15551. private _fragmentUrl;
  15552. private _vertexUrl;
  15553. private _parameters;
  15554. private _scaleRatio;
  15555. protected _indexParameters: any;
  15556. private _shareOutputWithPostProcess;
  15557. private _texelSize;
  15558. private _forcedOutputTexture;
  15559. /**
  15560. * Returns the fragment url or shader name used in the post process.
  15561. * @returns the fragment url or name in the shader store.
  15562. */
  15563. getEffectName(): string;
  15564. /**
  15565. * An event triggered when the postprocess is activated.
  15566. */
  15567. onActivateObservable: Observable<Camera>;
  15568. private _onActivateObserver;
  15569. /**
  15570. * A function that is added to the onActivateObservable
  15571. */
  15572. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15573. /**
  15574. * An event triggered when the postprocess changes its size.
  15575. */
  15576. onSizeChangedObservable: Observable<PostProcess>;
  15577. private _onSizeChangedObserver;
  15578. /**
  15579. * A function that is added to the onSizeChangedObservable
  15580. */
  15581. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15582. /**
  15583. * An event triggered when the postprocess applies its effect.
  15584. */
  15585. onApplyObservable: Observable<Effect>;
  15586. private _onApplyObserver;
  15587. /**
  15588. * A function that is added to the onApplyObservable
  15589. */
  15590. set onApply(callback: (effect: Effect) => void);
  15591. /**
  15592. * An event triggered before rendering the postprocess
  15593. */
  15594. onBeforeRenderObservable: Observable<Effect>;
  15595. private _onBeforeRenderObserver;
  15596. /**
  15597. * A function that is added to the onBeforeRenderObservable
  15598. */
  15599. set onBeforeRender(callback: (effect: Effect) => void);
  15600. /**
  15601. * An event triggered after rendering the postprocess
  15602. */
  15603. onAfterRenderObservable: Observable<Effect>;
  15604. private _onAfterRenderObserver;
  15605. /**
  15606. * A function that is added to the onAfterRenderObservable
  15607. */
  15608. set onAfterRender(callback: (efect: Effect) => void);
  15609. /**
  15610. * 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
  15611. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15612. */
  15613. get inputTexture(): InternalTexture;
  15614. set inputTexture(value: InternalTexture);
  15615. /**
  15616. * Gets the camera which post process is applied to.
  15617. * @returns The camera the post process is applied to.
  15618. */
  15619. getCamera(): Camera;
  15620. /**
  15621. * Gets the texel size of the postprocess.
  15622. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15623. */
  15624. get texelSize(): Vector2;
  15625. /**
  15626. * Creates a new instance PostProcess
  15627. * @param name The name of the PostProcess.
  15628. * @param fragmentUrl The url of the fragment shader to be used.
  15629. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15630. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15631. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15632. * @param camera The camera to apply the render pass to.
  15633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15634. * @param engine The engine which the post process will be applied. (default: current engine)
  15635. * @param reusable If the post process can be reused on the same frame. (default: false)
  15636. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15637. * @param textureType Type of textures used when performing the post process. (default: 0)
  15638. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15639. * @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
  15640. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15641. */
  15642. constructor(
  15643. /** Name of the PostProcess. */
  15644. 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);
  15645. /**
  15646. * Gets a string idenfifying the name of the class
  15647. * @returns "PostProcess" string
  15648. */
  15649. getClassName(): string;
  15650. /**
  15651. * Gets the engine which this post process belongs to.
  15652. * @returns The engine the post process was enabled with.
  15653. */
  15654. getEngine(): Engine;
  15655. /**
  15656. * The effect that is created when initializing the post process.
  15657. * @returns The created effect corresponding the the postprocess.
  15658. */
  15659. getEffect(): Effect;
  15660. /**
  15661. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15662. * @param postProcess The post process to share the output with.
  15663. * @returns This post process.
  15664. */
  15665. shareOutputWith(postProcess: PostProcess): PostProcess;
  15666. /**
  15667. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15668. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15669. */
  15670. useOwnOutput(): void;
  15671. /**
  15672. * Updates the effect with the current post process compile time values and recompiles the shader.
  15673. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15674. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15675. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15676. * @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
  15677. * @param onCompiled Called when the shader has been compiled.
  15678. * @param onError Called if there is an error when compiling a shader.
  15679. */
  15680. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15681. /**
  15682. * The post process is reusable if it can be used multiple times within one frame.
  15683. * @returns If the post process is reusable
  15684. */
  15685. isReusable(): boolean;
  15686. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15687. markTextureDirty(): void;
  15688. /**
  15689. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15690. * 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.
  15691. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15692. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15693. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15694. * @returns The target texture that was bound to be written to.
  15695. */
  15696. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15697. /**
  15698. * If the post process is supported.
  15699. */
  15700. get isSupported(): boolean;
  15701. /**
  15702. * The aspect ratio of the output texture.
  15703. */
  15704. get aspectRatio(): number;
  15705. /**
  15706. * Get a value indicating if the post-process is ready to be used
  15707. * @returns true if the post-process is ready (shader is compiled)
  15708. */
  15709. isReady(): boolean;
  15710. /**
  15711. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15712. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15713. */
  15714. apply(): Nullable<Effect>;
  15715. private _disposeTextures;
  15716. /**
  15717. * Disposes the post process.
  15718. * @param camera The camera to dispose the post process on.
  15719. */
  15720. dispose(camera?: Camera): void;
  15721. }
  15722. }
  15723. declare module BABYLON {
  15724. /** @hidden */
  15725. export var kernelBlurVaryingDeclaration: {
  15726. name: string;
  15727. shader: string;
  15728. };
  15729. }
  15730. declare module BABYLON {
  15731. /** @hidden */
  15732. export var kernelBlurFragment: {
  15733. name: string;
  15734. shader: string;
  15735. };
  15736. }
  15737. declare module BABYLON {
  15738. /** @hidden */
  15739. export var kernelBlurFragment2: {
  15740. name: string;
  15741. shader: string;
  15742. };
  15743. }
  15744. declare module BABYLON {
  15745. /** @hidden */
  15746. export var kernelBlurPixelShader: {
  15747. name: string;
  15748. shader: string;
  15749. };
  15750. }
  15751. declare module BABYLON {
  15752. /** @hidden */
  15753. export var kernelBlurVertex: {
  15754. name: string;
  15755. shader: string;
  15756. };
  15757. }
  15758. declare module BABYLON {
  15759. /** @hidden */
  15760. export var kernelBlurVertexShader: {
  15761. name: string;
  15762. shader: string;
  15763. };
  15764. }
  15765. declare module BABYLON {
  15766. /**
  15767. * The Blur Post Process which blurs an image based on a kernel and direction.
  15768. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15769. */
  15770. export class BlurPostProcess extends PostProcess {
  15771. /** The direction in which to blur the image. */
  15772. direction: Vector2;
  15773. private blockCompilation;
  15774. protected _kernel: number;
  15775. protected _idealKernel: number;
  15776. protected _packedFloat: boolean;
  15777. private _staticDefines;
  15778. /**
  15779. * Sets the length in pixels of the blur sample region
  15780. */
  15781. set kernel(v: number);
  15782. /**
  15783. * Gets the length in pixels of the blur sample region
  15784. */
  15785. get kernel(): number;
  15786. /**
  15787. * Sets wether or not the blur needs to unpack/repack floats
  15788. */
  15789. set packedFloat(v: boolean);
  15790. /**
  15791. * Gets wether or not the blur is unpacking/repacking floats
  15792. */
  15793. get packedFloat(): boolean;
  15794. /**
  15795. * Creates a new instance BlurPostProcess
  15796. * @param name The name of the effect.
  15797. * @param direction The direction in which to blur the image.
  15798. * @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.
  15799. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15800. * @param camera The camera to apply the render pass to.
  15801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15802. * @param engine The engine which the post process will be applied. (default: current engine)
  15803. * @param reusable If the post process can be reused on the same frame. (default: false)
  15804. * @param textureType Type of textures used when performing the post process. (default: 0)
  15805. * @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)
  15806. */
  15807. constructor(name: string,
  15808. /** The direction in which to blur the image. */
  15809. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15810. /**
  15811. * Updates the effect with the current post process compile time values and recompiles the shader.
  15812. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15813. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15814. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15815. * @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
  15816. * @param onCompiled Called when the shader has been compiled.
  15817. * @param onError Called if there is an error when compiling a shader.
  15818. */
  15819. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15820. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15821. /**
  15822. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15823. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15824. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15825. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15826. * The gaps between physical kernels are compensated for in the weighting of the samples
  15827. * @param idealKernel Ideal blur kernel.
  15828. * @return Nearest best kernel.
  15829. */
  15830. protected _nearestBestKernel(idealKernel: number): number;
  15831. /**
  15832. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15833. * @param x The point on the Gaussian distribution to sample.
  15834. * @return the value of the Gaussian function at x.
  15835. */
  15836. protected _gaussianWeight(x: number): number;
  15837. /**
  15838. * Generates a string that can be used as a floating point number in GLSL.
  15839. * @param x Value to print.
  15840. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15841. * @return GLSL float string.
  15842. */
  15843. protected _glslFloat(x: number, decimalFigures?: number): string;
  15844. }
  15845. }
  15846. declare module BABYLON {
  15847. /**
  15848. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15849. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15850. * You can then easily use it as a reflectionTexture on a flat surface.
  15851. * In case the surface is not a plane, please consider relying on reflection probes.
  15852. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15853. */
  15854. export class MirrorTexture extends RenderTargetTexture {
  15855. private scene;
  15856. /**
  15857. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15858. * 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.
  15859. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15860. */
  15861. mirrorPlane: Plane;
  15862. /**
  15863. * Define the blur ratio used to blur the reflection if needed.
  15864. */
  15865. set blurRatio(value: number);
  15866. get blurRatio(): number;
  15867. /**
  15868. * Define the adaptive blur kernel used to blur the reflection if needed.
  15869. * This will autocompute the closest best match for the `blurKernel`
  15870. */
  15871. set adaptiveBlurKernel(value: number);
  15872. /**
  15873. * Define the blur kernel used to blur the reflection if needed.
  15874. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15875. */
  15876. set blurKernel(value: number);
  15877. /**
  15878. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15879. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15880. */
  15881. set blurKernelX(value: number);
  15882. get blurKernelX(): number;
  15883. /**
  15884. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15885. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15886. */
  15887. set blurKernelY(value: number);
  15888. get blurKernelY(): number;
  15889. private _autoComputeBlurKernel;
  15890. protected _onRatioRescale(): void;
  15891. private _updateGammaSpace;
  15892. private _imageProcessingConfigChangeObserver;
  15893. private _transformMatrix;
  15894. private _mirrorMatrix;
  15895. private _savedViewMatrix;
  15896. private _blurX;
  15897. private _blurY;
  15898. private _adaptiveBlurKernel;
  15899. private _blurKernelX;
  15900. private _blurKernelY;
  15901. private _blurRatio;
  15902. /**
  15903. * Instantiates a Mirror Texture.
  15904. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15905. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15906. * You can then easily use it as a reflectionTexture on a flat surface.
  15907. * In case the surface is not a plane, please consider relying on reflection probes.
  15908. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15909. * @param name
  15910. * @param size
  15911. * @param scene
  15912. * @param generateMipMaps
  15913. * @param type
  15914. * @param samplingMode
  15915. * @param generateDepthBuffer
  15916. */
  15917. constructor(name: string, size: number | {
  15918. width: number;
  15919. height: number;
  15920. } | {
  15921. ratio: number;
  15922. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15923. private _preparePostProcesses;
  15924. /**
  15925. * Clone the mirror texture.
  15926. * @returns the cloned texture
  15927. */
  15928. clone(): MirrorTexture;
  15929. /**
  15930. * Serialize the texture to a JSON representation you could use in Parse later on
  15931. * @returns the serialized JSON representation
  15932. */
  15933. serialize(): any;
  15934. /**
  15935. * Dispose the texture and release its associated resources.
  15936. */
  15937. dispose(): void;
  15938. }
  15939. }
  15940. declare module BABYLON {
  15941. /**
  15942. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15943. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15944. */
  15945. export class Texture extends BaseTexture {
  15946. /**
  15947. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15948. */
  15949. static SerializeBuffers: boolean;
  15950. /** @hidden */
  15951. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15952. /** @hidden */
  15953. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15954. /** @hidden */
  15955. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15956. /** nearest is mag = nearest and min = nearest and mip = linear */
  15957. static readonly NEAREST_SAMPLINGMODE: number;
  15958. /** nearest is mag = nearest and min = nearest and mip = linear */
  15959. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15960. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15961. static readonly BILINEAR_SAMPLINGMODE: number;
  15962. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15963. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15964. /** Trilinear is mag = linear and min = linear and mip = linear */
  15965. static readonly TRILINEAR_SAMPLINGMODE: number;
  15966. /** Trilinear is mag = linear and min = linear and mip = linear */
  15967. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15968. /** mag = nearest and min = nearest and mip = nearest */
  15969. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15970. /** mag = nearest and min = linear and mip = nearest */
  15971. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15972. /** mag = nearest and min = linear and mip = linear */
  15973. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15974. /** mag = nearest and min = linear and mip = none */
  15975. static readonly NEAREST_LINEAR: number;
  15976. /** mag = nearest and min = nearest and mip = none */
  15977. static readonly NEAREST_NEAREST: number;
  15978. /** mag = linear and min = nearest and mip = nearest */
  15979. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15980. /** mag = linear and min = nearest and mip = linear */
  15981. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15982. /** mag = linear and min = linear and mip = none */
  15983. static readonly LINEAR_LINEAR: number;
  15984. /** mag = linear and min = nearest and mip = none */
  15985. static readonly LINEAR_NEAREST: number;
  15986. /** Explicit coordinates mode */
  15987. static readonly EXPLICIT_MODE: number;
  15988. /** Spherical coordinates mode */
  15989. static readonly SPHERICAL_MODE: number;
  15990. /** Planar coordinates mode */
  15991. static readonly PLANAR_MODE: number;
  15992. /** Cubic coordinates mode */
  15993. static readonly CUBIC_MODE: number;
  15994. /** Projection coordinates mode */
  15995. static readonly PROJECTION_MODE: number;
  15996. /** Inverse Cubic coordinates mode */
  15997. static readonly SKYBOX_MODE: number;
  15998. /** Inverse Cubic coordinates mode */
  15999. static readonly INVCUBIC_MODE: number;
  16000. /** Equirectangular coordinates mode */
  16001. static readonly EQUIRECTANGULAR_MODE: number;
  16002. /** Equirectangular Fixed coordinates mode */
  16003. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16004. /** Equirectangular Fixed Mirrored coordinates mode */
  16005. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16006. /** Texture is not repeating outside of 0..1 UVs */
  16007. static readonly CLAMP_ADDRESSMODE: number;
  16008. /** Texture is repeating outside of 0..1 UVs */
  16009. static readonly WRAP_ADDRESSMODE: number;
  16010. /** Texture is repeating and mirrored */
  16011. static readonly MIRROR_ADDRESSMODE: number;
  16012. /**
  16013. * 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
  16014. */
  16015. static UseSerializedUrlIfAny: boolean;
  16016. /**
  16017. * Define the url of the texture.
  16018. */
  16019. url: Nullable<string>;
  16020. /**
  16021. * Define an offset on the texture to offset the u coordinates of the UVs
  16022. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16023. */
  16024. uOffset: number;
  16025. /**
  16026. * Define an offset on the texture to offset the v coordinates of the UVs
  16027. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16028. */
  16029. vOffset: number;
  16030. /**
  16031. * Define an offset on the texture to scale the u coordinates of the UVs
  16032. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16033. */
  16034. uScale: number;
  16035. /**
  16036. * Define an offset on the texture to scale the v coordinates of the UVs
  16037. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16038. */
  16039. vScale: number;
  16040. /**
  16041. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16042. * @see http://doc.babylonjs.com/how_to/more_materials
  16043. */
  16044. uAng: number;
  16045. /**
  16046. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16047. * @see http://doc.babylonjs.com/how_to/more_materials
  16048. */
  16049. vAng: number;
  16050. /**
  16051. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16052. * @see http://doc.babylonjs.com/how_to/more_materials
  16053. */
  16054. wAng: number;
  16055. /**
  16056. * Defines the center of rotation (U)
  16057. */
  16058. uRotationCenter: number;
  16059. /**
  16060. * Defines the center of rotation (V)
  16061. */
  16062. vRotationCenter: number;
  16063. /**
  16064. * Defines the center of rotation (W)
  16065. */
  16066. wRotationCenter: number;
  16067. /**
  16068. * Are mip maps generated for this texture or not.
  16069. */
  16070. get noMipmap(): boolean;
  16071. /**
  16072. * List of inspectable custom properties (used by the Inspector)
  16073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16074. */
  16075. inspectableCustomProperties: Nullable<IInspectable[]>;
  16076. private _noMipmap;
  16077. /** @hidden */
  16078. _invertY: boolean;
  16079. private _rowGenerationMatrix;
  16080. private _cachedTextureMatrix;
  16081. private _projectionModeMatrix;
  16082. private _t0;
  16083. private _t1;
  16084. private _t2;
  16085. private _cachedUOffset;
  16086. private _cachedVOffset;
  16087. private _cachedUScale;
  16088. private _cachedVScale;
  16089. private _cachedUAng;
  16090. private _cachedVAng;
  16091. private _cachedWAng;
  16092. private _cachedProjectionMatrixId;
  16093. private _cachedCoordinatesMode;
  16094. /** @hidden */
  16095. protected _initialSamplingMode: number;
  16096. /** @hidden */
  16097. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16098. private _deleteBuffer;
  16099. protected _format: Nullable<number>;
  16100. private _delayedOnLoad;
  16101. private _delayedOnError;
  16102. private _mimeType?;
  16103. /**
  16104. * Observable triggered once the texture has been loaded.
  16105. */
  16106. onLoadObservable: Observable<Texture>;
  16107. protected _isBlocking: boolean;
  16108. /**
  16109. * Is the texture preventing material to render while loading.
  16110. * If false, a default texture will be used instead of the loading one during the preparation step.
  16111. */
  16112. set isBlocking(value: boolean);
  16113. get isBlocking(): boolean;
  16114. /**
  16115. * Get the current sampling mode associated with the texture.
  16116. */
  16117. get samplingMode(): number;
  16118. /**
  16119. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16120. */
  16121. get invertY(): boolean;
  16122. /**
  16123. * Instantiates a new texture.
  16124. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16125. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16126. * @param url defines the url of the picture to load as a texture
  16127. * @param scene defines the scene or engine the texture will belong to
  16128. * @param noMipmap defines if the texture will require mip maps or not
  16129. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16130. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16131. * @param onLoad defines a callback triggered when the texture has been loaded
  16132. * @param onError defines a callback triggered when an error occurred during the loading session
  16133. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16134. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16135. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16136. * @param mimeType defines an optional mime type information
  16137. */
  16138. 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);
  16139. /**
  16140. * Update the url (and optional buffer) of this texture if url was null during construction.
  16141. * @param url the url of the texture
  16142. * @param buffer the buffer of the texture (defaults to null)
  16143. * @param onLoad callback called when the texture is loaded (defaults to null)
  16144. */
  16145. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16146. /**
  16147. * Finish the loading sequence of a texture flagged as delayed load.
  16148. * @hidden
  16149. */
  16150. delayLoad(): void;
  16151. private _prepareRowForTextureGeneration;
  16152. /**
  16153. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16154. * @returns the transform matrix of the texture.
  16155. */
  16156. getTextureMatrix(uBase?: number): Matrix;
  16157. /**
  16158. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16159. * @returns The reflection texture transform
  16160. */
  16161. getReflectionTextureMatrix(): Matrix;
  16162. /**
  16163. * Clones the texture.
  16164. * @returns the cloned texture
  16165. */
  16166. clone(): Texture;
  16167. /**
  16168. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16169. * @returns The JSON representation of the texture
  16170. */
  16171. serialize(): any;
  16172. /**
  16173. * Get the current class name of the texture useful for serialization or dynamic coding.
  16174. * @returns "Texture"
  16175. */
  16176. getClassName(): string;
  16177. /**
  16178. * Dispose the texture and release its associated resources.
  16179. */
  16180. dispose(): void;
  16181. /**
  16182. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16183. * @param parsedTexture Define the JSON representation of the texture
  16184. * @param scene Define the scene the parsed texture should be instantiated in
  16185. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16186. * @returns The parsed texture if successful
  16187. */
  16188. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16189. /**
  16190. * Creates a texture from its base 64 representation.
  16191. * @param data Define the base64 payload without the data: prefix
  16192. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16193. * @param scene Define the scene the texture should belong to
  16194. * @param noMipmap Forces the texture to not create mip map information if true
  16195. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16196. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16197. * @param onLoad define a callback triggered when the texture has been loaded
  16198. * @param onError define a callback triggered when an error occurred during the loading session
  16199. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16200. * @returns the created texture
  16201. */
  16202. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16203. /**
  16204. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16205. * @param data Define the base64 payload without the data: prefix
  16206. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16207. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16208. * @param scene Define the scene the texture should belong to
  16209. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16210. * @param noMipmap Forces the texture to not create mip map information if true
  16211. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16212. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16213. * @param onLoad define a callback triggered when the texture has been loaded
  16214. * @param onError define a callback triggered when an error occurred during the loading session
  16215. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16216. * @returns the created texture
  16217. */
  16218. 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;
  16219. }
  16220. }
  16221. declare module BABYLON {
  16222. /**
  16223. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16224. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16225. */
  16226. export class PostProcessManager {
  16227. private _scene;
  16228. private _indexBuffer;
  16229. private _vertexBuffers;
  16230. /**
  16231. * Creates a new instance PostProcess
  16232. * @param scene The scene that the post process is associated with.
  16233. */
  16234. constructor(scene: Scene);
  16235. private _prepareBuffers;
  16236. private _buildIndexBuffer;
  16237. /**
  16238. * Rebuilds the vertex buffers of the manager.
  16239. * @hidden
  16240. */
  16241. _rebuild(): void;
  16242. /**
  16243. * Prepares a frame to be run through a post process.
  16244. * @param sourceTexture The input texture to the post procesess. (default: null)
  16245. * @param postProcesses An array of post processes to be run. (default: null)
  16246. * @returns True if the post processes were able to be run.
  16247. * @hidden
  16248. */
  16249. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16250. /**
  16251. * Manually render a set of post processes to a texture.
  16252. * @param postProcesses An array of post processes to be run.
  16253. * @param targetTexture The target texture to render to.
  16254. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16255. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16256. * @param lodLevel defines which lod of the texture to render to
  16257. */
  16258. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16259. /**
  16260. * Finalize the result of the output of the postprocesses.
  16261. * @param doNotPresent If true the result will not be displayed to the screen.
  16262. * @param targetTexture The target texture to render to.
  16263. * @param faceIndex The index of the face to bind the target texture to.
  16264. * @param postProcesses The array of post processes to render.
  16265. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16266. * @hidden
  16267. */
  16268. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16269. /**
  16270. * Disposes of the post process manager.
  16271. */
  16272. dispose(): void;
  16273. }
  16274. }
  16275. declare module BABYLON {
  16276. /** Interface used by value gradients (color, factor, ...) */
  16277. export interface IValueGradient {
  16278. /**
  16279. * Gets or sets the gradient value (between 0 and 1)
  16280. */
  16281. gradient: number;
  16282. }
  16283. /** Class used to store color4 gradient */
  16284. export class ColorGradient implements IValueGradient {
  16285. /**
  16286. * Gets or sets the gradient value (between 0 and 1)
  16287. */
  16288. gradient: number;
  16289. /**
  16290. * Gets or sets first associated color
  16291. */
  16292. color1: Color4;
  16293. /**
  16294. * Gets or sets second associated color
  16295. */
  16296. color2?: Color4;
  16297. /**
  16298. * Will get a color picked randomly between color1 and color2.
  16299. * If color2 is undefined then color1 will be used
  16300. * @param result defines the target Color4 to store the result in
  16301. */
  16302. getColorToRef(result: Color4): void;
  16303. }
  16304. /** Class used to store color 3 gradient */
  16305. export class Color3Gradient implements IValueGradient {
  16306. /**
  16307. * Gets or sets the gradient value (between 0 and 1)
  16308. */
  16309. gradient: number;
  16310. /**
  16311. * Gets or sets the associated color
  16312. */
  16313. color: Color3;
  16314. }
  16315. /** Class used to store factor gradient */
  16316. export class FactorGradient implements IValueGradient {
  16317. /**
  16318. * Gets or sets the gradient value (between 0 and 1)
  16319. */
  16320. gradient: number;
  16321. /**
  16322. * Gets or sets first associated factor
  16323. */
  16324. factor1: number;
  16325. /**
  16326. * Gets or sets second associated factor
  16327. */
  16328. factor2?: number;
  16329. /**
  16330. * Will get a number picked randomly between factor1 and factor2.
  16331. * If factor2 is undefined then factor1 will be used
  16332. * @returns the picked number
  16333. */
  16334. getFactor(): number;
  16335. }
  16336. /**
  16337. * Helper used to simplify some generic gradient tasks
  16338. */
  16339. export class GradientHelper {
  16340. /**
  16341. * Gets the current gradient from an array of IValueGradient
  16342. * @param ratio defines the current ratio to get
  16343. * @param gradients defines the array of IValueGradient
  16344. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16345. */
  16346. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16347. }
  16348. }
  16349. declare module BABYLON {
  16350. interface ThinEngine {
  16351. /**
  16352. * Creates a dynamic texture
  16353. * @param width defines the width of the texture
  16354. * @param height defines the height of the texture
  16355. * @param generateMipMaps defines if the engine should generate the mip levels
  16356. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16357. * @returns the dynamic texture inside an InternalTexture
  16358. */
  16359. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16360. /**
  16361. * Update the content of a dynamic texture
  16362. * @param texture defines the texture to update
  16363. * @param canvas defines the canvas containing the source
  16364. * @param invertY defines if data must be stored with Y axis inverted
  16365. * @param premulAlpha defines if alpha is stored as premultiplied
  16366. * @param format defines the format of the data
  16367. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16368. */
  16369. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16370. }
  16371. }
  16372. declare module BABYLON {
  16373. /**
  16374. * Helper class used to generate a canvas to manipulate images
  16375. */
  16376. export class CanvasGenerator {
  16377. /**
  16378. * Create a new canvas (or offscreen canvas depending on the context)
  16379. * @param width defines the expected width
  16380. * @param height defines the expected height
  16381. * @return a new canvas or offscreen canvas
  16382. */
  16383. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16384. }
  16385. }
  16386. declare module BABYLON {
  16387. /**
  16388. * A class extending Texture allowing drawing on a texture
  16389. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16390. */
  16391. export class DynamicTexture extends Texture {
  16392. private _generateMipMaps;
  16393. private _canvas;
  16394. private _context;
  16395. private _engine;
  16396. /**
  16397. * Creates a DynamicTexture
  16398. * @param name defines the name of the texture
  16399. * @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
  16400. * @param scene defines the scene where you want the texture
  16401. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16402. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16403. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16404. */
  16405. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16406. /**
  16407. * Get the current class name of the texture useful for serialization or dynamic coding.
  16408. * @returns "DynamicTexture"
  16409. */
  16410. getClassName(): string;
  16411. /**
  16412. * Gets the current state of canRescale
  16413. */
  16414. get canRescale(): boolean;
  16415. private _recreate;
  16416. /**
  16417. * Scales the texture
  16418. * @param ratio the scale factor to apply to both width and height
  16419. */
  16420. scale(ratio: number): void;
  16421. /**
  16422. * Resizes the texture
  16423. * @param width the new width
  16424. * @param height the new height
  16425. */
  16426. scaleTo(width: number, height: number): void;
  16427. /**
  16428. * Gets the context of the canvas used by the texture
  16429. * @returns the canvas context of the dynamic texture
  16430. */
  16431. getContext(): CanvasRenderingContext2D;
  16432. /**
  16433. * Clears the texture
  16434. */
  16435. clear(): void;
  16436. /**
  16437. * Updates the texture
  16438. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16439. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16440. */
  16441. update(invertY?: boolean, premulAlpha?: boolean): void;
  16442. /**
  16443. * Draws text onto the texture
  16444. * @param text defines the text to be drawn
  16445. * @param x defines the placement of the text from the left
  16446. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16447. * @param font defines the font to be used with font-style, font-size, font-name
  16448. * @param color defines the color used for the text
  16449. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16450. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16451. * @param update defines whether texture is immediately update (default is true)
  16452. */
  16453. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16454. /**
  16455. * Clones the texture
  16456. * @returns the clone of the texture.
  16457. */
  16458. clone(): DynamicTexture;
  16459. /**
  16460. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16461. * @returns a serialized dynamic texture object
  16462. */
  16463. serialize(): any;
  16464. /** @hidden */
  16465. _rebuild(): void;
  16466. }
  16467. }
  16468. declare module BABYLON {
  16469. interface AbstractScene {
  16470. /**
  16471. * The list of procedural textures added to the scene
  16472. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16473. */
  16474. proceduralTextures: Array<ProceduralTexture>;
  16475. }
  16476. /**
  16477. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16478. * in a given scene.
  16479. */
  16480. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16481. /**
  16482. * The component name helpfull to identify the component in the list of scene components.
  16483. */
  16484. readonly name: string;
  16485. /**
  16486. * The scene the component belongs to.
  16487. */
  16488. scene: Scene;
  16489. /**
  16490. * Creates a new instance of the component for the given scene
  16491. * @param scene Defines the scene to register the component in
  16492. */
  16493. constructor(scene: Scene);
  16494. /**
  16495. * Registers the component in a given scene
  16496. */
  16497. register(): void;
  16498. /**
  16499. * Rebuilds the elements related to this component in case of
  16500. * context lost for instance.
  16501. */
  16502. rebuild(): void;
  16503. /**
  16504. * Disposes the component and the associated ressources.
  16505. */
  16506. dispose(): void;
  16507. private _beforeClear;
  16508. }
  16509. }
  16510. declare module BABYLON {
  16511. interface ThinEngine {
  16512. /**
  16513. * Creates a new render target cube texture
  16514. * @param size defines the size of the texture
  16515. * @param options defines the options used to create the texture
  16516. * @returns a new render target cube texture stored in an InternalTexture
  16517. */
  16518. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16519. }
  16520. }
  16521. declare module BABYLON {
  16522. /** @hidden */
  16523. export var proceduralVertexShader: {
  16524. name: string;
  16525. shader: string;
  16526. };
  16527. }
  16528. declare module BABYLON {
  16529. /**
  16530. * 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.
  16531. * This is the base class of any Procedural texture and contains most of the shareable code.
  16532. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16533. */
  16534. export class ProceduralTexture extends Texture {
  16535. isCube: boolean;
  16536. /**
  16537. * Define if the texture is enabled or not (disabled texture will not render)
  16538. */
  16539. isEnabled: boolean;
  16540. /**
  16541. * Define if the texture must be cleared before rendering (default is true)
  16542. */
  16543. autoClear: boolean;
  16544. /**
  16545. * Callback called when the texture is generated
  16546. */
  16547. onGenerated: () => void;
  16548. /**
  16549. * Event raised when the texture is generated
  16550. */
  16551. onGeneratedObservable: Observable<ProceduralTexture>;
  16552. /** @hidden */
  16553. _generateMipMaps: boolean;
  16554. /** @hidden **/
  16555. _effect: Effect;
  16556. /** @hidden */
  16557. _textures: {
  16558. [key: string]: Texture;
  16559. };
  16560. private _size;
  16561. private _currentRefreshId;
  16562. private _refreshRate;
  16563. private _vertexBuffers;
  16564. private _indexBuffer;
  16565. private _uniforms;
  16566. private _samplers;
  16567. private _fragment;
  16568. private _floats;
  16569. private _ints;
  16570. private _floatsArrays;
  16571. private _colors3;
  16572. private _colors4;
  16573. private _vectors2;
  16574. private _vectors3;
  16575. private _matrices;
  16576. private _fallbackTexture;
  16577. private _fallbackTextureUsed;
  16578. private _engine;
  16579. private _cachedDefines;
  16580. private _contentUpdateId;
  16581. private _contentData;
  16582. /**
  16583. * Instantiates a new procedural texture.
  16584. * 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.
  16585. * This is the base class of any Procedural texture and contains most of the shareable code.
  16586. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16587. * @param name Define the name of the texture
  16588. * @param size Define the size of the texture to create
  16589. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16590. * @param scene Define the scene the texture belongs to
  16591. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16592. * @param generateMipMaps Define if the texture should creates mip maps or not
  16593. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16594. */
  16595. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16596. /**
  16597. * The effect that is created when initializing the post process.
  16598. * @returns The created effect corresponding the the postprocess.
  16599. */
  16600. getEffect(): Effect;
  16601. /**
  16602. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16603. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16604. */
  16605. getContent(): Nullable<ArrayBufferView>;
  16606. private _createIndexBuffer;
  16607. /** @hidden */
  16608. _rebuild(): void;
  16609. /**
  16610. * Resets the texture in order to recreate its associated resources.
  16611. * This can be called in case of context loss
  16612. */
  16613. reset(): void;
  16614. protected _getDefines(): string;
  16615. /**
  16616. * Is the texture ready to be used ? (rendered at least once)
  16617. * @returns true if ready, otherwise, false.
  16618. */
  16619. isReady(): boolean;
  16620. /**
  16621. * Resets the refresh counter of the texture and start bak from scratch.
  16622. * Could be useful to regenerate the texture if it is setup to render only once.
  16623. */
  16624. resetRefreshCounter(): void;
  16625. /**
  16626. * Set the fragment shader to use in order to render the texture.
  16627. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16628. */
  16629. setFragment(fragment: any): void;
  16630. /**
  16631. * Define the refresh rate of the texture or the rendering frequency.
  16632. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16633. */
  16634. get refreshRate(): number;
  16635. set refreshRate(value: number);
  16636. /** @hidden */
  16637. _shouldRender(): boolean;
  16638. /**
  16639. * Get the size the texture is rendering at.
  16640. * @returns the size (texture is always squared)
  16641. */
  16642. getRenderSize(): number;
  16643. /**
  16644. * Resize the texture to new value.
  16645. * @param size Define the new size the texture should have
  16646. * @param generateMipMaps Define whether the new texture should create mip maps
  16647. */
  16648. resize(size: number, generateMipMaps: boolean): void;
  16649. private _checkUniform;
  16650. /**
  16651. * Set a texture in the shader program used to render.
  16652. * @param name Define the name of the uniform samplers as defined in the shader
  16653. * @param texture Define the texture to bind to this sampler
  16654. * @return the texture itself allowing "fluent" like uniform updates
  16655. */
  16656. setTexture(name: string, texture: Texture): ProceduralTexture;
  16657. /**
  16658. * Set a float in the shader.
  16659. * @param name Define the name of the uniform as defined in the shader
  16660. * @param value Define the value to give to the uniform
  16661. * @return the texture itself allowing "fluent" like uniform updates
  16662. */
  16663. setFloat(name: string, value: number): ProceduralTexture;
  16664. /**
  16665. * Set a int in the shader.
  16666. * @param name Define the name of the uniform as defined in the shader
  16667. * @param value Define the value to give to the uniform
  16668. * @return the texture itself allowing "fluent" like uniform updates
  16669. */
  16670. setInt(name: string, value: number): ProceduralTexture;
  16671. /**
  16672. * Set an array of floats in the shader.
  16673. * @param name Define the name of the uniform as defined in the shader
  16674. * @param value Define the value to give to the uniform
  16675. * @return the texture itself allowing "fluent" like uniform updates
  16676. */
  16677. setFloats(name: string, value: number[]): ProceduralTexture;
  16678. /**
  16679. * Set a vec3 in the shader from a Color3.
  16680. * @param name Define the name of the uniform as defined in the shader
  16681. * @param value Define the value to give to the uniform
  16682. * @return the texture itself allowing "fluent" like uniform updates
  16683. */
  16684. setColor3(name: string, value: Color3): ProceduralTexture;
  16685. /**
  16686. * Set a vec4 in the shader from a Color4.
  16687. * @param name Define the name of the uniform as defined in the shader
  16688. * @param value Define the value to give to the uniform
  16689. * @return the texture itself allowing "fluent" like uniform updates
  16690. */
  16691. setColor4(name: string, value: Color4): ProceduralTexture;
  16692. /**
  16693. * Set a vec2 in the shader from a Vector2.
  16694. * @param name Define the name of the uniform as defined in the shader
  16695. * @param value Define the value to give to the uniform
  16696. * @return the texture itself allowing "fluent" like uniform updates
  16697. */
  16698. setVector2(name: string, value: Vector2): ProceduralTexture;
  16699. /**
  16700. * Set a vec3 in the shader from a Vector3.
  16701. * @param name Define the name of the uniform as defined in the shader
  16702. * @param value Define the value to give to the uniform
  16703. * @return the texture itself allowing "fluent" like uniform updates
  16704. */
  16705. setVector3(name: string, value: Vector3): ProceduralTexture;
  16706. /**
  16707. * Set a mat4 in the shader from a MAtrix.
  16708. * @param name Define the name of the uniform as defined in the shader
  16709. * @param value Define the value to give to the uniform
  16710. * @return the texture itself allowing "fluent" like uniform updates
  16711. */
  16712. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16713. /**
  16714. * Render the texture to its associated render target.
  16715. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16716. */
  16717. render(useCameraPostProcess?: boolean): void;
  16718. /**
  16719. * Clone the texture.
  16720. * @returns the cloned texture
  16721. */
  16722. clone(): ProceduralTexture;
  16723. /**
  16724. * Dispose the texture and release its asoociated resources.
  16725. */
  16726. dispose(): void;
  16727. }
  16728. }
  16729. declare module BABYLON {
  16730. /**
  16731. * This represents the base class for particle system in Babylon.
  16732. * 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.
  16733. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16734. * @example https://doc.babylonjs.com/babylon101/particles
  16735. */
  16736. export class BaseParticleSystem {
  16737. /**
  16738. * Source color is added to the destination color without alpha affecting the result
  16739. */
  16740. static BLENDMODE_ONEONE: number;
  16741. /**
  16742. * Blend current color and particle color using particle’s alpha
  16743. */
  16744. static BLENDMODE_STANDARD: number;
  16745. /**
  16746. * Add current color and particle color multiplied by particle’s alpha
  16747. */
  16748. static BLENDMODE_ADD: number;
  16749. /**
  16750. * Multiply current color with particle color
  16751. */
  16752. static BLENDMODE_MULTIPLY: number;
  16753. /**
  16754. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16755. */
  16756. static BLENDMODE_MULTIPLYADD: number;
  16757. /**
  16758. * List of animations used by the particle system.
  16759. */
  16760. animations: Animation[];
  16761. /**
  16762. * The id of the Particle system.
  16763. */
  16764. id: string;
  16765. /**
  16766. * The friendly name of the Particle system.
  16767. */
  16768. name: string;
  16769. /**
  16770. * The rendering group used by the Particle system to chose when to render.
  16771. */
  16772. renderingGroupId: number;
  16773. /**
  16774. * The emitter represents the Mesh or position we are attaching the particle system to.
  16775. */
  16776. emitter: Nullable<AbstractMesh | Vector3>;
  16777. /**
  16778. * The maximum number of particles to emit per frame
  16779. */
  16780. emitRate: number;
  16781. /**
  16782. * If you want to launch only a few particles at once, that can be done, as well.
  16783. */
  16784. manualEmitCount: number;
  16785. /**
  16786. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16787. */
  16788. updateSpeed: number;
  16789. /**
  16790. * The amount of time the particle system is running (depends of the overall update speed).
  16791. */
  16792. targetStopDuration: number;
  16793. /**
  16794. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16795. */
  16796. disposeOnStop: boolean;
  16797. /**
  16798. * Minimum power of emitting particles.
  16799. */
  16800. minEmitPower: number;
  16801. /**
  16802. * Maximum power of emitting particles.
  16803. */
  16804. maxEmitPower: number;
  16805. /**
  16806. * Minimum life time of emitting particles.
  16807. */
  16808. minLifeTime: number;
  16809. /**
  16810. * Maximum life time of emitting particles.
  16811. */
  16812. maxLifeTime: number;
  16813. /**
  16814. * Minimum Size of emitting particles.
  16815. */
  16816. minSize: number;
  16817. /**
  16818. * Maximum Size of emitting particles.
  16819. */
  16820. maxSize: number;
  16821. /**
  16822. * Minimum scale of emitting particles on X axis.
  16823. */
  16824. minScaleX: number;
  16825. /**
  16826. * Maximum scale of emitting particles on X axis.
  16827. */
  16828. maxScaleX: number;
  16829. /**
  16830. * Minimum scale of emitting particles on Y axis.
  16831. */
  16832. minScaleY: number;
  16833. /**
  16834. * Maximum scale of emitting particles on Y axis.
  16835. */
  16836. maxScaleY: number;
  16837. /**
  16838. * Gets or sets the minimal initial rotation in radians.
  16839. */
  16840. minInitialRotation: number;
  16841. /**
  16842. * Gets or sets the maximal initial rotation in radians.
  16843. */
  16844. maxInitialRotation: number;
  16845. /**
  16846. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16847. */
  16848. minAngularSpeed: number;
  16849. /**
  16850. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16851. */
  16852. maxAngularSpeed: number;
  16853. /**
  16854. * The texture used to render each particle. (this can be a spritesheet)
  16855. */
  16856. particleTexture: Nullable<Texture>;
  16857. /**
  16858. * The layer mask we are rendering the particles through.
  16859. */
  16860. layerMask: number;
  16861. /**
  16862. * This can help using your own shader to render the particle system.
  16863. * The according effect will be created
  16864. */
  16865. customShader: any;
  16866. /**
  16867. * By default particle system starts as soon as they are created. This prevents the
  16868. * automatic start to happen and let you decide when to start emitting particles.
  16869. */
  16870. preventAutoStart: boolean;
  16871. private _noiseTexture;
  16872. /**
  16873. * Gets or sets a texture used to add random noise to particle positions
  16874. */
  16875. get noiseTexture(): Nullable<ProceduralTexture>;
  16876. set noiseTexture(value: Nullable<ProceduralTexture>);
  16877. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16878. noiseStrength: Vector3;
  16879. /**
  16880. * Callback triggered when the particle animation is ending.
  16881. */
  16882. onAnimationEnd: Nullable<() => void>;
  16883. /**
  16884. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16885. */
  16886. blendMode: number;
  16887. /**
  16888. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16889. * to override the particles.
  16890. */
  16891. forceDepthWrite: boolean;
  16892. /** 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 */
  16893. preWarmCycles: number;
  16894. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16895. preWarmStepOffset: number;
  16896. /**
  16897. * 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)
  16898. */
  16899. spriteCellChangeSpeed: number;
  16900. /**
  16901. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16902. */
  16903. startSpriteCellID: number;
  16904. /**
  16905. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16906. */
  16907. endSpriteCellID: number;
  16908. /**
  16909. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16910. */
  16911. spriteCellWidth: number;
  16912. /**
  16913. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16914. */
  16915. spriteCellHeight: number;
  16916. /**
  16917. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16918. */
  16919. spriteRandomStartCell: boolean;
  16920. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16921. translationPivot: Vector2;
  16922. /** @hidden */
  16923. protected _isAnimationSheetEnabled: boolean;
  16924. /**
  16925. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16926. */
  16927. beginAnimationOnStart: boolean;
  16928. /**
  16929. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16930. */
  16931. beginAnimationFrom: number;
  16932. /**
  16933. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16934. */
  16935. beginAnimationTo: number;
  16936. /**
  16937. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16938. */
  16939. beginAnimationLoop: boolean;
  16940. /**
  16941. * Gets or sets a world offset applied to all particles
  16942. */
  16943. worldOffset: Vector3;
  16944. /**
  16945. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16946. */
  16947. get isAnimationSheetEnabled(): boolean;
  16948. set isAnimationSheetEnabled(value: boolean);
  16949. /**
  16950. * Get hosting scene
  16951. * @returns the scene
  16952. */
  16953. getScene(): Scene;
  16954. /**
  16955. * You can use gravity if you want to give an orientation to your particles.
  16956. */
  16957. gravity: Vector3;
  16958. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16959. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16960. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16961. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16962. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16963. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16964. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16965. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16966. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16967. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16968. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16969. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16970. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16971. /**
  16972. * Defines the delay in milliseconds before starting the system (0 by default)
  16973. */
  16974. startDelay: number;
  16975. /**
  16976. * Gets the current list of drag gradients.
  16977. * You must use addDragGradient and removeDragGradient to udpate this list
  16978. * @returns the list of drag gradients
  16979. */
  16980. getDragGradients(): Nullable<Array<FactorGradient>>;
  16981. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16982. limitVelocityDamping: number;
  16983. /**
  16984. * Gets the current list of limit velocity gradients.
  16985. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16986. * @returns the list of limit velocity gradients
  16987. */
  16988. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16989. /**
  16990. * Gets the current list of color gradients.
  16991. * You must use addColorGradient and removeColorGradient to udpate this list
  16992. * @returns the list of color gradients
  16993. */
  16994. getColorGradients(): Nullable<Array<ColorGradient>>;
  16995. /**
  16996. * Gets the current list of size gradients.
  16997. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16998. * @returns the list of size gradients
  16999. */
  17000. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17001. /**
  17002. * Gets the current list of color remap gradients.
  17003. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17004. * @returns the list of color remap gradients
  17005. */
  17006. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17007. /**
  17008. * Gets the current list of alpha remap gradients.
  17009. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17010. * @returns the list of alpha remap gradients
  17011. */
  17012. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17013. /**
  17014. * Gets the current list of life time gradients.
  17015. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17016. * @returns the list of life time gradients
  17017. */
  17018. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17019. /**
  17020. * Gets the current list of angular speed gradients.
  17021. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17022. * @returns the list of angular speed gradients
  17023. */
  17024. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17025. /**
  17026. * Gets the current list of velocity gradients.
  17027. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17028. * @returns the list of velocity gradients
  17029. */
  17030. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17031. /**
  17032. * Gets the current list of start size gradients.
  17033. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17034. * @returns the list of start size gradients
  17035. */
  17036. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17037. /**
  17038. * Gets the current list of emit rate gradients.
  17039. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17040. * @returns the list of emit rate gradients
  17041. */
  17042. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17043. /**
  17044. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17045. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17046. */
  17047. get direction1(): Vector3;
  17048. set direction1(value: Vector3);
  17049. /**
  17050. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17051. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17052. */
  17053. get direction2(): Vector3;
  17054. set direction2(value: Vector3);
  17055. /**
  17056. * 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.
  17057. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17058. */
  17059. get minEmitBox(): Vector3;
  17060. set minEmitBox(value: Vector3);
  17061. /**
  17062. * 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.
  17063. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17064. */
  17065. get maxEmitBox(): Vector3;
  17066. set maxEmitBox(value: Vector3);
  17067. /**
  17068. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17069. */
  17070. color1: Color4;
  17071. /**
  17072. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17073. */
  17074. color2: Color4;
  17075. /**
  17076. * Color the particle will have at the end of its lifetime
  17077. */
  17078. colorDead: Color4;
  17079. /**
  17080. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17081. */
  17082. textureMask: Color4;
  17083. /**
  17084. * The particle emitter type defines the emitter used by the particle system.
  17085. * It can be for example box, sphere, or cone...
  17086. */
  17087. particleEmitterType: IParticleEmitterType;
  17088. /** @hidden */
  17089. _isSubEmitter: boolean;
  17090. /**
  17091. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17092. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17093. */
  17094. billboardMode: number;
  17095. protected _isBillboardBased: boolean;
  17096. /**
  17097. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17098. */
  17099. get isBillboardBased(): boolean;
  17100. set isBillboardBased(value: boolean);
  17101. /**
  17102. * The scene the particle system belongs to.
  17103. */
  17104. protected _scene: Scene;
  17105. /**
  17106. * Local cache of defines for image processing.
  17107. */
  17108. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17109. /**
  17110. * Default configuration related to image processing available in the standard Material.
  17111. */
  17112. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17113. /**
  17114. * Gets the image processing configuration used either in this material.
  17115. */
  17116. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17117. /**
  17118. * Sets the Default image processing configuration used either in the this material.
  17119. *
  17120. * If sets to null, the scene one is in use.
  17121. */
  17122. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17123. /**
  17124. * Attaches a new image processing configuration to the Standard Material.
  17125. * @param configuration
  17126. */
  17127. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17128. /** @hidden */
  17129. protected _reset(): void;
  17130. /** @hidden */
  17131. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17132. /**
  17133. * Instantiates a particle system.
  17134. * 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.
  17135. * @param name The name of the particle system
  17136. */
  17137. constructor(name: string);
  17138. /**
  17139. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17140. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17141. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17142. * @returns the emitter
  17143. */
  17144. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17145. /**
  17146. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17147. * @param radius The radius of the hemisphere to emit from
  17148. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17149. * @returns the emitter
  17150. */
  17151. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17152. /**
  17153. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17154. * @param radius The radius of the sphere to emit from
  17155. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17156. * @returns the emitter
  17157. */
  17158. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17159. /**
  17160. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17161. * @param radius The radius of the sphere to emit from
  17162. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17163. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17164. * @returns the emitter
  17165. */
  17166. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17167. /**
  17168. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17169. * @param radius The radius of the emission cylinder
  17170. * @param height The height of the emission cylinder
  17171. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17172. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17173. * @returns the emitter
  17174. */
  17175. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17176. /**
  17177. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17178. * @param radius The radius of the cylinder to emit from
  17179. * @param height The height of the emission cylinder
  17180. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17181. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17182. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17183. * @returns the emitter
  17184. */
  17185. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17186. /**
  17187. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17188. * @param radius The radius of the cone to emit from
  17189. * @param angle The base angle of the cone
  17190. * @returns the emitter
  17191. */
  17192. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17193. /**
  17194. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17195. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17196. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17197. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17198. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17199. * @returns the emitter
  17200. */
  17201. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17202. }
  17203. }
  17204. declare module BABYLON {
  17205. /**
  17206. * Type of sub emitter
  17207. */
  17208. export enum SubEmitterType {
  17209. /**
  17210. * Attached to the particle over it's lifetime
  17211. */
  17212. ATTACHED = 0,
  17213. /**
  17214. * Created when the particle dies
  17215. */
  17216. END = 1
  17217. }
  17218. /**
  17219. * Sub emitter class used to emit particles from an existing particle
  17220. */
  17221. export class SubEmitter {
  17222. /**
  17223. * the particle system to be used by the sub emitter
  17224. */
  17225. particleSystem: ParticleSystem;
  17226. /**
  17227. * Type of the submitter (Default: END)
  17228. */
  17229. type: SubEmitterType;
  17230. /**
  17231. * 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)
  17232. * Note: This only is supported when using an emitter of type Mesh
  17233. */
  17234. inheritDirection: boolean;
  17235. /**
  17236. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17237. */
  17238. inheritedVelocityAmount: number;
  17239. /**
  17240. * Creates a sub emitter
  17241. * @param particleSystem the particle system to be used by the sub emitter
  17242. */
  17243. constructor(
  17244. /**
  17245. * the particle system to be used by the sub emitter
  17246. */
  17247. particleSystem: ParticleSystem);
  17248. /**
  17249. * Clones the sub emitter
  17250. * @returns the cloned sub emitter
  17251. */
  17252. clone(): SubEmitter;
  17253. /**
  17254. * Serialize current object to a JSON object
  17255. * @returns the serialized object
  17256. */
  17257. serialize(): any;
  17258. /** @hidden */
  17259. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17260. /**
  17261. * Creates a new SubEmitter from a serialized JSON version
  17262. * @param serializationObject defines the JSON object to read from
  17263. * @param scene defines the hosting scene
  17264. * @param rootUrl defines the rootUrl for data loading
  17265. * @returns a new SubEmitter
  17266. */
  17267. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17268. /** Release associated resources */
  17269. dispose(): void;
  17270. }
  17271. }
  17272. declare module BABYLON {
  17273. /** @hidden */
  17274. export var clipPlaneFragmentDeclaration: {
  17275. name: string;
  17276. shader: string;
  17277. };
  17278. }
  17279. declare module BABYLON {
  17280. /** @hidden */
  17281. export var imageProcessingDeclaration: {
  17282. name: string;
  17283. shader: string;
  17284. };
  17285. }
  17286. declare module BABYLON {
  17287. /** @hidden */
  17288. export var imageProcessingFunctions: {
  17289. name: string;
  17290. shader: string;
  17291. };
  17292. }
  17293. declare module BABYLON {
  17294. /** @hidden */
  17295. export var clipPlaneFragment: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module BABYLON {
  17301. /** @hidden */
  17302. export var particlesPixelShader: {
  17303. name: string;
  17304. shader: string;
  17305. };
  17306. }
  17307. declare module BABYLON {
  17308. /** @hidden */
  17309. export var clipPlaneVertexDeclaration: {
  17310. name: string;
  17311. shader: string;
  17312. };
  17313. }
  17314. declare module BABYLON {
  17315. /** @hidden */
  17316. export var clipPlaneVertex: {
  17317. name: string;
  17318. shader: string;
  17319. };
  17320. }
  17321. declare module BABYLON {
  17322. /** @hidden */
  17323. export var particlesVertexShader: {
  17324. name: string;
  17325. shader: string;
  17326. };
  17327. }
  17328. declare module BABYLON {
  17329. /**
  17330. * This represents a particle system in Babylon.
  17331. * 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.
  17332. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17333. * @example https://doc.babylonjs.com/babylon101/particles
  17334. */
  17335. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17336. /**
  17337. * Billboard mode will only apply to Y axis
  17338. */
  17339. static readonly BILLBOARDMODE_Y: number;
  17340. /**
  17341. * Billboard mode will apply to all axes
  17342. */
  17343. static readonly BILLBOARDMODE_ALL: number;
  17344. /**
  17345. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17346. */
  17347. static readonly BILLBOARDMODE_STRETCHED: number;
  17348. /**
  17349. * This function can be defined to provide custom update for active particles.
  17350. * This function will be called instead of regular update (age, position, color, etc.).
  17351. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17352. */
  17353. updateFunction: (particles: Particle[]) => void;
  17354. private _emitterWorldMatrix;
  17355. /**
  17356. * This function can be defined to specify initial direction for every new particle.
  17357. * It by default use the emitterType defined function
  17358. */
  17359. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17360. /**
  17361. * This function can be defined to specify initial position for every new particle.
  17362. * It by default use the emitterType defined function
  17363. */
  17364. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17365. /**
  17366. * @hidden
  17367. */
  17368. _inheritedVelocityOffset: Vector3;
  17369. /**
  17370. * An event triggered when the system is disposed
  17371. */
  17372. onDisposeObservable: Observable<ParticleSystem>;
  17373. private _onDisposeObserver;
  17374. /**
  17375. * Sets a callback that will be triggered when the system is disposed
  17376. */
  17377. set onDispose(callback: () => void);
  17378. private _particles;
  17379. private _epsilon;
  17380. private _capacity;
  17381. private _stockParticles;
  17382. private _newPartsExcess;
  17383. private _vertexData;
  17384. private _vertexBuffer;
  17385. private _vertexBuffers;
  17386. private _spriteBuffer;
  17387. private _indexBuffer;
  17388. private _effect;
  17389. private _customEffect;
  17390. private _cachedDefines;
  17391. private _scaledColorStep;
  17392. private _colorDiff;
  17393. private _scaledDirection;
  17394. private _scaledGravity;
  17395. private _currentRenderId;
  17396. private _alive;
  17397. private _useInstancing;
  17398. private _started;
  17399. private _stopped;
  17400. private _actualFrame;
  17401. private _scaledUpdateSpeed;
  17402. private _vertexBufferSize;
  17403. /** @hidden */
  17404. _currentEmitRateGradient: Nullable<FactorGradient>;
  17405. /** @hidden */
  17406. _currentEmitRate1: number;
  17407. /** @hidden */
  17408. _currentEmitRate2: number;
  17409. /** @hidden */
  17410. _currentStartSizeGradient: Nullable<FactorGradient>;
  17411. /** @hidden */
  17412. _currentStartSize1: number;
  17413. /** @hidden */
  17414. _currentStartSize2: number;
  17415. private readonly _rawTextureWidth;
  17416. private _rampGradientsTexture;
  17417. private _useRampGradients;
  17418. /** Gets or sets a boolean indicating that ramp gradients must be used
  17419. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17420. */
  17421. get useRampGradients(): boolean;
  17422. set useRampGradients(value: boolean);
  17423. /**
  17424. * 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.
  17425. * 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: [])
  17426. */
  17427. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17428. private _subEmitters;
  17429. /**
  17430. * @hidden
  17431. * If the particle systems emitter should be disposed when the particle system is disposed
  17432. */
  17433. _disposeEmitterOnDispose: boolean;
  17434. /**
  17435. * The current active Sub-systems, this property is used by the root particle system only.
  17436. */
  17437. activeSubSystems: Array<ParticleSystem>;
  17438. private _rootParticleSystem;
  17439. /**
  17440. * Gets the current list of active particles
  17441. */
  17442. get particles(): Particle[];
  17443. /**
  17444. * Returns the string "ParticleSystem"
  17445. * @returns a string containing the class name
  17446. */
  17447. getClassName(): string;
  17448. /**
  17449. * Instantiates a particle system.
  17450. * 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.
  17451. * @param name The name of the particle system
  17452. * @param capacity The max number of particles alive at the same time
  17453. * @param scene The scene the particle system belongs to
  17454. * @param customEffect a custom effect used to change the way particles are rendered by default
  17455. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17456. * @param epsilon Offset used to render the particles
  17457. */
  17458. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17459. private _addFactorGradient;
  17460. private _removeFactorGradient;
  17461. /**
  17462. * Adds a new life time gradient
  17463. * @param gradient defines the gradient to use (between 0 and 1)
  17464. * @param factor defines the life time factor to affect to the specified gradient
  17465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17466. * @returns the current particle system
  17467. */
  17468. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17469. /**
  17470. * Remove a specific life time gradient
  17471. * @param gradient defines the gradient to remove
  17472. * @returns the current particle system
  17473. */
  17474. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17475. /**
  17476. * Adds a new size gradient
  17477. * @param gradient defines the gradient to use (between 0 and 1)
  17478. * @param factor defines the size factor to affect to the specified gradient
  17479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17480. * @returns the current particle system
  17481. */
  17482. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17483. /**
  17484. * Remove a specific size gradient
  17485. * @param gradient defines the gradient to remove
  17486. * @returns the current particle system
  17487. */
  17488. removeSizeGradient(gradient: number): IParticleSystem;
  17489. /**
  17490. * Adds a new color remap gradient
  17491. * @param gradient defines the gradient to use (between 0 and 1)
  17492. * @param min defines the color remap minimal range
  17493. * @param max defines the color remap maximal range
  17494. * @returns the current particle system
  17495. */
  17496. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17497. /**
  17498. * Remove a specific color remap gradient
  17499. * @param gradient defines the gradient to remove
  17500. * @returns the current particle system
  17501. */
  17502. removeColorRemapGradient(gradient: number): IParticleSystem;
  17503. /**
  17504. * Adds a new alpha remap gradient
  17505. * @param gradient defines the gradient to use (between 0 and 1)
  17506. * @param min defines the alpha remap minimal range
  17507. * @param max defines the alpha remap maximal range
  17508. * @returns the current particle system
  17509. */
  17510. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17511. /**
  17512. * Remove a specific alpha remap gradient
  17513. * @param gradient defines the gradient to remove
  17514. * @returns the current particle system
  17515. */
  17516. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17517. /**
  17518. * Adds a new angular speed gradient
  17519. * @param gradient defines the gradient to use (between 0 and 1)
  17520. * @param factor defines the angular speed to affect to the specified gradient
  17521. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17522. * @returns the current particle system
  17523. */
  17524. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17525. /**
  17526. * Remove a specific angular speed gradient
  17527. * @param gradient defines the gradient to remove
  17528. * @returns the current particle system
  17529. */
  17530. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17531. /**
  17532. * Adds a new velocity gradient
  17533. * @param gradient defines the gradient to use (between 0 and 1)
  17534. * @param factor defines the velocity to affect to the specified gradient
  17535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17536. * @returns the current particle system
  17537. */
  17538. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17539. /**
  17540. * Remove a specific velocity gradient
  17541. * @param gradient defines the gradient to remove
  17542. * @returns the current particle system
  17543. */
  17544. removeVelocityGradient(gradient: number): IParticleSystem;
  17545. /**
  17546. * Adds a new limit velocity gradient
  17547. * @param gradient defines the gradient to use (between 0 and 1)
  17548. * @param factor defines the limit velocity value to affect to the specified gradient
  17549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17550. * @returns the current particle system
  17551. */
  17552. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17553. /**
  17554. * Remove a specific limit velocity gradient
  17555. * @param gradient defines the gradient to remove
  17556. * @returns the current particle system
  17557. */
  17558. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17559. /**
  17560. * Adds a new drag gradient
  17561. * @param gradient defines the gradient to use (between 0 and 1)
  17562. * @param factor defines the drag value to affect to the specified gradient
  17563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17564. * @returns the current particle system
  17565. */
  17566. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17567. /**
  17568. * Remove a specific drag gradient
  17569. * @param gradient defines the gradient to remove
  17570. * @returns the current particle system
  17571. */
  17572. removeDragGradient(gradient: number): IParticleSystem;
  17573. /**
  17574. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17575. * @param gradient defines the gradient to use (between 0 and 1)
  17576. * @param factor defines the emit rate value to affect to the specified gradient
  17577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17578. * @returns the current particle system
  17579. */
  17580. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17581. /**
  17582. * Remove a specific emit rate gradient
  17583. * @param gradient defines the gradient to remove
  17584. * @returns the current particle system
  17585. */
  17586. removeEmitRateGradient(gradient: number): IParticleSystem;
  17587. /**
  17588. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17589. * @param gradient defines the gradient to use (between 0 and 1)
  17590. * @param factor defines the start size value to affect to the specified gradient
  17591. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17592. * @returns the current particle system
  17593. */
  17594. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17595. /**
  17596. * Remove a specific start size gradient
  17597. * @param gradient defines the gradient to remove
  17598. * @returns the current particle system
  17599. */
  17600. removeStartSizeGradient(gradient: number): IParticleSystem;
  17601. private _createRampGradientTexture;
  17602. /**
  17603. * Gets the current list of ramp gradients.
  17604. * You must use addRampGradient and removeRampGradient to udpate this list
  17605. * @returns the list of ramp gradients
  17606. */
  17607. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17608. /**
  17609. * Adds a new ramp gradient used to remap particle colors
  17610. * @param gradient defines the gradient to use (between 0 and 1)
  17611. * @param color defines the color to affect to the specified gradient
  17612. * @returns the current particle system
  17613. */
  17614. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17615. /**
  17616. * Remove a specific ramp gradient
  17617. * @param gradient defines the gradient to remove
  17618. * @returns the current particle system
  17619. */
  17620. removeRampGradient(gradient: number): ParticleSystem;
  17621. /**
  17622. * Adds a new color gradient
  17623. * @param gradient defines the gradient to use (between 0 and 1)
  17624. * @param color1 defines the color to affect to the specified gradient
  17625. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17626. * @returns this particle system
  17627. */
  17628. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17629. /**
  17630. * Remove a specific color gradient
  17631. * @param gradient defines the gradient to remove
  17632. * @returns this particle system
  17633. */
  17634. removeColorGradient(gradient: number): IParticleSystem;
  17635. private _fetchR;
  17636. protected _reset(): void;
  17637. private _resetEffect;
  17638. private _createVertexBuffers;
  17639. private _createIndexBuffer;
  17640. /**
  17641. * Gets the maximum number of particles active at the same time.
  17642. * @returns The max number of active particles.
  17643. */
  17644. getCapacity(): number;
  17645. /**
  17646. * Gets whether there are still active particles in the system.
  17647. * @returns True if it is alive, otherwise false.
  17648. */
  17649. isAlive(): boolean;
  17650. /**
  17651. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17652. * @returns True if it has been started, otherwise false.
  17653. */
  17654. isStarted(): boolean;
  17655. private _prepareSubEmitterInternalArray;
  17656. /**
  17657. * Starts the particle system and begins to emit
  17658. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17659. */
  17660. start(delay?: number): void;
  17661. /**
  17662. * Stops the particle system.
  17663. * @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.
  17664. */
  17665. stop(stopSubEmitters?: boolean): void;
  17666. /**
  17667. * Remove all active particles
  17668. */
  17669. reset(): void;
  17670. /**
  17671. * @hidden (for internal use only)
  17672. */
  17673. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17674. /**
  17675. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17676. * Its lifetime will start back at 0.
  17677. */
  17678. recycleParticle: (particle: Particle) => void;
  17679. private _stopSubEmitters;
  17680. private _createParticle;
  17681. private _removeFromRoot;
  17682. private _emitFromParticle;
  17683. private _update;
  17684. /** @hidden */
  17685. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17686. /** @hidden */
  17687. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17688. /** @hidden */
  17689. private _getEffect;
  17690. /**
  17691. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17692. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17693. */
  17694. animate(preWarmOnly?: boolean): void;
  17695. private _appendParticleVertices;
  17696. /**
  17697. * Rebuilds the particle system.
  17698. */
  17699. rebuild(): void;
  17700. /**
  17701. * Is this system ready to be used/rendered
  17702. * @return true if the system is ready
  17703. */
  17704. isReady(): boolean;
  17705. private _render;
  17706. /**
  17707. * Renders the particle system in its current state.
  17708. * @returns the current number of particles
  17709. */
  17710. render(): number;
  17711. /**
  17712. * Disposes the particle system and free the associated resources
  17713. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17714. */
  17715. dispose(disposeTexture?: boolean): void;
  17716. /**
  17717. * Clones the particle system.
  17718. * @param name The name of the cloned object
  17719. * @param newEmitter The new emitter to use
  17720. * @returns the cloned particle system
  17721. */
  17722. clone(name: string, newEmitter: any): ParticleSystem;
  17723. /**
  17724. * Serializes the particle system to a JSON object.
  17725. * @returns the JSON object
  17726. */
  17727. serialize(): any;
  17728. /** @hidden */
  17729. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17730. /** @hidden */
  17731. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17732. /**
  17733. * Parses a JSON object to create a particle system.
  17734. * @param parsedParticleSystem The JSON object to parse
  17735. * @param scene The scene to create the particle system in
  17736. * @param rootUrl The root url to use to load external dependencies like texture
  17737. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17738. * @returns the Parsed particle system
  17739. */
  17740. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17741. }
  17742. }
  17743. declare module BABYLON {
  17744. /**
  17745. * A particle represents one of the element emitted by a particle system.
  17746. * This is mainly define by its coordinates, direction, velocity and age.
  17747. */
  17748. export class Particle {
  17749. /**
  17750. * The particle system the particle belongs to.
  17751. */
  17752. particleSystem: ParticleSystem;
  17753. private static _Count;
  17754. /**
  17755. * Unique ID of the particle
  17756. */
  17757. id: number;
  17758. /**
  17759. * The world position of the particle in the scene.
  17760. */
  17761. position: Vector3;
  17762. /**
  17763. * The world direction of the particle in the scene.
  17764. */
  17765. direction: Vector3;
  17766. /**
  17767. * The color of the particle.
  17768. */
  17769. color: Color4;
  17770. /**
  17771. * The color change of the particle per step.
  17772. */
  17773. colorStep: Color4;
  17774. /**
  17775. * Defines how long will the life of the particle be.
  17776. */
  17777. lifeTime: number;
  17778. /**
  17779. * The current age of the particle.
  17780. */
  17781. age: number;
  17782. /**
  17783. * The current size of the particle.
  17784. */
  17785. size: number;
  17786. /**
  17787. * The current scale of the particle.
  17788. */
  17789. scale: Vector2;
  17790. /**
  17791. * The current angle of the particle.
  17792. */
  17793. angle: number;
  17794. /**
  17795. * Defines how fast is the angle changing.
  17796. */
  17797. angularSpeed: number;
  17798. /**
  17799. * Defines the cell index used by the particle to be rendered from a sprite.
  17800. */
  17801. cellIndex: number;
  17802. /**
  17803. * The information required to support color remapping
  17804. */
  17805. remapData: Vector4;
  17806. /** @hidden */
  17807. _randomCellOffset?: number;
  17808. /** @hidden */
  17809. _initialDirection: Nullable<Vector3>;
  17810. /** @hidden */
  17811. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17812. /** @hidden */
  17813. _initialStartSpriteCellID: number;
  17814. /** @hidden */
  17815. _initialEndSpriteCellID: number;
  17816. /** @hidden */
  17817. _currentColorGradient: Nullable<ColorGradient>;
  17818. /** @hidden */
  17819. _currentColor1: Color4;
  17820. /** @hidden */
  17821. _currentColor2: Color4;
  17822. /** @hidden */
  17823. _currentSizeGradient: Nullable<FactorGradient>;
  17824. /** @hidden */
  17825. _currentSize1: number;
  17826. /** @hidden */
  17827. _currentSize2: number;
  17828. /** @hidden */
  17829. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17830. /** @hidden */
  17831. _currentAngularSpeed1: number;
  17832. /** @hidden */
  17833. _currentAngularSpeed2: number;
  17834. /** @hidden */
  17835. _currentVelocityGradient: Nullable<FactorGradient>;
  17836. /** @hidden */
  17837. _currentVelocity1: number;
  17838. /** @hidden */
  17839. _currentVelocity2: number;
  17840. /** @hidden */
  17841. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17842. /** @hidden */
  17843. _currentLimitVelocity1: number;
  17844. /** @hidden */
  17845. _currentLimitVelocity2: number;
  17846. /** @hidden */
  17847. _currentDragGradient: Nullable<FactorGradient>;
  17848. /** @hidden */
  17849. _currentDrag1: number;
  17850. /** @hidden */
  17851. _currentDrag2: number;
  17852. /** @hidden */
  17853. _randomNoiseCoordinates1: Vector3;
  17854. /** @hidden */
  17855. _randomNoiseCoordinates2: Vector3;
  17856. /**
  17857. * Creates a new instance Particle
  17858. * @param particleSystem the particle system the particle belongs to
  17859. */
  17860. constructor(
  17861. /**
  17862. * The particle system the particle belongs to.
  17863. */
  17864. particleSystem: ParticleSystem);
  17865. private updateCellInfoFromSystem;
  17866. /**
  17867. * Defines how the sprite cell index is updated for the particle
  17868. */
  17869. updateCellIndex(): void;
  17870. /** @hidden */
  17871. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17872. /** @hidden */
  17873. _inheritParticleInfoToSubEmitters(): void;
  17874. /** @hidden */
  17875. _reset(): void;
  17876. /**
  17877. * Copy the properties of particle to another one.
  17878. * @param other the particle to copy the information to.
  17879. */
  17880. copyTo(other: Particle): void;
  17881. }
  17882. }
  17883. declare module BABYLON {
  17884. /**
  17885. * Particle emitter represents a volume emitting particles.
  17886. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17887. */
  17888. export interface IParticleEmitterType {
  17889. /**
  17890. * Called by the particle System when the direction is computed for the created particle.
  17891. * @param worldMatrix is the world matrix of the particle system
  17892. * @param directionToUpdate is the direction vector to update with the result
  17893. * @param particle is the particle we are computed the direction for
  17894. */
  17895. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17896. /**
  17897. * Called by the particle System when the position is computed for the created particle.
  17898. * @param worldMatrix is the world matrix of the particle system
  17899. * @param positionToUpdate is the position vector to update with the result
  17900. * @param particle is the particle we are computed the position for
  17901. */
  17902. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17903. /**
  17904. * Clones the current emitter and returns a copy of it
  17905. * @returns the new emitter
  17906. */
  17907. clone(): IParticleEmitterType;
  17908. /**
  17909. * Called by the GPUParticleSystem to setup the update shader
  17910. * @param effect defines the update shader
  17911. */
  17912. applyToShader(effect: Effect): void;
  17913. /**
  17914. * Returns a string to use to update the GPU particles update shader
  17915. * @returns the effect defines string
  17916. */
  17917. getEffectDefines(): string;
  17918. /**
  17919. * Returns a string representing the class name
  17920. * @returns a string containing the class name
  17921. */
  17922. getClassName(): string;
  17923. /**
  17924. * Serializes the particle system to a JSON object.
  17925. * @returns the JSON object
  17926. */
  17927. serialize(): any;
  17928. /**
  17929. * Parse properties from a JSON object
  17930. * @param serializationObject defines the JSON object
  17931. */
  17932. parse(serializationObject: any): void;
  17933. }
  17934. }
  17935. declare module BABYLON {
  17936. /**
  17937. * Particle emitter emitting particles from the inside of a box.
  17938. * It emits the particles randomly between 2 given directions.
  17939. */
  17940. export class BoxParticleEmitter implements IParticleEmitterType {
  17941. /**
  17942. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17943. */
  17944. direction1: Vector3;
  17945. /**
  17946. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17947. */
  17948. direction2: Vector3;
  17949. /**
  17950. * 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.
  17951. */
  17952. minEmitBox: Vector3;
  17953. /**
  17954. * 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.
  17955. */
  17956. maxEmitBox: Vector3;
  17957. /**
  17958. * Creates a new instance BoxParticleEmitter
  17959. */
  17960. constructor();
  17961. /**
  17962. * Called by the particle System when the direction is computed for the created particle.
  17963. * @param worldMatrix is the world matrix of the particle system
  17964. * @param directionToUpdate is the direction vector to update with the result
  17965. * @param particle is the particle we are computed the direction for
  17966. */
  17967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17968. /**
  17969. * Called by the particle System when the position is computed for the created particle.
  17970. * @param worldMatrix is the world matrix of the particle system
  17971. * @param positionToUpdate is the position vector to update with the result
  17972. * @param particle is the particle we are computed the position for
  17973. */
  17974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17975. /**
  17976. * Clones the current emitter and returns a copy of it
  17977. * @returns the new emitter
  17978. */
  17979. clone(): BoxParticleEmitter;
  17980. /**
  17981. * Called by the GPUParticleSystem to setup the update shader
  17982. * @param effect defines the update shader
  17983. */
  17984. applyToShader(effect: Effect): void;
  17985. /**
  17986. * Returns a string to use to update the GPU particles update shader
  17987. * @returns a string containng the defines string
  17988. */
  17989. getEffectDefines(): string;
  17990. /**
  17991. * Returns the string "BoxParticleEmitter"
  17992. * @returns a string containing the class name
  17993. */
  17994. getClassName(): string;
  17995. /**
  17996. * Serializes the particle system to a JSON object.
  17997. * @returns the JSON object
  17998. */
  17999. serialize(): any;
  18000. /**
  18001. * Parse properties from a JSON object
  18002. * @param serializationObject defines the JSON object
  18003. */
  18004. parse(serializationObject: any): void;
  18005. }
  18006. }
  18007. declare module BABYLON {
  18008. /**
  18009. * Particle emitter emitting particles from the inside of a cone.
  18010. * It emits the particles alongside the cone volume from the base to the particle.
  18011. * The emission direction might be randomized.
  18012. */
  18013. export class ConeParticleEmitter implements IParticleEmitterType {
  18014. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18015. directionRandomizer: number;
  18016. private _radius;
  18017. private _angle;
  18018. private _height;
  18019. /**
  18020. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18021. */
  18022. radiusRange: number;
  18023. /**
  18024. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18025. */
  18026. heightRange: number;
  18027. /**
  18028. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18029. */
  18030. emitFromSpawnPointOnly: boolean;
  18031. /**
  18032. * Gets or sets the radius of the emission cone
  18033. */
  18034. get radius(): number;
  18035. set radius(value: number);
  18036. /**
  18037. * Gets or sets the angle of the emission cone
  18038. */
  18039. get angle(): number;
  18040. set angle(value: number);
  18041. private _buildHeight;
  18042. /**
  18043. * Creates a new instance ConeParticleEmitter
  18044. * @param radius the radius of the emission cone (1 by default)
  18045. * @param angle the cone base angle (PI by default)
  18046. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18047. */
  18048. constructor(radius?: number, angle?: number,
  18049. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18050. directionRandomizer?: number);
  18051. /**
  18052. * Called by the particle System when the direction is computed for the created particle.
  18053. * @param worldMatrix is the world matrix of the particle system
  18054. * @param directionToUpdate is the direction vector to update with the result
  18055. * @param particle is the particle we are computed the direction for
  18056. */
  18057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18058. /**
  18059. * Called by the particle System when the position is computed for the created particle.
  18060. * @param worldMatrix is the world matrix of the particle system
  18061. * @param positionToUpdate is the position vector to update with the result
  18062. * @param particle is the particle we are computed the position for
  18063. */
  18064. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18065. /**
  18066. * Clones the current emitter and returns a copy of it
  18067. * @returns the new emitter
  18068. */
  18069. clone(): ConeParticleEmitter;
  18070. /**
  18071. * Called by the GPUParticleSystem to setup the update shader
  18072. * @param effect defines the update shader
  18073. */
  18074. applyToShader(effect: Effect): void;
  18075. /**
  18076. * Returns a string to use to update the GPU particles update shader
  18077. * @returns a string containng the defines string
  18078. */
  18079. getEffectDefines(): string;
  18080. /**
  18081. * Returns the string "ConeParticleEmitter"
  18082. * @returns a string containing the class name
  18083. */
  18084. getClassName(): string;
  18085. /**
  18086. * Serializes the particle system to a JSON object.
  18087. * @returns the JSON object
  18088. */
  18089. serialize(): any;
  18090. /**
  18091. * Parse properties from a JSON object
  18092. * @param serializationObject defines the JSON object
  18093. */
  18094. parse(serializationObject: any): void;
  18095. }
  18096. }
  18097. declare module BABYLON {
  18098. /**
  18099. * Particle emitter emitting particles from the inside of a cylinder.
  18100. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18101. */
  18102. export class CylinderParticleEmitter implements IParticleEmitterType {
  18103. /**
  18104. * The radius of the emission cylinder.
  18105. */
  18106. radius: number;
  18107. /**
  18108. * The height of the emission cylinder.
  18109. */
  18110. height: number;
  18111. /**
  18112. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18113. */
  18114. radiusRange: number;
  18115. /**
  18116. * How much to randomize the particle direction [0-1].
  18117. */
  18118. directionRandomizer: number;
  18119. /**
  18120. * Creates a new instance CylinderParticleEmitter
  18121. * @param radius the radius of the emission cylinder (1 by default)
  18122. * @param height the height of the emission cylinder (1 by default)
  18123. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18124. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18125. */
  18126. constructor(
  18127. /**
  18128. * The radius of the emission cylinder.
  18129. */
  18130. radius?: number,
  18131. /**
  18132. * The height of the emission cylinder.
  18133. */
  18134. height?: number,
  18135. /**
  18136. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18137. */
  18138. radiusRange?: number,
  18139. /**
  18140. * How much to randomize the particle direction [0-1].
  18141. */
  18142. directionRandomizer?: number);
  18143. /**
  18144. * Called by the particle System when the direction is computed for the created particle.
  18145. * @param worldMatrix is the world matrix of the particle system
  18146. * @param directionToUpdate is the direction vector to update with the result
  18147. * @param particle is the particle we are computed the direction for
  18148. */
  18149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18150. /**
  18151. * Called by the particle System when the position is computed for the created particle.
  18152. * @param worldMatrix is the world matrix of the particle system
  18153. * @param positionToUpdate is the position vector to update with the result
  18154. * @param particle is the particle we are computed the position for
  18155. */
  18156. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18157. /**
  18158. * Clones the current emitter and returns a copy of it
  18159. * @returns the new emitter
  18160. */
  18161. clone(): CylinderParticleEmitter;
  18162. /**
  18163. * Called by the GPUParticleSystem to setup the update shader
  18164. * @param effect defines the update shader
  18165. */
  18166. applyToShader(effect: Effect): void;
  18167. /**
  18168. * Returns a string to use to update the GPU particles update shader
  18169. * @returns a string containng the defines string
  18170. */
  18171. getEffectDefines(): string;
  18172. /**
  18173. * Returns the string "CylinderParticleEmitter"
  18174. * @returns a string containing the class name
  18175. */
  18176. getClassName(): string;
  18177. /**
  18178. * Serializes the particle system to a JSON object.
  18179. * @returns the JSON object
  18180. */
  18181. serialize(): any;
  18182. /**
  18183. * Parse properties from a JSON object
  18184. * @param serializationObject defines the JSON object
  18185. */
  18186. parse(serializationObject: any): void;
  18187. }
  18188. /**
  18189. * Particle emitter emitting particles from the inside of a cylinder.
  18190. * It emits the particles randomly between two vectors.
  18191. */
  18192. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18193. /**
  18194. * The min limit of the emission direction.
  18195. */
  18196. direction1: Vector3;
  18197. /**
  18198. * The max limit of the emission direction.
  18199. */
  18200. direction2: Vector3;
  18201. /**
  18202. * Creates a new instance CylinderDirectedParticleEmitter
  18203. * @param radius the radius of the emission cylinder (1 by default)
  18204. * @param height the height of the emission cylinder (1 by default)
  18205. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18206. * @param direction1 the min limit of the emission direction (up vector by default)
  18207. * @param direction2 the max limit of the emission direction (up vector by default)
  18208. */
  18209. constructor(radius?: number, height?: number, radiusRange?: number,
  18210. /**
  18211. * The min limit of the emission direction.
  18212. */
  18213. direction1?: Vector3,
  18214. /**
  18215. * The max limit of the emission direction.
  18216. */
  18217. direction2?: Vector3);
  18218. /**
  18219. * Called by the particle System when the direction is computed for the created particle.
  18220. * @param worldMatrix is the world matrix of the particle system
  18221. * @param directionToUpdate is the direction vector to update with the result
  18222. * @param particle is the particle we are computed the direction for
  18223. */
  18224. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18225. /**
  18226. * Clones the current emitter and returns a copy of it
  18227. * @returns the new emitter
  18228. */
  18229. clone(): CylinderDirectedParticleEmitter;
  18230. /**
  18231. * Called by the GPUParticleSystem to setup the update shader
  18232. * @param effect defines the update shader
  18233. */
  18234. applyToShader(effect: Effect): void;
  18235. /**
  18236. * Returns a string to use to update the GPU particles update shader
  18237. * @returns a string containng the defines string
  18238. */
  18239. getEffectDefines(): string;
  18240. /**
  18241. * Returns the string "CylinderDirectedParticleEmitter"
  18242. * @returns a string containing the class name
  18243. */
  18244. getClassName(): string;
  18245. /**
  18246. * Serializes the particle system to a JSON object.
  18247. * @returns the JSON object
  18248. */
  18249. serialize(): any;
  18250. /**
  18251. * Parse properties from a JSON object
  18252. * @param serializationObject defines the JSON object
  18253. */
  18254. parse(serializationObject: any): void;
  18255. }
  18256. }
  18257. declare module BABYLON {
  18258. /**
  18259. * Particle emitter emitting particles from the inside of a hemisphere.
  18260. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18261. */
  18262. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18263. /**
  18264. * The radius of the emission hemisphere.
  18265. */
  18266. radius: number;
  18267. /**
  18268. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18269. */
  18270. radiusRange: number;
  18271. /**
  18272. * How much to randomize the particle direction [0-1].
  18273. */
  18274. directionRandomizer: number;
  18275. /**
  18276. * Creates a new instance HemisphericParticleEmitter
  18277. * @param radius the radius of the emission hemisphere (1 by default)
  18278. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18279. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18280. */
  18281. constructor(
  18282. /**
  18283. * The radius of the emission hemisphere.
  18284. */
  18285. radius?: number,
  18286. /**
  18287. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18288. */
  18289. radiusRange?: number,
  18290. /**
  18291. * How much to randomize the particle direction [0-1].
  18292. */
  18293. directionRandomizer?: number);
  18294. /**
  18295. * Called by the particle System when the direction is computed for the created particle.
  18296. * @param worldMatrix is the world matrix of the particle system
  18297. * @param directionToUpdate is the direction vector to update with the result
  18298. * @param particle is the particle we are computed the direction for
  18299. */
  18300. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18301. /**
  18302. * Called by the particle System when the position is computed for the created particle.
  18303. * @param worldMatrix is the world matrix of the particle system
  18304. * @param positionToUpdate is the position vector to update with the result
  18305. * @param particle is the particle we are computed the position for
  18306. */
  18307. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18308. /**
  18309. * Clones the current emitter and returns a copy of it
  18310. * @returns the new emitter
  18311. */
  18312. clone(): HemisphericParticleEmitter;
  18313. /**
  18314. * Called by the GPUParticleSystem to setup the update shader
  18315. * @param effect defines the update shader
  18316. */
  18317. applyToShader(effect: Effect): void;
  18318. /**
  18319. * Returns a string to use to update the GPU particles update shader
  18320. * @returns a string containng the defines string
  18321. */
  18322. getEffectDefines(): string;
  18323. /**
  18324. * Returns the string "HemisphericParticleEmitter"
  18325. * @returns a string containing the class name
  18326. */
  18327. getClassName(): string;
  18328. /**
  18329. * Serializes the particle system to a JSON object.
  18330. * @returns the JSON object
  18331. */
  18332. serialize(): any;
  18333. /**
  18334. * Parse properties from a JSON object
  18335. * @param serializationObject defines the JSON object
  18336. */
  18337. parse(serializationObject: any): void;
  18338. }
  18339. }
  18340. declare module BABYLON {
  18341. /**
  18342. * Particle emitter emitting particles from a point.
  18343. * It emits the particles randomly between 2 given directions.
  18344. */
  18345. export class PointParticleEmitter implements IParticleEmitterType {
  18346. /**
  18347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18348. */
  18349. direction1: Vector3;
  18350. /**
  18351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18352. */
  18353. direction2: Vector3;
  18354. /**
  18355. * Creates a new instance PointParticleEmitter
  18356. */
  18357. constructor();
  18358. /**
  18359. * Called by the particle System when the direction is computed for the created particle.
  18360. * @param worldMatrix is the world matrix of the particle system
  18361. * @param directionToUpdate is the direction vector to update with the result
  18362. * @param particle is the particle we are computed the direction for
  18363. */
  18364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18365. /**
  18366. * Called by the particle System when the position is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param positionToUpdate is the position vector to update with the result
  18369. * @param particle is the particle we are computed the position for
  18370. */
  18371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Clones the current emitter and returns a copy of it
  18374. * @returns the new emitter
  18375. */
  18376. clone(): PointParticleEmitter;
  18377. /**
  18378. * Called by the GPUParticleSystem to setup the update shader
  18379. * @param effect defines the update shader
  18380. */
  18381. applyToShader(effect: Effect): void;
  18382. /**
  18383. * Returns a string to use to update the GPU particles update shader
  18384. * @returns a string containng the defines string
  18385. */
  18386. getEffectDefines(): string;
  18387. /**
  18388. * Returns the string "PointParticleEmitter"
  18389. * @returns a string containing the class name
  18390. */
  18391. getClassName(): string;
  18392. /**
  18393. * Serializes the particle system to a JSON object.
  18394. * @returns the JSON object
  18395. */
  18396. serialize(): any;
  18397. /**
  18398. * Parse properties from a JSON object
  18399. * @param serializationObject defines the JSON object
  18400. */
  18401. parse(serializationObject: any): void;
  18402. }
  18403. }
  18404. declare module BABYLON {
  18405. /**
  18406. * Particle emitter emitting particles from the inside of a sphere.
  18407. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18408. */
  18409. export class SphereParticleEmitter implements IParticleEmitterType {
  18410. /**
  18411. * The radius of the emission sphere.
  18412. */
  18413. radius: number;
  18414. /**
  18415. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18416. */
  18417. radiusRange: number;
  18418. /**
  18419. * How much to randomize the particle direction [0-1].
  18420. */
  18421. directionRandomizer: number;
  18422. /**
  18423. * Creates a new instance SphereParticleEmitter
  18424. * @param radius the radius of the emission sphere (1 by default)
  18425. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18426. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18427. */
  18428. constructor(
  18429. /**
  18430. * The radius of the emission sphere.
  18431. */
  18432. radius?: number,
  18433. /**
  18434. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18435. */
  18436. radiusRange?: number,
  18437. /**
  18438. * How much to randomize the particle direction [0-1].
  18439. */
  18440. directionRandomizer?: number);
  18441. /**
  18442. * Called by the particle System when the direction is computed for the created particle.
  18443. * @param worldMatrix is the world matrix of the particle system
  18444. * @param directionToUpdate is the direction vector to update with the result
  18445. * @param particle is the particle we are computed the direction for
  18446. */
  18447. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18448. /**
  18449. * Called by the particle System when the position is computed for the created particle.
  18450. * @param worldMatrix is the world matrix of the particle system
  18451. * @param positionToUpdate is the position vector to update with the result
  18452. * @param particle is the particle we are computed the position for
  18453. */
  18454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18455. /**
  18456. * Clones the current emitter and returns a copy of it
  18457. * @returns the new emitter
  18458. */
  18459. clone(): SphereParticleEmitter;
  18460. /**
  18461. * Called by the GPUParticleSystem to setup the update shader
  18462. * @param effect defines the update shader
  18463. */
  18464. applyToShader(effect: Effect): void;
  18465. /**
  18466. * Returns a string to use to update the GPU particles update shader
  18467. * @returns a string containng the defines string
  18468. */
  18469. getEffectDefines(): string;
  18470. /**
  18471. * Returns the string "SphereParticleEmitter"
  18472. * @returns a string containing the class name
  18473. */
  18474. getClassName(): string;
  18475. /**
  18476. * Serializes the particle system to a JSON object.
  18477. * @returns the JSON object
  18478. */
  18479. serialize(): any;
  18480. /**
  18481. * Parse properties from a JSON object
  18482. * @param serializationObject defines the JSON object
  18483. */
  18484. parse(serializationObject: any): void;
  18485. }
  18486. /**
  18487. * Particle emitter emitting particles from the inside of a sphere.
  18488. * It emits the particles randomly between two vectors.
  18489. */
  18490. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18491. /**
  18492. * The min limit of the emission direction.
  18493. */
  18494. direction1: Vector3;
  18495. /**
  18496. * The max limit of the emission direction.
  18497. */
  18498. direction2: Vector3;
  18499. /**
  18500. * Creates a new instance SphereDirectedParticleEmitter
  18501. * @param radius the radius of the emission sphere (1 by default)
  18502. * @param direction1 the min limit of the emission direction (up vector by default)
  18503. * @param direction2 the max limit of the emission direction (up vector by default)
  18504. */
  18505. constructor(radius?: number,
  18506. /**
  18507. * The min limit of the emission direction.
  18508. */
  18509. direction1?: Vector3,
  18510. /**
  18511. * The max limit of the emission direction.
  18512. */
  18513. direction2?: Vector3);
  18514. /**
  18515. * Called by the particle System when the direction is computed for the created particle.
  18516. * @param worldMatrix is the world matrix of the particle system
  18517. * @param directionToUpdate is the direction vector to update with the result
  18518. * @param particle is the particle we are computed the direction for
  18519. */
  18520. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18521. /**
  18522. * Clones the current emitter and returns a copy of it
  18523. * @returns the new emitter
  18524. */
  18525. clone(): SphereDirectedParticleEmitter;
  18526. /**
  18527. * Called by the GPUParticleSystem to setup the update shader
  18528. * @param effect defines the update shader
  18529. */
  18530. applyToShader(effect: Effect): void;
  18531. /**
  18532. * Returns a string to use to update the GPU particles update shader
  18533. * @returns a string containng the defines string
  18534. */
  18535. getEffectDefines(): string;
  18536. /**
  18537. * Returns the string "SphereDirectedParticleEmitter"
  18538. * @returns a string containing the class name
  18539. */
  18540. getClassName(): string;
  18541. /**
  18542. * Serializes the particle system to a JSON object.
  18543. * @returns the JSON object
  18544. */
  18545. serialize(): any;
  18546. /**
  18547. * Parse properties from a JSON object
  18548. * @param serializationObject defines the JSON object
  18549. */
  18550. parse(serializationObject: any): void;
  18551. }
  18552. }
  18553. declare module BABYLON {
  18554. /**
  18555. * Interface representing a particle system in Babylon.js.
  18556. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18557. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18558. */
  18559. export interface IParticleSystem {
  18560. /**
  18561. * List of animations used by the particle system.
  18562. */
  18563. animations: Animation[];
  18564. /**
  18565. * The id of the Particle system.
  18566. */
  18567. id: string;
  18568. /**
  18569. * The name of the Particle system.
  18570. */
  18571. name: string;
  18572. /**
  18573. * The emitter represents the Mesh or position we are attaching the particle system to.
  18574. */
  18575. emitter: Nullable<AbstractMesh | Vector3>;
  18576. /**
  18577. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18578. */
  18579. isBillboardBased: boolean;
  18580. /**
  18581. * The rendering group used by the Particle system to chose when to render.
  18582. */
  18583. renderingGroupId: number;
  18584. /**
  18585. * The layer mask we are rendering the particles through.
  18586. */
  18587. layerMask: number;
  18588. /**
  18589. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18590. */
  18591. updateSpeed: number;
  18592. /**
  18593. * The amount of time the particle system is running (depends of the overall update speed).
  18594. */
  18595. targetStopDuration: number;
  18596. /**
  18597. * The texture used to render each particle. (this can be a spritesheet)
  18598. */
  18599. particleTexture: Nullable<Texture>;
  18600. /**
  18601. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18602. */
  18603. blendMode: number;
  18604. /**
  18605. * Minimum life time of emitting particles.
  18606. */
  18607. minLifeTime: number;
  18608. /**
  18609. * Maximum life time of emitting particles.
  18610. */
  18611. maxLifeTime: number;
  18612. /**
  18613. * Minimum Size of emitting particles.
  18614. */
  18615. minSize: number;
  18616. /**
  18617. * Maximum Size of emitting particles.
  18618. */
  18619. maxSize: number;
  18620. /**
  18621. * Minimum scale of emitting particles on X axis.
  18622. */
  18623. minScaleX: number;
  18624. /**
  18625. * Maximum scale of emitting particles on X axis.
  18626. */
  18627. maxScaleX: number;
  18628. /**
  18629. * Minimum scale of emitting particles on Y axis.
  18630. */
  18631. minScaleY: number;
  18632. /**
  18633. * Maximum scale of emitting particles on Y axis.
  18634. */
  18635. maxScaleY: number;
  18636. /**
  18637. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18638. */
  18639. color1: Color4;
  18640. /**
  18641. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18642. */
  18643. color2: Color4;
  18644. /**
  18645. * Color the particle will have at the end of its lifetime.
  18646. */
  18647. colorDead: Color4;
  18648. /**
  18649. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18650. */
  18651. emitRate: number;
  18652. /**
  18653. * You can use gravity if you want to give an orientation to your particles.
  18654. */
  18655. gravity: Vector3;
  18656. /**
  18657. * Minimum power of emitting particles.
  18658. */
  18659. minEmitPower: number;
  18660. /**
  18661. * Maximum power of emitting particles.
  18662. */
  18663. maxEmitPower: number;
  18664. /**
  18665. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18666. */
  18667. minAngularSpeed: number;
  18668. /**
  18669. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18670. */
  18671. maxAngularSpeed: number;
  18672. /**
  18673. * Gets or sets the minimal initial rotation in radians.
  18674. */
  18675. minInitialRotation: number;
  18676. /**
  18677. * Gets or sets the maximal initial rotation in radians.
  18678. */
  18679. maxInitialRotation: number;
  18680. /**
  18681. * The particle emitter type defines the emitter used by the particle system.
  18682. * It can be for example box, sphere, or cone...
  18683. */
  18684. particleEmitterType: Nullable<IParticleEmitterType>;
  18685. /**
  18686. * Defines the delay in milliseconds before starting the system (0 by default)
  18687. */
  18688. startDelay: number;
  18689. /**
  18690. * 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
  18691. */
  18692. preWarmCycles: number;
  18693. /**
  18694. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18695. */
  18696. preWarmStepOffset: number;
  18697. /**
  18698. * 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)
  18699. */
  18700. spriteCellChangeSpeed: number;
  18701. /**
  18702. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18703. */
  18704. startSpriteCellID: number;
  18705. /**
  18706. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18707. */
  18708. endSpriteCellID: number;
  18709. /**
  18710. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18711. */
  18712. spriteCellWidth: number;
  18713. /**
  18714. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18715. */
  18716. spriteCellHeight: number;
  18717. /**
  18718. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18719. */
  18720. spriteRandomStartCell: boolean;
  18721. /**
  18722. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18723. */
  18724. isAnimationSheetEnabled: boolean;
  18725. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18726. translationPivot: Vector2;
  18727. /**
  18728. * Gets or sets a texture used to add random noise to particle positions
  18729. */
  18730. noiseTexture: Nullable<BaseTexture>;
  18731. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18732. noiseStrength: Vector3;
  18733. /**
  18734. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18735. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18736. */
  18737. billboardMode: number;
  18738. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18739. limitVelocityDamping: number;
  18740. /**
  18741. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18742. */
  18743. beginAnimationOnStart: boolean;
  18744. /**
  18745. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18746. */
  18747. beginAnimationFrom: number;
  18748. /**
  18749. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18750. */
  18751. beginAnimationTo: number;
  18752. /**
  18753. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18754. */
  18755. beginAnimationLoop: boolean;
  18756. /**
  18757. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18758. */
  18759. disposeOnStop: boolean;
  18760. /**
  18761. * Gets the maximum number of particles active at the same time.
  18762. * @returns The max number of active particles.
  18763. */
  18764. getCapacity(): number;
  18765. /**
  18766. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18767. * @returns True if it has been started, otherwise false.
  18768. */
  18769. isStarted(): boolean;
  18770. /**
  18771. * Animates the particle system for this frame.
  18772. */
  18773. animate(): void;
  18774. /**
  18775. * Renders the particle system in its current state.
  18776. * @returns the current number of particles
  18777. */
  18778. render(): number;
  18779. /**
  18780. * Dispose the particle system and frees its associated resources.
  18781. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18782. */
  18783. dispose(disposeTexture?: boolean): void;
  18784. /**
  18785. * Clones the particle system.
  18786. * @param name The name of the cloned object
  18787. * @param newEmitter The new emitter to use
  18788. * @returns the cloned particle system
  18789. */
  18790. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18791. /**
  18792. * Serializes the particle system to a JSON object.
  18793. * @returns the JSON object
  18794. */
  18795. serialize(): any;
  18796. /**
  18797. * Rebuild the particle system
  18798. */
  18799. rebuild(): void;
  18800. /**
  18801. * Starts the particle system and begins to emit
  18802. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18803. */
  18804. start(delay?: number): void;
  18805. /**
  18806. * Stops the particle system.
  18807. */
  18808. stop(): void;
  18809. /**
  18810. * Remove all active particles
  18811. */
  18812. reset(): void;
  18813. /**
  18814. * Is this system ready to be used/rendered
  18815. * @return true if the system is ready
  18816. */
  18817. isReady(): boolean;
  18818. /**
  18819. * Adds a new color gradient
  18820. * @param gradient defines the gradient to use (between 0 and 1)
  18821. * @param color1 defines the color to affect to the specified gradient
  18822. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18823. * @returns the current particle system
  18824. */
  18825. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18826. /**
  18827. * Remove a specific color gradient
  18828. * @param gradient defines the gradient to remove
  18829. * @returns the current particle system
  18830. */
  18831. removeColorGradient(gradient: number): IParticleSystem;
  18832. /**
  18833. * Adds a new size gradient
  18834. * @param gradient defines the gradient to use (between 0 and 1)
  18835. * @param factor defines the size factor to affect to the specified gradient
  18836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18837. * @returns the current particle system
  18838. */
  18839. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18840. /**
  18841. * Remove a specific size gradient
  18842. * @param gradient defines the gradient to remove
  18843. * @returns the current particle system
  18844. */
  18845. removeSizeGradient(gradient: number): IParticleSystem;
  18846. /**
  18847. * Gets the current list of color gradients.
  18848. * You must use addColorGradient and removeColorGradient to udpate this list
  18849. * @returns the list of color gradients
  18850. */
  18851. getColorGradients(): Nullable<Array<ColorGradient>>;
  18852. /**
  18853. * Gets the current list of size gradients.
  18854. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18855. * @returns the list of size gradients
  18856. */
  18857. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18858. /**
  18859. * Gets the current list of angular speed gradients.
  18860. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18861. * @returns the list of angular speed gradients
  18862. */
  18863. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18864. /**
  18865. * Adds a new angular speed gradient
  18866. * @param gradient defines the gradient to use (between 0 and 1)
  18867. * @param factor defines the angular speed to affect to the specified gradient
  18868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18869. * @returns the current particle system
  18870. */
  18871. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18872. /**
  18873. * Remove a specific angular speed gradient
  18874. * @param gradient defines the gradient to remove
  18875. * @returns the current particle system
  18876. */
  18877. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18878. /**
  18879. * Gets the current list of velocity gradients.
  18880. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18881. * @returns the list of velocity gradients
  18882. */
  18883. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18884. /**
  18885. * Adds a new velocity gradient
  18886. * @param gradient defines the gradient to use (between 0 and 1)
  18887. * @param factor defines the velocity to affect to the specified gradient
  18888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18889. * @returns the current particle system
  18890. */
  18891. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18892. /**
  18893. * Remove a specific velocity gradient
  18894. * @param gradient defines the gradient to remove
  18895. * @returns the current particle system
  18896. */
  18897. removeVelocityGradient(gradient: number): IParticleSystem;
  18898. /**
  18899. * Gets the current list of limit velocity gradients.
  18900. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18901. * @returns the list of limit velocity gradients
  18902. */
  18903. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18904. /**
  18905. * Adds a new limit velocity gradient
  18906. * @param gradient defines the gradient to use (between 0 and 1)
  18907. * @param factor defines the limit velocity to affect to the specified gradient
  18908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18909. * @returns the current particle system
  18910. */
  18911. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18912. /**
  18913. * Remove a specific limit velocity gradient
  18914. * @param gradient defines the gradient to remove
  18915. * @returns the current particle system
  18916. */
  18917. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18918. /**
  18919. * Adds a new drag gradient
  18920. * @param gradient defines the gradient to use (between 0 and 1)
  18921. * @param factor defines the drag to affect to the specified gradient
  18922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18923. * @returns the current particle system
  18924. */
  18925. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18926. /**
  18927. * Remove a specific drag gradient
  18928. * @param gradient defines the gradient to remove
  18929. * @returns the current particle system
  18930. */
  18931. removeDragGradient(gradient: number): IParticleSystem;
  18932. /**
  18933. * Gets the current list of drag gradients.
  18934. * You must use addDragGradient and removeDragGradient to udpate this list
  18935. * @returns the list of drag gradients
  18936. */
  18937. getDragGradients(): Nullable<Array<FactorGradient>>;
  18938. /**
  18939. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18940. * @param gradient defines the gradient to use (between 0 and 1)
  18941. * @param factor defines the emit rate to affect to the specified gradient
  18942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18943. * @returns the current particle system
  18944. */
  18945. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18946. /**
  18947. * Remove a specific emit rate gradient
  18948. * @param gradient defines the gradient to remove
  18949. * @returns the current particle system
  18950. */
  18951. removeEmitRateGradient(gradient: number): IParticleSystem;
  18952. /**
  18953. * Gets the current list of emit rate gradients.
  18954. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18955. * @returns the list of emit rate gradients
  18956. */
  18957. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18958. /**
  18959. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18960. * @param gradient defines the gradient to use (between 0 and 1)
  18961. * @param factor defines the start size to affect to the specified gradient
  18962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18963. * @returns the current particle system
  18964. */
  18965. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18966. /**
  18967. * Remove a specific start size gradient
  18968. * @param gradient defines the gradient to remove
  18969. * @returns the current particle system
  18970. */
  18971. removeStartSizeGradient(gradient: number): IParticleSystem;
  18972. /**
  18973. * Gets the current list of start size gradients.
  18974. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18975. * @returns the list of start size gradients
  18976. */
  18977. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18978. /**
  18979. * Adds a new life time gradient
  18980. * @param gradient defines the gradient to use (between 0 and 1)
  18981. * @param factor defines the life time factor to affect to the specified gradient
  18982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18983. * @returns the current particle system
  18984. */
  18985. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18986. /**
  18987. * Remove a specific life time gradient
  18988. * @param gradient defines the gradient to remove
  18989. * @returns the current particle system
  18990. */
  18991. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18992. /**
  18993. * Gets the current list of life time gradients.
  18994. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18995. * @returns the list of life time gradients
  18996. */
  18997. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18998. /**
  18999. * Gets the current list of color gradients.
  19000. * You must use addColorGradient and removeColorGradient to udpate this list
  19001. * @returns the list of color gradients
  19002. */
  19003. getColorGradients(): Nullable<Array<ColorGradient>>;
  19004. /**
  19005. * Adds a new ramp gradient used to remap particle colors
  19006. * @param gradient defines the gradient to use (between 0 and 1)
  19007. * @param color defines the color to affect to the specified gradient
  19008. * @returns the current particle system
  19009. */
  19010. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19011. /**
  19012. * Gets the current list of ramp gradients.
  19013. * You must use addRampGradient and removeRampGradient to udpate this list
  19014. * @returns the list of ramp gradients
  19015. */
  19016. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19017. /** Gets or sets a boolean indicating that ramp gradients must be used
  19018. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19019. */
  19020. useRampGradients: boolean;
  19021. /**
  19022. * Adds a new color remap gradient
  19023. * @param gradient defines the gradient to use (between 0 and 1)
  19024. * @param min defines the color remap minimal range
  19025. * @param max defines the color remap maximal range
  19026. * @returns the current particle system
  19027. */
  19028. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19029. /**
  19030. * Gets the current list of color remap gradients.
  19031. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19032. * @returns the list of color remap gradients
  19033. */
  19034. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19035. /**
  19036. * Adds a new alpha remap gradient
  19037. * @param gradient defines the gradient to use (between 0 and 1)
  19038. * @param min defines the alpha remap minimal range
  19039. * @param max defines the alpha remap maximal range
  19040. * @returns the current particle system
  19041. */
  19042. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19043. /**
  19044. * Gets the current list of alpha remap gradients.
  19045. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19046. * @returns the list of alpha remap gradients
  19047. */
  19048. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19049. /**
  19050. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19051. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19052. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19053. * @returns the emitter
  19054. */
  19055. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19056. /**
  19057. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19058. * @param radius The radius of the hemisphere to emit from
  19059. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19060. * @returns the emitter
  19061. */
  19062. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19063. /**
  19064. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19065. * @param radius The radius of the sphere to emit from
  19066. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19067. * @returns the emitter
  19068. */
  19069. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19070. /**
  19071. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19072. * @param radius The radius of the sphere to emit from
  19073. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19074. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19075. * @returns the emitter
  19076. */
  19077. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19078. /**
  19079. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19080. * @param radius The radius of the emission cylinder
  19081. * @param height The height of the emission cylinder
  19082. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19083. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19084. * @returns the emitter
  19085. */
  19086. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19087. /**
  19088. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19089. * @param radius The radius of the cylinder to emit from
  19090. * @param height The height of the emission cylinder
  19091. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19092. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19093. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19094. * @returns the emitter
  19095. */
  19096. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19097. /**
  19098. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19099. * @param radius The radius of the cone to emit from
  19100. * @param angle The base angle of the cone
  19101. * @returns the emitter
  19102. */
  19103. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19104. /**
  19105. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19106. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19107. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19108. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19109. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19110. * @returns the emitter
  19111. */
  19112. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19113. /**
  19114. * Get hosting scene
  19115. * @returns the scene
  19116. */
  19117. getScene(): Scene;
  19118. }
  19119. }
  19120. declare module BABYLON {
  19121. /**
  19122. * Creates an instance based on a source mesh.
  19123. */
  19124. export class InstancedMesh extends AbstractMesh {
  19125. private _sourceMesh;
  19126. private _currentLOD;
  19127. /** @hidden */
  19128. _indexInSourceMeshInstanceArray: number;
  19129. constructor(name: string, source: Mesh);
  19130. /**
  19131. * Returns the string "InstancedMesh".
  19132. */
  19133. getClassName(): string;
  19134. /** Gets the list of lights affecting that mesh */
  19135. get lightSources(): Light[];
  19136. _resyncLightSources(): void;
  19137. _resyncLightSource(light: Light): void;
  19138. _removeLightSource(light: Light, dispose: boolean): void;
  19139. /**
  19140. * If the source mesh receives shadows
  19141. */
  19142. get receiveShadows(): boolean;
  19143. /**
  19144. * The material of the source mesh
  19145. */
  19146. get material(): Nullable<Material>;
  19147. /**
  19148. * Visibility of the source mesh
  19149. */
  19150. get visibility(): number;
  19151. /**
  19152. * Skeleton of the source mesh
  19153. */
  19154. get skeleton(): Nullable<Skeleton>;
  19155. /**
  19156. * Rendering ground id of the source mesh
  19157. */
  19158. get renderingGroupId(): number;
  19159. set renderingGroupId(value: number);
  19160. /**
  19161. * Returns the total number of vertices (integer).
  19162. */
  19163. getTotalVertices(): number;
  19164. /**
  19165. * Returns a positive integer : the total number of indices in this mesh geometry.
  19166. * @returns the numner of indices or zero if the mesh has no geometry.
  19167. */
  19168. getTotalIndices(): number;
  19169. /**
  19170. * The source mesh of the instance
  19171. */
  19172. get sourceMesh(): Mesh;
  19173. /**
  19174. * Is this node ready to be used/rendered
  19175. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19176. * @return {boolean} is it ready
  19177. */
  19178. isReady(completeCheck?: boolean): boolean;
  19179. /**
  19180. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19181. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19182. * @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.
  19183. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19184. */
  19185. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19186. /**
  19187. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19188. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19189. * The `data` are either a numeric array either a Float32Array.
  19190. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19191. * 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).
  19192. * Note that a new underlying VertexBuffer object is created each call.
  19193. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19194. *
  19195. * Possible `kind` values :
  19196. * - VertexBuffer.PositionKind
  19197. * - VertexBuffer.UVKind
  19198. * - VertexBuffer.UV2Kind
  19199. * - VertexBuffer.UV3Kind
  19200. * - VertexBuffer.UV4Kind
  19201. * - VertexBuffer.UV5Kind
  19202. * - VertexBuffer.UV6Kind
  19203. * - VertexBuffer.ColorKind
  19204. * - VertexBuffer.MatricesIndicesKind
  19205. * - VertexBuffer.MatricesIndicesExtraKind
  19206. * - VertexBuffer.MatricesWeightsKind
  19207. * - VertexBuffer.MatricesWeightsExtraKind
  19208. *
  19209. * Returns the Mesh.
  19210. */
  19211. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19212. /**
  19213. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19214. * If the mesh has no geometry, it is simply returned as it is.
  19215. * The `data` are either a numeric array either a Float32Array.
  19216. * No new underlying VertexBuffer object is created.
  19217. * 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.
  19218. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19219. *
  19220. * Possible `kind` values :
  19221. * - VertexBuffer.PositionKind
  19222. * - VertexBuffer.UVKind
  19223. * - VertexBuffer.UV2Kind
  19224. * - VertexBuffer.UV3Kind
  19225. * - VertexBuffer.UV4Kind
  19226. * - VertexBuffer.UV5Kind
  19227. * - VertexBuffer.UV6Kind
  19228. * - VertexBuffer.ColorKind
  19229. * - VertexBuffer.MatricesIndicesKind
  19230. * - VertexBuffer.MatricesIndicesExtraKind
  19231. * - VertexBuffer.MatricesWeightsKind
  19232. * - VertexBuffer.MatricesWeightsExtraKind
  19233. *
  19234. * Returns the Mesh.
  19235. */
  19236. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19237. /**
  19238. * Sets the mesh indices.
  19239. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19240. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19241. * This method creates a new index buffer each call.
  19242. * Returns the Mesh.
  19243. */
  19244. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19245. /**
  19246. * Boolean : True if the mesh owns the requested kind of data.
  19247. */
  19248. isVerticesDataPresent(kind: string): boolean;
  19249. /**
  19250. * Returns an array of indices (IndicesArray).
  19251. */
  19252. getIndices(): Nullable<IndicesArray>;
  19253. get _positions(): Nullable<Vector3[]>;
  19254. /**
  19255. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19256. * This means the mesh underlying bounding box and sphere are recomputed.
  19257. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19258. * @returns the current mesh
  19259. */
  19260. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19261. /** @hidden */
  19262. _preActivate(): InstancedMesh;
  19263. /** @hidden */
  19264. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19265. /** @hidden */
  19266. _postActivate(): void;
  19267. getWorldMatrix(): Matrix;
  19268. get isAnInstance(): boolean;
  19269. /**
  19270. * Returns the current associated LOD AbstractMesh.
  19271. */
  19272. getLOD(camera: Camera): AbstractMesh;
  19273. /** @hidden */
  19274. _syncSubMeshes(): InstancedMesh;
  19275. /** @hidden */
  19276. _generatePointsArray(): boolean;
  19277. /**
  19278. * Creates a new InstancedMesh from the current mesh.
  19279. * - name (string) : the cloned mesh name
  19280. * - newParent (optional Node) : the optional Node to parent the clone to.
  19281. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19282. *
  19283. * Returns the clone.
  19284. */
  19285. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19286. /**
  19287. * Disposes the InstancedMesh.
  19288. * Returns nothing.
  19289. */
  19290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19291. }
  19292. interface Mesh {
  19293. /**
  19294. * Register a custom buffer that will be instanced
  19295. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19296. * @param kind defines the buffer kind
  19297. * @param stride defines the stride in floats
  19298. */
  19299. registerInstancedBuffer(kind: string, stride: number): void;
  19300. /** @hidden */
  19301. _userInstancedBuffersStorage: {
  19302. data: {
  19303. [key: string]: Float32Array;
  19304. };
  19305. sizes: {
  19306. [key: string]: number;
  19307. };
  19308. vertexBuffers: {
  19309. [key: string]: Nullable<VertexBuffer>;
  19310. };
  19311. strides: {
  19312. [key: string]: number;
  19313. };
  19314. };
  19315. }
  19316. interface AbstractMesh {
  19317. /**
  19318. * Object used to store instanced buffers defined by user
  19319. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19320. */
  19321. instancedBuffers: {
  19322. [key: string]: any;
  19323. };
  19324. }
  19325. }
  19326. declare module BABYLON {
  19327. /**
  19328. * Defines the options associated with the creation of a shader material.
  19329. */
  19330. export interface IShaderMaterialOptions {
  19331. /**
  19332. * Does the material work in alpha blend mode
  19333. */
  19334. needAlphaBlending: boolean;
  19335. /**
  19336. * Does the material work in alpha test mode
  19337. */
  19338. needAlphaTesting: boolean;
  19339. /**
  19340. * The list of attribute names used in the shader
  19341. */
  19342. attributes: string[];
  19343. /**
  19344. * The list of unifrom names used in the shader
  19345. */
  19346. uniforms: string[];
  19347. /**
  19348. * The list of UBO names used in the shader
  19349. */
  19350. uniformBuffers: string[];
  19351. /**
  19352. * The list of sampler names used in the shader
  19353. */
  19354. samplers: string[];
  19355. /**
  19356. * The list of defines used in the shader
  19357. */
  19358. defines: string[];
  19359. }
  19360. /**
  19361. * 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.
  19362. *
  19363. * This returned material effects how the mesh will look based on the code in the shaders.
  19364. *
  19365. * @see http://doc.babylonjs.com/how_to/shader_material
  19366. */
  19367. export class ShaderMaterial extends Material {
  19368. private _shaderPath;
  19369. private _options;
  19370. private _textures;
  19371. private _textureArrays;
  19372. private _floats;
  19373. private _ints;
  19374. private _floatsArrays;
  19375. private _colors3;
  19376. private _colors3Arrays;
  19377. private _colors4;
  19378. private _colors4Arrays;
  19379. private _vectors2;
  19380. private _vectors3;
  19381. private _vectors4;
  19382. private _matrices;
  19383. private _matrixArrays;
  19384. private _matrices3x3;
  19385. private _matrices2x2;
  19386. private _vectors2Arrays;
  19387. private _vectors3Arrays;
  19388. private _vectors4Arrays;
  19389. private _cachedWorldViewMatrix;
  19390. private _cachedWorldViewProjectionMatrix;
  19391. private _renderId;
  19392. private _multiview;
  19393. /**
  19394. * Instantiate a new shader material.
  19395. * 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.
  19396. * This returned material effects how the mesh will look based on the code in the shaders.
  19397. * @see http://doc.babylonjs.com/how_to/shader_material
  19398. * @param name Define the name of the material in the scene
  19399. * @param scene Define the scene the material belongs to
  19400. * @param shaderPath Defines the route to the shader code in one of three ways:
  19401. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19402. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19403. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19404. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19405. * @param options Define the options used to create the shader
  19406. */
  19407. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19408. /**
  19409. * Gets the shader path used to define the shader code
  19410. * It can be modified to trigger a new compilation
  19411. */
  19412. get shaderPath(): any;
  19413. /**
  19414. * Sets the shader path used to define the shader code
  19415. * It can be modified to trigger a new compilation
  19416. */
  19417. set shaderPath(shaderPath: any);
  19418. /**
  19419. * Gets the options used to compile the shader.
  19420. * They can be modified to trigger a new compilation
  19421. */
  19422. get options(): IShaderMaterialOptions;
  19423. /**
  19424. * Gets the current class name of the material e.g. "ShaderMaterial"
  19425. * Mainly use in serialization.
  19426. * @returns the class name
  19427. */
  19428. getClassName(): string;
  19429. /**
  19430. * Specifies if the material will require alpha blending
  19431. * @returns a boolean specifying if alpha blending is needed
  19432. */
  19433. needAlphaBlending(): boolean;
  19434. /**
  19435. * Specifies if this material should be rendered in alpha test mode
  19436. * @returns a boolean specifying if an alpha test is needed.
  19437. */
  19438. needAlphaTesting(): boolean;
  19439. private _checkUniform;
  19440. /**
  19441. * Set a texture in the shader.
  19442. * @param name Define the name of the uniform samplers as defined in the shader
  19443. * @param texture Define the texture to bind to this sampler
  19444. * @return the material itself allowing "fluent" like uniform updates
  19445. */
  19446. setTexture(name: string, texture: Texture): ShaderMaterial;
  19447. /**
  19448. * Set a texture array in the shader.
  19449. * @param name Define the name of the uniform sampler array as defined in the shader
  19450. * @param textures Define the list of textures to bind to this sampler
  19451. * @return the material itself allowing "fluent" like uniform updates
  19452. */
  19453. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19454. /**
  19455. * Set a float in the shader.
  19456. * @param name Define the name of the uniform as defined in the shader
  19457. * @param value Define the value to give to the uniform
  19458. * @return the material itself allowing "fluent" like uniform updates
  19459. */
  19460. setFloat(name: string, value: number): ShaderMaterial;
  19461. /**
  19462. * Set a int in the shader.
  19463. * @param name Define the name of the uniform as defined in the shader
  19464. * @param value Define the value to give to the uniform
  19465. * @return the material itself allowing "fluent" like uniform updates
  19466. */
  19467. setInt(name: string, value: number): ShaderMaterial;
  19468. /**
  19469. * Set an array of floats in the shader.
  19470. * @param name Define the name of the uniform as defined in the shader
  19471. * @param value Define the value to give to the uniform
  19472. * @return the material itself allowing "fluent" like uniform updates
  19473. */
  19474. setFloats(name: string, value: number[]): ShaderMaterial;
  19475. /**
  19476. * Set a vec3 in the shader from a Color3.
  19477. * @param name Define the name of the uniform as defined in the shader
  19478. * @param value Define the value to give to the uniform
  19479. * @return the material itself allowing "fluent" like uniform updates
  19480. */
  19481. setColor3(name: string, value: Color3): ShaderMaterial;
  19482. /**
  19483. * Set a vec3 array in the shader from a Color3 array.
  19484. * @param name Define the name of the uniform as defined in the shader
  19485. * @param value Define the value to give to the uniform
  19486. * @return the material itself allowing "fluent" like uniform updates
  19487. */
  19488. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19489. /**
  19490. * Set a vec4 in the shader from a Color4.
  19491. * @param name Define the name of the uniform as defined in the shader
  19492. * @param value Define the value to give to the uniform
  19493. * @return the material itself allowing "fluent" like uniform updates
  19494. */
  19495. setColor4(name: string, value: Color4): ShaderMaterial;
  19496. /**
  19497. * Set a vec4 array in the shader from a Color4 array.
  19498. * @param name Define the name of the uniform as defined in the shader
  19499. * @param value Define the value to give to the uniform
  19500. * @return the material itself allowing "fluent" like uniform updates
  19501. */
  19502. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19503. /**
  19504. * Set a vec2 in the shader from a Vector2.
  19505. * @param name Define the name of the uniform as defined in the shader
  19506. * @param value Define the value to give to the uniform
  19507. * @return the material itself allowing "fluent" like uniform updates
  19508. */
  19509. setVector2(name: string, value: Vector2): ShaderMaterial;
  19510. /**
  19511. * Set a vec3 in the shader from a Vector3.
  19512. * @param name Define the name of the uniform as defined in the shader
  19513. * @param value Define the value to give to the uniform
  19514. * @return the material itself allowing "fluent" like uniform updates
  19515. */
  19516. setVector3(name: string, value: Vector3): ShaderMaterial;
  19517. /**
  19518. * Set a vec4 in the shader from a Vector4.
  19519. * @param name Define the name of the uniform as defined in the shader
  19520. * @param value Define the value to give to the uniform
  19521. * @return the material itself allowing "fluent" like uniform updates
  19522. */
  19523. setVector4(name: string, value: Vector4): ShaderMaterial;
  19524. /**
  19525. * Set a mat4 in the shader from a Matrix.
  19526. * @param name Define the name of the uniform as defined in the shader
  19527. * @param value Define the value to give to the uniform
  19528. * @return the material itself allowing "fluent" like uniform updates
  19529. */
  19530. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19531. /**
  19532. * Set a float32Array in the shader from a matrix array.
  19533. * @param name Define the name of the uniform as defined in the shader
  19534. * @param value Define the value to give to the uniform
  19535. * @return the material itself allowing "fluent" like uniform updates
  19536. */
  19537. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19538. /**
  19539. * Set a mat3 in the shader from a Float32Array.
  19540. * @param name Define the name of the uniform as defined in the shader
  19541. * @param value Define the value to give to the uniform
  19542. * @return the material itself allowing "fluent" like uniform updates
  19543. */
  19544. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19545. /**
  19546. * Set a mat2 in the shader from a Float32Array.
  19547. * @param name Define the name of the uniform as defined in the shader
  19548. * @param value Define the value to give to the uniform
  19549. * @return the material itself allowing "fluent" like uniform updates
  19550. */
  19551. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19552. /**
  19553. * Set a vec2 array in the shader from a number array.
  19554. * @param name Define the name of the uniform as defined in the shader
  19555. * @param value Define the value to give to the uniform
  19556. * @return the material itself allowing "fluent" like uniform updates
  19557. */
  19558. setArray2(name: string, value: number[]): ShaderMaterial;
  19559. /**
  19560. * Set a vec3 array in the shader from a number array.
  19561. * @param name Define the name of the uniform as defined in the shader
  19562. * @param value Define the value to give to the uniform
  19563. * @return the material itself allowing "fluent" like uniform updates
  19564. */
  19565. setArray3(name: string, value: number[]): ShaderMaterial;
  19566. /**
  19567. * Set a vec4 array in the shader from a number array.
  19568. * @param name Define the name of the uniform as defined in the shader
  19569. * @param value Define the value to give to the uniform
  19570. * @return the material itself allowing "fluent" like uniform updates
  19571. */
  19572. setArray4(name: string, value: number[]): ShaderMaterial;
  19573. private _checkCache;
  19574. /**
  19575. * Specifies that the submesh is ready to be used
  19576. * @param mesh defines the mesh to check
  19577. * @param subMesh defines which submesh to check
  19578. * @param useInstances specifies that instances should be used
  19579. * @returns a boolean indicating that the submesh is ready or not
  19580. */
  19581. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19582. /**
  19583. * Checks if the material is ready to render the requested mesh
  19584. * @param mesh Define the mesh to render
  19585. * @param useInstances Define whether or not the material is used with instances
  19586. * @returns true if ready, otherwise false
  19587. */
  19588. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19589. /**
  19590. * Binds the world matrix to the material
  19591. * @param world defines the world transformation matrix
  19592. */
  19593. bindOnlyWorldMatrix(world: Matrix): void;
  19594. /**
  19595. * Binds the material to the mesh
  19596. * @param world defines the world transformation matrix
  19597. * @param mesh defines the mesh to bind the material to
  19598. */
  19599. bind(world: Matrix, mesh?: Mesh): void;
  19600. /**
  19601. * Gets the active textures from the material
  19602. * @returns an array of textures
  19603. */
  19604. getActiveTextures(): BaseTexture[];
  19605. /**
  19606. * Specifies if the material uses a texture
  19607. * @param texture defines the texture to check against the material
  19608. * @returns a boolean specifying if the material uses the texture
  19609. */
  19610. hasTexture(texture: BaseTexture): boolean;
  19611. /**
  19612. * Makes a duplicate of the material, and gives it a new name
  19613. * @param name defines the new name for the duplicated material
  19614. * @returns the cloned material
  19615. */
  19616. clone(name: string): ShaderMaterial;
  19617. /**
  19618. * Disposes the material
  19619. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19620. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19621. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19622. */
  19623. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19624. /**
  19625. * Serializes this material in a JSON representation
  19626. * @returns the serialized material object
  19627. */
  19628. serialize(): any;
  19629. /**
  19630. * Creates a shader material from parsed shader material data
  19631. * @param source defines the JSON represnetation of the material
  19632. * @param scene defines the hosting scene
  19633. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19634. * @returns a new material
  19635. */
  19636. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19637. }
  19638. }
  19639. declare module BABYLON {
  19640. /** @hidden */
  19641. export var colorPixelShader: {
  19642. name: string;
  19643. shader: string;
  19644. };
  19645. }
  19646. declare module BABYLON {
  19647. /** @hidden */
  19648. export var colorVertexShader: {
  19649. name: string;
  19650. shader: string;
  19651. };
  19652. }
  19653. declare module BABYLON {
  19654. /**
  19655. * Line mesh
  19656. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19657. */
  19658. export class LinesMesh extends Mesh {
  19659. /**
  19660. * If vertex color should be applied to the mesh
  19661. */
  19662. readonly useVertexColor?: boolean | undefined;
  19663. /**
  19664. * If vertex alpha should be applied to the mesh
  19665. */
  19666. readonly useVertexAlpha?: boolean | undefined;
  19667. /**
  19668. * Color of the line (Default: White)
  19669. */
  19670. color: Color3;
  19671. /**
  19672. * Alpha of the line (Default: 1)
  19673. */
  19674. alpha: number;
  19675. /**
  19676. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19677. * This margin is expressed in world space coordinates, so its value may vary.
  19678. * Default value is 0.1
  19679. */
  19680. intersectionThreshold: number;
  19681. private _colorShader;
  19682. private color4;
  19683. /**
  19684. * Creates a new LinesMesh
  19685. * @param name defines the name
  19686. * @param scene defines the hosting scene
  19687. * @param parent defines the parent mesh if any
  19688. * @param source defines the optional source LinesMesh used to clone data from
  19689. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19690. * When false, achieved by calling a clone(), also passing False.
  19691. * This will make creation of children, recursive.
  19692. * @param useVertexColor defines if this LinesMesh supports vertex color
  19693. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19694. */
  19695. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19696. /**
  19697. * If vertex color should be applied to the mesh
  19698. */
  19699. useVertexColor?: boolean | undefined,
  19700. /**
  19701. * If vertex alpha should be applied to the mesh
  19702. */
  19703. useVertexAlpha?: boolean | undefined);
  19704. private _addClipPlaneDefine;
  19705. private _removeClipPlaneDefine;
  19706. isReady(): boolean;
  19707. /**
  19708. * Returns the string "LineMesh"
  19709. */
  19710. getClassName(): string;
  19711. /**
  19712. * @hidden
  19713. */
  19714. get material(): Material;
  19715. /**
  19716. * @hidden
  19717. */
  19718. set material(value: Material);
  19719. /**
  19720. * @hidden
  19721. */
  19722. get checkCollisions(): boolean;
  19723. /** @hidden */
  19724. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19725. /** @hidden */
  19726. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19727. /**
  19728. * Disposes of the line mesh
  19729. * @param doNotRecurse If children should be disposed
  19730. */
  19731. dispose(doNotRecurse?: boolean): void;
  19732. /**
  19733. * Returns a new LineMesh object cloned from the current one.
  19734. */
  19735. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19736. /**
  19737. * Creates a new InstancedLinesMesh object from the mesh model.
  19738. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19739. * @param name defines the name of the new instance
  19740. * @returns a new InstancedLinesMesh
  19741. */
  19742. createInstance(name: string): InstancedLinesMesh;
  19743. }
  19744. /**
  19745. * Creates an instance based on a source LinesMesh
  19746. */
  19747. export class InstancedLinesMesh extends InstancedMesh {
  19748. /**
  19749. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19750. * This margin is expressed in world space coordinates, so its value may vary.
  19751. * Initilized with the intersectionThreshold value of the source LinesMesh
  19752. */
  19753. intersectionThreshold: number;
  19754. constructor(name: string, source: LinesMesh);
  19755. /**
  19756. * Returns the string "InstancedLinesMesh".
  19757. */
  19758. getClassName(): string;
  19759. }
  19760. }
  19761. declare module BABYLON {
  19762. /** @hidden */
  19763. export var linePixelShader: {
  19764. name: string;
  19765. shader: string;
  19766. };
  19767. }
  19768. declare module BABYLON {
  19769. /** @hidden */
  19770. export var lineVertexShader: {
  19771. name: string;
  19772. shader: string;
  19773. };
  19774. }
  19775. declare module BABYLON {
  19776. interface AbstractMesh {
  19777. /**
  19778. * Gets the edgesRenderer associated with the mesh
  19779. */
  19780. edgesRenderer: Nullable<EdgesRenderer>;
  19781. }
  19782. interface LinesMesh {
  19783. /**
  19784. * Enables the edge rendering mode on the mesh.
  19785. * This mode makes the mesh edges visible
  19786. * @param epsilon defines the maximal distance between two angles to detect a face
  19787. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19788. * @returns the currentAbstractMesh
  19789. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19790. */
  19791. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19792. }
  19793. interface InstancedLinesMesh {
  19794. /**
  19795. * Enables the edge rendering mode on the mesh.
  19796. * This mode makes the mesh edges visible
  19797. * @param epsilon defines the maximal distance between two angles to detect a face
  19798. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19799. * @returns the current InstancedLinesMesh
  19800. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19801. */
  19802. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19803. }
  19804. /**
  19805. * Defines the minimum contract an Edges renderer should follow.
  19806. */
  19807. export interface IEdgesRenderer extends IDisposable {
  19808. /**
  19809. * Gets or sets a boolean indicating if the edgesRenderer is active
  19810. */
  19811. isEnabled: boolean;
  19812. /**
  19813. * Renders the edges of the attached mesh,
  19814. */
  19815. render(): void;
  19816. /**
  19817. * Checks wether or not the edges renderer is ready to render.
  19818. * @return true if ready, otherwise false.
  19819. */
  19820. isReady(): boolean;
  19821. }
  19822. /**
  19823. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19824. */
  19825. export class EdgesRenderer implements IEdgesRenderer {
  19826. /**
  19827. * Define the size of the edges with an orthographic camera
  19828. */
  19829. edgesWidthScalerForOrthographic: number;
  19830. /**
  19831. * Define the size of the edges with a perspective camera
  19832. */
  19833. edgesWidthScalerForPerspective: number;
  19834. protected _source: AbstractMesh;
  19835. protected _linesPositions: number[];
  19836. protected _linesNormals: number[];
  19837. protected _linesIndices: number[];
  19838. protected _epsilon: number;
  19839. protected _indicesCount: number;
  19840. protected _lineShader: ShaderMaterial;
  19841. protected _ib: DataBuffer;
  19842. protected _buffers: {
  19843. [key: string]: Nullable<VertexBuffer>;
  19844. };
  19845. protected _checkVerticesInsteadOfIndices: boolean;
  19846. private _meshRebuildObserver;
  19847. private _meshDisposeObserver;
  19848. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19849. isEnabled: boolean;
  19850. /**
  19851. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19852. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19853. * @param source Mesh used to create edges
  19854. * @param epsilon sum of angles in adjacency to check for edge
  19855. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19856. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19857. */
  19858. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19859. protected _prepareRessources(): void;
  19860. /** @hidden */
  19861. _rebuild(): void;
  19862. /**
  19863. * Releases the required resources for the edges renderer
  19864. */
  19865. dispose(): void;
  19866. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19867. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19868. /**
  19869. * Checks if the pair of p0 and p1 is en edge
  19870. * @param faceIndex
  19871. * @param edge
  19872. * @param faceNormals
  19873. * @param p0
  19874. * @param p1
  19875. * @private
  19876. */
  19877. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19878. /**
  19879. * push line into the position, normal and index buffer
  19880. * @protected
  19881. */
  19882. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19883. /**
  19884. * Generates lines edges from adjacencjes
  19885. * @private
  19886. */
  19887. _generateEdgesLines(): void;
  19888. /**
  19889. * Checks wether or not the edges renderer is ready to render.
  19890. * @return true if ready, otherwise false.
  19891. */
  19892. isReady(): boolean;
  19893. /**
  19894. * Renders the edges of the attached mesh,
  19895. */
  19896. render(): void;
  19897. }
  19898. /**
  19899. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19900. */
  19901. export class LineEdgesRenderer extends EdgesRenderer {
  19902. /**
  19903. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19904. * @param source LineMesh used to generate edges
  19905. * @param epsilon not important (specified angle for edge detection)
  19906. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19907. */
  19908. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19909. /**
  19910. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19911. */
  19912. _generateEdgesLines(): void;
  19913. }
  19914. }
  19915. declare module BABYLON {
  19916. /**
  19917. * This represents the object necessary to create a rendering group.
  19918. * This is exclusively used and created by the rendering manager.
  19919. * To modify the behavior, you use the available helpers in your scene or meshes.
  19920. * @hidden
  19921. */
  19922. export class RenderingGroup {
  19923. index: number;
  19924. private static _zeroVector;
  19925. private _scene;
  19926. private _opaqueSubMeshes;
  19927. private _transparentSubMeshes;
  19928. private _alphaTestSubMeshes;
  19929. private _depthOnlySubMeshes;
  19930. private _particleSystems;
  19931. private _spriteManagers;
  19932. private _opaqueSortCompareFn;
  19933. private _alphaTestSortCompareFn;
  19934. private _transparentSortCompareFn;
  19935. private _renderOpaque;
  19936. private _renderAlphaTest;
  19937. private _renderTransparent;
  19938. /** @hidden */
  19939. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19940. onBeforeTransparentRendering: () => void;
  19941. /**
  19942. * Set the opaque sort comparison function.
  19943. * If null the sub meshes will be render in the order they were created
  19944. */
  19945. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19946. /**
  19947. * Set the alpha test sort comparison function.
  19948. * If null the sub meshes will be render in the order they were created
  19949. */
  19950. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19951. /**
  19952. * Set the transparent sort comparison function.
  19953. * If null the sub meshes will be render in the order they were created
  19954. */
  19955. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19956. /**
  19957. * Creates a new rendering group.
  19958. * @param index The rendering group index
  19959. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19960. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19961. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19962. */
  19963. 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>);
  19964. /**
  19965. * Render all the sub meshes contained in the group.
  19966. * @param customRenderFunction Used to override the default render behaviour of the group.
  19967. * @returns true if rendered some submeshes.
  19968. */
  19969. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19970. /**
  19971. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19972. * @param subMeshes The submeshes to render
  19973. */
  19974. private renderOpaqueSorted;
  19975. /**
  19976. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19977. * @param subMeshes The submeshes to render
  19978. */
  19979. private renderAlphaTestSorted;
  19980. /**
  19981. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19982. * @param subMeshes The submeshes to render
  19983. */
  19984. private renderTransparentSorted;
  19985. /**
  19986. * Renders the submeshes in a specified order.
  19987. * @param subMeshes The submeshes to sort before render
  19988. * @param sortCompareFn The comparison function use to sort
  19989. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19990. * @param transparent Specifies to activate blending if true
  19991. */
  19992. private static renderSorted;
  19993. /**
  19994. * Renders the submeshes in the order they were dispatched (no sort applied).
  19995. * @param subMeshes The submeshes to render
  19996. */
  19997. private static renderUnsorted;
  19998. /**
  19999. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20000. * are rendered back to front if in the same alpha index.
  20001. *
  20002. * @param a The first submesh
  20003. * @param b The second submesh
  20004. * @returns The result of the comparison
  20005. */
  20006. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20007. /**
  20008. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20009. * are rendered back to front.
  20010. *
  20011. * @param a The first submesh
  20012. * @param b The second submesh
  20013. * @returns The result of the comparison
  20014. */
  20015. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20016. /**
  20017. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20018. * are rendered front to back (prevent overdraw).
  20019. *
  20020. * @param a The first submesh
  20021. * @param b The second submesh
  20022. * @returns The result of the comparison
  20023. */
  20024. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20025. /**
  20026. * Resets the different lists of submeshes to prepare a new frame.
  20027. */
  20028. prepare(): void;
  20029. dispose(): void;
  20030. /**
  20031. * Inserts the submesh in its correct queue depending on its material.
  20032. * @param subMesh The submesh to dispatch
  20033. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20034. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20035. */
  20036. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20037. dispatchSprites(spriteManager: ISpriteManager): void;
  20038. dispatchParticles(particleSystem: IParticleSystem): void;
  20039. private _renderParticles;
  20040. private _renderSprites;
  20041. }
  20042. }
  20043. declare module BABYLON {
  20044. /**
  20045. * Interface describing the different options available in the rendering manager
  20046. * regarding Auto Clear between groups.
  20047. */
  20048. export interface IRenderingManagerAutoClearSetup {
  20049. /**
  20050. * Defines whether or not autoclear is enable.
  20051. */
  20052. autoClear: boolean;
  20053. /**
  20054. * Defines whether or not to autoclear the depth buffer.
  20055. */
  20056. depth: boolean;
  20057. /**
  20058. * Defines whether or not to autoclear the stencil buffer.
  20059. */
  20060. stencil: boolean;
  20061. }
  20062. /**
  20063. * This class is used by the onRenderingGroupObservable
  20064. */
  20065. export class RenderingGroupInfo {
  20066. /**
  20067. * The Scene that being rendered
  20068. */
  20069. scene: Scene;
  20070. /**
  20071. * The camera currently used for the rendering pass
  20072. */
  20073. camera: Nullable<Camera>;
  20074. /**
  20075. * The ID of the renderingGroup being processed
  20076. */
  20077. renderingGroupId: number;
  20078. }
  20079. /**
  20080. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20081. * It is enable to manage the different groups as well as the different necessary sort functions.
  20082. * This should not be used directly aside of the few static configurations
  20083. */
  20084. export class RenderingManager {
  20085. /**
  20086. * The max id used for rendering groups (not included)
  20087. */
  20088. static MAX_RENDERINGGROUPS: number;
  20089. /**
  20090. * The min id used for rendering groups (included)
  20091. */
  20092. static MIN_RENDERINGGROUPS: number;
  20093. /**
  20094. * Used to globally prevent autoclearing scenes.
  20095. */
  20096. static AUTOCLEAR: boolean;
  20097. /**
  20098. * @hidden
  20099. */
  20100. _useSceneAutoClearSetup: boolean;
  20101. private _scene;
  20102. private _renderingGroups;
  20103. private _depthStencilBufferAlreadyCleaned;
  20104. private _autoClearDepthStencil;
  20105. private _customOpaqueSortCompareFn;
  20106. private _customAlphaTestSortCompareFn;
  20107. private _customTransparentSortCompareFn;
  20108. private _renderingGroupInfo;
  20109. /**
  20110. * Instantiates a new rendering group for a particular scene
  20111. * @param scene Defines the scene the groups belongs to
  20112. */
  20113. constructor(scene: Scene);
  20114. private _clearDepthStencilBuffer;
  20115. /**
  20116. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20117. * @hidden
  20118. */
  20119. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20120. /**
  20121. * Resets the different information of the group to prepare a new frame
  20122. * @hidden
  20123. */
  20124. reset(): void;
  20125. /**
  20126. * Dispose and release the group and its associated resources.
  20127. * @hidden
  20128. */
  20129. dispose(): void;
  20130. /**
  20131. * Clear the info related to rendering groups preventing retention points during dispose.
  20132. */
  20133. freeRenderingGroups(): void;
  20134. private _prepareRenderingGroup;
  20135. /**
  20136. * Add a sprite manager to the rendering manager in order to render it this frame.
  20137. * @param spriteManager Define the sprite manager to render
  20138. */
  20139. dispatchSprites(spriteManager: ISpriteManager): void;
  20140. /**
  20141. * Add a particle system to the rendering manager in order to render it this frame.
  20142. * @param particleSystem Define the particle system to render
  20143. */
  20144. dispatchParticles(particleSystem: IParticleSystem): void;
  20145. /**
  20146. * Add a submesh to the manager in order to render it this frame
  20147. * @param subMesh The submesh to dispatch
  20148. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20149. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20150. */
  20151. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20152. /**
  20153. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20154. * This allowed control for front to back rendering or reversly depending of the special needs.
  20155. *
  20156. * @param renderingGroupId The rendering group id corresponding to its index
  20157. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20158. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20159. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20160. */
  20161. 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;
  20162. /**
  20163. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20164. *
  20165. * @param renderingGroupId The rendering group id corresponding to its index
  20166. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20167. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20168. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20169. */
  20170. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20171. /**
  20172. * Gets the current auto clear configuration for one rendering group of the rendering
  20173. * manager.
  20174. * @param index the rendering group index to get the information for
  20175. * @returns The auto clear setup for the requested rendering group
  20176. */
  20177. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20178. }
  20179. }
  20180. declare module BABYLON {
  20181. /**
  20182. * This Helps creating a texture that will be created from a camera in your scene.
  20183. * It is basically a dynamic texture that could be used to create special effects for instance.
  20184. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20185. */
  20186. export class RenderTargetTexture extends Texture {
  20187. isCube: boolean;
  20188. /**
  20189. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20190. */
  20191. static readonly REFRESHRATE_RENDER_ONCE: number;
  20192. /**
  20193. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20194. */
  20195. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20196. /**
  20197. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20198. * the central point of your effect and can save a lot of performances.
  20199. */
  20200. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20201. /**
  20202. * Use this predicate to dynamically define the list of mesh you want to render.
  20203. * If set, the renderList property will be overwritten.
  20204. */
  20205. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20206. private _renderList;
  20207. /**
  20208. * Use this list to define the list of mesh you want to render.
  20209. */
  20210. get renderList(): Nullable<Array<AbstractMesh>>;
  20211. set renderList(value: Nullable<Array<AbstractMesh>>);
  20212. private _hookArray;
  20213. /**
  20214. * Define if particles should be rendered in your texture.
  20215. */
  20216. renderParticles: boolean;
  20217. /**
  20218. * Define if sprites should be rendered in your texture.
  20219. */
  20220. renderSprites: boolean;
  20221. /**
  20222. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20223. */
  20224. coordinatesMode: number;
  20225. /**
  20226. * Define the camera used to render the texture.
  20227. */
  20228. activeCamera: Nullable<Camera>;
  20229. /**
  20230. * Override the render function of the texture with your own one.
  20231. */
  20232. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20233. /**
  20234. * Define if camera post processes should be use while rendering the texture.
  20235. */
  20236. useCameraPostProcesses: boolean;
  20237. /**
  20238. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20239. */
  20240. ignoreCameraViewport: boolean;
  20241. private _postProcessManager;
  20242. private _postProcesses;
  20243. private _resizeObserver;
  20244. /**
  20245. * An event triggered when the texture is unbind.
  20246. */
  20247. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20248. /**
  20249. * An event triggered when the texture is unbind.
  20250. */
  20251. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20252. private _onAfterUnbindObserver;
  20253. /**
  20254. * Set a after unbind callback in the texture.
  20255. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20256. */
  20257. set onAfterUnbind(callback: () => void);
  20258. /**
  20259. * An event triggered before rendering the texture
  20260. */
  20261. onBeforeRenderObservable: Observable<number>;
  20262. private _onBeforeRenderObserver;
  20263. /**
  20264. * Set a before render callback in the texture.
  20265. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20266. */
  20267. set onBeforeRender(callback: (faceIndex: number) => void);
  20268. /**
  20269. * An event triggered after rendering the texture
  20270. */
  20271. onAfterRenderObservable: Observable<number>;
  20272. private _onAfterRenderObserver;
  20273. /**
  20274. * Set a after render callback in the texture.
  20275. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20276. */
  20277. set onAfterRender(callback: (faceIndex: number) => void);
  20278. /**
  20279. * An event triggered after the texture clear
  20280. */
  20281. onClearObservable: Observable<Engine>;
  20282. private _onClearObserver;
  20283. /**
  20284. * Set a clear callback in the texture.
  20285. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20286. */
  20287. set onClear(callback: (Engine: Engine) => void);
  20288. /**
  20289. * An event triggered when the texture is resized.
  20290. */
  20291. onResizeObservable: Observable<RenderTargetTexture>;
  20292. /**
  20293. * Define the clear color of the Render Target if it should be different from the scene.
  20294. */
  20295. clearColor: Color4;
  20296. protected _size: number | {
  20297. width: number;
  20298. height: number;
  20299. };
  20300. protected _initialSizeParameter: number | {
  20301. width: number;
  20302. height: number;
  20303. } | {
  20304. ratio: number;
  20305. };
  20306. protected _sizeRatio: Nullable<number>;
  20307. /** @hidden */
  20308. _generateMipMaps: boolean;
  20309. protected _renderingManager: RenderingManager;
  20310. /** @hidden */
  20311. _waitingRenderList: string[];
  20312. protected _doNotChangeAspectRatio: boolean;
  20313. protected _currentRefreshId: number;
  20314. protected _refreshRate: number;
  20315. protected _textureMatrix: Matrix;
  20316. protected _samples: number;
  20317. protected _renderTargetOptions: RenderTargetCreationOptions;
  20318. /**
  20319. * Gets render target creation options that were used.
  20320. */
  20321. get renderTargetOptions(): RenderTargetCreationOptions;
  20322. protected _engine: Engine;
  20323. protected _onRatioRescale(): void;
  20324. /**
  20325. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20326. * It must define where the camera used to render the texture is set
  20327. */
  20328. boundingBoxPosition: Vector3;
  20329. private _boundingBoxSize;
  20330. /**
  20331. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20332. * When defined, the cubemap will switch to local mode
  20333. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20334. * @example https://www.babylonjs-playground.com/#RNASML
  20335. */
  20336. set boundingBoxSize(value: Vector3);
  20337. get boundingBoxSize(): Vector3;
  20338. /**
  20339. * In case the RTT has been created with a depth texture, get the associated
  20340. * depth texture.
  20341. * Otherwise, return null.
  20342. */
  20343. depthStencilTexture: Nullable<InternalTexture>;
  20344. /**
  20345. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20346. * or used a shadow, depth texture...
  20347. * @param name The friendly name of the texture
  20348. * @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)
  20349. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20350. * @param generateMipMaps True if mip maps need to be generated after render.
  20351. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20352. * @param type The type of the buffer in the RTT (int, half float, float...)
  20353. * @param isCube True if a cube texture needs to be created
  20354. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20355. * @param generateDepthBuffer True to generate a depth buffer
  20356. * @param generateStencilBuffer True to generate a stencil buffer
  20357. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20358. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20359. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20360. */
  20361. constructor(name: string, size: number | {
  20362. width: number;
  20363. height: number;
  20364. } | {
  20365. ratio: number;
  20366. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20367. /**
  20368. * Creates a depth stencil texture.
  20369. * This is only available in WebGL 2 or with the depth texture extension available.
  20370. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20371. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20372. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20373. */
  20374. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20375. private _processSizeParameter;
  20376. /**
  20377. * Define the number of samples to use in case of MSAA.
  20378. * It defaults to one meaning no MSAA has been enabled.
  20379. */
  20380. get samples(): number;
  20381. set samples(value: number);
  20382. /**
  20383. * Resets the refresh counter of the texture and start bak from scratch.
  20384. * Could be useful to regenerate the texture if it is setup to render only once.
  20385. */
  20386. resetRefreshCounter(): void;
  20387. /**
  20388. * Define the refresh rate of the texture or the rendering frequency.
  20389. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20390. */
  20391. get refreshRate(): number;
  20392. set refreshRate(value: number);
  20393. /**
  20394. * Adds a post process to the render target rendering passes.
  20395. * @param postProcess define the post process to add
  20396. */
  20397. addPostProcess(postProcess: PostProcess): void;
  20398. /**
  20399. * Clear all the post processes attached to the render target
  20400. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20401. */
  20402. clearPostProcesses(dispose?: boolean): void;
  20403. /**
  20404. * Remove one of the post process from the list of attached post processes to the texture
  20405. * @param postProcess define the post process to remove from the list
  20406. */
  20407. removePostProcess(postProcess: PostProcess): void;
  20408. /** @hidden */
  20409. _shouldRender(): boolean;
  20410. /**
  20411. * Gets the actual render size of the texture.
  20412. * @returns the width of the render size
  20413. */
  20414. getRenderSize(): number;
  20415. /**
  20416. * Gets the actual render width of the texture.
  20417. * @returns the width of the render size
  20418. */
  20419. getRenderWidth(): number;
  20420. /**
  20421. * Gets the actual render height of the texture.
  20422. * @returns the height of the render size
  20423. */
  20424. getRenderHeight(): number;
  20425. /**
  20426. * Get if the texture can be rescaled or not.
  20427. */
  20428. get canRescale(): boolean;
  20429. /**
  20430. * Resize the texture using a ratio.
  20431. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20432. */
  20433. scale(ratio: number): void;
  20434. /**
  20435. * Get the texture reflection matrix used to rotate/transform the reflection.
  20436. * @returns the reflection matrix
  20437. */
  20438. getReflectionTextureMatrix(): Matrix;
  20439. /**
  20440. * Resize the texture to a new desired size.
  20441. * Be carrefull as it will recreate all the data in the new texture.
  20442. * @param size Define the new size. It can be:
  20443. * - a number for squared texture,
  20444. * - an object containing { width: number, height: number }
  20445. * - or an object containing a ratio { ratio: number }
  20446. */
  20447. resize(size: number | {
  20448. width: number;
  20449. height: number;
  20450. } | {
  20451. ratio: number;
  20452. }): void;
  20453. /**
  20454. * Renders all the objects from the render list into the texture.
  20455. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20456. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20457. */
  20458. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20459. private _bestReflectionRenderTargetDimension;
  20460. /**
  20461. * @hidden
  20462. * @param faceIndex face index to bind to if this is a cubetexture
  20463. */
  20464. _bindFrameBuffer(faceIndex?: number): void;
  20465. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20466. private renderToTarget;
  20467. /**
  20468. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20469. * This allowed control for front to back rendering or reversly depending of the special needs.
  20470. *
  20471. * @param renderingGroupId The rendering group id corresponding to its index
  20472. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20473. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20474. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20475. */
  20476. 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;
  20477. /**
  20478. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20479. *
  20480. * @param renderingGroupId The rendering group id corresponding to its index
  20481. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20482. */
  20483. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20484. /**
  20485. * Clones the texture.
  20486. * @returns the cloned texture
  20487. */
  20488. clone(): RenderTargetTexture;
  20489. /**
  20490. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20491. * @returns The JSON representation of the texture
  20492. */
  20493. serialize(): any;
  20494. /**
  20495. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20496. */
  20497. disposeFramebufferObjects(): void;
  20498. /**
  20499. * Dispose the texture and release its associated resources.
  20500. */
  20501. dispose(): void;
  20502. /** @hidden */
  20503. _rebuild(): void;
  20504. /**
  20505. * Clear the info related to rendering groups preventing retention point in material dispose.
  20506. */
  20507. freeRenderingGroups(): void;
  20508. /**
  20509. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20510. * @returns the view count
  20511. */
  20512. getViewCount(): number;
  20513. }
  20514. }
  20515. declare module BABYLON {
  20516. /**
  20517. * Options for compiling materials.
  20518. */
  20519. export interface IMaterialCompilationOptions {
  20520. /**
  20521. * Defines whether clip planes are enabled.
  20522. */
  20523. clipPlane: boolean;
  20524. /**
  20525. * Defines whether instances are enabled.
  20526. */
  20527. useInstances: boolean;
  20528. }
  20529. /**
  20530. * Base class for the main features of a material in Babylon.js
  20531. */
  20532. export class Material implements IAnimatable {
  20533. /**
  20534. * Returns the triangle fill mode
  20535. */
  20536. static readonly TriangleFillMode: number;
  20537. /**
  20538. * Returns the wireframe mode
  20539. */
  20540. static readonly WireFrameFillMode: number;
  20541. /**
  20542. * Returns the point fill mode
  20543. */
  20544. static readonly PointFillMode: number;
  20545. /**
  20546. * Returns the point list draw mode
  20547. */
  20548. static readonly PointListDrawMode: number;
  20549. /**
  20550. * Returns the line list draw mode
  20551. */
  20552. static readonly LineListDrawMode: number;
  20553. /**
  20554. * Returns the line loop draw mode
  20555. */
  20556. static readonly LineLoopDrawMode: number;
  20557. /**
  20558. * Returns the line strip draw mode
  20559. */
  20560. static readonly LineStripDrawMode: number;
  20561. /**
  20562. * Returns the triangle strip draw mode
  20563. */
  20564. static readonly TriangleStripDrawMode: number;
  20565. /**
  20566. * Returns the triangle fan draw mode
  20567. */
  20568. static readonly TriangleFanDrawMode: number;
  20569. /**
  20570. * Stores the clock-wise side orientation
  20571. */
  20572. static readonly ClockWiseSideOrientation: number;
  20573. /**
  20574. * Stores the counter clock-wise side orientation
  20575. */
  20576. static readonly CounterClockWiseSideOrientation: number;
  20577. /**
  20578. * The dirty texture flag value
  20579. */
  20580. static readonly TextureDirtyFlag: number;
  20581. /**
  20582. * The dirty light flag value
  20583. */
  20584. static readonly LightDirtyFlag: number;
  20585. /**
  20586. * The dirty fresnel flag value
  20587. */
  20588. static readonly FresnelDirtyFlag: number;
  20589. /**
  20590. * The dirty attribute flag value
  20591. */
  20592. static readonly AttributesDirtyFlag: number;
  20593. /**
  20594. * The dirty misc flag value
  20595. */
  20596. static readonly MiscDirtyFlag: number;
  20597. /**
  20598. * The all dirty flag value
  20599. */
  20600. static readonly AllDirtyFlag: number;
  20601. /**
  20602. * The ID of the material
  20603. */
  20604. id: string;
  20605. /**
  20606. * Gets or sets the unique id of the material
  20607. */
  20608. uniqueId: number;
  20609. /**
  20610. * The name of the material
  20611. */
  20612. name: string;
  20613. /**
  20614. * Gets or sets user defined metadata
  20615. */
  20616. metadata: any;
  20617. /**
  20618. * For internal use only. Please do not use.
  20619. */
  20620. reservedDataStore: any;
  20621. /**
  20622. * Specifies if the ready state should be checked on each call
  20623. */
  20624. checkReadyOnEveryCall: boolean;
  20625. /**
  20626. * Specifies if the ready state should be checked once
  20627. */
  20628. checkReadyOnlyOnce: boolean;
  20629. /**
  20630. * The state of the material
  20631. */
  20632. state: string;
  20633. /**
  20634. * The alpha value of the material
  20635. */
  20636. protected _alpha: number;
  20637. /**
  20638. * List of inspectable custom properties (used by the Inspector)
  20639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20640. */
  20641. inspectableCustomProperties: IInspectable[];
  20642. /**
  20643. * Sets the alpha value of the material
  20644. */
  20645. set alpha(value: number);
  20646. /**
  20647. * Gets the alpha value of the material
  20648. */
  20649. get alpha(): number;
  20650. /**
  20651. * Specifies if back face culling is enabled
  20652. */
  20653. protected _backFaceCulling: boolean;
  20654. /**
  20655. * Sets the back-face culling state
  20656. */
  20657. set backFaceCulling(value: boolean);
  20658. /**
  20659. * Gets the back-face culling state
  20660. */
  20661. get backFaceCulling(): boolean;
  20662. /**
  20663. * Stores the value for side orientation
  20664. */
  20665. sideOrientation: number;
  20666. /**
  20667. * Callback triggered when the material is compiled
  20668. */
  20669. onCompiled: Nullable<(effect: Effect) => void>;
  20670. /**
  20671. * Callback triggered when an error occurs
  20672. */
  20673. onError: Nullable<(effect: Effect, errors: string) => void>;
  20674. /**
  20675. * Callback triggered to get the render target textures
  20676. */
  20677. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20678. /**
  20679. * Gets a boolean indicating that current material needs to register RTT
  20680. */
  20681. get hasRenderTargetTextures(): boolean;
  20682. /**
  20683. * Specifies if the material should be serialized
  20684. */
  20685. doNotSerialize: boolean;
  20686. /**
  20687. * @hidden
  20688. */
  20689. _storeEffectOnSubMeshes: boolean;
  20690. /**
  20691. * Stores the animations for the material
  20692. */
  20693. animations: Nullable<Array<Animation>>;
  20694. /**
  20695. * An event triggered when the material is disposed
  20696. */
  20697. onDisposeObservable: Observable<Material>;
  20698. /**
  20699. * An observer which watches for dispose events
  20700. */
  20701. private _onDisposeObserver;
  20702. private _onUnBindObservable;
  20703. /**
  20704. * Called during a dispose event
  20705. */
  20706. set onDispose(callback: () => void);
  20707. private _onBindObservable;
  20708. /**
  20709. * An event triggered when the material is bound
  20710. */
  20711. get onBindObservable(): Observable<AbstractMesh>;
  20712. /**
  20713. * An observer which watches for bind events
  20714. */
  20715. private _onBindObserver;
  20716. /**
  20717. * Called during a bind event
  20718. */
  20719. set onBind(callback: (Mesh: AbstractMesh) => void);
  20720. /**
  20721. * An event triggered when the material is unbound
  20722. */
  20723. get onUnBindObservable(): Observable<Material>;
  20724. /**
  20725. * Stores the value of the alpha mode
  20726. */
  20727. private _alphaMode;
  20728. /**
  20729. * Sets the value of the alpha mode.
  20730. *
  20731. * | Value | Type | Description |
  20732. * | --- | --- | --- |
  20733. * | 0 | ALPHA_DISABLE | |
  20734. * | 1 | ALPHA_ADD | |
  20735. * | 2 | ALPHA_COMBINE | |
  20736. * | 3 | ALPHA_SUBTRACT | |
  20737. * | 4 | ALPHA_MULTIPLY | |
  20738. * | 5 | ALPHA_MAXIMIZED | |
  20739. * | 6 | ALPHA_ONEONE | |
  20740. * | 7 | ALPHA_PREMULTIPLIED | |
  20741. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20742. * | 9 | ALPHA_INTERPOLATE | |
  20743. * | 10 | ALPHA_SCREENMODE | |
  20744. *
  20745. */
  20746. set alphaMode(value: number);
  20747. /**
  20748. * Gets the value of the alpha mode
  20749. */
  20750. get alphaMode(): number;
  20751. /**
  20752. * Stores the state of the need depth pre-pass value
  20753. */
  20754. private _needDepthPrePass;
  20755. /**
  20756. * Sets the need depth pre-pass value
  20757. */
  20758. set needDepthPrePass(value: boolean);
  20759. /**
  20760. * Gets the depth pre-pass value
  20761. */
  20762. get needDepthPrePass(): boolean;
  20763. /**
  20764. * Specifies if depth writing should be disabled
  20765. */
  20766. disableDepthWrite: boolean;
  20767. /**
  20768. * Specifies if depth writing should be forced
  20769. */
  20770. forceDepthWrite: boolean;
  20771. /**
  20772. * Specifies the depth function that should be used. 0 means the default engine function
  20773. */
  20774. depthFunction: number;
  20775. /**
  20776. * Specifies if there should be a separate pass for culling
  20777. */
  20778. separateCullingPass: boolean;
  20779. /**
  20780. * Stores the state specifing if fog should be enabled
  20781. */
  20782. private _fogEnabled;
  20783. /**
  20784. * Sets the state for enabling fog
  20785. */
  20786. set fogEnabled(value: boolean);
  20787. /**
  20788. * Gets the value of the fog enabled state
  20789. */
  20790. get fogEnabled(): boolean;
  20791. /**
  20792. * Stores the size of points
  20793. */
  20794. pointSize: number;
  20795. /**
  20796. * Stores the z offset value
  20797. */
  20798. zOffset: number;
  20799. /**
  20800. * Gets a value specifying if wireframe mode is enabled
  20801. */
  20802. get wireframe(): boolean;
  20803. /**
  20804. * Sets the state of wireframe mode
  20805. */
  20806. set wireframe(value: boolean);
  20807. /**
  20808. * Gets the value specifying if point clouds are enabled
  20809. */
  20810. get pointsCloud(): boolean;
  20811. /**
  20812. * Sets the state of point cloud mode
  20813. */
  20814. set pointsCloud(value: boolean);
  20815. /**
  20816. * Gets the material fill mode
  20817. */
  20818. get fillMode(): number;
  20819. /**
  20820. * Sets the material fill mode
  20821. */
  20822. set fillMode(value: number);
  20823. /**
  20824. * @hidden
  20825. * Stores the effects for the material
  20826. */
  20827. _effect: Nullable<Effect>;
  20828. /**
  20829. * @hidden
  20830. * Specifies if the material was previously ready
  20831. */
  20832. _wasPreviouslyReady: boolean;
  20833. /**
  20834. * Specifies if uniform buffers should be used
  20835. */
  20836. private _useUBO;
  20837. /**
  20838. * Stores a reference to the scene
  20839. */
  20840. private _scene;
  20841. /**
  20842. * Stores the fill mode state
  20843. */
  20844. private _fillMode;
  20845. /**
  20846. * Specifies if the depth write state should be cached
  20847. */
  20848. private _cachedDepthWriteState;
  20849. /**
  20850. * Specifies if the depth function state should be cached
  20851. */
  20852. private _cachedDepthFunctionState;
  20853. /**
  20854. * Stores the uniform buffer
  20855. */
  20856. protected _uniformBuffer: UniformBuffer;
  20857. /** @hidden */
  20858. _indexInSceneMaterialArray: number;
  20859. /** @hidden */
  20860. meshMap: Nullable<{
  20861. [id: string]: AbstractMesh | undefined;
  20862. }>;
  20863. /**
  20864. * Creates a material instance
  20865. * @param name defines the name of the material
  20866. * @param scene defines the scene to reference
  20867. * @param doNotAdd specifies if the material should be added to the scene
  20868. */
  20869. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20870. /**
  20871. * Returns a string representation of the current material
  20872. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20873. * @returns a string with material information
  20874. */
  20875. toString(fullDetails?: boolean): string;
  20876. /**
  20877. * Gets the class name of the material
  20878. * @returns a string with the class name of the material
  20879. */
  20880. getClassName(): string;
  20881. /**
  20882. * Specifies if updates for the material been locked
  20883. */
  20884. get isFrozen(): boolean;
  20885. /**
  20886. * Locks updates for the material
  20887. */
  20888. freeze(): void;
  20889. /**
  20890. * Unlocks updates for the material
  20891. */
  20892. unfreeze(): void;
  20893. /**
  20894. * Specifies if the material is ready to be used
  20895. * @param mesh defines the mesh to check
  20896. * @param useInstances specifies if instances should be used
  20897. * @returns a boolean indicating if the material is ready to be used
  20898. */
  20899. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20900. /**
  20901. * Specifies that the submesh is ready to be used
  20902. * @param mesh defines the mesh to check
  20903. * @param subMesh defines which submesh to check
  20904. * @param useInstances specifies that instances should be used
  20905. * @returns a boolean indicating that the submesh is ready or not
  20906. */
  20907. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20908. /**
  20909. * Returns the material effect
  20910. * @returns the effect associated with the material
  20911. */
  20912. getEffect(): Nullable<Effect>;
  20913. /**
  20914. * Returns the current scene
  20915. * @returns a Scene
  20916. */
  20917. getScene(): Scene;
  20918. /**
  20919. * Specifies if the material will require alpha blending
  20920. * @returns a boolean specifying if alpha blending is needed
  20921. */
  20922. needAlphaBlending(): boolean;
  20923. /**
  20924. * Specifies if the mesh will require alpha blending
  20925. * @param mesh defines the mesh to check
  20926. * @returns a boolean specifying if alpha blending is needed for the mesh
  20927. */
  20928. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20929. /**
  20930. * Specifies if this material should be rendered in alpha test mode
  20931. * @returns a boolean specifying if an alpha test is needed.
  20932. */
  20933. needAlphaTesting(): boolean;
  20934. /**
  20935. * Gets the texture used for the alpha test
  20936. * @returns the texture to use for alpha testing
  20937. */
  20938. getAlphaTestTexture(): Nullable<BaseTexture>;
  20939. /**
  20940. * Marks the material to indicate that it needs to be re-calculated
  20941. */
  20942. markDirty(): void;
  20943. /** @hidden */
  20944. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20945. /**
  20946. * Binds the material to the mesh
  20947. * @param world defines the world transformation matrix
  20948. * @param mesh defines the mesh to bind the material to
  20949. */
  20950. bind(world: Matrix, mesh?: Mesh): void;
  20951. /**
  20952. * Binds the submesh to the material
  20953. * @param world defines the world transformation matrix
  20954. * @param mesh defines the mesh containing the submesh
  20955. * @param subMesh defines the submesh to bind the material to
  20956. */
  20957. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20958. /**
  20959. * Binds the world matrix to the material
  20960. * @param world defines the world transformation matrix
  20961. */
  20962. bindOnlyWorldMatrix(world: Matrix): void;
  20963. /**
  20964. * Binds the scene's uniform buffer to the effect.
  20965. * @param effect defines the effect to bind to the scene uniform buffer
  20966. * @param sceneUbo defines the uniform buffer storing scene data
  20967. */
  20968. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20969. /**
  20970. * Binds the view matrix to the effect
  20971. * @param effect defines the effect to bind the view matrix to
  20972. */
  20973. bindView(effect: Effect): void;
  20974. /**
  20975. * Binds the view projection matrix to the effect
  20976. * @param effect defines the effect to bind the view projection matrix to
  20977. */
  20978. bindViewProjection(effect: Effect): void;
  20979. /**
  20980. * Specifies if material alpha testing should be turned on for the mesh
  20981. * @param mesh defines the mesh to check
  20982. */
  20983. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20984. /**
  20985. * Processes to execute after binding the material to a mesh
  20986. * @param mesh defines the rendered mesh
  20987. */
  20988. protected _afterBind(mesh?: Mesh): void;
  20989. /**
  20990. * Unbinds the material from the mesh
  20991. */
  20992. unbind(): void;
  20993. /**
  20994. * Gets the active textures from the material
  20995. * @returns an array of textures
  20996. */
  20997. getActiveTextures(): BaseTexture[];
  20998. /**
  20999. * Specifies if the material uses a texture
  21000. * @param texture defines the texture to check against the material
  21001. * @returns a boolean specifying if the material uses the texture
  21002. */
  21003. hasTexture(texture: BaseTexture): boolean;
  21004. /**
  21005. * Makes a duplicate of the material, and gives it a new name
  21006. * @param name defines the new name for the duplicated material
  21007. * @returns the cloned material
  21008. */
  21009. clone(name: string): Nullable<Material>;
  21010. /**
  21011. * Gets the meshes bound to the material
  21012. * @returns an array of meshes bound to the material
  21013. */
  21014. getBindedMeshes(): AbstractMesh[];
  21015. /**
  21016. * Force shader compilation
  21017. * @param mesh defines the mesh associated with this material
  21018. * @param onCompiled defines a function to execute once the material is compiled
  21019. * @param options defines the options to configure the compilation
  21020. * @param onError defines a function to execute if the material fails compiling
  21021. */
  21022. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21023. /**
  21024. * Force shader compilation
  21025. * @param mesh defines the mesh that will use this material
  21026. * @param options defines additional options for compiling the shaders
  21027. * @returns a promise that resolves when the compilation completes
  21028. */
  21029. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21030. private static readonly _AllDirtyCallBack;
  21031. private static readonly _ImageProcessingDirtyCallBack;
  21032. private static readonly _TextureDirtyCallBack;
  21033. private static readonly _FresnelDirtyCallBack;
  21034. private static readonly _MiscDirtyCallBack;
  21035. private static readonly _LightsDirtyCallBack;
  21036. private static readonly _AttributeDirtyCallBack;
  21037. private static _FresnelAndMiscDirtyCallBack;
  21038. private static _TextureAndMiscDirtyCallBack;
  21039. private static readonly _DirtyCallbackArray;
  21040. private static readonly _RunDirtyCallBacks;
  21041. /**
  21042. * Marks a define in the material to indicate that it needs to be re-computed
  21043. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21044. */
  21045. markAsDirty(flag: number): void;
  21046. /**
  21047. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21048. * @param func defines a function which checks material defines against the submeshes
  21049. */
  21050. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21051. /**
  21052. * Indicates that we need to re-calculated for all submeshes
  21053. */
  21054. protected _markAllSubMeshesAsAllDirty(): void;
  21055. /**
  21056. * Indicates that image processing needs to be re-calculated for all submeshes
  21057. */
  21058. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21059. /**
  21060. * Indicates that textures need to be re-calculated for all submeshes
  21061. */
  21062. protected _markAllSubMeshesAsTexturesDirty(): void;
  21063. /**
  21064. * Indicates that fresnel needs to be re-calculated for all submeshes
  21065. */
  21066. protected _markAllSubMeshesAsFresnelDirty(): void;
  21067. /**
  21068. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21069. */
  21070. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21071. /**
  21072. * Indicates that lights need to be re-calculated for all submeshes
  21073. */
  21074. protected _markAllSubMeshesAsLightsDirty(): void;
  21075. /**
  21076. * Indicates that attributes need to be re-calculated for all submeshes
  21077. */
  21078. protected _markAllSubMeshesAsAttributesDirty(): void;
  21079. /**
  21080. * Indicates that misc needs to be re-calculated for all submeshes
  21081. */
  21082. protected _markAllSubMeshesAsMiscDirty(): void;
  21083. /**
  21084. * Indicates that textures and misc need to be re-calculated for all submeshes
  21085. */
  21086. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21087. /**
  21088. * Disposes the material
  21089. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21090. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21091. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21092. */
  21093. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21094. /** @hidden */
  21095. private releaseVertexArrayObject;
  21096. /**
  21097. * Serializes this material
  21098. * @returns the serialized material object
  21099. */
  21100. serialize(): any;
  21101. /**
  21102. * Creates a material from parsed material data
  21103. * @param parsedMaterial defines parsed material data
  21104. * @param scene defines the hosting scene
  21105. * @param rootUrl defines the root URL to use to load textures
  21106. * @returns a new material
  21107. */
  21108. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21109. }
  21110. }
  21111. declare module BABYLON {
  21112. /**
  21113. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21114. * separate meshes. This can be use to improve performances.
  21115. * @see http://doc.babylonjs.com/how_to/multi_materials
  21116. */
  21117. export class MultiMaterial extends Material {
  21118. private _subMaterials;
  21119. /**
  21120. * Gets or Sets the list of Materials used within the multi material.
  21121. * They need to be ordered according to the submeshes order in the associated mesh
  21122. */
  21123. get subMaterials(): Nullable<Material>[];
  21124. set subMaterials(value: Nullable<Material>[]);
  21125. /**
  21126. * Function used to align with Node.getChildren()
  21127. * @returns the list of Materials used within the multi material
  21128. */
  21129. getChildren(): Nullable<Material>[];
  21130. /**
  21131. * Instantiates a new Multi Material
  21132. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21133. * separate meshes. This can be use to improve performances.
  21134. * @see http://doc.babylonjs.com/how_to/multi_materials
  21135. * @param name Define the name in the scene
  21136. * @param scene Define the scene the material belongs to
  21137. */
  21138. constructor(name: string, scene: Scene);
  21139. private _hookArray;
  21140. /**
  21141. * Get one of the submaterial by its index in the submaterials array
  21142. * @param index The index to look the sub material at
  21143. * @returns The Material if the index has been defined
  21144. */
  21145. getSubMaterial(index: number): Nullable<Material>;
  21146. /**
  21147. * Get the list of active textures for the whole sub materials list.
  21148. * @returns All the textures that will be used during the rendering
  21149. */
  21150. getActiveTextures(): BaseTexture[];
  21151. /**
  21152. * Gets the current class name of the material e.g. "MultiMaterial"
  21153. * Mainly use in serialization.
  21154. * @returns the class name
  21155. */
  21156. getClassName(): string;
  21157. /**
  21158. * Checks if the material is ready to render the requested sub mesh
  21159. * @param mesh Define the mesh the submesh belongs to
  21160. * @param subMesh Define the sub mesh to look readyness for
  21161. * @param useInstances Define whether or not the material is used with instances
  21162. * @returns true if ready, otherwise false
  21163. */
  21164. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21165. /**
  21166. * Clones the current material and its related sub materials
  21167. * @param name Define the name of the newly cloned material
  21168. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21169. * @returns the cloned material
  21170. */
  21171. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21172. /**
  21173. * Serializes the materials into a JSON representation.
  21174. * @returns the JSON representation
  21175. */
  21176. serialize(): any;
  21177. /**
  21178. * Dispose the material and release its associated resources
  21179. * @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)
  21180. * @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)
  21181. * @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)
  21182. */
  21183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21184. /**
  21185. * Creates a MultiMaterial from parsed MultiMaterial data.
  21186. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21187. * @param scene defines the hosting scene
  21188. * @returns a new MultiMaterial
  21189. */
  21190. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21191. }
  21192. }
  21193. declare module BABYLON {
  21194. /**
  21195. * Base class for submeshes
  21196. */
  21197. export class BaseSubMesh {
  21198. /** @hidden */
  21199. _materialDefines: Nullable<MaterialDefines>;
  21200. /** @hidden */
  21201. _materialEffect: Nullable<Effect>;
  21202. /**
  21203. * Gets material defines used by the effect associated to the sub mesh
  21204. */
  21205. get materialDefines(): Nullable<MaterialDefines>;
  21206. /**
  21207. * Sets material defines used by the effect associated to the sub mesh
  21208. */
  21209. set materialDefines(defines: Nullable<MaterialDefines>);
  21210. /**
  21211. * Gets associated effect
  21212. */
  21213. get effect(): Nullable<Effect>;
  21214. /**
  21215. * Sets associated effect (effect used to render this submesh)
  21216. * @param effect defines the effect to associate with
  21217. * @param defines defines the set of defines used to compile this effect
  21218. */
  21219. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21220. }
  21221. /**
  21222. * Defines a subdivision inside a mesh
  21223. */
  21224. export class SubMesh extends BaseSubMesh implements ICullable {
  21225. /** the material index to use */
  21226. materialIndex: number;
  21227. /** vertex index start */
  21228. verticesStart: number;
  21229. /** vertices count */
  21230. verticesCount: number;
  21231. /** index start */
  21232. indexStart: number;
  21233. /** indices count */
  21234. indexCount: number;
  21235. /** @hidden */
  21236. _linesIndexCount: number;
  21237. private _mesh;
  21238. private _renderingMesh;
  21239. private _boundingInfo;
  21240. private _linesIndexBuffer;
  21241. /** @hidden */
  21242. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21243. /** @hidden */
  21244. _trianglePlanes: Plane[];
  21245. /** @hidden */
  21246. _lastColliderTransformMatrix: Nullable<Matrix>;
  21247. /** @hidden */
  21248. _renderId: number;
  21249. /** @hidden */
  21250. _alphaIndex: number;
  21251. /** @hidden */
  21252. _distanceToCamera: number;
  21253. /** @hidden */
  21254. _id: number;
  21255. private _currentMaterial;
  21256. /**
  21257. * Add a new submesh to a mesh
  21258. * @param materialIndex defines the material index to use
  21259. * @param verticesStart defines vertex index start
  21260. * @param verticesCount defines vertices count
  21261. * @param indexStart defines index start
  21262. * @param indexCount defines indices count
  21263. * @param mesh defines the parent mesh
  21264. * @param renderingMesh defines an optional rendering mesh
  21265. * @param createBoundingBox defines if bounding box should be created for this submesh
  21266. * @returns the new submesh
  21267. */
  21268. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21269. /**
  21270. * Creates a new submesh
  21271. * @param materialIndex defines the material index to use
  21272. * @param verticesStart defines vertex index start
  21273. * @param verticesCount defines vertices count
  21274. * @param indexStart defines index start
  21275. * @param indexCount defines indices count
  21276. * @param mesh defines the parent mesh
  21277. * @param renderingMesh defines an optional rendering mesh
  21278. * @param createBoundingBox defines if bounding box should be created for this submesh
  21279. */
  21280. constructor(
  21281. /** the material index to use */
  21282. materialIndex: number,
  21283. /** vertex index start */
  21284. verticesStart: number,
  21285. /** vertices count */
  21286. verticesCount: number,
  21287. /** index start */
  21288. indexStart: number,
  21289. /** indices count */
  21290. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21291. /**
  21292. * Returns true if this submesh covers the entire parent mesh
  21293. * @ignorenaming
  21294. */
  21295. get IsGlobal(): boolean;
  21296. /**
  21297. * Returns the submesh BoudingInfo object
  21298. * @returns current bounding info (or mesh's one if the submesh is global)
  21299. */
  21300. getBoundingInfo(): BoundingInfo;
  21301. /**
  21302. * Sets the submesh BoundingInfo
  21303. * @param boundingInfo defines the new bounding info to use
  21304. * @returns the SubMesh
  21305. */
  21306. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21307. /**
  21308. * Returns the mesh of the current submesh
  21309. * @return the parent mesh
  21310. */
  21311. getMesh(): AbstractMesh;
  21312. /**
  21313. * Returns the rendering mesh of the submesh
  21314. * @returns the rendering mesh (could be different from parent mesh)
  21315. */
  21316. getRenderingMesh(): Mesh;
  21317. /**
  21318. * Returns the submesh material
  21319. * @returns null or the current material
  21320. */
  21321. getMaterial(): Nullable<Material>;
  21322. /**
  21323. * Sets a new updated BoundingInfo object to the submesh
  21324. * @param data defines an optional position array to use to determine the bounding info
  21325. * @returns the SubMesh
  21326. */
  21327. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21328. /** @hidden */
  21329. _checkCollision(collider: Collider): boolean;
  21330. /**
  21331. * Updates the submesh BoundingInfo
  21332. * @param world defines the world matrix to use to update the bounding info
  21333. * @returns the submesh
  21334. */
  21335. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21336. /**
  21337. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21338. * @param frustumPlanes defines the frustum planes
  21339. * @returns true if the submesh is intersecting with the frustum
  21340. */
  21341. isInFrustum(frustumPlanes: Plane[]): boolean;
  21342. /**
  21343. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21344. * @param frustumPlanes defines the frustum planes
  21345. * @returns true if the submesh is inside the frustum
  21346. */
  21347. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21348. /**
  21349. * Renders the submesh
  21350. * @param enableAlphaMode defines if alpha needs to be used
  21351. * @returns the submesh
  21352. */
  21353. render(enableAlphaMode: boolean): SubMesh;
  21354. /**
  21355. * @hidden
  21356. */
  21357. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21358. /**
  21359. * Checks if the submesh intersects with a ray
  21360. * @param ray defines the ray to test
  21361. * @returns true is the passed ray intersects the submesh bounding box
  21362. */
  21363. canIntersects(ray: Ray): boolean;
  21364. /**
  21365. * Intersects current submesh with a ray
  21366. * @param ray defines the ray to test
  21367. * @param positions defines mesh's positions array
  21368. * @param indices defines mesh's indices array
  21369. * @param fastCheck defines if only bounding info should be used
  21370. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21371. * @returns intersection info or null if no intersection
  21372. */
  21373. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21374. /** @hidden */
  21375. private _intersectLines;
  21376. /** @hidden */
  21377. private _intersectUnIndexedLines;
  21378. /** @hidden */
  21379. private _intersectTriangles;
  21380. /** @hidden */
  21381. private _intersectUnIndexedTriangles;
  21382. /** @hidden */
  21383. _rebuild(): void;
  21384. /**
  21385. * Creates a new submesh from the passed mesh
  21386. * @param newMesh defines the new hosting mesh
  21387. * @param newRenderingMesh defines an optional rendering mesh
  21388. * @returns the new submesh
  21389. */
  21390. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21391. /**
  21392. * Release associated resources
  21393. */
  21394. dispose(): void;
  21395. /**
  21396. * Gets the class name
  21397. * @returns the string "SubMesh".
  21398. */
  21399. getClassName(): string;
  21400. /**
  21401. * Creates a new submesh from indices data
  21402. * @param materialIndex the index of the main mesh material
  21403. * @param startIndex the index where to start the copy in the mesh indices array
  21404. * @param indexCount the number of indices to copy then from the startIndex
  21405. * @param mesh the main mesh to create the submesh from
  21406. * @param renderingMesh the optional rendering mesh
  21407. * @returns a new submesh
  21408. */
  21409. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21410. }
  21411. }
  21412. declare module BABYLON {
  21413. /**
  21414. * Class used to represent data loading progression
  21415. */
  21416. export class SceneLoaderFlags {
  21417. private static _ForceFullSceneLoadingForIncremental;
  21418. private static _ShowLoadingScreen;
  21419. private static _CleanBoneMatrixWeights;
  21420. private static _loggingLevel;
  21421. /**
  21422. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21423. */
  21424. static get ForceFullSceneLoadingForIncremental(): boolean;
  21425. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21426. /**
  21427. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21428. */
  21429. static get ShowLoadingScreen(): boolean;
  21430. static set ShowLoadingScreen(value: boolean);
  21431. /**
  21432. * Defines the current logging level (while loading the scene)
  21433. * @ignorenaming
  21434. */
  21435. static get loggingLevel(): number;
  21436. static set loggingLevel(value: number);
  21437. /**
  21438. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21439. */
  21440. static get CleanBoneMatrixWeights(): boolean;
  21441. static set CleanBoneMatrixWeights(value: boolean);
  21442. }
  21443. }
  21444. declare module BABYLON {
  21445. /**
  21446. * Class used to store geometry data (vertex buffers + index buffer)
  21447. */
  21448. export class Geometry implements IGetSetVerticesData {
  21449. /**
  21450. * Gets or sets the ID of the geometry
  21451. */
  21452. id: string;
  21453. /**
  21454. * Gets or sets the unique ID of the geometry
  21455. */
  21456. uniqueId: number;
  21457. /**
  21458. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21459. */
  21460. delayLoadState: number;
  21461. /**
  21462. * Gets the file containing the data to load when running in delay load state
  21463. */
  21464. delayLoadingFile: Nullable<string>;
  21465. /**
  21466. * Callback called when the geometry is updated
  21467. */
  21468. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21469. private _scene;
  21470. private _engine;
  21471. private _meshes;
  21472. private _totalVertices;
  21473. /** @hidden */
  21474. _indices: IndicesArray;
  21475. /** @hidden */
  21476. _vertexBuffers: {
  21477. [key: string]: VertexBuffer;
  21478. };
  21479. private _isDisposed;
  21480. private _extend;
  21481. private _boundingBias;
  21482. /** @hidden */
  21483. _delayInfo: Array<string>;
  21484. private _indexBuffer;
  21485. private _indexBufferIsUpdatable;
  21486. /** @hidden */
  21487. _boundingInfo: Nullable<BoundingInfo>;
  21488. /** @hidden */
  21489. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21490. /** @hidden */
  21491. _softwareSkinningFrameId: number;
  21492. private _vertexArrayObjects;
  21493. private _updatable;
  21494. /** @hidden */
  21495. _positions: Nullable<Vector3[]>;
  21496. /**
  21497. * 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
  21498. */
  21499. get boundingBias(): Vector2;
  21500. /**
  21501. * 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
  21502. */
  21503. set boundingBias(value: Vector2);
  21504. /**
  21505. * Static function used to attach a new empty geometry to a mesh
  21506. * @param mesh defines the mesh to attach the geometry to
  21507. * @returns the new Geometry
  21508. */
  21509. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21510. /**
  21511. * Creates a new geometry
  21512. * @param id defines the unique ID
  21513. * @param scene defines the hosting scene
  21514. * @param vertexData defines the VertexData used to get geometry data
  21515. * @param updatable defines if geometry must be updatable (false by default)
  21516. * @param mesh defines the mesh that will be associated with the geometry
  21517. */
  21518. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21519. /**
  21520. * Gets the current extend of the geometry
  21521. */
  21522. get extend(): {
  21523. minimum: Vector3;
  21524. maximum: Vector3;
  21525. };
  21526. /**
  21527. * Gets the hosting scene
  21528. * @returns the hosting Scene
  21529. */
  21530. getScene(): Scene;
  21531. /**
  21532. * Gets the hosting engine
  21533. * @returns the hosting Engine
  21534. */
  21535. getEngine(): Engine;
  21536. /**
  21537. * Defines if the geometry is ready to use
  21538. * @returns true if the geometry is ready to be used
  21539. */
  21540. isReady(): boolean;
  21541. /**
  21542. * Gets a value indicating that the geometry should not be serialized
  21543. */
  21544. get doNotSerialize(): boolean;
  21545. /** @hidden */
  21546. _rebuild(): void;
  21547. /**
  21548. * Affects all geometry data in one call
  21549. * @param vertexData defines the geometry data
  21550. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21551. */
  21552. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21553. /**
  21554. * Set specific vertex data
  21555. * @param kind defines the data kind (Position, normal, etc...)
  21556. * @param data defines the vertex data to use
  21557. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21558. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21559. */
  21560. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21561. /**
  21562. * Removes a specific vertex data
  21563. * @param kind defines the data kind (Position, normal, etc...)
  21564. */
  21565. removeVerticesData(kind: string): void;
  21566. /**
  21567. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21568. * @param buffer defines the vertex buffer to use
  21569. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21570. */
  21571. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21572. /**
  21573. * Update a specific vertex buffer
  21574. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21575. * It will do nothing if the buffer is not updatable
  21576. * @param kind defines the data kind (Position, normal, etc...)
  21577. * @param data defines the data to use
  21578. * @param offset defines the offset in the target buffer where to store the data
  21579. * @param useBytes set to true if the offset is in bytes
  21580. */
  21581. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21582. /**
  21583. * Update a specific vertex buffer
  21584. * This function will create a new buffer if the current one is not updatable
  21585. * @param kind defines the data kind (Position, normal, etc...)
  21586. * @param data defines the data to use
  21587. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21588. */
  21589. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21590. private _updateBoundingInfo;
  21591. /** @hidden */
  21592. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21593. /**
  21594. * Gets total number of vertices
  21595. * @returns the total number of vertices
  21596. */
  21597. getTotalVertices(): number;
  21598. /**
  21599. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21600. * @param kind defines the data kind (Position, normal, etc...)
  21601. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21602. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21603. * @returns a float array containing vertex data
  21604. */
  21605. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21606. /**
  21607. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21608. * @param kind defines the data kind (Position, normal, etc...)
  21609. * @returns true if the vertex buffer with the specified kind is updatable
  21610. */
  21611. isVertexBufferUpdatable(kind: string): boolean;
  21612. /**
  21613. * Gets a specific vertex buffer
  21614. * @param kind defines the data kind (Position, normal, etc...)
  21615. * @returns a VertexBuffer
  21616. */
  21617. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21618. /**
  21619. * Returns all vertex buffers
  21620. * @return an object holding all vertex buffers indexed by kind
  21621. */
  21622. getVertexBuffers(): Nullable<{
  21623. [key: string]: VertexBuffer;
  21624. }>;
  21625. /**
  21626. * Gets a boolean indicating if specific vertex buffer is present
  21627. * @param kind defines the data kind (Position, normal, etc...)
  21628. * @returns true if data is present
  21629. */
  21630. isVerticesDataPresent(kind: string): boolean;
  21631. /**
  21632. * Gets a list of all attached data kinds (Position, normal, etc...)
  21633. * @returns a list of string containing all kinds
  21634. */
  21635. getVerticesDataKinds(): string[];
  21636. /**
  21637. * Update index buffer
  21638. * @param indices defines the indices to store in the index buffer
  21639. * @param offset defines the offset in the target buffer where to store the data
  21640. * @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)
  21641. */
  21642. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21643. /**
  21644. * Creates a new index buffer
  21645. * @param indices defines the indices to store in the index buffer
  21646. * @param totalVertices defines the total number of vertices (could be null)
  21647. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21648. */
  21649. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21650. /**
  21651. * Return the total number of indices
  21652. * @returns the total number of indices
  21653. */
  21654. getTotalIndices(): number;
  21655. /**
  21656. * Gets the index buffer array
  21657. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21659. * @returns the index buffer array
  21660. */
  21661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21662. /**
  21663. * Gets the index buffer
  21664. * @return the index buffer
  21665. */
  21666. getIndexBuffer(): Nullable<DataBuffer>;
  21667. /** @hidden */
  21668. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21669. /**
  21670. * Release the associated resources for a specific mesh
  21671. * @param mesh defines the source mesh
  21672. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21673. */
  21674. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21675. /**
  21676. * Apply current geometry to a given mesh
  21677. * @param mesh defines the mesh to apply geometry to
  21678. */
  21679. applyToMesh(mesh: Mesh): void;
  21680. private _updateExtend;
  21681. private _applyToMesh;
  21682. private notifyUpdate;
  21683. /**
  21684. * Load the geometry if it was flagged as delay loaded
  21685. * @param scene defines the hosting scene
  21686. * @param onLoaded defines a callback called when the geometry is loaded
  21687. */
  21688. load(scene: Scene, onLoaded?: () => void): void;
  21689. private _queueLoad;
  21690. /**
  21691. * Invert the geometry to move from a right handed system to a left handed one.
  21692. */
  21693. toLeftHanded(): void;
  21694. /** @hidden */
  21695. _resetPointsArrayCache(): void;
  21696. /** @hidden */
  21697. _generatePointsArray(): boolean;
  21698. /**
  21699. * Gets a value indicating if the geometry is disposed
  21700. * @returns true if the geometry was disposed
  21701. */
  21702. isDisposed(): boolean;
  21703. private _disposeVertexArrayObjects;
  21704. /**
  21705. * Free all associated resources
  21706. */
  21707. dispose(): void;
  21708. /**
  21709. * Clone the current geometry into a new geometry
  21710. * @param id defines the unique ID of the new geometry
  21711. * @returns a new geometry object
  21712. */
  21713. copy(id: string): Geometry;
  21714. /**
  21715. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21716. * @return a JSON representation of the current geometry data (without the vertices data)
  21717. */
  21718. serialize(): any;
  21719. private toNumberArray;
  21720. /**
  21721. * Serialize all vertices data into a JSON oject
  21722. * @returns a JSON representation of the current geometry data
  21723. */
  21724. serializeVerticeData(): any;
  21725. /**
  21726. * Extracts a clone of a mesh geometry
  21727. * @param mesh defines the source mesh
  21728. * @param id defines the unique ID of the new geometry object
  21729. * @returns the new geometry object
  21730. */
  21731. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21732. /**
  21733. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21734. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21735. * Be aware Math.random() could cause collisions, but:
  21736. * "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"
  21737. * @returns a string containing a new GUID
  21738. */
  21739. static RandomId(): string;
  21740. /** @hidden */
  21741. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21742. private static _CleanMatricesWeights;
  21743. /**
  21744. * Create a new geometry from persisted data (Using .babylon file format)
  21745. * @param parsedVertexData defines the persisted data
  21746. * @param scene defines the hosting scene
  21747. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21748. * @returns the new geometry object
  21749. */
  21750. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21751. }
  21752. }
  21753. declare module BABYLON {
  21754. /**
  21755. * Define an interface for all classes that will get and set the data on vertices
  21756. */
  21757. export interface IGetSetVerticesData {
  21758. /**
  21759. * Gets a boolean indicating if specific vertex data is present
  21760. * @param kind defines the vertex data kind to use
  21761. * @returns true is data kind is present
  21762. */
  21763. isVerticesDataPresent(kind: string): boolean;
  21764. /**
  21765. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21766. * @param kind defines the data kind (Position, normal, etc...)
  21767. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21769. * @returns a float array containing vertex data
  21770. */
  21771. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21772. /**
  21773. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21774. * @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.
  21775. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21776. * @returns the indices array or an empty array if the mesh has no geometry
  21777. */
  21778. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21779. /**
  21780. * Set specific vertex data
  21781. * @param kind defines the data kind (Position, normal, etc...)
  21782. * @param data defines the vertex data to use
  21783. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21784. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21785. */
  21786. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21787. /**
  21788. * Update a specific associated vertex buffer
  21789. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21790. * - VertexBuffer.PositionKind
  21791. * - VertexBuffer.UVKind
  21792. * - VertexBuffer.UV2Kind
  21793. * - VertexBuffer.UV3Kind
  21794. * - VertexBuffer.UV4Kind
  21795. * - VertexBuffer.UV5Kind
  21796. * - VertexBuffer.UV6Kind
  21797. * - VertexBuffer.ColorKind
  21798. * - VertexBuffer.MatricesIndicesKind
  21799. * - VertexBuffer.MatricesIndicesExtraKind
  21800. * - VertexBuffer.MatricesWeightsKind
  21801. * - VertexBuffer.MatricesWeightsExtraKind
  21802. * @param data defines the data source
  21803. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21804. * @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)
  21805. */
  21806. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21807. /**
  21808. * Creates a new index buffer
  21809. * @param indices defines the indices to store in the index buffer
  21810. * @param totalVertices defines the total number of vertices (could be null)
  21811. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21812. */
  21813. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21814. }
  21815. /**
  21816. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21817. */
  21818. export class VertexData {
  21819. /**
  21820. * Mesh side orientation : usually the external or front surface
  21821. */
  21822. static readonly FRONTSIDE: number;
  21823. /**
  21824. * Mesh side orientation : usually the internal or back surface
  21825. */
  21826. static readonly BACKSIDE: number;
  21827. /**
  21828. * Mesh side orientation : both internal and external or front and back surfaces
  21829. */
  21830. static readonly DOUBLESIDE: number;
  21831. /**
  21832. * Mesh side orientation : by default, `FRONTSIDE`
  21833. */
  21834. static readonly DEFAULTSIDE: number;
  21835. /**
  21836. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21837. */
  21838. positions: Nullable<FloatArray>;
  21839. /**
  21840. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21841. */
  21842. normals: Nullable<FloatArray>;
  21843. /**
  21844. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21845. */
  21846. tangents: Nullable<FloatArray>;
  21847. /**
  21848. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21849. */
  21850. uvs: Nullable<FloatArray>;
  21851. /**
  21852. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21853. */
  21854. uvs2: Nullable<FloatArray>;
  21855. /**
  21856. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21857. */
  21858. uvs3: Nullable<FloatArray>;
  21859. /**
  21860. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21861. */
  21862. uvs4: Nullable<FloatArray>;
  21863. /**
  21864. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21865. */
  21866. uvs5: Nullable<FloatArray>;
  21867. /**
  21868. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21869. */
  21870. uvs6: Nullable<FloatArray>;
  21871. /**
  21872. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21873. */
  21874. colors: Nullable<FloatArray>;
  21875. /**
  21876. * 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).
  21877. */
  21878. matricesIndices: Nullable<FloatArray>;
  21879. /**
  21880. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21881. */
  21882. matricesWeights: Nullable<FloatArray>;
  21883. /**
  21884. * An array extending the number of possible indices
  21885. */
  21886. matricesIndicesExtra: Nullable<FloatArray>;
  21887. /**
  21888. * An array extending the number of possible weights when the number of indices is extended
  21889. */
  21890. matricesWeightsExtra: Nullable<FloatArray>;
  21891. /**
  21892. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21893. */
  21894. indices: Nullable<IndicesArray>;
  21895. /**
  21896. * Uses the passed data array to set the set the values for the specified kind of data
  21897. * @param data a linear array of floating numbers
  21898. * @param kind the type of data that is being set, eg positions, colors etc
  21899. */
  21900. set(data: FloatArray, kind: string): void;
  21901. /**
  21902. * Associates the vertexData to the passed Mesh.
  21903. * Sets it as updatable or not (default `false`)
  21904. * @param mesh the mesh the vertexData is applied to
  21905. * @param updatable when used and having the value true allows new data to update the vertexData
  21906. * @returns the VertexData
  21907. */
  21908. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21909. /**
  21910. * Associates the vertexData to the passed Geometry.
  21911. * Sets it as updatable or not (default `false`)
  21912. * @param geometry the geometry the vertexData is applied to
  21913. * @param updatable when used and having the value true allows new data to update the vertexData
  21914. * @returns VertexData
  21915. */
  21916. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21917. /**
  21918. * Updates the associated mesh
  21919. * @param mesh the mesh to be updated
  21920. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21921. * @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
  21922. * @returns VertexData
  21923. */
  21924. updateMesh(mesh: Mesh): VertexData;
  21925. /**
  21926. * Updates the associated geometry
  21927. * @param geometry the geometry to be updated
  21928. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21929. * @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
  21930. * @returns VertexData.
  21931. */
  21932. updateGeometry(geometry: Geometry): VertexData;
  21933. private _applyTo;
  21934. private _update;
  21935. /**
  21936. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21937. * @param matrix the transforming matrix
  21938. * @returns the VertexData
  21939. */
  21940. transform(matrix: Matrix): VertexData;
  21941. /**
  21942. * Merges the passed VertexData into the current one
  21943. * @param other the VertexData to be merged into the current one
  21944. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21945. * @returns the modified VertexData
  21946. */
  21947. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21948. private _mergeElement;
  21949. private _validate;
  21950. /**
  21951. * Serializes the VertexData
  21952. * @returns a serialized object
  21953. */
  21954. serialize(): any;
  21955. /**
  21956. * Extracts the vertexData from a mesh
  21957. * @param mesh the mesh from which to extract the VertexData
  21958. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21959. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21960. * @returns the object VertexData associated to the passed mesh
  21961. */
  21962. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21963. /**
  21964. * Extracts the vertexData from the geometry
  21965. * @param geometry the geometry from which to extract the VertexData
  21966. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21967. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21968. * @returns the object VertexData associated to the passed mesh
  21969. */
  21970. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21971. private static _ExtractFrom;
  21972. /**
  21973. * Creates the VertexData for a Ribbon
  21974. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21975. * * pathArray array of paths, each of which an array of successive Vector3
  21976. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21977. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21978. * * 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
  21979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21980. * * 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)
  21981. * * 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)
  21982. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21983. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21984. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21985. * @returns the VertexData of the ribbon
  21986. */
  21987. static CreateRibbon(options: {
  21988. pathArray: Vector3[][];
  21989. closeArray?: boolean;
  21990. closePath?: boolean;
  21991. offset?: number;
  21992. sideOrientation?: number;
  21993. frontUVs?: Vector4;
  21994. backUVs?: Vector4;
  21995. invertUV?: boolean;
  21996. uvs?: Vector2[];
  21997. colors?: Color4[];
  21998. }): VertexData;
  21999. /**
  22000. * Creates the VertexData for a box
  22001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22002. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22003. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22004. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22005. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22006. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22007. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22009. * * 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)
  22010. * * 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)
  22011. * @returns the VertexData of the box
  22012. */
  22013. static CreateBox(options: {
  22014. size?: number;
  22015. width?: number;
  22016. height?: number;
  22017. depth?: number;
  22018. faceUV?: Vector4[];
  22019. faceColors?: Color4[];
  22020. sideOrientation?: number;
  22021. frontUVs?: Vector4;
  22022. backUVs?: Vector4;
  22023. }): VertexData;
  22024. /**
  22025. * Creates the VertexData for a tiled box
  22026. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22027. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22028. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22029. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22031. * @returns the VertexData of the box
  22032. */
  22033. static CreateTiledBox(options: {
  22034. pattern?: number;
  22035. width?: number;
  22036. height?: number;
  22037. depth?: number;
  22038. tileSize?: number;
  22039. tileWidth?: number;
  22040. tileHeight?: number;
  22041. alignHorizontal?: number;
  22042. alignVertical?: number;
  22043. faceUV?: Vector4[];
  22044. faceColors?: Color4[];
  22045. sideOrientation?: number;
  22046. }): VertexData;
  22047. /**
  22048. * Creates the VertexData for a tiled plane
  22049. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22050. * * pattern a limited pattern arrangement depending on the number
  22051. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22052. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22053. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22055. * * 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)
  22056. * * 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)
  22057. * @returns the VertexData of the tiled plane
  22058. */
  22059. static CreateTiledPlane(options: {
  22060. pattern?: number;
  22061. tileSize?: number;
  22062. tileWidth?: number;
  22063. tileHeight?: number;
  22064. size?: number;
  22065. width?: number;
  22066. height?: number;
  22067. alignHorizontal?: number;
  22068. alignVertical?: number;
  22069. sideOrientation?: number;
  22070. frontUVs?: Vector4;
  22071. backUVs?: Vector4;
  22072. }): VertexData;
  22073. /**
  22074. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22075. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22076. * * segments sets the number of horizontal strips optional, default 32
  22077. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22078. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22079. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22080. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22081. * * 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
  22082. * * 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
  22083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22084. * * 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)
  22085. * * 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)
  22086. * @returns the VertexData of the ellipsoid
  22087. */
  22088. static CreateSphere(options: {
  22089. segments?: number;
  22090. diameter?: number;
  22091. diameterX?: number;
  22092. diameterY?: number;
  22093. diameterZ?: number;
  22094. arc?: number;
  22095. slice?: number;
  22096. sideOrientation?: number;
  22097. frontUVs?: Vector4;
  22098. backUVs?: Vector4;
  22099. }): VertexData;
  22100. /**
  22101. * Creates the VertexData for a cylinder, cone or prism
  22102. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22103. * * height sets the height (y direction) of the cylinder, optional, default 2
  22104. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22105. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22106. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22107. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22108. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22109. * * 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
  22110. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22111. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22112. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22113. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22115. * * 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)
  22116. * * 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)
  22117. * @returns the VertexData of the cylinder, cone or prism
  22118. */
  22119. static CreateCylinder(options: {
  22120. height?: number;
  22121. diameterTop?: number;
  22122. diameterBottom?: number;
  22123. diameter?: number;
  22124. tessellation?: number;
  22125. subdivisions?: number;
  22126. arc?: number;
  22127. faceColors?: Color4[];
  22128. faceUV?: Vector4[];
  22129. hasRings?: boolean;
  22130. enclose?: boolean;
  22131. sideOrientation?: number;
  22132. frontUVs?: Vector4;
  22133. backUVs?: Vector4;
  22134. }): VertexData;
  22135. /**
  22136. * Creates the VertexData for a torus
  22137. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22138. * * diameter the diameter of the torus, optional default 1
  22139. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22140. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22142. * * 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)
  22143. * * 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)
  22144. * @returns the VertexData of the torus
  22145. */
  22146. static CreateTorus(options: {
  22147. diameter?: number;
  22148. thickness?: number;
  22149. tessellation?: number;
  22150. sideOrientation?: number;
  22151. frontUVs?: Vector4;
  22152. backUVs?: Vector4;
  22153. }): VertexData;
  22154. /**
  22155. * Creates the VertexData of the LineSystem
  22156. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22157. * - lines an array of lines, each line being an array of successive Vector3
  22158. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22159. * @returns the VertexData of the LineSystem
  22160. */
  22161. static CreateLineSystem(options: {
  22162. lines: Vector3[][];
  22163. colors?: Nullable<Color4[][]>;
  22164. }): VertexData;
  22165. /**
  22166. * Create the VertexData for a DashedLines
  22167. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22168. * - points an array successive Vector3
  22169. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22170. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22171. * - dashNb the intended total number of dashes, optional, default 200
  22172. * @returns the VertexData for the DashedLines
  22173. */
  22174. static CreateDashedLines(options: {
  22175. points: Vector3[];
  22176. dashSize?: number;
  22177. gapSize?: number;
  22178. dashNb?: number;
  22179. }): VertexData;
  22180. /**
  22181. * Creates the VertexData for a Ground
  22182. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22183. * - width the width (x direction) of the ground, optional, default 1
  22184. * - height the height (z direction) of the ground, optional, default 1
  22185. * - subdivisions the number of subdivisions per side, optional, default 1
  22186. * @returns the VertexData of the Ground
  22187. */
  22188. static CreateGround(options: {
  22189. width?: number;
  22190. height?: number;
  22191. subdivisions?: number;
  22192. subdivisionsX?: number;
  22193. subdivisionsY?: number;
  22194. }): VertexData;
  22195. /**
  22196. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22197. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22198. * * xmin the ground minimum X coordinate, optional, default -1
  22199. * * zmin the ground minimum Z coordinate, optional, default -1
  22200. * * xmax the ground maximum X coordinate, optional, default 1
  22201. * * zmax the ground maximum Z coordinate, optional, default 1
  22202. * * 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}
  22203. * * 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}
  22204. * @returns the VertexData of the TiledGround
  22205. */
  22206. static CreateTiledGround(options: {
  22207. xmin: number;
  22208. zmin: number;
  22209. xmax: number;
  22210. zmax: number;
  22211. subdivisions?: {
  22212. w: number;
  22213. h: number;
  22214. };
  22215. precision?: {
  22216. w: number;
  22217. h: number;
  22218. };
  22219. }): VertexData;
  22220. /**
  22221. * Creates the VertexData of the Ground designed from a heightmap
  22222. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22223. * * width the width (x direction) of the ground
  22224. * * height the height (z direction) of the ground
  22225. * * subdivisions the number of subdivisions per side
  22226. * * minHeight the minimum altitude on the ground, optional, default 0
  22227. * * maxHeight the maximum altitude on the ground, optional default 1
  22228. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22229. * * buffer the array holding the image color data
  22230. * * bufferWidth the width of image
  22231. * * bufferHeight the height of image
  22232. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22233. * @returns the VertexData of the Ground designed from a heightmap
  22234. */
  22235. static CreateGroundFromHeightMap(options: {
  22236. width: number;
  22237. height: number;
  22238. subdivisions: number;
  22239. minHeight: number;
  22240. maxHeight: number;
  22241. colorFilter: Color3;
  22242. buffer: Uint8Array;
  22243. bufferWidth: number;
  22244. bufferHeight: number;
  22245. alphaFilter: number;
  22246. }): VertexData;
  22247. /**
  22248. * Creates the VertexData for a Plane
  22249. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22250. * * size sets the width and height of the plane to the value of size, optional default 1
  22251. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22252. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22254. * * 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)
  22255. * * 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)
  22256. * @returns the VertexData of the box
  22257. */
  22258. static CreatePlane(options: {
  22259. size?: number;
  22260. width?: number;
  22261. height?: number;
  22262. sideOrientation?: number;
  22263. frontUVs?: Vector4;
  22264. backUVs?: Vector4;
  22265. }): VertexData;
  22266. /**
  22267. * Creates the VertexData of the Disc or regular Polygon
  22268. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22269. * * radius the radius of the disc, optional default 0.5
  22270. * * tessellation the number of polygon sides, optional, default 64
  22271. * * 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
  22272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22273. * * 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)
  22274. * * 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)
  22275. * @returns the VertexData of the box
  22276. */
  22277. static CreateDisc(options: {
  22278. radius?: number;
  22279. tessellation?: number;
  22280. arc?: number;
  22281. sideOrientation?: number;
  22282. frontUVs?: Vector4;
  22283. backUVs?: Vector4;
  22284. }): VertexData;
  22285. /**
  22286. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22287. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22288. * @param polygon a mesh built from polygonTriangulation.build()
  22289. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22290. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22291. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22292. * @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)
  22293. * @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)
  22294. * @returns the VertexData of the Polygon
  22295. */
  22296. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22297. /**
  22298. * Creates the VertexData of the IcoSphere
  22299. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22300. * * radius the radius of the IcoSphere, optional default 1
  22301. * * radiusX allows stretching in the x direction, optional, default radius
  22302. * * radiusY allows stretching in the y direction, optional, default radius
  22303. * * radiusZ allows stretching in the z direction, optional, default radius
  22304. * * flat when true creates a flat shaded mesh, optional, default true
  22305. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22306. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22307. * * 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)
  22308. * * 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)
  22309. * @returns the VertexData of the IcoSphere
  22310. */
  22311. static CreateIcoSphere(options: {
  22312. radius?: number;
  22313. radiusX?: number;
  22314. radiusY?: number;
  22315. radiusZ?: number;
  22316. flat?: boolean;
  22317. subdivisions?: number;
  22318. sideOrientation?: number;
  22319. frontUVs?: Vector4;
  22320. backUVs?: Vector4;
  22321. }): VertexData;
  22322. /**
  22323. * Creates the VertexData for a Polyhedron
  22324. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22325. * * type provided types are:
  22326. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22327. * * 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)
  22328. * * size the size of the IcoSphere, optional default 1
  22329. * * sizeX allows stretching in the x direction, optional, default size
  22330. * * sizeY allows stretching in the y direction, optional, default size
  22331. * * sizeZ allows stretching in the z direction, optional, default size
  22332. * * 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
  22333. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22334. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22335. * * flat when true creates a flat shaded mesh, optional, default true
  22336. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22338. * * 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)
  22339. * * 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)
  22340. * @returns the VertexData of the Polyhedron
  22341. */
  22342. static CreatePolyhedron(options: {
  22343. type?: number;
  22344. size?: number;
  22345. sizeX?: number;
  22346. sizeY?: number;
  22347. sizeZ?: number;
  22348. custom?: any;
  22349. faceUV?: Vector4[];
  22350. faceColors?: Color4[];
  22351. flat?: boolean;
  22352. sideOrientation?: number;
  22353. frontUVs?: Vector4;
  22354. backUVs?: Vector4;
  22355. }): VertexData;
  22356. /**
  22357. * Creates the VertexData for a TorusKnot
  22358. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22359. * * radius the radius of the torus knot, optional, default 2
  22360. * * tube the thickness of the tube, optional, default 0.5
  22361. * * radialSegments the number of sides on each tube segments, optional, default 32
  22362. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22363. * * p the number of windings around the z axis, optional, default 2
  22364. * * q the number of windings around the x axis, optional, default 3
  22365. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22366. * * 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)
  22367. * * 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)
  22368. * @returns the VertexData of the Torus Knot
  22369. */
  22370. static CreateTorusKnot(options: {
  22371. radius?: number;
  22372. tube?: number;
  22373. radialSegments?: number;
  22374. tubularSegments?: number;
  22375. p?: number;
  22376. q?: number;
  22377. sideOrientation?: number;
  22378. frontUVs?: Vector4;
  22379. backUVs?: Vector4;
  22380. }): VertexData;
  22381. /**
  22382. * Compute normals for given positions and indices
  22383. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22384. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22385. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22386. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22387. * * facetNormals : optional array of facet normals (vector3)
  22388. * * facetPositions : optional array of facet positions (vector3)
  22389. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22390. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22391. * * bInfo : optional bounding info, required for facetPartitioning computation
  22392. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22393. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22394. * * useRightHandedSystem: optional boolean to for right handed system computation
  22395. * * depthSort : optional boolean to enable the facet depth sort computation
  22396. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22397. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22398. */
  22399. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22400. facetNormals?: any;
  22401. facetPositions?: any;
  22402. facetPartitioning?: any;
  22403. ratio?: number;
  22404. bInfo?: any;
  22405. bbSize?: Vector3;
  22406. subDiv?: any;
  22407. useRightHandedSystem?: boolean;
  22408. depthSort?: boolean;
  22409. distanceTo?: Vector3;
  22410. depthSortedFacets?: any;
  22411. }): void;
  22412. /** @hidden */
  22413. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22414. /**
  22415. * Applies VertexData created from the imported parameters to the geometry
  22416. * @param parsedVertexData the parsed data from an imported file
  22417. * @param geometry the geometry to apply the VertexData to
  22418. */
  22419. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22420. }
  22421. }
  22422. declare module BABYLON {
  22423. /**
  22424. * Defines a target to use with MorphTargetManager
  22425. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22426. */
  22427. export class MorphTarget implements IAnimatable {
  22428. /** defines the name of the target */
  22429. name: string;
  22430. /**
  22431. * Gets or sets the list of animations
  22432. */
  22433. animations: Animation[];
  22434. private _scene;
  22435. private _positions;
  22436. private _normals;
  22437. private _tangents;
  22438. private _uvs;
  22439. private _influence;
  22440. private _uniqueId;
  22441. /**
  22442. * Observable raised when the influence changes
  22443. */
  22444. onInfluenceChanged: Observable<boolean>;
  22445. /** @hidden */
  22446. _onDataLayoutChanged: Observable<void>;
  22447. /**
  22448. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22449. */
  22450. get influence(): number;
  22451. set influence(influence: number);
  22452. /**
  22453. * Gets or sets the id of the morph Target
  22454. */
  22455. id: string;
  22456. private _animationPropertiesOverride;
  22457. /**
  22458. * Gets or sets the animation properties override
  22459. */
  22460. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22461. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22462. /**
  22463. * Creates a new MorphTarget
  22464. * @param name defines the name of the target
  22465. * @param influence defines the influence to use
  22466. * @param scene defines the scene the morphtarget belongs to
  22467. */
  22468. constructor(
  22469. /** defines the name of the target */
  22470. name: string, influence?: number, scene?: Nullable<Scene>);
  22471. /**
  22472. * Gets the unique ID of this manager
  22473. */
  22474. get uniqueId(): number;
  22475. /**
  22476. * Gets a boolean defining if the target contains position data
  22477. */
  22478. get hasPositions(): boolean;
  22479. /**
  22480. * Gets a boolean defining if the target contains normal data
  22481. */
  22482. get hasNormals(): boolean;
  22483. /**
  22484. * Gets a boolean defining if the target contains tangent data
  22485. */
  22486. get hasTangents(): boolean;
  22487. /**
  22488. * Gets a boolean defining if the target contains texture coordinates data
  22489. */
  22490. get hasUVs(): boolean;
  22491. /**
  22492. * Affects position data to this target
  22493. * @param data defines the position data to use
  22494. */
  22495. setPositions(data: Nullable<FloatArray>): void;
  22496. /**
  22497. * Gets the position data stored in this target
  22498. * @returns a FloatArray containing the position data (or null if not present)
  22499. */
  22500. getPositions(): Nullable<FloatArray>;
  22501. /**
  22502. * Affects normal data to this target
  22503. * @param data defines the normal data to use
  22504. */
  22505. setNormals(data: Nullable<FloatArray>): void;
  22506. /**
  22507. * Gets the normal data stored in this target
  22508. * @returns a FloatArray containing the normal data (or null if not present)
  22509. */
  22510. getNormals(): Nullable<FloatArray>;
  22511. /**
  22512. * Affects tangent data to this target
  22513. * @param data defines the tangent data to use
  22514. */
  22515. setTangents(data: Nullable<FloatArray>): void;
  22516. /**
  22517. * Gets the tangent data stored in this target
  22518. * @returns a FloatArray containing the tangent data (or null if not present)
  22519. */
  22520. getTangents(): Nullable<FloatArray>;
  22521. /**
  22522. * Affects texture coordinates data to this target
  22523. * @param data defines the texture coordinates data to use
  22524. */
  22525. setUVs(data: Nullable<FloatArray>): void;
  22526. /**
  22527. * Gets the texture coordinates data stored in this target
  22528. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22529. */
  22530. getUVs(): Nullable<FloatArray>;
  22531. /**
  22532. * Clone the current target
  22533. * @returns a new MorphTarget
  22534. */
  22535. clone(): MorphTarget;
  22536. /**
  22537. * Serializes the current target into a Serialization object
  22538. * @returns the serialized object
  22539. */
  22540. serialize(): any;
  22541. /**
  22542. * Returns the string "MorphTarget"
  22543. * @returns "MorphTarget"
  22544. */
  22545. getClassName(): string;
  22546. /**
  22547. * Creates a new target from serialized data
  22548. * @param serializationObject defines the serialized data to use
  22549. * @returns a new MorphTarget
  22550. */
  22551. static Parse(serializationObject: any): MorphTarget;
  22552. /**
  22553. * Creates a MorphTarget from mesh data
  22554. * @param mesh defines the source mesh
  22555. * @param name defines the name to use for the new target
  22556. * @param influence defines the influence to attach to the target
  22557. * @returns a new MorphTarget
  22558. */
  22559. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22560. }
  22561. }
  22562. declare module BABYLON {
  22563. /**
  22564. * This class is used to deform meshes using morphing between different targets
  22565. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22566. */
  22567. export class MorphTargetManager {
  22568. private _targets;
  22569. private _targetInfluenceChangedObservers;
  22570. private _targetDataLayoutChangedObservers;
  22571. private _activeTargets;
  22572. private _scene;
  22573. private _influences;
  22574. private _supportsNormals;
  22575. private _supportsTangents;
  22576. private _supportsUVs;
  22577. private _vertexCount;
  22578. private _uniqueId;
  22579. private _tempInfluences;
  22580. /**
  22581. * Gets or sets a boolean indicating if normals must be morphed
  22582. */
  22583. enableNormalMorphing: boolean;
  22584. /**
  22585. * Gets or sets a boolean indicating if tangents must be morphed
  22586. */
  22587. enableTangentMorphing: boolean;
  22588. /**
  22589. * Gets or sets a boolean indicating if UV must be morphed
  22590. */
  22591. enableUVMorphing: boolean;
  22592. /**
  22593. * Creates a new MorphTargetManager
  22594. * @param scene defines the current scene
  22595. */
  22596. constructor(scene?: Nullable<Scene>);
  22597. /**
  22598. * Gets the unique ID of this manager
  22599. */
  22600. get uniqueId(): number;
  22601. /**
  22602. * Gets the number of vertices handled by this manager
  22603. */
  22604. get vertexCount(): number;
  22605. /**
  22606. * Gets a boolean indicating if this manager supports morphing of normals
  22607. */
  22608. get supportsNormals(): boolean;
  22609. /**
  22610. * Gets a boolean indicating if this manager supports morphing of tangents
  22611. */
  22612. get supportsTangents(): boolean;
  22613. /**
  22614. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22615. */
  22616. get supportsUVs(): boolean;
  22617. /**
  22618. * Gets the number of targets stored in this manager
  22619. */
  22620. get numTargets(): number;
  22621. /**
  22622. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22623. */
  22624. get numInfluencers(): number;
  22625. /**
  22626. * Gets the list of influences (one per target)
  22627. */
  22628. get influences(): Float32Array;
  22629. /**
  22630. * Gets the active target at specified index. An active target is a target with an influence > 0
  22631. * @param index defines the index to check
  22632. * @returns the requested target
  22633. */
  22634. getActiveTarget(index: number): MorphTarget;
  22635. /**
  22636. * Gets the target at specified index
  22637. * @param index defines the index to check
  22638. * @returns the requested target
  22639. */
  22640. getTarget(index: number): MorphTarget;
  22641. /**
  22642. * Add a new target to this manager
  22643. * @param target defines the target to add
  22644. */
  22645. addTarget(target: MorphTarget): void;
  22646. /**
  22647. * Removes a target from the manager
  22648. * @param target defines the target to remove
  22649. */
  22650. removeTarget(target: MorphTarget): void;
  22651. /**
  22652. * Clone the current manager
  22653. * @returns a new MorphTargetManager
  22654. */
  22655. clone(): MorphTargetManager;
  22656. /**
  22657. * Serializes the current manager into a Serialization object
  22658. * @returns the serialized object
  22659. */
  22660. serialize(): any;
  22661. private _syncActiveTargets;
  22662. /**
  22663. * Syncrhonize the targets with all the meshes using this morph target manager
  22664. */
  22665. synchronize(): void;
  22666. /**
  22667. * Creates a new MorphTargetManager from serialized data
  22668. * @param serializationObject defines the serialized data
  22669. * @param scene defines the hosting scene
  22670. * @returns the new MorphTargetManager
  22671. */
  22672. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22673. }
  22674. }
  22675. declare module BABYLON {
  22676. /**
  22677. * Class used to represent a specific level of detail of a mesh
  22678. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22679. */
  22680. export class MeshLODLevel {
  22681. /** Defines the distance where this level should start being displayed */
  22682. distance: number;
  22683. /** Defines the mesh to use to render this level */
  22684. mesh: Nullable<Mesh>;
  22685. /**
  22686. * Creates a new LOD level
  22687. * @param distance defines the distance where this level should star being displayed
  22688. * @param mesh defines the mesh to use to render this level
  22689. */
  22690. constructor(
  22691. /** Defines the distance where this level should start being displayed */
  22692. distance: number,
  22693. /** Defines the mesh to use to render this level */
  22694. mesh: Nullable<Mesh>);
  22695. }
  22696. }
  22697. declare module BABYLON {
  22698. /**
  22699. * Mesh representing the gorund
  22700. */
  22701. export class GroundMesh extends Mesh {
  22702. /** If octree should be generated */
  22703. generateOctree: boolean;
  22704. private _heightQuads;
  22705. /** @hidden */
  22706. _subdivisionsX: number;
  22707. /** @hidden */
  22708. _subdivisionsY: number;
  22709. /** @hidden */
  22710. _width: number;
  22711. /** @hidden */
  22712. _height: number;
  22713. /** @hidden */
  22714. _minX: number;
  22715. /** @hidden */
  22716. _maxX: number;
  22717. /** @hidden */
  22718. _minZ: number;
  22719. /** @hidden */
  22720. _maxZ: number;
  22721. constructor(name: string, scene: Scene);
  22722. /**
  22723. * "GroundMesh"
  22724. * @returns "GroundMesh"
  22725. */
  22726. getClassName(): string;
  22727. /**
  22728. * The minimum of x and y subdivisions
  22729. */
  22730. get subdivisions(): number;
  22731. /**
  22732. * X subdivisions
  22733. */
  22734. get subdivisionsX(): number;
  22735. /**
  22736. * Y subdivisions
  22737. */
  22738. get subdivisionsY(): number;
  22739. /**
  22740. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22741. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22742. * @param chunksCount the number of subdivisions for x and y
  22743. * @param octreeBlocksSize (Default: 32)
  22744. */
  22745. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22746. /**
  22747. * Returns a height (y) value in the Worl system :
  22748. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22749. * @param x x coordinate
  22750. * @param z z coordinate
  22751. * @returns the ground y position if (x, z) are outside the ground surface.
  22752. */
  22753. getHeightAtCoordinates(x: number, z: number): number;
  22754. /**
  22755. * Returns a normalized vector (Vector3) orthogonal to the ground
  22756. * at the ground coordinates (x, z) expressed in the World system.
  22757. * @param x x coordinate
  22758. * @param z z coordinate
  22759. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22760. */
  22761. getNormalAtCoordinates(x: number, z: number): Vector3;
  22762. /**
  22763. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22764. * at the ground coordinates (x, z) expressed in the World system.
  22765. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22766. * @param x x coordinate
  22767. * @param z z coordinate
  22768. * @param ref vector to store the result
  22769. * @returns the GroundMesh.
  22770. */
  22771. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22772. /**
  22773. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22774. * if the ground has been updated.
  22775. * This can be used in the render loop.
  22776. * @returns the GroundMesh.
  22777. */
  22778. updateCoordinateHeights(): GroundMesh;
  22779. private _getFacetAt;
  22780. private _initHeightQuads;
  22781. private _computeHeightQuads;
  22782. /**
  22783. * Serializes this ground mesh
  22784. * @param serializationObject object to write serialization to
  22785. */
  22786. serialize(serializationObject: any): void;
  22787. /**
  22788. * Parses a serialized ground mesh
  22789. * @param parsedMesh the serialized mesh
  22790. * @param scene the scene to create the ground mesh in
  22791. * @returns the created ground mesh
  22792. */
  22793. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22794. }
  22795. }
  22796. declare module BABYLON {
  22797. /**
  22798. * Interface for Physics-Joint data
  22799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22800. */
  22801. export interface PhysicsJointData {
  22802. /**
  22803. * The main pivot of the joint
  22804. */
  22805. mainPivot?: Vector3;
  22806. /**
  22807. * The connected pivot of the joint
  22808. */
  22809. connectedPivot?: Vector3;
  22810. /**
  22811. * The main axis of the joint
  22812. */
  22813. mainAxis?: Vector3;
  22814. /**
  22815. * The connected axis of the joint
  22816. */
  22817. connectedAxis?: Vector3;
  22818. /**
  22819. * The collision of the joint
  22820. */
  22821. collision?: boolean;
  22822. /**
  22823. * Native Oimo/Cannon/Energy data
  22824. */
  22825. nativeParams?: any;
  22826. }
  22827. /**
  22828. * This is a holder class for the physics joint created by the physics plugin
  22829. * It holds a set of functions to control the underlying joint
  22830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22831. */
  22832. export class PhysicsJoint {
  22833. /**
  22834. * The type of the physics joint
  22835. */
  22836. type: number;
  22837. /**
  22838. * The data for the physics joint
  22839. */
  22840. jointData: PhysicsJointData;
  22841. private _physicsJoint;
  22842. protected _physicsPlugin: IPhysicsEnginePlugin;
  22843. /**
  22844. * Initializes the physics joint
  22845. * @param type The type of the physics joint
  22846. * @param jointData The data for the physics joint
  22847. */
  22848. constructor(
  22849. /**
  22850. * The type of the physics joint
  22851. */
  22852. type: number,
  22853. /**
  22854. * The data for the physics joint
  22855. */
  22856. jointData: PhysicsJointData);
  22857. /**
  22858. * Gets the physics joint
  22859. */
  22860. get physicsJoint(): any;
  22861. /**
  22862. * Sets the physics joint
  22863. */
  22864. set physicsJoint(newJoint: any);
  22865. /**
  22866. * Sets the physics plugin
  22867. */
  22868. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22869. /**
  22870. * Execute a function that is physics-plugin specific.
  22871. * @param {Function} func the function that will be executed.
  22872. * It accepts two parameters: the physics world and the physics joint
  22873. */
  22874. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22875. /**
  22876. * Distance-Joint type
  22877. */
  22878. static DistanceJoint: number;
  22879. /**
  22880. * Hinge-Joint type
  22881. */
  22882. static HingeJoint: number;
  22883. /**
  22884. * Ball-and-Socket joint type
  22885. */
  22886. static BallAndSocketJoint: number;
  22887. /**
  22888. * Wheel-Joint type
  22889. */
  22890. static WheelJoint: number;
  22891. /**
  22892. * Slider-Joint type
  22893. */
  22894. static SliderJoint: number;
  22895. /**
  22896. * Prismatic-Joint type
  22897. */
  22898. static PrismaticJoint: number;
  22899. /**
  22900. * Universal-Joint type
  22901. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22902. */
  22903. static UniversalJoint: number;
  22904. /**
  22905. * Hinge-Joint 2 type
  22906. */
  22907. static Hinge2Joint: number;
  22908. /**
  22909. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22910. */
  22911. static PointToPointJoint: number;
  22912. /**
  22913. * Spring-Joint type
  22914. */
  22915. static SpringJoint: number;
  22916. /**
  22917. * Lock-Joint type
  22918. */
  22919. static LockJoint: number;
  22920. }
  22921. /**
  22922. * A class representing a physics distance joint
  22923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22924. */
  22925. export class DistanceJoint extends PhysicsJoint {
  22926. /**
  22927. *
  22928. * @param jointData The data for the Distance-Joint
  22929. */
  22930. constructor(jointData: DistanceJointData);
  22931. /**
  22932. * Update the predefined distance.
  22933. * @param maxDistance The maximum preferred distance
  22934. * @param minDistance The minimum preferred distance
  22935. */
  22936. updateDistance(maxDistance: number, minDistance?: number): void;
  22937. }
  22938. /**
  22939. * Represents a Motor-Enabled Joint
  22940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22941. */
  22942. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22943. /**
  22944. * Initializes the Motor-Enabled Joint
  22945. * @param type The type of the joint
  22946. * @param jointData The physica joint data for the joint
  22947. */
  22948. constructor(type: number, jointData: PhysicsJointData);
  22949. /**
  22950. * Set the motor values.
  22951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22952. * @param force the force to apply
  22953. * @param maxForce max force for this motor.
  22954. */
  22955. setMotor(force?: number, maxForce?: number): void;
  22956. /**
  22957. * Set the motor's limits.
  22958. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22959. * @param upperLimit The upper limit of the motor
  22960. * @param lowerLimit The lower limit of the motor
  22961. */
  22962. setLimit(upperLimit: number, lowerLimit?: number): void;
  22963. }
  22964. /**
  22965. * This class represents a single physics Hinge-Joint
  22966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22967. */
  22968. export class HingeJoint extends MotorEnabledJoint {
  22969. /**
  22970. * Initializes the Hinge-Joint
  22971. * @param jointData The joint data for the Hinge-Joint
  22972. */
  22973. constructor(jointData: PhysicsJointData);
  22974. /**
  22975. * Set the motor values.
  22976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22977. * @param {number} force the force to apply
  22978. * @param {number} maxForce max force for this motor.
  22979. */
  22980. setMotor(force?: number, maxForce?: number): void;
  22981. /**
  22982. * Set the motor's limits.
  22983. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22984. * @param upperLimit The upper limit of the motor
  22985. * @param lowerLimit The lower limit of the motor
  22986. */
  22987. setLimit(upperLimit: number, lowerLimit?: number): void;
  22988. }
  22989. /**
  22990. * This class represents a dual hinge physics joint (same as wheel joint)
  22991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22992. */
  22993. export class Hinge2Joint extends MotorEnabledJoint {
  22994. /**
  22995. * Initializes the Hinge2-Joint
  22996. * @param jointData The joint data for the Hinge2-Joint
  22997. */
  22998. constructor(jointData: PhysicsJointData);
  22999. /**
  23000. * Set the motor values.
  23001. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23002. * @param {number} targetSpeed the speed the motor is to reach
  23003. * @param {number} maxForce max force for this motor.
  23004. * @param {motorIndex} the motor's index, 0 or 1.
  23005. */
  23006. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23007. /**
  23008. * Set the motor limits.
  23009. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23010. * @param {number} upperLimit the upper limit
  23011. * @param {number} lowerLimit lower limit
  23012. * @param {motorIndex} the motor's index, 0 or 1.
  23013. */
  23014. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23015. }
  23016. /**
  23017. * Interface for a motor enabled joint
  23018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23019. */
  23020. export interface IMotorEnabledJoint {
  23021. /**
  23022. * Physics joint
  23023. */
  23024. physicsJoint: any;
  23025. /**
  23026. * Sets the motor of the motor-enabled joint
  23027. * @param force The force of the motor
  23028. * @param maxForce The maximum force of the motor
  23029. * @param motorIndex The index of the motor
  23030. */
  23031. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23032. /**
  23033. * Sets the limit of the motor
  23034. * @param upperLimit The upper limit of the motor
  23035. * @param lowerLimit The lower limit of the motor
  23036. * @param motorIndex The index of the motor
  23037. */
  23038. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23039. }
  23040. /**
  23041. * Joint data for a Distance-Joint
  23042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23043. */
  23044. export interface DistanceJointData extends PhysicsJointData {
  23045. /**
  23046. * Max distance the 2 joint objects can be apart
  23047. */
  23048. maxDistance: number;
  23049. }
  23050. /**
  23051. * Joint data from a spring joint
  23052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23053. */
  23054. export interface SpringJointData extends PhysicsJointData {
  23055. /**
  23056. * Length of the spring
  23057. */
  23058. length: number;
  23059. /**
  23060. * Stiffness of the spring
  23061. */
  23062. stiffness: number;
  23063. /**
  23064. * Damping of the spring
  23065. */
  23066. damping: number;
  23067. /** this callback will be called when applying the force to the impostors. */
  23068. forceApplicationCallback: () => void;
  23069. }
  23070. }
  23071. declare module BABYLON {
  23072. /**
  23073. * Holds the data for the raycast result
  23074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23075. */
  23076. export class PhysicsRaycastResult {
  23077. private _hasHit;
  23078. private _hitDistance;
  23079. private _hitNormalWorld;
  23080. private _hitPointWorld;
  23081. private _rayFromWorld;
  23082. private _rayToWorld;
  23083. /**
  23084. * Gets if there was a hit
  23085. */
  23086. get hasHit(): boolean;
  23087. /**
  23088. * Gets the distance from the hit
  23089. */
  23090. get hitDistance(): number;
  23091. /**
  23092. * Gets the hit normal/direction in the world
  23093. */
  23094. get hitNormalWorld(): Vector3;
  23095. /**
  23096. * Gets the hit point in the world
  23097. */
  23098. get hitPointWorld(): Vector3;
  23099. /**
  23100. * Gets the ray "start point" of the ray in the world
  23101. */
  23102. get rayFromWorld(): Vector3;
  23103. /**
  23104. * Gets the ray "end point" of the ray in the world
  23105. */
  23106. get rayToWorld(): Vector3;
  23107. /**
  23108. * Sets the hit data (normal & point in world space)
  23109. * @param hitNormalWorld defines the normal in world space
  23110. * @param hitPointWorld defines the point in world space
  23111. */
  23112. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23113. /**
  23114. * Sets the distance from the start point to the hit point
  23115. * @param distance
  23116. */
  23117. setHitDistance(distance: number): void;
  23118. /**
  23119. * Calculates the distance manually
  23120. */
  23121. calculateHitDistance(): void;
  23122. /**
  23123. * Resets all the values to default
  23124. * @param from The from point on world space
  23125. * @param to The to point on world space
  23126. */
  23127. reset(from?: Vector3, to?: Vector3): void;
  23128. }
  23129. /**
  23130. * Interface for the size containing width and height
  23131. */
  23132. interface IXYZ {
  23133. /**
  23134. * X
  23135. */
  23136. x: number;
  23137. /**
  23138. * Y
  23139. */
  23140. y: number;
  23141. /**
  23142. * Z
  23143. */
  23144. z: number;
  23145. }
  23146. }
  23147. declare module BABYLON {
  23148. /**
  23149. * Interface used to describe a physics joint
  23150. */
  23151. export interface PhysicsImpostorJoint {
  23152. /** Defines the main impostor to which the joint is linked */
  23153. mainImpostor: PhysicsImpostor;
  23154. /** Defines the impostor that is connected to the main impostor using this joint */
  23155. connectedImpostor: PhysicsImpostor;
  23156. /** Defines the joint itself */
  23157. joint: PhysicsJoint;
  23158. }
  23159. /** @hidden */
  23160. export interface IPhysicsEnginePlugin {
  23161. world: any;
  23162. name: string;
  23163. setGravity(gravity: Vector3): void;
  23164. setTimeStep(timeStep: number): void;
  23165. getTimeStep(): number;
  23166. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23167. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23169. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23170. removePhysicsBody(impostor: PhysicsImpostor): void;
  23171. generateJoint(joint: PhysicsImpostorJoint): void;
  23172. removeJoint(joint: PhysicsImpostorJoint): void;
  23173. isSupported(): boolean;
  23174. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23175. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23176. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23177. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23178. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23179. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23180. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23181. getBodyMass(impostor: PhysicsImpostor): number;
  23182. getBodyFriction(impostor: PhysicsImpostor): number;
  23183. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23184. getBodyRestitution(impostor: PhysicsImpostor): number;
  23185. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23186. getBodyPressure?(impostor: PhysicsImpostor): number;
  23187. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23188. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23189. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23190. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23191. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23192. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23193. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23194. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23195. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23196. sleepBody(impostor: PhysicsImpostor): void;
  23197. wakeUpBody(impostor: PhysicsImpostor): void;
  23198. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23199. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23200. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23201. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23202. getRadius(impostor: PhysicsImpostor): number;
  23203. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23204. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23205. dispose(): void;
  23206. }
  23207. /**
  23208. * Interface used to define a physics engine
  23209. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23210. */
  23211. export interface IPhysicsEngine {
  23212. /**
  23213. * Gets the gravity vector used by the simulation
  23214. */
  23215. gravity: Vector3;
  23216. /**
  23217. * Sets the gravity vector used by the simulation
  23218. * @param gravity defines the gravity vector to use
  23219. */
  23220. setGravity(gravity: Vector3): void;
  23221. /**
  23222. * Set the time step of the physics engine.
  23223. * Default is 1/60.
  23224. * To slow it down, enter 1/600 for example.
  23225. * To speed it up, 1/30
  23226. * @param newTimeStep the new timestep to apply to this world.
  23227. */
  23228. setTimeStep(newTimeStep: number): void;
  23229. /**
  23230. * Get the time step of the physics engine.
  23231. * @returns the current time step
  23232. */
  23233. getTimeStep(): number;
  23234. /**
  23235. * Set the sub time step of the physics engine.
  23236. * Default is 0 meaning there is no sub steps
  23237. * To increase physics resolution precision, set a small value (like 1 ms)
  23238. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23239. */
  23240. setSubTimeStep(subTimeStep: number): void;
  23241. /**
  23242. * Get the sub time step of the physics engine.
  23243. * @returns the current sub time step
  23244. */
  23245. getSubTimeStep(): number;
  23246. /**
  23247. * Release all resources
  23248. */
  23249. dispose(): void;
  23250. /**
  23251. * Gets the name of the current physics plugin
  23252. * @returns the name of the plugin
  23253. */
  23254. getPhysicsPluginName(): string;
  23255. /**
  23256. * Adding a new impostor for the impostor tracking.
  23257. * This will be done by the impostor itself.
  23258. * @param impostor the impostor to add
  23259. */
  23260. addImpostor(impostor: PhysicsImpostor): void;
  23261. /**
  23262. * Remove an impostor from the engine.
  23263. * This impostor and its mesh will not longer be updated by the physics engine.
  23264. * @param impostor the impostor to remove
  23265. */
  23266. removeImpostor(impostor: PhysicsImpostor): void;
  23267. /**
  23268. * Add a joint to the physics engine
  23269. * @param mainImpostor defines the main impostor to which the joint is added.
  23270. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23271. * @param joint defines the joint that will connect both impostors.
  23272. */
  23273. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23274. /**
  23275. * Removes a joint from the simulation
  23276. * @param mainImpostor defines the impostor used with the joint
  23277. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23278. * @param joint defines the joint to remove
  23279. */
  23280. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23281. /**
  23282. * Gets the current plugin used to run the simulation
  23283. * @returns current plugin
  23284. */
  23285. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23286. /**
  23287. * Gets the list of physic impostors
  23288. * @returns an array of PhysicsImpostor
  23289. */
  23290. getImpostors(): Array<PhysicsImpostor>;
  23291. /**
  23292. * Gets the impostor for a physics enabled object
  23293. * @param object defines the object impersonated by the impostor
  23294. * @returns the PhysicsImpostor or null if not found
  23295. */
  23296. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23297. /**
  23298. * Gets the impostor for a physics body object
  23299. * @param body defines physics body used by the impostor
  23300. * @returns the PhysicsImpostor or null if not found
  23301. */
  23302. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23303. /**
  23304. * Does a raycast in the physics world
  23305. * @param from when should the ray start?
  23306. * @param to when should the ray end?
  23307. * @returns PhysicsRaycastResult
  23308. */
  23309. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23310. /**
  23311. * Called by the scene. No need to call it.
  23312. * @param delta defines the timespam between frames
  23313. */
  23314. _step(delta: number): void;
  23315. }
  23316. }
  23317. declare module BABYLON {
  23318. /**
  23319. * The interface for the physics imposter parameters
  23320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23321. */
  23322. export interface PhysicsImpostorParameters {
  23323. /**
  23324. * The mass of the physics imposter
  23325. */
  23326. mass: number;
  23327. /**
  23328. * The friction of the physics imposter
  23329. */
  23330. friction?: number;
  23331. /**
  23332. * The coefficient of restitution of the physics imposter
  23333. */
  23334. restitution?: number;
  23335. /**
  23336. * The native options of the physics imposter
  23337. */
  23338. nativeOptions?: any;
  23339. /**
  23340. * Specifies if the parent should be ignored
  23341. */
  23342. ignoreParent?: boolean;
  23343. /**
  23344. * Specifies if bi-directional transformations should be disabled
  23345. */
  23346. disableBidirectionalTransformation?: boolean;
  23347. /**
  23348. * The pressure inside the physics imposter, soft object only
  23349. */
  23350. pressure?: number;
  23351. /**
  23352. * The stiffness the physics imposter, soft object only
  23353. */
  23354. stiffness?: number;
  23355. /**
  23356. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23357. */
  23358. velocityIterations?: number;
  23359. /**
  23360. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23361. */
  23362. positionIterations?: number;
  23363. /**
  23364. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23365. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23366. * Add to fix multiple points
  23367. */
  23368. fixedPoints?: number;
  23369. /**
  23370. * The collision margin around a soft object
  23371. */
  23372. margin?: number;
  23373. /**
  23374. * The collision margin around a soft object
  23375. */
  23376. damping?: number;
  23377. /**
  23378. * The path for a rope based on an extrusion
  23379. */
  23380. path?: any;
  23381. /**
  23382. * The shape of an extrusion used for a rope based on an extrusion
  23383. */
  23384. shape?: any;
  23385. }
  23386. /**
  23387. * Interface for a physics-enabled object
  23388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23389. */
  23390. export interface IPhysicsEnabledObject {
  23391. /**
  23392. * The position of the physics-enabled object
  23393. */
  23394. position: Vector3;
  23395. /**
  23396. * The rotation of the physics-enabled object
  23397. */
  23398. rotationQuaternion: Nullable<Quaternion>;
  23399. /**
  23400. * The scale of the physics-enabled object
  23401. */
  23402. scaling: Vector3;
  23403. /**
  23404. * The rotation of the physics-enabled object
  23405. */
  23406. rotation?: Vector3;
  23407. /**
  23408. * The parent of the physics-enabled object
  23409. */
  23410. parent?: any;
  23411. /**
  23412. * The bounding info of the physics-enabled object
  23413. * @returns The bounding info of the physics-enabled object
  23414. */
  23415. getBoundingInfo(): BoundingInfo;
  23416. /**
  23417. * Computes the world matrix
  23418. * @param force Specifies if the world matrix should be computed by force
  23419. * @returns A world matrix
  23420. */
  23421. computeWorldMatrix(force: boolean): Matrix;
  23422. /**
  23423. * Gets the world matrix
  23424. * @returns A world matrix
  23425. */
  23426. getWorldMatrix?(): Matrix;
  23427. /**
  23428. * Gets the child meshes
  23429. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23430. * @returns An array of abstract meshes
  23431. */
  23432. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23433. /**
  23434. * Gets the vertex data
  23435. * @param kind The type of vertex data
  23436. * @returns A nullable array of numbers, or a float32 array
  23437. */
  23438. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23439. /**
  23440. * Gets the indices from the mesh
  23441. * @returns A nullable array of index arrays
  23442. */
  23443. getIndices?(): Nullable<IndicesArray>;
  23444. /**
  23445. * Gets the scene from the mesh
  23446. * @returns the indices array or null
  23447. */
  23448. getScene?(): Scene;
  23449. /**
  23450. * Gets the absolute position from the mesh
  23451. * @returns the absolute position
  23452. */
  23453. getAbsolutePosition(): Vector3;
  23454. /**
  23455. * Gets the absolute pivot point from the mesh
  23456. * @returns the absolute pivot point
  23457. */
  23458. getAbsolutePivotPoint(): Vector3;
  23459. /**
  23460. * Rotates the mesh
  23461. * @param axis The axis of rotation
  23462. * @param amount The amount of rotation
  23463. * @param space The space of the rotation
  23464. * @returns The rotation transform node
  23465. */
  23466. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23467. /**
  23468. * Translates the mesh
  23469. * @param axis The axis of translation
  23470. * @param distance The distance of translation
  23471. * @param space The space of the translation
  23472. * @returns The transform node
  23473. */
  23474. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23475. /**
  23476. * Sets the absolute position of the mesh
  23477. * @param absolutePosition The absolute position of the mesh
  23478. * @returns The transform node
  23479. */
  23480. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23481. /**
  23482. * Gets the class name of the mesh
  23483. * @returns The class name
  23484. */
  23485. getClassName(): string;
  23486. }
  23487. /**
  23488. * Represents a physics imposter
  23489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23490. */
  23491. export class PhysicsImpostor {
  23492. /**
  23493. * The physics-enabled object used as the physics imposter
  23494. */
  23495. object: IPhysicsEnabledObject;
  23496. /**
  23497. * The type of the physics imposter
  23498. */
  23499. type: number;
  23500. private _options;
  23501. private _scene?;
  23502. /**
  23503. * The default object size of the imposter
  23504. */
  23505. static DEFAULT_OBJECT_SIZE: Vector3;
  23506. /**
  23507. * The identity quaternion of the imposter
  23508. */
  23509. static IDENTITY_QUATERNION: Quaternion;
  23510. /** @hidden */
  23511. _pluginData: any;
  23512. private _physicsEngine;
  23513. private _physicsBody;
  23514. private _bodyUpdateRequired;
  23515. private _onBeforePhysicsStepCallbacks;
  23516. private _onAfterPhysicsStepCallbacks;
  23517. /** @hidden */
  23518. _onPhysicsCollideCallbacks: Array<{
  23519. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23520. otherImpostors: Array<PhysicsImpostor>;
  23521. }>;
  23522. private _deltaPosition;
  23523. private _deltaRotation;
  23524. private _deltaRotationConjugated;
  23525. /** @hidden */
  23526. _isFromLine: boolean;
  23527. private _parent;
  23528. private _isDisposed;
  23529. private static _tmpVecs;
  23530. private static _tmpQuat;
  23531. /**
  23532. * Specifies if the physics imposter is disposed
  23533. */
  23534. get isDisposed(): boolean;
  23535. /**
  23536. * Gets the mass of the physics imposter
  23537. */
  23538. get mass(): number;
  23539. set mass(value: number);
  23540. /**
  23541. * Gets the coefficient of friction
  23542. */
  23543. get friction(): number;
  23544. /**
  23545. * Sets the coefficient of friction
  23546. */
  23547. set friction(value: number);
  23548. /**
  23549. * Gets the coefficient of restitution
  23550. */
  23551. get restitution(): number;
  23552. /**
  23553. * Sets the coefficient of restitution
  23554. */
  23555. set restitution(value: number);
  23556. /**
  23557. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23558. */
  23559. get pressure(): number;
  23560. /**
  23561. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23562. */
  23563. set pressure(value: number);
  23564. /**
  23565. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23566. */
  23567. get stiffness(): number;
  23568. /**
  23569. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23570. */
  23571. set stiffness(value: number);
  23572. /**
  23573. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23574. */
  23575. get velocityIterations(): number;
  23576. /**
  23577. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23578. */
  23579. set velocityIterations(value: number);
  23580. /**
  23581. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23582. */
  23583. get positionIterations(): number;
  23584. /**
  23585. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23586. */
  23587. set positionIterations(value: number);
  23588. /**
  23589. * The unique id of the physics imposter
  23590. * set by the physics engine when adding this impostor to the array
  23591. */
  23592. uniqueId: number;
  23593. /**
  23594. * @hidden
  23595. */
  23596. soft: boolean;
  23597. /**
  23598. * @hidden
  23599. */
  23600. segments: number;
  23601. private _joints;
  23602. /**
  23603. * Initializes the physics imposter
  23604. * @param object The physics-enabled object used as the physics imposter
  23605. * @param type The type of the physics imposter
  23606. * @param _options The options for the physics imposter
  23607. * @param _scene The Babylon scene
  23608. */
  23609. constructor(
  23610. /**
  23611. * The physics-enabled object used as the physics imposter
  23612. */
  23613. object: IPhysicsEnabledObject,
  23614. /**
  23615. * The type of the physics imposter
  23616. */
  23617. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23618. /**
  23619. * This function will completly initialize this impostor.
  23620. * It will create a new body - but only if this mesh has no parent.
  23621. * If it has, this impostor will not be used other than to define the impostor
  23622. * of the child mesh.
  23623. * @hidden
  23624. */
  23625. _init(): void;
  23626. private _getPhysicsParent;
  23627. /**
  23628. * Should a new body be generated.
  23629. * @returns boolean specifying if body initialization is required
  23630. */
  23631. isBodyInitRequired(): boolean;
  23632. /**
  23633. * Sets the updated scaling
  23634. * @param updated Specifies if the scaling is updated
  23635. */
  23636. setScalingUpdated(): void;
  23637. /**
  23638. * Force a regeneration of this or the parent's impostor's body.
  23639. * Use under cautious - This will remove all joints already implemented.
  23640. */
  23641. forceUpdate(): void;
  23642. /**
  23643. * Gets the body that holds this impostor. Either its own, or its parent.
  23644. */
  23645. get physicsBody(): any;
  23646. /**
  23647. * Get the parent of the physics imposter
  23648. * @returns Physics imposter or null
  23649. */
  23650. get parent(): Nullable<PhysicsImpostor>;
  23651. /**
  23652. * Sets the parent of the physics imposter
  23653. */
  23654. set parent(value: Nullable<PhysicsImpostor>);
  23655. /**
  23656. * Set the physics body. Used mainly by the physics engine/plugin
  23657. */
  23658. set physicsBody(physicsBody: any);
  23659. /**
  23660. * Resets the update flags
  23661. */
  23662. resetUpdateFlags(): void;
  23663. /**
  23664. * Gets the object extend size
  23665. * @returns the object extend size
  23666. */
  23667. getObjectExtendSize(): Vector3;
  23668. /**
  23669. * Gets the object center
  23670. * @returns The object center
  23671. */
  23672. getObjectCenter(): Vector3;
  23673. /**
  23674. * Get a specific parametes from the options parameter
  23675. * @param paramName The object parameter name
  23676. * @returns The object parameter
  23677. */
  23678. getParam(paramName: string): any;
  23679. /**
  23680. * Sets a specific parameter in the options given to the physics plugin
  23681. * @param paramName The parameter name
  23682. * @param value The value of the parameter
  23683. */
  23684. setParam(paramName: string, value: number): void;
  23685. /**
  23686. * Specifically change the body's mass option. Won't recreate the physics body object
  23687. * @param mass The mass of the physics imposter
  23688. */
  23689. setMass(mass: number): void;
  23690. /**
  23691. * Gets the linear velocity
  23692. * @returns linear velocity or null
  23693. */
  23694. getLinearVelocity(): Nullable<Vector3>;
  23695. /**
  23696. * Sets the linear velocity
  23697. * @param velocity linear velocity or null
  23698. */
  23699. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23700. /**
  23701. * Gets the angular velocity
  23702. * @returns angular velocity or null
  23703. */
  23704. getAngularVelocity(): Nullable<Vector3>;
  23705. /**
  23706. * Sets the angular velocity
  23707. * @param velocity The velocity or null
  23708. */
  23709. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23710. /**
  23711. * Execute a function with the physics plugin native code
  23712. * Provide a function the will have two variables - the world object and the physics body object
  23713. * @param func The function to execute with the physics plugin native code
  23714. */
  23715. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23716. /**
  23717. * Register a function that will be executed before the physics world is stepping forward
  23718. * @param func The function to execute before the physics world is stepped forward
  23719. */
  23720. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23721. /**
  23722. * Unregister a function that will be executed before the physics world is stepping forward
  23723. * @param func The function to execute before the physics world is stepped forward
  23724. */
  23725. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23726. /**
  23727. * Register a function that will be executed after the physics step
  23728. * @param func The function to execute after physics step
  23729. */
  23730. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23731. /**
  23732. * Unregisters a function that will be executed after the physics step
  23733. * @param func The function to execute after physics step
  23734. */
  23735. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23736. /**
  23737. * register a function that will be executed when this impostor collides against a different body
  23738. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23739. * @param func Callback that is executed on collision
  23740. */
  23741. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23742. /**
  23743. * Unregisters the physics imposter on contact
  23744. * @param collideAgainst The physics object to collide against
  23745. * @param func Callback to execute on collision
  23746. */
  23747. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23748. private _tmpQuat;
  23749. private _tmpQuat2;
  23750. /**
  23751. * Get the parent rotation
  23752. * @returns The parent rotation
  23753. */
  23754. getParentsRotation(): Quaternion;
  23755. /**
  23756. * this function is executed by the physics engine.
  23757. */
  23758. beforeStep: () => void;
  23759. /**
  23760. * this function is executed by the physics engine
  23761. */
  23762. afterStep: () => void;
  23763. /**
  23764. * Legacy collision detection event support
  23765. */
  23766. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23767. /**
  23768. * event and body object due to cannon's event-based architecture.
  23769. */
  23770. onCollide: (e: {
  23771. body: any;
  23772. }) => void;
  23773. /**
  23774. * Apply a force
  23775. * @param force The force to apply
  23776. * @param contactPoint The contact point for the force
  23777. * @returns The physics imposter
  23778. */
  23779. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23780. /**
  23781. * Apply an impulse
  23782. * @param force The impulse force
  23783. * @param contactPoint The contact point for the impulse force
  23784. * @returns The physics imposter
  23785. */
  23786. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23787. /**
  23788. * A help function to create a joint
  23789. * @param otherImpostor A physics imposter used to create a joint
  23790. * @param jointType The type of joint
  23791. * @param jointData The data for the joint
  23792. * @returns The physics imposter
  23793. */
  23794. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23795. /**
  23796. * Add a joint to this impostor with a different impostor
  23797. * @param otherImpostor A physics imposter used to add a joint
  23798. * @param joint The joint to add
  23799. * @returns The physics imposter
  23800. */
  23801. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23802. /**
  23803. * Add an anchor to a cloth impostor
  23804. * @param otherImpostor rigid impostor to anchor to
  23805. * @param width ratio across width from 0 to 1
  23806. * @param height ratio up height from 0 to 1
  23807. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23808. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23809. * @returns impostor the soft imposter
  23810. */
  23811. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23812. /**
  23813. * Add a hook to a rope impostor
  23814. * @param otherImpostor rigid impostor to anchor to
  23815. * @param length ratio across rope from 0 to 1
  23816. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23817. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23818. * @returns impostor the rope imposter
  23819. */
  23820. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23821. /**
  23822. * Will keep this body still, in a sleep mode.
  23823. * @returns the physics imposter
  23824. */
  23825. sleep(): PhysicsImpostor;
  23826. /**
  23827. * Wake the body up.
  23828. * @returns The physics imposter
  23829. */
  23830. wakeUp(): PhysicsImpostor;
  23831. /**
  23832. * Clones the physics imposter
  23833. * @param newObject The physics imposter clones to this physics-enabled object
  23834. * @returns A nullable physics imposter
  23835. */
  23836. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23837. /**
  23838. * Disposes the physics imposter
  23839. */
  23840. dispose(): void;
  23841. /**
  23842. * Sets the delta position
  23843. * @param position The delta position amount
  23844. */
  23845. setDeltaPosition(position: Vector3): void;
  23846. /**
  23847. * Sets the delta rotation
  23848. * @param rotation The delta rotation amount
  23849. */
  23850. setDeltaRotation(rotation: Quaternion): void;
  23851. /**
  23852. * Gets the box size of the physics imposter and stores the result in the input parameter
  23853. * @param result Stores the box size
  23854. * @returns The physics imposter
  23855. */
  23856. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23857. /**
  23858. * Gets the radius of the physics imposter
  23859. * @returns Radius of the physics imposter
  23860. */
  23861. getRadius(): number;
  23862. /**
  23863. * Sync a bone with this impostor
  23864. * @param bone The bone to sync to the impostor.
  23865. * @param boneMesh The mesh that the bone is influencing.
  23866. * @param jointPivot The pivot of the joint / bone in local space.
  23867. * @param distToJoint Optional distance from the impostor to the joint.
  23868. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23869. */
  23870. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23871. /**
  23872. * Sync impostor to a bone
  23873. * @param bone The bone that the impostor will be synced to.
  23874. * @param boneMesh The mesh that the bone is influencing.
  23875. * @param jointPivot The pivot of the joint / bone in local space.
  23876. * @param distToJoint Optional distance from the impostor to the joint.
  23877. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23878. * @param boneAxis Optional vector3 axis the bone is aligned with
  23879. */
  23880. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23881. /**
  23882. * No-Imposter type
  23883. */
  23884. static NoImpostor: number;
  23885. /**
  23886. * Sphere-Imposter type
  23887. */
  23888. static SphereImpostor: number;
  23889. /**
  23890. * Box-Imposter type
  23891. */
  23892. static BoxImpostor: number;
  23893. /**
  23894. * Plane-Imposter type
  23895. */
  23896. static PlaneImpostor: number;
  23897. /**
  23898. * Mesh-imposter type
  23899. */
  23900. static MeshImpostor: number;
  23901. /**
  23902. * Capsule-Impostor type (Ammo.js plugin only)
  23903. */
  23904. static CapsuleImpostor: number;
  23905. /**
  23906. * Cylinder-Imposter type
  23907. */
  23908. static CylinderImpostor: number;
  23909. /**
  23910. * Particle-Imposter type
  23911. */
  23912. static ParticleImpostor: number;
  23913. /**
  23914. * Heightmap-Imposter type
  23915. */
  23916. static HeightmapImpostor: number;
  23917. /**
  23918. * ConvexHull-Impostor type (Ammo.js plugin only)
  23919. */
  23920. static ConvexHullImpostor: number;
  23921. /**
  23922. * Custom-Imposter type (Ammo.js plugin only)
  23923. */
  23924. static CustomImpostor: number;
  23925. /**
  23926. * Rope-Imposter type
  23927. */
  23928. static RopeImpostor: number;
  23929. /**
  23930. * Cloth-Imposter type
  23931. */
  23932. static ClothImpostor: number;
  23933. /**
  23934. * Softbody-Imposter type
  23935. */
  23936. static SoftbodyImpostor: number;
  23937. }
  23938. }
  23939. declare module BABYLON {
  23940. /**
  23941. * @hidden
  23942. **/
  23943. export class _CreationDataStorage {
  23944. closePath?: boolean;
  23945. closeArray?: boolean;
  23946. idx: number[];
  23947. dashSize: number;
  23948. gapSize: number;
  23949. path3D: Path3D;
  23950. pathArray: Vector3[][];
  23951. arc: number;
  23952. radius: number;
  23953. cap: number;
  23954. tessellation: number;
  23955. }
  23956. /**
  23957. * @hidden
  23958. **/
  23959. class _InstanceDataStorage {
  23960. visibleInstances: any;
  23961. batchCache: _InstancesBatch;
  23962. instancesBufferSize: number;
  23963. instancesBuffer: Nullable<Buffer>;
  23964. instancesData: Float32Array;
  23965. overridenInstanceCount: number;
  23966. isFrozen: boolean;
  23967. previousBatch: Nullable<_InstancesBatch>;
  23968. hardwareInstancedRendering: boolean;
  23969. sideOrientation: number;
  23970. manualUpdate: boolean;
  23971. }
  23972. /**
  23973. * @hidden
  23974. **/
  23975. export class _InstancesBatch {
  23976. mustReturn: boolean;
  23977. visibleInstances: Nullable<InstancedMesh[]>[];
  23978. renderSelf: boolean[];
  23979. hardwareInstancedRendering: boolean[];
  23980. }
  23981. /**
  23982. * Class used to represent renderable models
  23983. */
  23984. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23985. /**
  23986. * Mesh side orientation : usually the external or front surface
  23987. */
  23988. static readonly FRONTSIDE: number;
  23989. /**
  23990. * Mesh side orientation : usually the internal or back surface
  23991. */
  23992. static readonly BACKSIDE: number;
  23993. /**
  23994. * Mesh side orientation : both internal and external or front and back surfaces
  23995. */
  23996. static readonly DOUBLESIDE: number;
  23997. /**
  23998. * Mesh side orientation : by default, `FRONTSIDE`
  23999. */
  24000. static readonly DEFAULTSIDE: number;
  24001. /**
  24002. * Mesh cap setting : no cap
  24003. */
  24004. static readonly NO_CAP: number;
  24005. /**
  24006. * Mesh cap setting : one cap at the beginning of the mesh
  24007. */
  24008. static readonly CAP_START: number;
  24009. /**
  24010. * Mesh cap setting : one cap at the end of the mesh
  24011. */
  24012. static readonly CAP_END: number;
  24013. /**
  24014. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24015. */
  24016. static readonly CAP_ALL: number;
  24017. /**
  24018. * Mesh pattern setting : no flip or rotate
  24019. */
  24020. static readonly NO_FLIP: number;
  24021. /**
  24022. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24023. */
  24024. static readonly FLIP_TILE: number;
  24025. /**
  24026. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24027. */
  24028. static readonly ROTATE_TILE: number;
  24029. /**
  24030. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24031. */
  24032. static readonly FLIP_ROW: number;
  24033. /**
  24034. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24035. */
  24036. static readonly ROTATE_ROW: number;
  24037. /**
  24038. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24039. */
  24040. static readonly FLIP_N_ROTATE_TILE: number;
  24041. /**
  24042. * Mesh pattern setting : rotate pattern and rotate
  24043. */
  24044. static readonly FLIP_N_ROTATE_ROW: number;
  24045. /**
  24046. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24047. */
  24048. static readonly CENTER: number;
  24049. /**
  24050. * Mesh tile positioning : part tiles on left
  24051. */
  24052. static readonly LEFT: number;
  24053. /**
  24054. * Mesh tile positioning : part tiles on right
  24055. */
  24056. static readonly RIGHT: number;
  24057. /**
  24058. * Mesh tile positioning : part tiles on top
  24059. */
  24060. static readonly TOP: number;
  24061. /**
  24062. * Mesh tile positioning : part tiles on bottom
  24063. */
  24064. static readonly BOTTOM: number;
  24065. /**
  24066. * Gets the default side orientation.
  24067. * @param orientation the orientation to value to attempt to get
  24068. * @returns the default orientation
  24069. * @hidden
  24070. */
  24071. static _GetDefaultSideOrientation(orientation?: number): number;
  24072. private _internalMeshDataInfo;
  24073. /**
  24074. * An event triggered before rendering the mesh
  24075. */
  24076. get onBeforeRenderObservable(): Observable<Mesh>;
  24077. /**
  24078. * An event triggered before binding the mesh
  24079. */
  24080. get onBeforeBindObservable(): Observable<Mesh>;
  24081. /**
  24082. * An event triggered after rendering the mesh
  24083. */
  24084. get onAfterRenderObservable(): Observable<Mesh>;
  24085. /**
  24086. * An event triggered before drawing the mesh
  24087. */
  24088. get onBeforeDrawObservable(): Observable<Mesh>;
  24089. private _onBeforeDrawObserver;
  24090. /**
  24091. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24092. */
  24093. set onBeforeDraw(callback: () => void);
  24094. get hasInstances(): boolean;
  24095. /**
  24096. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24097. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24098. */
  24099. delayLoadState: number;
  24100. /**
  24101. * Gets the list of instances created from this mesh
  24102. * it is not supposed to be modified manually.
  24103. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24104. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24105. */
  24106. instances: InstancedMesh[];
  24107. /**
  24108. * Gets the file containing delay loading data for this mesh
  24109. */
  24110. delayLoadingFile: string;
  24111. /** @hidden */
  24112. _binaryInfo: any;
  24113. /**
  24114. * User defined function used to change how LOD level selection is done
  24115. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24116. */
  24117. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24118. /**
  24119. * Gets or sets the morph target manager
  24120. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24121. */
  24122. get morphTargetManager(): Nullable<MorphTargetManager>;
  24123. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24124. /** @hidden */
  24125. _creationDataStorage: Nullable<_CreationDataStorage>;
  24126. /** @hidden */
  24127. _geometry: Nullable<Geometry>;
  24128. /** @hidden */
  24129. _delayInfo: Array<string>;
  24130. /** @hidden */
  24131. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24132. /** @hidden */
  24133. _instanceDataStorage: _InstanceDataStorage;
  24134. private _effectiveMaterial;
  24135. /** @hidden */
  24136. _shouldGenerateFlatShading: boolean;
  24137. /** @hidden */
  24138. _originalBuilderSideOrientation: number;
  24139. /**
  24140. * Use this property to change the original side orientation defined at construction time
  24141. */
  24142. overrideMaterialSideOrientation: Nullable<number>;
  24143. /**
  24144. * Gets the source mesh (the one used to clone this one from)
  24145. */
  24146. get source(): Nullable<Mesh>;
  24147. /**
  24148. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24149. */
  24150. get isUnIndexed(): boolean;
  24151. set isUnIndexed(value: boolean);
  24152. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24153. get worldMatrixInstancedBuffer(): Float32Array;
  24154. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24155. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24156. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24157. /**
  24158. * @constructor
  24159. * @param name The value used by scene.getMeshByName() to do a lookup.
  24160. * @param scene The scene to add this mesh to.
  24161. * @param parent The parent of this mesh, if it has one
  24162. * @param source An optional Mesh from which geometry is shared, cloned.
  24163. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24164. * When false, achieved by calling a clone(), also passing False.
  24165. * This will make creation of children, recursive.
  24166. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24167. */
  24168. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24169. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24170. doNotInstantiate: boolean;
  24171. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24172. /**
  24173. * Gets the class name
  24174. * @returns the string "Mesh".
  24175. */
  24176. getClassName(): string;
  24177. /** @hidden */
  24178. get _isMesh(): boolean;
  24179. /**
  24180. * Returns a description of this mesh
  24181. * @param fullDetails define if full details about this mesh must be used
  24182. * @returns a descriptive string representing this mesh
  24183. */
  24184. toString(fullDetails?: boolean): string;
  24185. /** @hidden */
  24186. _unBindEffect(): void;
  24187. /**
  24188. * Gets a boolean indicating if this mesh has LOD
  24189. */
  24190. get hasLODLevels(): boolean;
  24191. /**
  24192. * Gets the list of MeshLODLevel associated with the current mesh
  24193. * @returns an array of MeshLODLevel
  24194. */
  24195. getLODLevels(): MeshLODLevel[];
  24196. private _sortLODLevels;
  24197. /**
  24198. * Add a mesh as LOD level triggered at the given distance.
  24199. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24200. * @param distance The distance from the center of the object to show this level
  24201. * @param mesh The mesh to be added as LOD level (can be null)
  24202. * @return This mesh (for chaining)
  24203. */
  24204. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24205. /**
  24206. * Returns the LOD level mesh at the passed distance or null if not found.
  24207. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24208. * @param distance The distance from the center of the object to show this level
  24209. * @returns a Mesh or `null`
  24210. */
  24211. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24212. /**
  24213. * Remove a mesh from the LOD array
  24214. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24215. * @param mesh defines the mesh to be removed
  24216. * @return This mesh (for chaining)
  24217. */
  24218. removeLODLevel(mesh: Mesh): Mesh;
  24219. /**
  24220. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24221. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24222. * @param camera defines the camera to use to compute distance
  24223. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24224. * @return This mesh (for chaining)
  24225. */
  24226. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24227. /**
  24228. * Gets the mesh internal Geometry object
  24229. */
  24230. get geometry(): Nullable<Geometry>;
  24231. /**
  24232. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24233. * @returns the total number of vertices
  24234. */
  24235. getTotalVertices(): number;
  24236. /**
  24237. * Returns the content of an associated vertex buffer
  24238. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24239. * - VertexBuffer.PositionKind
  24240. * - VertexBuffer.UVKind
  24241. * - VertexBuffer.UV2Kind
  24242. * - VertexBuffer.UV3Kind
  24243. * - VertexBuffer.UV4Kind
  24244. * - VertexBuffer.UV5Kind
  24245. * - VertexBuffer.UV6Kind
  24246. * - VertexBuffer.ColorKind
  24247. * - VertexBuffer.MatricesIndicesKind
  24248. * - VertexBuffer.MatricesIndicesExtraKind
  24249. * - VertexBuffer.MatricesWeightsKind
  24250. * - VertexBuffer.MatricesWeightsExtraKind
  24251. * @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
  24252. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24253. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24254. */
  24255. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24256. /**
  24257. * Returns the mesh VertexBuffer object from the requested `kind`
  24258. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24259. * - VertexBuffer.PositionKind
  24260. * - VertexBuffer.NormalKind
  24261. * - VertexBuffer.UVKind
  24262. * - VertexBuffer.UV2Kind
  24263. * - VertexBuffer.UV3Kind
  24264. * - VertexBuffer.UV4Kind
  24265. * - VertexBuffer.UV5Kind
  24266. * - VertexBuffer.UV6Kind
  24267. * - VertexBuffer.ColorKind
  24268. * - VertexBuffer.MatricesIndicesKind
  24269. * - VertexBuffer.MatricesIndicesExtraKind
  24270. * - VertexBuffer.MatricesWeightsKind
  24271. * - VertexBuffer.MatricesWeightsExtraKind
  24272. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24273. */
  24274. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24275. /**
  24276. * Tests if a specific vertex buffer is associated with this mesh
  24277. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24278. * - VertexBuffer.PositionKind
  24279. * - VertexBuffer.NormalKind
  24280. * - VertexBuffer.UVKind
  24281. * - VertexBuffer.UV2Kind
  24282. * - VertexBuffer.UV3Kind
  24283. * - VertexBuffer.UV4Kind
  24284. * - VertexBuffer.UV5Kind
  24285. * - VertexBuffer.UV6Kind
  24286. * - VertexBuffer.ColorKind
  24287. * - VertexBuffer.MatricesIndicesKind
  24288. * - VertexBuffer.MatricesIndicesExtraKind
  24289. * - VertexBuffer.MatricesWeightsKind
  24290. * - VertexBuffer.MatricesWeightsExtraKind
  24291. * @returns a boolean
  24292. */
  24293. isVerticesDataPresent(kind: string): boolean;
  24294. /**
  24295. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24296. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24297. * - VertexBuffer.PositionKind
  24298. * - VertexBuffer.UVKind
  24299. * - VertexBuffer.UV2Kind
  24300. * - VertexBuffer.UV3Kind
  24301. * - VertexBuffer.UV4Kind
  24302. * - VertexBuffer.UV5Kind
  24303. * - VertexBuffer.UV6Kind
  24304. * - VertexBuffer.ColorKind
  24305. * - VertexBuffer.MatricesIndicesKind
  24306. * - VertexBuffer.MatricesIndicesExtraKind
  24307. * - VertexBuffer.MatricesWeightsKind
  24308. * - VertexBuffer.MatricesWeightsExtraKind
  24309. * @returns a boolean
  24310. */
  24311. isVertexBufferUpdatable(kind: string): boolean;
  24312. /**
  24313. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24314. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24315. * - VertexBuffer.PositionKind
  24316. * - VertexBuffer.NormalKind
  24317. * - VertexBuffer.UVKind
  24318. * - VertexBuffer.UV2Kind
  24319. * - VertexBuffer.UV3Kind
  24320. * - VertexBuffer.UV4Kind
  24321. * - VertexBuffer.UV5Kind
  24322. * - VertexBuffer.UV6Kind
  24323. * - VertexBuffer.ColorKind
  24324. * - VertexBuffer.MatricesIndicesKind
  24325. * - VertexBuffer.MatricesIndicesExtraKind
  24326. * - VertexBuffer.MatricesWeightsKind
  24327. * - VertexBuffer.MatricesWeightsExtraKind
  24328. * @returns an array of strings
  24329. */
  24330. getVerticesDataKinds(): string[];
  24331. /**
  24332. * Returns a positive integer : the total number of indices in this mesh geometry.
  24333. * @returns the numner of indices or zero if the mesh has no geometry.
  24334. */
  24335. getTotalIndices(): number;
  24336. /**
  24337. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24338. * @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.
  24339. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24340. * @returns the indices array or an empty array if the mesh has no geometry
  24341. */
  24342. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24343. get isBlocked(): boolean;
  24344. /**
  24345. * Determine if the current mesh is ready to be rendered
  24346. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24347. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24348. * @returns true if all associated assets are ready (material, textures, shaders)
  24349. */
  24350. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24351. /**
  24352. * 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.
  24353. */
  24354. get areNormalsFrozen(): boolean;
  24355. /**
  24356. * 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.
  24357. * @returns the current mesh
  24358. */
  24359. freezeNormals(): Mesh;
  24360. /**
  24361. * 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
  24362. * @returns the current mesh
  24363. */
  24364. unfreezeNormals(): Mesh;
  24365. /**
  24366. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24367. */
  24368. set overridenInstanceCount(count: number);
  24369. /** @hidden */
  24370. _preActivate(): Mesh;
  24371. /** @hidden */
  24372. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24373. /** @hidden */
  24374. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24375. /**
  24376. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24377. * This means the mesh underlying bounding box and sphere are recomputed.
  24378. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24379. * @returns the current mesh
  24380. */
  24381. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24382. /** @hidden */
  24383. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24384. /**
  24385. * This function will subdivide the mesh into multiple submeshes
  24386. * @param count defines the expected number of submeshes
  24387. */
  24388. subdivide(count: number): void;
  24389. /**
  24390. * Copy a FloatArray into a specific associated vertex buffer
  24391. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24392. * - VertexBuffer.PositionKind
  24393. * - VertexBuffer.UVKind
  24394. * - VertexBuffer.UV2Kind
  24395. * - VertexBuffer.UV3Kind
  24396. * - VertexBuffer.UV4Kind
  24397. * - VertexBuffer.UV5Kind
  24398. * - VertexBuffer.UV6Kind
  24399. * - VertexBuffer.ColorKind
  24400. * - VertexBuffer.MatricesIndicesKind
  24401. * - VertexBuffer.MatricesIndicesExtraKind
  24402. * - VertexBuffer.MatricesWeightsKind
  24403. * - VertexBuffer.MatricesWeightsExtraKind
  24404. * @param data defines the data source
  24405. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24406. * @param stride defines the data stride size (can be null)
  24407. * @returns the current mesh
  24408. */
  24409. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24410. /**
  24411. * Delete a vertex buffer associated with this mesh
  24412. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24413. * - VertexBuffer.PositionKind
  24414. * - VertexBuffer.UVKind
  24415. * - VertexBuffer.UV2Kind
  24416. * - VertexBuffer.UV3Kind
  24417. * - VertexBuffer.UV4Kind
  24418. * - VertexBuffer.UV5Kind
  24419. * - VertexBuffer.UV6Kind
  24420. * - VertexBuffer.ColorKind
  24421. * - VertexBuffer.MatricesIndicesKind
  24422. * - VertexBuffer.MatricesIndicesExtraKind
  24423. * - VertexBuffer.MatricesWeightsKind
  24424. * - VertexBuffer.MatricesWeightsExtraKind
  24425. */
  24426. removeVerticesData(kind: string): void;
  24427. /**
  24428. * Flags an associated vertex buffer as updatable
  24429. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24430. * - VertexBuffer.PositionKind
  24431. * - VertexBuffer.UVKind
  24432. * - VertexBuffer.UV2Kind
  24433. * - VertexBuffer.UV3Kind
  24434. * - VertexBuffer.UV4Kind
  24435. * - VertexBuffer.UV5Kind
  24436. * - VertexBuffer.UV6Kind
  24437. * - VertexBuffer.ColorKind
  24438. * - VertexBuffer.MatricesIndicesKind
  24439. * - VertexBuffer.MatricesIndicesExtraKind
  24440. * - VertexBuffer.MatricesWeightsKind
  24441. * - VertexBuffer.MatricesWeightsExtraKind
  24442. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24443. */
  24444. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24445. /**
  24446. * Sets the mesh global Vertex Buffer
  24447. * @param buffer defines the buffer to use
  24448. * @returns the current mesh
  24449. */
  24450. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24451. /**
  24452. * Update a specific associated vertex buffer
  24453. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24454. * - VertexBuffer.PositionKind
  24455. * - VertexBuffer.UVKind
  24456. * - VertexBuffer.UV2Kind
  24457. * - VertexBuffer.UV3Kind
  24458. * - VertexBuffer.UV4Kind
  24459. * - VertexBuffer.UV5Kind
  24460. * - VertexBuffer.UV6Kind
  24461. * - VertexBuffer.ColorKind
  24462. * - VertexBuffer.MatricesIndicesKind
  24463. * - VertexBuffer.MatricesIndicesExtraKind
  24464. * - VertexBuffer.MatricesWeightsKind
  24465. * - VertexBuffer.MatricesWeightsExtraKind
  24466. * @param data defines the data source
  24467. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24468. * @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)
  24469. * @returns the current mesh
  24470. */
  24471. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24472. /**
  24473. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24474. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24475. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24476. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24477. * @returns the current mesh
  24478. */
  24479. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24480. /**
  24481. * Creates a un-shared specific occurence of the geometry for the mesh.
  24482. * @returns the current mesh
  24483. */
  24484. makeGeometryUnique(): Mesh;
  24485. /**
  24486. * Set the index buffer of this mesh
  24487. * @param indices defines the source data
  24488. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24489. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24490. * @returns the current mesh
  24491. */
  24492. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24493. /**
  24494. * Update the current index buffer
  24495. * @param indices defines the source data
  24496. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24497. * @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)
  24498. * @returns the current mesh
  24499. */
  24500. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24501. /**
  24502. * Invert the geometry to move from a right handed system to a left handed one.
  24503. * @returns the current mesh
  24504. */
  24505. toLeftHanded(): Mesh;
  24506. /** @hidden */
  24507. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24508. /** @hidden */
  24509. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24510. /**
  24511. * Registers for this mesh a javascript function called just before the rendering process
  24512. * @param func defines the function to call before rendering this mesh
  24513. * @returns the current mesh
  24514. */
  24515. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24516. /**
  24517. * Disposes a previously registered javascript function called before the rendering
  24518. * @param func defines the function to remove
  24519. * @returns the current mesh
  24520. */
  24521. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24522. /**
  24523. * Registers for this mesh a javascript function called just after the rendering is complete
  24524. * @param func defines the function to call after rendering this mesh
  24525. * @returns the current mesh
  24526. */
  24527. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24528. /**
  24529. * Disposes a previously registered javascript function called after the rendering.
  24530. * @param func defines the function to remove
  24531. * @returns the current mesh
  24532. */
  24533. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24534. /** @hidden */
  24535. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24536. /** @hidden */
  24537. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24538. /** @hidden */
  24539. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24540. /** @hidden */
  24541. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24542. /** @hidden */
  24543. _rebuild(): void;
  24544. /** @hidden */
  24545. _freeze(): void;
  24546. /** @hidden */
  24547. _unFreeze(): void;
  24548. /**
  24549. * 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
  24550. * @param subMesh defines the subMesh to render
  24551. * @param enableAlphaMode defines if alpha mode can be changed
  24552. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24553. * @returns the current mesh
  24554. */
  24555. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24556. private _onBeforeDraw;
  24557. /**
  24558. * Renormalize the mesh and patch it up if there are no weights
  24559. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24560. * However in the case of zero weights then we set just a single influence to 1.
  24561. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24562. */
  24563. cleanMatrixWeights(): void;
  24564. private normalizeSkinFourWeights;
  24565. private normalizeSkinWeightsAndExtra;
  24566. /**
  24567. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24568. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24569. * the user know there was an issue with importing the mesh
  24570. * @returns a validation object with skinned, valid and report string
  24571. */
  24572. validateSkinning(): {
  24573. skinned: boolean;
  24574. valid: boolean;
  24575. report: string;
  24576. };
  24577. /** @hidden */
  24578. _checkDelayState(): Mesh;
  24579. private _queueLoad;
  24580. /**
  24581. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24582. * A mesh is in the frustum if its bounding box intersects the frustum
  24583. * @param frustumPlanes defines the frustum to test
  24584. * @returns true if the mesh is in the frustum planes
  24585. */
  24586. isInFrustum(frustumPlanes: Plane[]): boolean;
  24587. /**
  24588. * Sets the mesh material by the material or multiMaterial `id` property
  24589. * @param id is a string identifying the material or the multiMaterial
  24590. * @returns the current mesh
  24591. */
  24592. setMaterialByID(id: string): Mesh;
  24593. /**
  24594. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24595. * @returns an array of IAnimatable
  24596. */
  24597. getAnimatables(): IAnimatable[];
  24598. /**
  24599. * Modifies the mesh geometry according to the passed transformation matrix.
  24600. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24601. * The mesh normals are modified using the same transformation.
  24602. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24603. * @param transform defines the transform matrix to use
  24604. * @see http://doc.babylonjs.com/resources/baking_transformations
  24605. * @returns the current mesh
  24606. */
  24607. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24608. /**
  24609. * Modifies the mesh geometry according to its own current World Matrix.
  24610. * The mesh World Matrix is then reset.
  24611. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24612. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24613. * @see http://doc.babylonjs.com/resources/baking_transformations
  24614. * @returns the current mesh
  24615. */
  24616. bakeCurrentTransformIntoVertices(): Mesh;
  24617. /** @hidden */
  24618. get _positions(): Nullable<Vector3[]>;
  24619. /** @hidden */
  24620. _resetPointsArrayCache(): Mesh;
  24621. /** @hidden */
  24622. _generatePointsArray(): boolean;
  24623. /**
  24624. * Returns a new Mesh object generated from the current mesh properties.
  24625. * This method must not get confused with createInstance()
  24626. * @param name is a string, the name given to the new mesh
  24627. * @param newParent can be any Node object (default `null`)
  24628. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24629. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24630. * @returns a new mesh
  24631. */
  24632. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24633. /**
  24634. * Releases resources associated with this mesh.
  24635. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24636. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24637. */
  24638. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24639. /** @hidden */
  24640. _disposeInstanceSpecificData(): void;
  24641. /**
  24642. * Modifies the mesh geometry according to a displacement map.
  24643. * 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.
  24644. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24645. * @param url is a string, the URL from the image file is to be downloaded.
  24646. * @param minHeight is the lower limit of the displacement.
  24647. * @param maxHeight is the upper limit of the displacement.
  24648. * @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.
  24649. * @param uvOffset is an optional vector2 used to offset UV.
  24650. * @param uvScale is an optional vector2 used to scale UV.
  24651. * @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.
  24652. * @returns the Mesh.
  24653. */
  24654. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24655. /**
  24656. * Modifies the mesh geometry according to a displacementMap buffer.
  24657. * 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.
  24658. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24659. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24660. * @param heightMapWidth is the width of the buffer image.
  24661. * @param heightMapHeight is the height of the buffer image.
  24662. * @param minHeight is the lower limit of the displacement.
  24663. * @param maxHeight is the upper limit of the displacement.
  24664. * @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.
  24665. * @param uvOffset is an optional vector2 used to offset UV.
  24666. * @param uvScale is an optional vector2 used to scale UV.
  24667. * @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.
  24668. * @returns the Mesh.
  24669. */
  24670. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24671. /**
  24672. * Modify the mesh to get a flat shading rendering.
  24673. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24674. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24675. * @returns current mesh
  24676. */
  24677. convertToFlatShadedMesh(): Mesh;
  24678. /**
  24679. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24680. * In other words, more vertices, no more indices and a single bigger VBO.
  24681. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24682. * @returns current mesh
  24683. */
  24684. convertToUnIndexedMesh(): Mesh;
  24685. /**
  24686. * Inverses facet orientations.
  24687. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24688. * @param flipNormals will also inverts the normals
  24689. * @returns current mesh
  24690. */
  24691. flipFaces(flipNormals?: boolean): Mesh;
  24692. /**
  24693. * Increase the number of facets and hence vertices in a mesh
  24694. * Vertex normals are interpolated from existing vertex normals
  24695. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24696. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24697. */
  24698. increaseVertices(numberPerEdge: number): void;
  24699. /**
  24700. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24701. * This will undo any application of covertToFlatShadedMesh
  24702. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24703. */
  24704. forceSharedVertices(): void;
  24705. /** @hidden */
  24706. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24707. /** @hidden */
  24708. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24709. /**
  24710. * Creates a new InstancedMesh object from the mesh model.
  24711. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24712. * @param name defines the name of the new instance
  24713. * @returns a new InstancedMesh
  24714. */
  24715. createInstance(name: string): InstancedMesh;
  24716. /**
  24717. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24718. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24719. * @returns the current mesh
  24720. */
  24721. synchronizeInstances(): Mesh;
  24722. /**
  24723. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24724. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24725. * This should be used together with the simplification to avoid disappearing triangles.
  24726. * @param successCallback an optional success callback to be called after the optimization finished.
  24727. * @returns the current mesh
  24728. */
  24729. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24730. /**
  24731. * Serialize current mesh
  24732. * @param serializationObject defines the object which will receive the serialization data
  24733. */
  24734. serialize(serializationObject: any): void;
  24735. /** @hidden */
  24736. _syncGeometryWithMorphTargetManager(): void;
  24737. /** @hidden */
  24738. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24739. /**
  24740. * Returns a new Mesh object parsed from the source provided.
  24741. * @param parsedMesh is the source
  24742. * @param scene defines the hosting scene
  24743. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24744. * @returns a new Mesh
  24745. */
  24746. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24747. /**
  24748. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24749. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24750. * @param name defines the name of the mesh to create
  24751. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24752. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24753. * @param closePath creates a seam between the first and the last points of each path of the path array
  24754. * @param offset is taken in account only if the `pathArray` is containing a single path
  24755. * @param scene defines the hosting scene
  24756. * @param updatable defines if the mesh must be flagged as updatable
  24757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24758. * @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)
  24759. * @returns a new Mesh
  24760. */
  24761. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24762. /**
  24763. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24764. * @param name defines the name of the mesh to create
  24765. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24766. * @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
  24767. * @param scene defines the hosting scene
  24768. * @param updatable defines if the mesh must be flagged as updatable
  24769. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24770. * @returns a new Mesh
  24771. */
  24772. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24773. /**
  24774. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24775. * @param name defines the name of the mesh to create
  24776. * @param size sets the size (float) of each box side (default 1)
  24777. * @param scene defines the hosting scene
  24778. * @param updatable defines if the mesh must be flagged as updatable
  24779. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24780. * @returns a new Mesh
  24781. */
  24782. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24783. /**
  24784. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24785. * @param name defines the name of the mesh to create
  24786. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24787. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24788. * @param scene defines the hosting scene
  24789. * @param updatable defines if the mesh must be flagged as updatable
  24790. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24791. * @returns a new Mesh
  24792. */
  24793. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24794. /**
  24795. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24796. * @param name defines the name of the mesh to create
  24797. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24798. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24799. * @param scene defines the hosting scene
  24800. * @returns a new Mesh
  24801. */
  24802. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24803. /**
  24804. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24805. * @param name defines the name of the mesh to create
  24806. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24807. * @param diameterTop set the top cap diameter (floats, default 1)
  24808. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24809. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24810. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24811. * @param scene defines the hosting scene
  24812. * @param updatable defines if the mesh must be flagged as updatable
  24813. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24814. * @returns a new Mesh
  24815. */
  24816. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24817. /**
  24818. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24819. * @param name defines the name of the mesh to create
  24820. * @param diameter sets the diameter size (float) of the torus (default 1)
  24821. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24822. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24823. * @param scene defines the hosting scene
  24824. * @param updatable defines if the mesh must be flagged as updatable
  24825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24826. * @returns a new Mesh
  24827. */
  24828. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24829. /**
  24830. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24831. * @param name defines the name of the mesh to create
  24832. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24833. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24834. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24835. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24836. * @param p the number of windings on X axis (positive integers, default 2)
  24837. * @param q the number of windings on Y axis (positive integers, default 3)
  24838. * @param scene defines the hosting scene
  24839. * @param updatable defines if the mesh must be flagged as updatable
  24840. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24841. * @returns a new Mesh
  24842. */
  24843. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24844. /**
  24845. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24846. * @param name defines the name of the mesh to create
  24847. * @param points is an array successive Vector3
  24848. * @param scene defines the hosting scene
  24849. * @param updatable defines if the mesh must be flagged as updatable
  24850. * @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).
  24851. * @returns a new Mesh
  24852. */
  24853. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24854. /**
  24855. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24856. * @param name defines the name of the mesh to create
  24857. * @param points is an array successive Vector3
  24858. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24859. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24860. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24861. * @param scene defines the hosting scene
  24862. * @param updatable defines if the mesh must be flagged as updatable
  24863. * @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)
  24864. * @returns a new Mesh
  24865. */
  24866. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24867. /**
  24868. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24869. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24870. * 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.
  24871. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24872. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24873. * Remember you can only change the shape positions, not their number when updating a polygon.
  24874. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24875. * @param name defines the name of the mesh to create
  24876. * @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
  24877. * @param scene defines the hosting scene
  24878. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24879. * @param updatable defines if the mesh must be flagged as updatable
  24880. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24881. * @param earcutInjection can be used to inject your own earcut reference
  24882. * @returns a new Mesh
  24883. */
  24884. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24885. /**
  24886. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24887. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24888. * @param name defines the name of the mesh to create
  24889. * @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
  24890. * @param depth defines the height of extrusion
  24891. * @param scene defines the hosting scene
  24892. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24893. * @param updatable defines if the mesh must be flagged as updatable
  24894. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24895. * @param earcutInjection can be used to inject your own earcut reference
  24896. * @returns a new Mesh
  24897. */
  24898. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24899. /**
  24900. * Creates an extruded shape mesh.
  24901. * 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
  24902. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24903. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24904. * @param name defines the name of the mesh to create
  24905. * @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
  24906. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24907. * @param scale is the value to scale the shape
  24908. * @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
  24909. * @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
  24910. * @param scene defines the hosting scene
  24911. * @param updatable defines if the mesh must be flagged as updatable
  24912. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24913. * @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)
  24914. * @returns a new Mesh
  24915. */
  24916. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24917. /**
  24918. * Creates an custom extruded shape mesh.
  24919. * The custom extrusion is a parametric shape.
  24920. * It has no predefined shape. Its final shape will depend on the input parameters.
  24921. * Please consider using the same method from the MeshBuilder class instead
  24922. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24923. * @param name defines the name of the mesh to create
  24924. * @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
  24925. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24926. * @param scaleFunction is a custom Javascript function called on each path point
  24927. * @param rotationFunction is a custom Javascript function called on each path point
  24928. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24929. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24930. * @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
  24931. * @param scene defines the hosting scene
  24932. * @param updatable defines if the mesh must be flagged as updatable
  24933. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24934. * @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)
  24935. * @returns a new Mesh
  24936. */
  24937. 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;
  24938. /**
  24939. * Creates lathe mesh.
  24940. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24941. * Please consider using the same method from the MeshBuilder class instead
  24942. * @param name defines the name of the mesh to create
  24943. * @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
  24944. * @param radius is the radius value of the lathe
  24945. * @param tessellation is the side number of the lathe.
  24946. * @param scene defines the hosting scene
  24947. * @param updatable defines if the mesh must be flagged as updatable
  24948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24949. * @returns a new Mesh
  24950. */
  24951. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24952. /**
  24953. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24954. * @param name defines the name of the mesh to create
  24955. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24956. * @param scene defines the hosting scene
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24959. * @returns a new Mesh
  24960. */
  24961. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24962. /**
  24963. * Creates a ground mesh.
  24964. * Please consider using the same method from the MeshBuilder class instead
  24965. * @param name defines the name of the mesh to create
  24966. * @param width set the width of the ground
  24967. * @param height set the height of the ground
  24968. * @param subdivisions sets the number of subdivisions per side
  24969. * @param scene defines the hosting scene
  24970. * @param updatable defines if the mesh must be flagged as updatable
  24971. * @returns a new Mesh
  24972. */
  24973. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24974. /**
  24975. * Creates a tiled ground mesh.
  24976. * Please consider using the same method from the MeshBuilder class instead
  24977. * @param name defines the name of the mesh to create
  24978. * @param xmin set the ground minimum X coordinate
  24979. * @param zmin set the ground minimum Y coordinate
  24980. * @param xmax set the ground maximum X coordinate
  24981. * @param zmax set the ground maximum Z coordinate
  24982. * @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
  24983. * @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
  24984. * @param scene defines the hosting scene
  24985. * @param updatable defines if the mesh must be flagged as updatable
  24986. * @returns a new Mesh
  24987. */
  24988. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24989. w: number;
  24990. h: number;
  24991. }, precision: {
  24992. w: number;
  24993. h: number;
  24994. }, scene: Scene, updatable?: boolean): Mesh;
  24995. /**
  24996. * Creates a ground mesh from a height map.
  24997. * Please consider using the same method from the MeshBuilder class instead
  24998. * @see http://doc.babylonjs.com/babylon101/height_map
  24999. * @param name defines the name of the mesh to create
  25000. * @param url sets the URL of the height map image resource
  25001. * @param width set the ground width size
  25002. * @param height set the ground height size
  25003. * @param subdivisions sets the number of subdivision per side
  25004. * @param minHeight is the minimum altitude on the ground
  25005. * @param maxHeight is the maximum altitude on the ground
  25006. * @param scene defines the hosting scene
  25007. * @param updatable defines if the mesh must be flagged as updatable
  25008. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25009. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25010. * @returns a new Mesh
  25011. */
  25012. 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;
  25013. /**
  25014. * Creates a tube mesh.
  25015. * The tube is a parametric shape.
  25016. * It has no predefined shape. Its final shape will depend on the input parameters.
  25017. * Please consider using the same method from the MeshBuilder class instead
  25018. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25019. * @param name defines the name of the mesh to create
  25020. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25021. * @param radius sets the tube radius size
  25022. * @param tessellation is the number of sides on the tubular surface
  25023. * @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
  25024. * @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
  25025. * @param scene defines the hosting scene
  25026. * @param updatable defines if the mesh must be flagged as updatable
  25027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25028. * @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)
  25029. * @returns a new Mesh
  25030. */
  25031. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25032. (i: number, distance: number): number;
  25033. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25034. /**
  25035. * Creates a polyhedron mesh.
  25036. * Please consider using the same method from the MeshBuilder class instead.
  25037. * * 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
  25038. * * The parameter `size` (positive float, default 1) sets the polygon size
  25039. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25040. * * 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`
  25041. * * 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
  25042. * * 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)`)
  25043. * * 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
  25044. * * 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
  25045. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25046. * * 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
  25047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25048. * @param name defines the name of the mesh to create
  25049. * @param options defines the options used to create the mesh
  25050. * @param scene defines the hosting scene
  25051. * @returns a new Mesh
  25052. */
  25053. static CreatePolyhedron(name: string, options: {
  25054. type?: number;
  25055. size?: number;
  25056. sizeX?: number;
  25057. sizeY?: number;
  25058. sizeZ?: number;
  25059. custom?: any;
  25060. faceUV?: Vector4[];
  25061. faceColors?: Color4[];
  25062. updatable?: boolean;
  25063. sideOrientation?: number;
  25064. }, scene: Scene): Mesh;
  25065. /**
  25066. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25067. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25068. * * 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`)
  25069. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25070. * * 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
  25071. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25072. * * 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
  25073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25074. * @param name defines the name of the mesh
  25075. * @param options defines the options used to create the mesh
  25076. * @param scene defines the hosting scene
  25077. * @returns a new Mesh
  25078. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25079. */
  25080. static CreateIcoSphere(name: string, options: {
  25081. radius?: number;
  25082. flat?: boolean;
  25083. subdivisions?: number;
  25084. sideOrientation?: number;
  25085. updatable?: boolean;
  25086. }, scene: Scene): Mesh;
  25087. /**
  25088. * Creates a decal mesh.
  25089. * Please consider using the same method from the MeshBuilder class instead.
  25090. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25091. * @param name defines the name of the mesh
  25092. * @param sourceMesh defines the mesh receiving the decal
  25093. * @param position sets the position of the decal in world coordinates
  25094. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25095. * @param size sets the decal scaling
  25096. * @param angle sets the angle to rotate the decal
  25097. * @returns a new Mesh
  25098. */
  25099. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25100. /**
  25101. * Prepare internal position array for software CPU skinning
  25102. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25103. */
  25104. setPositionsForCPUSkinning(): Float32Array;
  25105. /**
  25106. * Prepare internal normal array for software CPU skinning
  25107. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25108. */
  25109. setNormalsForCPUSkinning(): Float32Array;
  25110. /**
  25111. * Updates the vertex buffer by applying transformation from the bones
  25112. * @param skeleton defines the skeleton to apply to current mesh
  25113. * @returns the current mesh
  25114. */
  25115. applySkeleton(skeleton: Skeleton): Mesh;
  25116. /**
  25117. * 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
  25118. * @param meshes defines the list of meshes to scan
  25119. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25120. */
  25121. static MinMax(meshes: AbstractMesh[]): {
  25122. min: Vector3;
  25123. max: Vector3;
  25124. };
  25125. /**
  25126. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25127. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25128. * @returns a vector3
  25129. */
  25130. static Center(meshesOrMinMaxVector: {
  25131. min: Vector3;
  25132. max: Vector3;
  25133. } | AbstractMesh[]): Vector3;
  25134. /**
  25135. * Merge the array of meshes into a single mesh for performance reasons.
  25136. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25137. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25138. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25139. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25140. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25141. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25142. * @returns a new mesh
  25143. */
  25144. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25145. /** @hidden */
  25146. addInstance(instance: InstancedMesh): void;
  25147. /** @hidden */
  25148. removeInstance(instance: InstancedMesh): void;
  25149. }
  25150. }
  25151. declare module BABYLON {
  25152. /**
  25153. * This is the base class of all the camera used in the application.
  25154. * @see http://doc.babylonjs.com/features/cameras
  25155. */
  25156. export class Camera extends Node {
  25157. /** @hidden */
  25158. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25159. /**
  25160. * This is the default projection mode used by the cameras.
  25161. * It helps recreating a feeling of perspective and better appreciate depth.
  25162. * This is the best way to simulate real life cameras.
  25163. */
  25164. static readonly PERSPECTIVE_CAMERA: number;
  25165. /**
  25166. * This helps creating camera with an orthographic mode.
  25167. * 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.
  25168. */
  25169. static readonly ORTHOGRAPHIC_CAMERA: number;
  25170. /**
  25171. * This is the default FOV mode for perspective cameras.
  25172. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25173. */
  25174. static readonly FOVMODE_VERTICAL_FIXED: number;
  25175. /**
  25176. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25177. */
  25178. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25179. /**
  25180. * This specifies ther is no need for a camera rig.
  25181. * Basically only one eye is rendered corresponding to the camera.
  25182. */
  25183. static readonly RIG_MODE_NONE: number;
  25184. /**
  25185. * Simulates a camera Rig with one blue eye and one red eye.
  25186. * This can be use with 3d blue and red glasses.
  25187. */
  25188. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25189. /**
  25190. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25191. */
  25192. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25193. /**
  25194. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25195. */
  25196. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25197. /**
  25198. * Defines that both eyes of the camera will be rendered over under each other.
  25199. */
  25200. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25201. /**
  25202. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25203. */
  25204. static readonly RIG_MODE_VR: number;
  25205. /**
  25206. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25207. */
  25208. static readonly RIG_MODE_WEBVR: number;
  25209. /**
  25210. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25211. */
  25212. static readonly RIG_MODE_CUSTOM: number;
  25213. /**
  25214. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25215. */
  25216. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25217. /**
  25218. * Define the input manager associated with the camera.
  25219. */
  25220. inputs: CameraInputsManager<Camera>;
  25221. /** @hidden */
  25222. _position: Vector3;
  25223. /**
  25224. * Define the current local position of the camera in the scene
  25225. */
  25226. get position(): Vector3;
  25227. set position(newPosition: Vector3);
  25228. /**
  25229. * The vector the camera should consider as up.
  25230. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25231. */
  25232. upVector: Vector3;
  25233. /**
  25234. * Define the current limit on the left side for an orthographic camera
  25235. * In scene unit
  25236. */
  25237. orthoLeft: Nullable<number>;
  25238. /**
  25239. * Define the current limit on the right side for an orthographic camera
  25240. * In scene unit
  25241. */
  25242. orthoRight: Nullable<number>;
  25243. /**
  25244. * Define the current limit on the bottom side for an orthographic camera
  25245. * In scene unit
  25246. */
  25247. orthoBottom: Nullable<number>;
  25248. /**
  25249. * Define the current limit on the top side for an orthographic camera
  25250. * In scene unit
  25251. */
  25252. orthoTop: Nullable<number>;
  25253. /**
  25254. * Field Of View is set in Radians. (default is 0.8)
  25255. */
  25256. fov: number;
  25257. /**
  25258. * Define the minimum distance the camera can see from.
  25259. * This is important to note that the depth buffer are not infinite and the closer it starts
  25260. * the more your scene might encounter depth fighting issue.
  25261. */
  25262. minZ: number;
  25263. /**
  25264. * Define the maximum distance the camera can see to.
  25265. * This is important to note that the depth buffer are not infinite and the further it end
  25266. * the more your scene might encounter depth fighting issue.
  25267. */
  25268. maxZ: number;
  25269. /**
  25270. * Define the default inertia of the camera.
  25271. * This helps giving a smooth feeling to the camera movement.
  25272. */
  25273. inertia: number;
  25274. /**
  25275. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25276. */
  25277. mode: number;
  25278. /**
  25279. * Define wether the camera is intermediate.
  25280. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25281. */
  25282. isIntermediate: boolean;
  25283. /**
  25284. * Define the viewport of the camera.
  25285. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25286. */
  25287. viewport: Viewport;
  25288. /**
  25289. * Restricts the camera to viewing objects with the same layerMask.
  25290. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25291. */
  25292. layerMask: number;
  25293. /**
  25294. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25295. */
  25296. fovMode: number;
  25297. /**
  25298. * Rig mode of the camera.
  25299. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25300. * This is normally controlled byt the camera themselves as internal use.
  25301. */
  25302. cameraRigMode: number;
  25303. /**
  25304. * Defines the distance between both "eyes" in case of a RIG
  25305. */
  25306. interaxialDistance: number;
  25307. /**
  25308. * Defines if stereoscopic rendering is done side by side or over under.
  25309. */
  25310. isStereoscopicSideBySide: boolean;
  25311. /**
  25312. * 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
  25313. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25314. * else in the scene. (Eg. security camera)
  25315. *
  25316. * 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)
  25317. */
  25318. customRenderTargets: RenderTargetTexture[];
  25319. /**
  25320. * When set, the camera will render to this render target instead of the default canvas
  25321. *
  25322. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25323. */
  25324. outputRenderTarget: Nullable<RenderTargetTexture>;
  25325. /**
  25326. * Observable triggered when the camera view matrix has changed.
  25327. */
  25328. onViewMatrixChangedObservable: Observable<Camera>;
  25329. /**
  25330. * Observable triggered when the camera Projection matrix has changed.
  25331. */
  25332. onProjectionMatrixChangedObservable: Observable<Camera>;
  25333. /**
  25334. * Observable triggered when the inputs have been processed.
  25335. */
  25336. onAfterCheckInputsObservable: Observable<Camera>;
  25337. /**
  25338. * Observable triggered when reset has been called and applied to the camera.
  25339. */
  25340. onRestoreStateObservable: Observable<Camera>;
  25341. /** @hidden */
  25342. _cameraRigParams: any;
  25343. /** @hidden */
  25344. _rigCameras: Camera[];
  25345. /** @hidden */
  25346. _rigPostProcess: Nullable<PostProcess>;
  25347. protected _webvrViewMatrix: Matrix;
  25348. /** @hidden */
  25349. _skipRendering: boolean;
  25350. /** @hidden */
  25351. _projectionMatrix: Matrix;
  25352. /** @hidden */
  25353. _postProcesses: Nullable<PostProcess>[];
  25354. /** @hidden */
  25355. _activeMeshes: SmartArray<AbstractMesh>;
  25356. protected _globalPosition: Vector3;
  25357. /** @hidden */
  25358. _computedViewMatrix: Matrix;
  25359. private _doNotComputeProjectionMatrix;
  25360. private _transformMatrix;
  25361. private _frustumPlanes;
  25362. private _refreshFrustumPlanes;
  25363. private _storedFov;
  25364. private _stateStored;
  25365. /**
  25366. * Instantiates a new camera object.
  25367. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25368. * @see http://doc.babylonjs.com/features/cameras
  25369. * @param name Defines the name of the camera in the scene
  25370. * @param position Defines the position of the camera
  25371. * @param scene Defines the scene the camera belongs too
  25372. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25373. */
  25374. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25375. /**
  25376. * Store current camera state (fov, position, etc..)
  25377. * @returns the camera
  25378. */
  25379. storeState(): Camera;
  25380. /**
  25381. * Restores the camera state values if it has been stored. You must call storeState() first
  25382. */
  25383. protected _restoreStateValues(): boolean;
  25384. /**
  25385. * Restored camera state. You must call storeState() first.
  25386. * @returns true if restored and false otherwise
  25387. */
  25388. restoreState(): boolean;
  25389. /**
  25390. * Gets the class name of the camera.
  25391. * @returns the class name
  25392. */
  25393. getClassName(): string;
  25394. /** @hidden */
  25395. readonly _isCamera: boolean;
  25396. /**
  25397. * Gets a string representation of the camera useful for debug purpose.
  25398. * @param fullDetails Defines that a more verboe level of logging is required
  25399. * @returns the string representation
  25400. */
  25401. toString(fullDetails?: boolean): string;
  25402. /**
  25403. * Gets the current world space position of the camera.
  25404. */
  25405. get globalPosition(): Vector3;
  25406. /**
  25407. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25408. * @returns the active meshe list
  25409. */
  25410. getActiveMeshes(): SmartArray<AbstractMesh>;
  25411. /**
  25412. * Check wether a mesh is part of the current active mesh list of the camera
  25413. * @param mesh Defines the mesh to check
  25414. * @returns true if active, false otherwise
  25415. */
  25416. isActiveMesh(mesh: Mesh): boolean;
  25417. /**
  25418. * Is this camera ready to be used/rendered
  25419. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25420. * @return true if the camera is ready
  25421. */
  25422. isReady(completeCheck?: boolean): boolean;
  25423. /** @hidden */
  25424. _initCache(): void;
  25425. /** @hidden */
  25426. _updateCache(ignoreParentClass?: boolean): void;
  25427. /** @hidden */
  25428. _isSynchronized(): boolean;
  25429. /** @hidden */
  25430. _isSynchronizedViewMatrix(): boolean;
  25431. /** @hidden */
  25432. _isSynchronizedProjectionMatrix(): boolean;
  25433. /**
  25434. * Attach the input controls to a specific dom element to get the input from.
  25435. * @param element Defines the element the controls should be listened from
  25436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25437. */
  25438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25439. /**
  25440. * Detach the current controls from the specified dom element.
  25441. * @param element Defines the element to stop listening the inputs from
  25442. */
  25443. detachControl(element: HTMLElement): void;
  25444. /**
  25445. * Update the camera state according to the different inputs gathered during the frame.
  25446. */
  25447. update(): void;
  25448. /** @hidden */
  25449. _checkInputs(): void;
  25450. /** @hidden */
  25451. get rigCameras(): Camera[];
  25452. /**
  25453. * Gets the post process used by the rig cameras
  25454. */
  25455. get rigPostProcess(): Nullable<PostProcess>;
  25456. /**
  25457. * Internal, gets the first post proces.
  25458. * @returns the first post process to be run on this camera.
  25459. */
  25460. _getFirstPostProcess(): Nullable<PostProcess>;
  25461. private _cascadePostProcessesToRigCams;
  25462. /**
  25463. * Attach a post process to the camera.
  25464. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25465. * @param postProcess The post process to attach to the camera
  25466. * @param insertAt The position of the post process in case several of them are in use in the scene
  25467. * @returns the position the post process has been inserted at
  25468. */
  25469. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25470. /**
  25471. * Detach a post process to the camera.
  25472. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25473. * @param postProcess The post process to detach from the camera
  25474. */
  25475. detachPostProcess(postProcess: PostProcess): void;
  25476. /**
  25477. * Gets the current world matrix of the camera
  25478. */
  25479. getWorldMatrix(): Matrix;
  25480. /** @hidden */
  25481. _getViewMatrix(): Matrix;
  25482. /**
  25483. * Gets the current view matrix of the camera.
  25484. * @param force forces the camera to recompute the matrix without looking at the cached state
  25485. * @returns the view matrix
  25486. */
  25487. getViewMatrix(force?: boolean): Matrix;
  25488. /**
  25489. * Freeze the projection matrix.
  25490. * It will prevent the cache check of the camera projection compute and can speed up perf
  25491. * if no parameter of the camera are meant to change
  25492. * @param projection Defines manually a projection if necessary
  25493. */
  25494. freezeProjectionMatrix(projection?: Matrix): void;
  25495. /**
  25496. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25497. */
  25498. unfreezeProjectionMatrix(): void;
  25499. /**
  25500. * Gets the current projection matrix of the camera.
  25501. * @param force forces the camera to recompute the matrix without looking at the cached state
  25502. * @returns the projection matrix
  25503. */
  25504. getProjectionMatrix(force?: boolean): Matrix;
  25505. /**
  25506. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25507. * @returns a Matrix
  25508. */
  25509. getTransformationMatrix(): Matrix;
  25510. private _updateFrustumPlanes;
  25511. /**
  25512. * Checks if a cullable object (mesh...) is in the camera frustum
  25513. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25514. * @param target The object to check
  25515. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25516. * @returns true if the object is in frustum otherwise false
  25517. */
  25518. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25519. /**
  25520. * Checks if a cullable object (mesh...) is in the camera frustum
  25521. * Unlike isInFrustum this cheks the full bounding box
  25522. * @param target The object to check
  25523. * @returns true if the object is in frustum otherwise false
  25524. */
  25525. isCompletelyInFrustum(target: ICullable): boolean;
  25526. /**
  25527. * Gets a ray in the forward direction from the camera.
  25528. * @param length Defines the length of the ray to create
  25529. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25530. * @param origin Defines the start point of the ray which defaults to the camera position
  25531. * @returns the forward ray
  25532. */
  25533. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25534. /**
  25535. * Releases resources associated with this node.
  25536. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25537. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25538. */
  25539. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25540. /** @hidden */
  25541. _isLeftCamera: boolean;
  25542. /**
  25543. * Gets the left camera of a rig setup in case of Rigged Camera
  25544. */
  25545. get isLeftCamera(): boolean;
  25546. /** @hidden */
  25547. _isRightCamera: boolean;
  25548. /**
  25549. * Gets the right camera of a rig setup in case of Rigged Camera
  25550. */
  25551. get isRightCamera(): boolean;
  25552. /**
  25553. * Gets the left camera of a rig setup in case of Rigged Camera
  25554. */
  25555. get leftCamera(): Nullable<FreeCamera>;
  25556. /**
  25557. * Gets the right camera of a rig setup in case of Rigged Camera
  25558. */
  25559. get rightCamera(): Nullable<FreeCamera>;
  25560. /**
  25561. * Gets the left camera target of a rig setup in case of Rigged Camera
  25562. * @returns the target position
  25563. */
  25564. getLeftTarget(): Nullable<Vector3>;
  25565. /**
  25566. * Gets the right camera target of a rig setup in case of Rigged Camera
  25567. * @returns the target position
  25568. */
  25569. getRightTarget(): Nullable<Vector3>;
  25570. /**
  25571. * @hidden
  25572. */
  25573. setCameraRigMode(mode: number, rigParams: any): void;
  25574. /** @hidden */
  25575. static _setStereoscopicRigMode(camera: Camera): void;
  25576. /** @hidden */
  25577. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25578. /** @hidden */
  25579. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25580. /** @hidden */
  25581. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25582. /** @hidden */
  25583. _getVRProjectionMatrix(): Matrix;
  25584. protected _updateCameraRotationMatrix(): void;
  25585. protected _updateWebVRCameraRotationMatrix(): void;
  25586. /**
  25587. * This function MUST be overwritten by the different WebVR cameras available.
  25588. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25589. * @hidden
  25590. */
  25591. _getWebVRProjectionMatrix(): Matrix;
  25592. /**
  25593. * This function MUST be overwritten by the different WebVR cameras available.
  25594. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25595. * @hidden
  25596. */
  25597. _getWebVRViewMatrix(): Matrix;
  25598. /** @hidden */
  25599. setCameraRigParameter(name: string, value: any): void;
  25600. /**
  25601. * needs to be overridden by children so sub has required properties to be copied
  25602. * @hidden
  25603. */
  25604. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25605. /**
  25606. * May need to be overridden by children
  25607. * @hidden
  25608. */
  25609. _updateRigCameras(): void;
  25610. /** @hidden */
  25611. _setupInputs(): void;
  25612. /**
  25613. * Serialiaze the camera setup to a json represention
  25614. * @returns the JSON representation
  25615. */
  25616. serialize(): any;
  25617. /**
  25618. * Clones the current camera.
  25619. * @param name The cloned camera name
  25620. * @returns the cloned camera
  25621. */
  25622. clone(name: string): Camera;
  25623. /**
  25624. * Gets the direction of the camera relative to a given local axis.
  25625. * @param localAxis Defines the reference axis to provide a relative direction.
  25626. * @return the direction
  25627. */
  25628. getDirection(localAxis: Vector3): Vector3;
  25629. /**
  25630. * Returns the current camera absolute rotation
  25631. */
  25632. get absoluteRotation(): Quaternion;
  25633. /**
  25634. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25635. * @param localAxis Defines the reference axis to provide a relative direction.
  25636. * @param result Defines the vector to store the result in
  25637. */
  25638. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25639. /**
  25640. * Gets a camera constructor for a given camera type
  25641. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25642. * @param name The name of the camera the result will be able to instantiate
  25643. * @param scene The scene the result will construct the camera in
  25644. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25645. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25646. * @returns a factory method to construc the camera
  25647. */
  25648. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25649. /**
  25650. * Compute the world matrix of the camera.
  25651. * @returns the camera world matrix
  25652. */
  25653. computeWorldMatrix(): Matrix;
  25654. /**
  25655. * Parse a JSON and creates the camera from the parsed information
  25656. * @param parsedCamera The JSON to parse
  25657. * @param scene The scene to instantiate the camera in
  25658. * @returns the newly constructed camera
  25659. */
  25660. static Parse(parsedCamera: any, scene: Scene): Camera;
  25661. }
  25662. }
  25663. declare module BABYLON {
  25664. /**
  25665. * Class containing static functions to help procedurally build meshes
  25666. */
  25667. export class DiscBuilder {
  25668. /**
  25669. * Creates a plane polygonal mesh. By default, this is a disc
  25670. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25671. * * 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
  25672. * * 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
  25673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25674. * * 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
  25675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25676. * @param name defines the name of the mesh
  25677. * @param options defines the options used to create the mesh
  25678. * @param scene defines the hosting scene
  25679. * @returns the plane polygonal mesh
  25680. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25681. */
  25682. static CreateDisc(name: string, options: {
  25683. radius?: number;
  25684. tessellation?: number;
  25685. arc?: number;
  25686. updatable?: boolean;
  25687. sideOrientation?: number;
  25688. frontUVs?: Vector4;
  25689. backUVs?: Vector4;
  25690. }, scene?: Nullable<Scene>): Mesh;
  25691. }
  25692. }
  25693. declare module BABYLON {
  25694. /**
  25695. * This represents all the required information to add a fresnel effect on a material:
  25696. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25697. */
  25698. export class FresnelParameters {
  25699. private _isEnabled;
  25700. /**
  25701. * Define if the fresnel effect is enable or not.
  25702. */
  25703. get isEnabled(): boolean;
  25704. set isEnabled(value: boolean);
  25705. /**
  25706. * Define the color used on edges (grazing angle)
  25707. */
  25708. leftColor: Color3;
  25709. /**
  25710. * Define the color used on center
  25711. */
  25712. rightColor: Color3;
  25713. /**
  25714. * Define bias applied to computed fresnel term
  25715. */
  25716. bias: number;
  25717. /**
  25718. * Defined the power exponent applied to fresnel term
  25719. */
  25720. power: number;
  25721. /**
  25722. * Clones the current fresnel and its valuues
  25723. * @returns a clone fresnel configuration
  25724. */
  25725. clone(): FresnelParameters;
  25726. /**
  25727. * Serializes the current fresnel parameters to a JSON representation.
  25728. * @return the JSON serialization
  25729. */
  25730. serialize(): any;
  25731. /**
  25732. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25733. * @param parsedFresnelParameters Define the JSON representation
  25734. * @returns the parsed parameters
  25735. */
  25736. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25737. }
  25738. }
  25739. declare module BABYLON {
  25740. /**
  25741. * Base class of materials working in push mode in babylon JS
  25742. * @hidden
  25743. */
  25744. export class PushMaterial extends Material {
  25745. protected _activeEffect: Effect;
  25746. protected _normalMatrix: Matrix;
  25747. /**
  25748. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25749. * This means that the material can keep using a previous shader while a new one is being compiled.
  25750. * This is mostly used when shader parallel compilation is supported (true by default)
  25751. */
  25752. allowShaderHotSwapping: boolean;
  25753. constructor(name: string, scene: Scene);
  25754. getEffect(): Effect;
  25755. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25756. /**
  25757. * Binds the given world matrix to the active effect
  25758. *
  25759. * @param world the matrix to bind
  25760. */
  25761. bindOnlyWorldMatrix(world: Matrix): void;
  25762. /**
  25763. * Binds the given normal matrix to the active effect
  25764. *
  25765. * @param normalMatrix the matrix to bind
  25766. */
  25767. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25768. bind(world: Matrix, mesh?: Mesh): void;
  25769. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25770. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25771. }
  25772. }
  25773. declare module BABYLON {
  25774. /**
  25775. * This groups all the flags used to control the materials channel.
  25776. */
  25777. export class MaterialFlags {
  25778. private static _DiffuseTextureEnabled;
  25779. /**
  25780. * Are diffuse textures enabled in the application.
  25781. */
  25782. static get DiffuseTextureEnabled(): boolean;
  25783. static set DiffuseTextureEnabled(value: boolean);
  25784. private static _AmbientTextureEnabled;
  25785. /**
  25786. * Are ambient textures enabled in the application.
  25787. */
  25788. static get AmbientTextureEnabled(): boolean;
  25789. static set AmbientTextureEnabled(value: boolean);
  25790. private static _OpacityTextureEnabled;
  25791. /**
  25792. * Are opacity textures enabled in the application.
  25793. */
  25794. static get OpacityTextureEnabled(): boolean;
  25795. static set OpacityTextureEnabled(value: boolean);
  25796. private static _ReflectionTextureEnabled;
  25797. /**
  25798. * Are reflection textures enabled in the application.
  25799. */
  25800. static get ReflectionTextureEnabled(): boolean;
  25801. static set ReflectionTextureEnabled(value: boolean);
  25802. private static _EmissiveTextureEnabled;
  25803. /**
  25804. * Are emissive textures enabled in the application.
  25805. */
  25806. static get EmissiveTextureEnabled(): boolean;
  25807. static set EmissiveTextureEnabled(value: boolean);
  25808. private static _SpecularTextureEnabled;
  25809. /**
  25810. * Are specular textures enabled in the application.
  25811. */
  25812. static get SpecularTextureEnabled(): boolean;
  25813. static set SpecularTextureEnabled(value: boolean);
  25814. private static _BumpTextureEnabled;
  25815. /**
  25816. * Are bump textures enabled in the application.
  25817. */
  25818. static get BumpTextureEnabled(): boolean;
  25819. static set BumpTextureEnabled(value: boolean);
  25820. private static _LightmapTextureEnabled;
  25821. /**
  25822. * Are lightmap textures enabled in the application.
  25823. */
  25824. static get LightmapTextureEnabled(): boolean;
  25825. static set LightmapTextureEnabled(value: boolean);
  25826. private static _RefractionTextureEnabled;
  25827. /**
  25828. * Are refraction textures enabled in the application.
  25829. */
  25830. static get RefractionTextureEnabled(): boolean;
  25831. static set RefractionTextureEnabled(value: boolean);
  25832. private static _ColorGradingTextureEnabled;
  25833. /**
  25834. * Are color grading textures enabled in the application.
  25835. */
  25836. static get ColorGradingTextureEnabled(): boolean;
  25837. static set ColorGradingTextureEnabled(value: boolean);
  25838. private static _FresnelEnabled;
  25839. /**
  25840. * Are fresnels enabled in the application.
  25841. */
  25842. static get FresnelEnabled(): boolean;
  25843. static set FresnelEnabled(value: boolean);
  25844. private static _ClearCoatTextureEnabled;
  25845. /**
  25846. * Are clear coat textures enabled in the application.
  25847. */
  25848. static get ClearCoatTextureEnabled(): boolean;
  25849. static set ClearCoatTextureEnabled(value: boolean);
  25850. private static _ClearCoatBumpTextureEnabled;
  25851. /**
  25852. * Are clear coat bump textures enabled in the application.
  25853. */
  25854. static get ClearCoatBumpTextureEnabled(): boolean;
  25855. static set ClearCoatBumpTextureEnabled(value: boolean);
  25856. private static _ClearCoatTintTextureEnabled;
  25857. /**
  25858. * Are clear coat tint textures enabled in the application.
  25859. */
  25860. static get ClearCoatTintTextureEnabled(): boolean;
  25861. static set ClearCoatTintTextureEnabled(value: boolean);
  25862. private static _SheenTextureEnabled;
  25863. /**
  25864. * Are sheen textures enabled in the application.
  25865. */
  25866. static get SheenTextureEnabled(): boolean;
  25867. static set SheenTextureEnabled(value: boolean);
  25868. private static _AnisotropicTextureEnabled;
  25869. /**
  25870. * Are anisotropic textures enabled in the application.
  25871. */
  25872. static get AnisotropicTextureEnabled(): boolean;
  25873. static set AnisotropicTextureEnabled(value: boolean);
  25874. private static _ThicknessTextureEnabled;
  25875. /**
  25876. * Are thickness textures enabled in the application.
  25877. */
  25878. static get ThicknessTextureEnabled(): boolean;
  25879. static set ThicknessTextureEnabled(value: boolean);
  25880. }
  25881. }
  25882. declare module BABYLON {
  25883. /** @hidden */
  25884. export var defaultFragmentDeclaration: {
  25885. name: string;
  25886. shader: string;
  25887. };
  25888. }
  25889. declare module BABYLON {
  25890. /** @hidden */
  25891. export var defaultUboDeclaration: {
  25892. name: string;
  25893. shader: string;
  25894. };
  25895. }
  25896. declare module BABYLON {
  25897. /** @hidden */
  25898. export var lightFragmentDeclaration: {
  25899. name: string;
  25900. shader: string;
  25901. };
  25902. }
  25903. declare module BABYLON {
  25904. /** @hidden */
  25905. export var lightUboDeclaration: {
  25906. name: string;
  25907. shader: string;
  25908. };
  25909. }
  25910. declare module BABYLON {
  25911. /** @hidden */
  25912. export var lightsFragmentFunctions: {
  25913. name: string;
  25914. shader: string;
  25915. };
  25916. }
  25917. declare module BABYLON {
  25918. /** @hidden */
  25919. export var shadowsFragmentFunctions: {
  25920. name: string;
  25921. shader: string;
  25922. };
  25923. }
  25924. declare module BABYLON {
  25925. /** @hidden */
  25926. export var fresnelFunction: {
  25927. name: string;
  25928. shader: string;
  25929. };
  25930. }
  25931. declare module BABYLON {
  25932. /** @hidden */
  25933. export var reflectionFunction: {
  25934. name: string;
  25935. shader: string;
  25936. };
  25937. }
  25938. declare module BABYLON {
  25939. /** @hidden */
  25940. export var bumpFragmentFunctions: {
  25941. name: string;
  25942. shader: string;
  25943. };
  25944. }
  25945. declare module BABYLON {
  25946. /** @hidden */
  25947. export var logDepthDeclaration: {
  25948. name: string;
  25949. shader: string;
  25950. };
  25951. }
  25952. declare module BABYLON {
  25953. /** @hidden */
  25954. export var bumpFragment: {
  25955. name: string;
  25956. shader: string;
  25957. };
  25958. }
  25959. declare module BABYLON {
  25960. /** @hidden */
  25961. export var depthPrePass: {
  25962. name: string;
  25963. shader: string;
  25964. };
  25965. }
  25966. declare module BABYLON {
  25967. /** @hidden */
  25968. export var lightFragment: {
  25969. name: string;
  25970. shader: string;
  25971. };
  25972. }
  25973. declare module BABYLON {
  25974. /** @hidden */
  25975. export var logDepthFragment: {
  25976. name: string;
  25977. shader: string;
  25978. };
  25979. }
  25980. declare module BABYLON {
  25981. /** @hidden */
  25982. export var defaultPixelShader: {
  25983. name: string;
  25984. shader: string;
  25985. };
  25986. }
  25987. declare module BABYLON {
  25988. /** @hidden */
  25989. export var defaultVertexDeclaration: {
  25990. name: string;
  25991. shader: string;
  25992. };
  25993. }
  25994. declare module BABYLON {
  25995. /** @hidden */
  25996. export var bumpVertexDeclaration: {
  25997. name: string;
  25998. shader: string;
  25999. };
  26000. }
  26001. declare module BABYLON {
  26002. /** @hidden */
  26003. export var bumpVertex: {
  26004. name: string;
  26005. shader: string;
  26006. };
  26007. }
  26008. declare module BABYLON {
  26009. /** @hidden */
  26010. export var fogVertex: {
  26011. name: string;
  26012. shader: string;
  26013. };
  26014. }
  26015. declare module BABYLON {
  26016. /** @hidden */
  26017. export var shadowsVertex: {
  26018. name: string;
  26019. shader: string;
  26020. };
  26021. }
  26022. declare module BABYLON {
  26023. /** @hidden */
  26024. export var pointCloudVertex: {
  26025. name: string;
  26026. shader: string;
  26027. };
  26028. }
  26029. declare module BABYLON {
  26030. /** @hidden */
  26031. export var logDepthVertex: {
  26032. name: string;
  26033. shader: string;
  26034. };
  26035. }
  26036. declare module BABYLON {
  26037. /** @hidden */
  26038. export var defaultVertexShader: {
  26039. name: string;
  26040. shader: string;
  26041. };
  26042. }
  26043. declare module BABYLON {
  26044. /** @hidden */
  26045. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26046. MAINUV1: boolean;
  26047. MAINUV2: boolean;
  26048. DIFFUSE: boolean;
  26049. DIFFUSEDIRECTUV: number;
  26050. AMBIENT: boolean;
  26051. AMBIENTDIRECTUV: number;
  26052. OPACITY: boolean;
  26053. OPACITYDIRECTUV: number;
  26054. OPACITYRGB: boolean;
  26055. REFLECTION: boolean;
  26056. EMISSIVE: boolean;
  26057. EMISSIVEDIRECTUV: number;
  26058. SPECULAR: boolean;
  26059. SPECULARDIRECTUV: number;
  26060. BUMP: boolean;
  26061. BUMPDIRECTUV: number;
  26062. PARALLAX: boolean;
  26063. PARALLAXOCCLUSION: boolean;
  26064. SPECULAROVERALPHA: boolean;
  26065. CLIPPLANE: boolean;
  26066. CLIPPLANE2: boolean;
  26067. CLIPPLANE3: boolean;
  26068. CLIPPLANE4: boolean;
  26069. ALPHATEST: boolean;
  26070. DEPTHPREPASS: boolean;
  26071. ALPHAFROMDIFFUSE: boolean;
  26072. POINTSIZE: boolean;
  26073. FOG: boolean;
  26074. SPECULARTERM: boolean;
  26075. DIFFUSEFRESNEL: boolean;
  26076. OPACITYFRESNEL: boolean;
  26077. REFLECTIONFRESNEL: boolean;
  26078. REFRACTIONFRESNEL: boolean;
  26079. EMISSIVEFRESNEL: boolean;
  26080. FRESNEL: boolean;
  26081. NORMAL: boolean;
  26082. UV1: boolean;
  26083. UV2: boolean;
  26084. VERTEXCOLOR: boolean;
  26085. VERTEXALPHA: boolean;
  26086. NUM_BONE_INFLUENCERS: number;
  26087. BonesPerMesh: number;
  26088. BONETEXTURE: boolean;
  26089. INSTANCES: boolean;
  26090. GLOSSINESS: boolean;
  26091. ROUGHNESS: boolean;
  26092. EMISSIVEASILLUMINATION: boolean;
  26093. LINKEMISSIVEWITHDIFFUSE: boolean;
  26094. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26095. LIGHTMAP: boolean;
  26096. LIGHTMAPDIRECTUV: number;
  26097. OBJECTSPACE_NORMALMAP: boolean;
  26098. USELIGHTMAPASSHADOWMAP: boolean;
  26099. REFLECTIONMAP_3D: boolean;
  26100. REFLECTIONMAP_SPHERICAL: boolean;
  26101. REFLECTIONMAP_PLANAR: boolean;
  26102. REFLECTIONMAP_CUBIC: boolean;
  26103. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26104. REFLECTIONMAP_PROJECTION: boolean;
  26105. REFLECTIONMAP_SKYBOX: boolean;
  26106. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26107. REFLECTIONMAP_EXPLICIT: boolean;
  26108. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26109. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26110. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26111. INVERTCUBICMAP: boolean;
  26112. LOGARITHMICDEPTH: boolean;
  26113. REFRACTION: boolean;
  26114. REFRACTIONMAP_3D: boolean;
  26115. REFLECTIONOVERALPHA: boolean;
  26116. TWOSIDEDLIGHTING: boolean;
  26117. SHADOWFLOAT: boolean;
  26118. MORPHTARGETS: boolean;
  26119. MORPHTARGETS_NORMAL: boolean;
  26120. MORPHTARGETS_TANGENT: boolean;
  26121. MORPHTARGETS_UV: boolean;
  26122. NUM_MORPH_INFLUENCERS: number;
  26123. NONUNIFORMSCALING: boolean;
  26124. PREMULTIPLYALPHA: boolean;
  26125. IMAGEPROCESSING: boolean;
  26126. VIGNETTE: boolean;
  26127. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26128. VIGNETTEBLENDMODEOPAQUE: boolean;
  26129. TONEMAPPING: boolean;
  26130. TONEMAPPING_ACES: boolean;
  26131. CONTRAST: boolean;
  26132. COLORCURVES: boolean;
  26133. COLORGRADING: boolean;
  26134. COLORGRADING3D: boolean;
  26135. SAMPLER3DGREENDEPTH: boolean;
  26136. SAMPLER3DBGRMAP: boolean;
  26137. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26138. MULTIVIEW: boolean;
  26139. /**
  26140. * If the reflection texture on this material is in linear color space
  26141. * @hidden
  26142. */
  26143. IS_REFLECTION_LINEAR: boolean;
  26144. /**
  26145. * If the refraction texture on this material is in linear color space
  26146. * @hidden
  26147. */
  26148. IS_REFRACTION_LINEAR: boolean;
  26149. EXPOSURE: boolean;
  26150. constructor();
  26151. setReflectionMode(modeToEnable: string): void;
  26152. }
  26153. /**
  26154. * This is the default material used in Babylon. It is the best trade off between quality
  26155. * and performances.
  26156. * @see http://doc.babylonjs.com/babylon101/materials
  26157. */
  26158. export class StandardMaterial extends PushMaterial {
  26159. private _diffuseTexture;
  26160. /**
  26161. * The basic texture of the material as viewed under a light.
  26162. */
  26163. diffuseTexture: Nullable<BaseTexture>;
  26164. private _ambientTexture;
  26165. /**
  26166. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26167. */
  26168. ambientTexture: Nullable<BaseTexture>;
  26169. private _opacityTexture;
  26170. /**
  26171. * Define the transparency of the material from a texture.
  26172. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26173. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26174. */
  26175. opacityTexture: Nullable<BaseTexture>;
  26176. private _reflectionTexture;
  26177. /**
  26178. * Define the texture used to display the reflection.
  26179. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26180. */
  26181. reflectionTexture: Nullable<BaseTexture>;
  26182. private _emissiveTexture;
  26183. /**
  26184. * Define texture of the material as if self lit.
  26185. * This will be mixed in the final result even in the absence of light.
  26186. */
  26187. emissiveTexture: Nullable<BaseTexture>;
  26188. private _specularTexture;
  26189. /**
  26190. * Define how the color and intensity of the highlight given by the light in the material.
  26191. */
  26192. specularTexture: Nullable<BaseTexture>;
  26193. private _bumpTexture;
  26194. /**
  26195. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26196. * 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.
  26197. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26198. */
  26199. bumpTexture: Nullable<BaseTexture>;
  26200. private _lightmapTexture;
  26201. /**
  26202. * Complex lighting can be computationally expensive to compute at runtime.
  26203. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26204. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26205. */
  26206. lightmapTexture: Nullable<BaseTexture>;
  26207. private _refractionTexture;
  26208. /**
  26209. * Define the texture used to display the refraction.
  26210. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26211. */
  26212. refractionTexture: Nullable<BaseTexture>;
  26213. /**
  26214. * The color of the material lit by the environmental background lighting.
  26215. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26216. */
  26217. ambientColor: Color3;
  26218. /**
  26219. * The basic color of the material as viewed under a light.
  26220. */
  26221. diffuseColor: Color3;
  26222. /**
  26223. * Define how the color and intensity of the highlight given by the light in the material.
  26224. */
  26225. specularColor: Color3;
  26226. /**
  26227. * Define the color of the material as if self lit.
  26228. * This will be mixed in the final result even in the absence of light.
  26229. */
  26230. emissiveColor: Color3;
  26231. /**
  26232. * Defines how sharp are the highlights in the material.
  26233. * The bigger the value the sharper giving a more glossy feeling to the result.
  26234. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26235. */
  26236. specularPower: number;
  26237. private _useAlphaFromDiffuseTexture;
  26238. /**
  26239. * Does the transparency come from the diffuse texture alpha channel.
  26240. */
  26241. useAlphaFromDiffuseTexture: boolean;
  26242. private _useEmissiveAsIllumination;
  26243. /**
  26244. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26245. */
  26246. useEmissiveAsIllumination: boolean;
  26247. private _linkEmissiveWithDiffuse;
  26248. /**
  26249. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26250. * the emissive level when the final color is close to one.
  26251. */
  26252. linkEmissiveWithDiffuse: boolean;
  26253. private _useSpecularOverAlpha;
  26254. /**
  26255. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26256. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26257. */
  26258. useSpecularOverAlpha: boolean;
  26259. private _useReflectionOverAlpha;
  26260. /**
  26261. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26262. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26263. */
  26264. useReflectionOverAlpha: boolean;
  26265. private _disableLighting;
  26266. /**
  26267. * Does lights from the scene impacts this material.
  26268. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26269. */
  26270. disableLighting: boolean;
  26271. private _useObjectSpaceNormalMap;
  26272. /**
  26273. * Allows using an object space normal map (instead of tangent space).
  26274. */
  26275. useObjectSpaceNormalMap: boolean;
  26276. private _useParallax;
  26277. /**
  26278. * Is parallax enabled or not.
  26279. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26280. */
  26281. useParallax: boolean;
  26282. private _useParallaxOcclusion;
  26283. /**
  26284. * Is parallax occlusion enabled or not.
  26285. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26286. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26287. */
  26288. useParallaxOcclusion: boolean;
  26289. /**
  26290. * 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.
  26291. */
  26292. parallaxScaleBias: number;
  26293. private _roughness;
  26294. /**
  26295. * Helps to define how blurry the reflections should appears in the material.
  26296. */
  26297. roughness: number;
  26298. /**
  26299. * In case of refraction, define the value of the index of refraction.
  26300. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26301. */
  26302. indexOfRefraction: number;
  26303. /**
  26304. * Invert the refraction texture alongside the y axis.
  26305. * It can be useful with procedural textures or probe for instance.
  26306. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26307. */
  26308. invertRefractionY: boolean;
  26309. /**
  26310. * Defines the alpha limits in alpha test mode.
  26311. */
  26312. alphaCutOff: number;
  26313. private _useLightmapAsShadowmap;
  26314. /**
  26315. * In case of light mapping, define whether the map contains light or shadow informations.
  26316. */
  26317. useLightmapAsShadowmap: boolean;
  26318. private _diffuseFresnelParameters;
  26319. /**
  26320. * Define the diffuse fresnel parameters of the material.
  26321. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26322. */
  26323. diffuseFresnelParameters: FresnelParameters;
  26324. private _opacityFresnelParameters;
  26325. /**
  26326. * Define the opacity fresnel parameters of the material.
  26327. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26328. */
  26329. opacityFresnelParameters: FresnelParameters;
  26330. private _reflectionFresnelParameters;
  26331. /**
  26332. * Define the reflection fresnel parameters of the material.
  26333. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26334. */
  26335. reflectionFresnelParameters: FresnelParameters;
  26336. private _refractionFresnelParameters;
  26337. /**
  26338. * Define the refraction fresnel parameters of the material.
  26339. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26340. */
  26341. refractionFresnelParameters: FresnelParameters;
  26342. private _emissiveFresnelParameters;
  26343. /**
  26344. * Define the emissive fresnel parameters of the material.
  26345. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26346. */
  26347. emissiveFresnelParameters: FresnelParameters;
  26348. private _useReflectionFresnelFromSpecular;
  26349. /**
  26350. * If true automatically deducts the fresnels values from the material specularity.
  26351. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26352. */
  26353. useReflectionFresnelFromSpecular: boolean;
  26354. private _useGlossinessFromSpecularMapAlpha;
  26355. /**
  26356. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26357. */
  26358. useGlossinessFromSpecularMapAlpha: boolean;
  26359. private _maxSimultaneousLights;
  26360. /**
  26361. * Defines the maximum number of lights that can be used in the material
  26362. */
  26363. maxSimultaneousLights: number;
  26364. private _invertNormalMapX;
  26365. /**
  26366. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26367. */
  26368. invertNormalMapX: boolean;
  26369. private _invertNormalMapY;
  26370. /**
  26371. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26372. */
  26373. invertNormalMapY: boolean;
  26374. private _twoSidedLighting;
  26375. /**
  26376. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26377. */
  26378. twoSidedLighting: boolean;
  26379. /**
  26380. * Default configuration related to image processing available in the standard Material.
  26381. */
  26382. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26383. /**
  26384. * Gets the image processing configuration used either in this material.
  26385. */
  26386. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26387. /**
  26388. * Sets the Default image processing configuration used either in the this material.
  26389. *
  26390. * If sets to null, the scene one is in use.
  26391. */
  26392. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26393. /**
  26394. * Keep track of the image processing observer to allow dispose and replace.
  26395. */
  26396. private _imageProcessingObserver;
  26397. /**
  26398. * Attaches a new image processing configuration to the Standard Material.
  26399. * @param configuration
  26400. */
  26401. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26402. /**
  26403. * Gets wether the color curves effect is enabled.
  26404. */
  26405. get cameraColorCurvesEnabled(): boolean;
  26406. /**
  26407. * Sets wether the color curves effect is enabled.
  26408. */
  26409. set cameraColorCurvesEnabled(value: boolean);
  26410. /**
  26411. * Gets wether the color grading effect is enabled.
  26412. */
  26413. get cameraColorGradingEnabled(): boolean;
  26414. /**
  26415. * Gets wether the color grading effect is enabled.
  26416. */
  26417. set cameraColorGradingEnabled(value: boolean);
  26418. /**
  26419. * Gets wether tonemapping is enabled or not.
  26420. */
  26421. get cameraToneMappingEnabled(): boolean;
  26422. /**
  26423. * Sets wether tonemapping is enabled or not
  26424. */
  26425. set cameraToneMappingEnabled(value: boolean);
  26426. /**
  26427. * The camera exposure used on this material.
  26428. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26429. * This corresponds to a photographic exposure.
  26430. */
  26431. get cameraExposure(): number;
  26432. /**
  26433. * The camera exposure used on this material.
  26434. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26435. * This corresponds to a photographic exposure.
  26436. */
  26437. set cameraExposure(value: number);
  26438. /**
  26439. * Gets The camera contrast used on this material.
  26440. */
  26441. get cameraContrast(): number;
  26442. /**
  26443. * Sets The camera contrast used on this material.
  26444. */
  26445. set cameraContrast(value: number);
  26446. /**
  26447. * Gets the Color Grading 2D Lookup Texture.
  26448. */
  26449. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26450. /**
  26451. * Sets the Color Grading 2D Lookup Texture.
  26452. */
  26453. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26454. /**
  26455. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26456. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26457. * 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;
  26458. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26459. */
  26460. get cameraColorCurves(): Nullable<ColorCurves>;
  26461. /**
  26462. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26463. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26464. * 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;
  26465. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26466. */
  26467. set cameraColorCurves(value: Nullable<ColorCurves>);
  26468. /**
  26469. * Custom callback helping to override the default shader used in the material.
  26470. */
  26471. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26472. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26473. protected _worldViewProjectionMatrix: Matrix;
  26474. protected _globalAmbientColor: Color3;
  26475. protected _useLogarithmicDepth: boolean;
  26476. protected _rebuildInParallel: boolean;
  26477. /**
  26478. * Instantiates a new standard material.
  26479. * This is the default material used in Babylon. It is the best trade off between quality
  26480. * and performances.
  26481. * @see http://doc.babylonjs.com/babylon101/materials
  26482. * @param name Define the name of the material in the scene
  26483. * @param scene Define the scene the material belong to
  26484. */
  26485. constructor(name: string, scene: Scene);
  26486. /**
  26487. * Gets a boolean indicating that current material needs to register RTT
  26488. */
  26489. get hasRenderTargetTextures(): boolean;
  26490. /**
  26491. * Gets the current class name of the material e.g. "StandardMaterial"
  26492. * Mainly use in serialization.
  26493. * @returns the class name
  26494. */
  26495. getClassName(): string;
  26496. /**
  26497. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26498. * You can try switching to logarithmic depth.
  26499. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26500. */
  26501. get useLogarithmicDepth(): boolean;
  26502. set useLogarithmicDepth(value: boolean);
  26503. /**
  26504. * Specifies if the material will require alpha blending
  26505. * @returns a boolean specifying if alpha blending is needed
  26506. */
  26507. needAlphaBlending(): boolean;
  26508. /**
  26509. * Specifies if this material should be rendered in alpha test mode
  26510. * @returns a boolean specifying if an alpha test is needed.
  26511. */
  26512. needAlphaTesting(): boolean;
  26513. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26514. /**
  26515. * Get the texture used for alpha test purpose.
  26516. * @returns the diffuse texture in case of the standard material.
  26517. */
  26518. getAlphaTestTexture(): Nullable<BaseTexture>;
  26519. /**
  26520. * Get if the submesh is ready to be used and all its information available.
  26521. * Child classes can use it to update shaders
  26522. * @param mesh defines the mesh to check
  26523. * @param subMesh defines which submesh to check
  26524. * @param useInstances specifies that instances should be used
  26525. * @returns a boolean indicating that the submesh is ready or not
  26526. */
  26527. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26528. /**
  26529. * Builds the material UBO layouts.
  26530. * Used internally during the effect preparation.
  26531. */
  26532. buildUniformLayout(): void;
  26533. /**
  26534. * Unbinds the material from the mesh
  26535. */
  26536. unbind(): void;
  26537. /**
  26538. * Binds the submesh to this material by preparing the effect and shader to draw
  26539. * @param world defines the world transformation matrix
  26540. * @param mesh defines the mesh containing the submesh
  26541. * @param subMesh defines the submesh to bind the material to
  26542. */
  26543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26544. /**
  26545. * Get the list of animatables in the material.
  26546. * @returns the list of animatables object used in the material
  26547. */
  26548. getAnimatables(): IAnimatable[];
  26549. /**
  26550. * Gets the active textures from the material
  26551. * @returns an array of textures
  26552. */
  26553. getActiveTextures(): BaseTexture[];
  26554. /**
  26555. * Specifies if the material uses a texture
  26556. * @param texture defines the texture to check against the material
  26557. * @returns a boolean specifying if the material uses the texture
  26558. */
  26559. hasTexture(texture: BaseTexture): boolean;
  26560. /**
  26561. * Disposes the material
  26562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26564. */
  26565. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26566. /**
  26567. * Makes a duplicate of the material, and gives it a new name
  26568. * @param name defines the new name for the duplicated material
  26569. * @returns the cloned material
  26570. */
  26571. clone(name: string): StandardMaterial;
  26572. /**
  26573. * Serializes this material in a JSON representation
  26574. * @returns the serialized material object
  26575. */
  26576. serialize(): any;
  26577. /**
  26578. * Creates a standard material from parsed material data
  26579. * @param source defines the JSON representation of the material
  26580. * @param scene defines the hosting scene
  26581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26582. * @returns a new standard material
  26583. */
  26584. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26585. /**
  26586. * Are diffuse textures enabled in the application.
  26587. */
  26588. static get DiffuseTextureEnabled(): boolean;
  26589. static set DiffuseTextureEnabled(value: boolean);
  26590. /**
  26591. * Are ambient textures enabled in the application.
  26592. */
  26593. static get AmbientTextureEnabled(): boolean;
  26594. static set AmbientTextureEnabled(value: boolean);
  26595. /**
  26596. * Are opacity textures enabled in the application.
  26597. */
  26598. static get OpacityTextureEnabled(): boolean;
  26599. static set OpacityTextureEnabled(value: boolean);
  26600. /**
  26601. * Are reflection textures enabled in the application.
  26602. */
  26603. static get ReflectionTextureEnabled(): boolean;
  26604. static set ReflectionTextureEnabled(value: boolean);
  26605. /**
  26606. * Are emissive textures enabled in the application.
  26607. */
  26608. static get EmissiveTextureEnabled(): boolean;
  26609. static set EmissiveTextureEnabled(value: boolean);
  26610. /**
  26611. * Are specular textures enabled in the application.
  26612. */
  26613. static get SpecularTextureEnabled(): boolean;
  26614. static set SpecularTextureEnabled(value: boolean);
  26615. /**
  26616. * Are bump textures enabled in the application.
  26617. */
  26618. static get BumpTextureEnabled(): boolean;
  26619. static set BumpTextureEnabled(value: boolean);
  26620. /**
  26621. * Are lightmap textures enabled in the application.
  26622. */
  26623. static get LightmapTextureEnabled(): boolean;
  26624. static set LightmapTextureEnabled(value: boolean);
  26625. /**
  26626. * Are refraction textures enabled in the application.
  26627. */
  26628. static get RefractionTextureEnabled(): boolean;
  26629. static set RefractionTextureEnabled(value: boolean);
  26630. /**
  26631. * Are color grading textures enabled in the application.
  26632. */
  26633. static get ColorGradingTextureEnabled(): boolean;
  26634. static set ColorGradingTextureEnabled(value: boolean);
  26635. /**
  26636. * Are fresnels enabled in the application.
  26637. */
  26638. static get FresnelEnabled(): boolean;
  26639. static set FresnelEnabled(value: boolean);
  26640. }
  26641. }
  26642. declare module BABYLON {
  26643. /**
  26644. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26645. *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.
  26646. * The SPS is also a particle system. It provides some methods to manage the particles.
  26647. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26648. *
  26649. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26650. */
  26651. export class SolidParticleSystem implements IDisposable {
  26652. /**
  26653. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26654. * Example : var p = SPS.particles[i];
  26655. */
  26656. particles: SolidParticle[];
  26657. /**
  26658. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26659. */
  26660. nbParticles: number;
  26661. /**
  26662. * If the particles must ever face the camera (default false). Useful for planar particles.
  26663. */
  26664. billboard: boolean;
  26665. /**
  26666. * Recompute normals when adding a shape
  26667. */
  26668. recomputeNormals: boolean;
  26669. /**
  26670. * This a counter ofr your own usage. It's not set by any SPS functions.
  26671. */
  26672. counter: number;
  26673. /**
  26674. * The SPS name. This name is also given to the underlying mesh.
  26675. */
  26676. name: string;
  26677. /**
  26678. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26679. */
  26680. mesh: Mesh;
  26681. /**
  26682. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26683. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26684. */
  26685. vars: any;
  26686. /**
  26687. * This array is populated when the SPS is set as 'pickable'.
  26688. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26689. * Each element of this array is an object `{idx: int, faceId: int}`.
  26690. * `idx` is the picked particle index in the `SPS.particles` array
  26691. * `faceId` is the picked face index counted within this particle.
  26692. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26693. */
  26694. pickedParticles: {
  26695. idx: number;
  26696. faceId: number;
  26697. }[];
  26698. /**
  26699. * This array is populated when `enableDepthSort` is set to true.
  26700. * Each element of this array is an instance of the class DepthSortedParticle.
  26701. */
  26702. depthSortedParticles: DepthSortedParticle[];
  26703. /**
  26704. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26705. * @hidden
  26706. */
  26707. _bSphereOnly: boolean;
  26708. /**
  26709. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26710. * @hidden
  26711. */
  26712. _bSphereRadiusFactor: number;
  26713. private _scene;
  26714. private _positions;
  26715. private _indices;
  26716. private _normals;
  26717. private _colors;
  26718. private _uvs;
  26719. private _indices32;
  26720. private _positions32;
  26721. private _normals32;
  26722. private _fixedNormal32;
  26723. private _colors32;
  26724. private _uvs32;
  26725. private _index;
  26726. private _updatable;
  26727. private _pickable;
  26728. private _isVisibilityBoxLocked;
  26729. private _alwaysVisible;
  26730. private _depthSort;
  26731. private _expandable;
  26732. private _shapeCounter;
  26733. private _copy;
  26734. private _color;
  26735. private _computeParticleColor;
  26736. private _computeParticleTexture;
  26737. private _computeParticleRotation;
  26738. private _computeParticleVertex;
  26739. private _computeBoundingBox;
  26740. private _depthSortParticles;
  26741. private _camera;
  26742. private _mustUnrotateFixedNormals;
  26743. private _particlesIntersect;
  26744. private _needs32Bits;
  26745. private _isNotBuilt;
  26746. private _lastParticleId;
  26747. private _idxOfId;
  26748. private _multimaterialEnabled;
  26749. private _useModelMaterial;
  26750. private _indicesByMaterial;
  26751. private _materialIndexes;
  26752. private _depthSortFunction;
  26753. private _materialSortFunction;
  26754. private _materials;
  26755. private _multimaterial;
  26756. private _materialIndexesById;
  26757. private _defaultMaterial;
  26758. private _autoUpdateSubMeshes;
  26759. /**
  26760. * Creates a SPS (Solid Particle System) object.
  26761. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26762. * @param scene (Scene) is the scene in which the SPS is added.
  26763. * @param options defines the options of the sps e.g.
  26764. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26765. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26766. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26767. * * 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.
  26768. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26769. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26770. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26771. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26772. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26773. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26774. */
  26775. constructor(name: string, scene: Scene, options?: {
  26776. updatable?: boolean;
  26777. isPickable?: boolean;
  26778. enableDepthSort?: boolean;
  26779. particleIntersection?: boolean;
  26780. boundingSphereOnly?: boolean;
  26781. bSphereRadiusFactor?: number;
  26782. expandable?: boolean;
  26783. useModelMaterial?: boolean;
  26784. enableMultiMaterial?: boolean;
  26785. });
  26786. /**
  26787. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26788. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26789. * @returns the created mesh
  26790. */
  26791. buildMesh(): Mesh;
  26792. /**
  26793. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26794. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26795. * Thus the particles generated from `digest()` have their property `position` set yet.
  26796. * @param mesh ( Mesh ) is the mesh to be digested
  26797. * @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
  26798. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26799. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26800. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26801. * @returns the current SPS
  26802. */
  26803. digest(mesh: Mesh, options?: {
  26804. facetNb?: number;
  26805. number?: number;
  26806. delta?: number;
  26807. storage?: [];
  26808. }): SolidParticleSystem;
  26809. /**
  26810. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26811. * @hidden
  26812. */
  26813. private _unrotateFixedNormals;
  26814. /**
  26815. * Resets the temporary working copy particle
  26816. * @hidden
  26817. */
  26818. private _resetCopy;
  26819. /**
  26820. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26821. * @param p the current index in the positions array to be updated
  26822. * @param ind the current index in the indices array
  26823. * @param shape a Vector3 array, the shape geometry
  26824. * @param positions the positions array to be updated
  26825. * @param meshInd the shape indices array
  26826. * @param indices the indices array to be updated
  26827. * @param meshUV the shape uv array
  26828. * @param uvs the uv array to be updated
  26829. * @param meshCol the shape color array
  26830. * @param colors the color array to be updated
  26831. * @param meshNor the shape normals array
  26832. * @param normals the normals array to be updated
  26833. * @param idx the particle index
  26834. * @param idxInShape the particle index in its shape
  26835. * @param options the addShape() method passed options
  26836. * @model the particle model
  26837. * @hidden
  26838. */
  26839. private _meshBuilder;
  26840. /**
  26841. * Returns a shape Vector3 array from positions float array
  26842. * @param positions float array
  26843. * @returns a vector3 array
  26844. * @hidden
  26845. */
  26846. private _posToShape;
  26847. /**
  26848. * Returns a shapeUV array from a float uvs (array deep copy)
  26849. * @param uvs as a float array
  26850. * @returns a shapeUV array
  26851. * @hidden
  26852. */
  26853. private _uvsToShapeUV;
  26854. /**
  26855. * Adds a new particle object in the particles array
  26856. * @param idx particle index in particles array
  26857. * @param id particle id
  26858. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26859. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26860. * @param model particle ModelShape object
  26861. * @param shapeId model shape identifier
  26862. * @param idxInShape index of the particle in the current model
  26863. * @param bInfo model bounding info object
  26864. * @param storage target storage array, if any
  26865. * @hidden
  26866. */
  26867. private _addParticle;
  26868. /**
  26869. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26870. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26871. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26872. * @param nb (positive integer) the number of particles to be created from this model
  26873. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26874. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26875. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26876. * @returns the number of shapes in the system
  26877. */
  26878. addShape(mesh: Mesh, nb: number, options?: {
  26879. positionFunction?: any;
  26880. vertexFunction?: any;
  26881. storage?: [];
  26882. }): number;
  26883. /**
  26884. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26885. * @hidden
  26886. */
  26887. private _rebuildParticle;
  26888. /**
  26889. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26890. * @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.
  26891. * @returns the SPS.
  26892. */
  26893. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26894. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26895. * Returns an array with the removed particles.
  26896. * 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.
  26897. * The SPS can't be empty so at least one particle needs to remain in place.
  26898. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26899. * @param start index of the first particle to remove
  26900. * @param end index of the last particle to remove (included)
  26901. * @returns an array populated with the removed particles
  26902. */
  26903. removeParticles(start: number, end: number): SolidParticle[];
  26904. /**
  26905. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26906. * @param solidParticleArray an array populated with Solid Particles objects
  26907. * @returns the SPS
  26908. */
  26909. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26910. /**
  26911. * Creates a new particle and modifies the SPS mesh geometry :
  26912. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26913. * - calls _addParticle() to populate the particle array
  26914. * factorized code from addShape() and insertParticlesFromArray()
  26915. * @param idx particle index in the particles array
  26916. * @param i particle index in its shape
  26917. * @param modelShape particle ModelShape object
  26918. * @param shape shape vertex array
  26919. * @param meshInd shape indices array
  26920. * @param meshUV shape uv array
  26921. * @param meshCol shape color array
  26922. * @param meshNor shape normals array
  26923. * @param bbInfo shape bounding info
  26924. * @param storage target particle storage
  26925. * @options addShape() passed options
  26926. * @hidden
  26927. */
  26928. private _insertNewParticle;
  26929. /**
  26930. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26931. * This method calls `updateParticle()` for each particle of the SPS.
  26932. * For an animated SPS, it is usually called within the render loop.
  26933. * 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.
  26934. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26935. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26936. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26937. * @returns the SPS.
  26938. */
  26939. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26940. /**
  26941. * Disposes the SPS.
  26942. */
  26943. dispose(): void;
  26944. /**
  26945. * Returns a SolidParticle object from its identifier : particle.id
  26946. * @param id (integer) the particle Id
  26947. * @returns the searched particle or null if not found in the SPS.
  26948. */
  26949. getParticleById(id: number): Nullable<SolidParticle>;
  26950. /**
  26951. * Returns a new array populated with the particles having the passed shapeId.
  26952. * @param shapeId (integer) the shape identifier
  26953. * @returns a new solid particle array
  26954. */
  26955. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26956. /**
  26957. * Populates the passed array "ref" with the particles having the passed shapeId.
  26958. * @param shapeId the shape identifier
  26959. * @returns the SPS
  26960. * @param ref
  26961. */
  26962. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26963. /**
  26964. * Computes the required SubMeshes according the materials assigned to the particles.
  26965. * @returns the solid particle system.
  26966. * Does nothing if called before the SPS mesh is built.
  26967. */
  26968. computeSubMeshes(): SolidParticleSystem;
  26969. /**
  26970. * Sorts the solid particles by material when MultiMaterial is enabled.
  26971. * Updates the indices32 array.
  26972. * Updates the indicesByMaterial array.
  26973. * Updates the mesh indices array.
  26974. * @returns the SPS
  26975. * @hidden
  26976. */
  26977. private _sortParticlesByMaterial;
  26978. /**
  26979. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26980. * @hidden
  26981. */
  26982. private _setMaterialIndexesById;
  26983. /**
  26984. * Returns an array with unique values of Materials from the passed array
  26985. * @param array the material array to be checked and filtered
  26986. * @hidden
  26987. */
  26988. private _filterUniqueMaterialId;
  26989. /**
  26990. * Sets a new Standard Material as _defaultMaterial if not already set.
  26991. * @hidden
  26992. */
  26993. private _setDefaultMaterial;
  26994. /**
  26995. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26996. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26997. * @returns the SPS.
  26998. */
  26999. refreshVisibleSize(): SolidParticleSystem;
  27000. /**
  27001. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27002. * @param size the size (float) of the visibility box
  27003. * note : this doesn't lock the SPS mesh bounding box.
  27004. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27005. */
  27006. setVisibilityBox(size: number): void;
  27007. /**
  27008. * Gets whether the SPS as always visible or not
  27009. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27010. */
  27011. get isAlwaysVisible(): boolean;
  27012. /**
  27013. * Sets the SPS as always visible or not
  27014. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27015. */
  27016. set isAlwaysVisible(val: boolean);
  27017. /**
  27018. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27019. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27020. */
  27021. set isVisibilityBoxLocked(val: boolean);
  27022. /**
  27023. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27024. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27025. */
  27026. get isVisibilityBoxLocked(): boolean;
  27027. /**
  27028. * Tells to `setParticles()` to compute the particle rotations or not.
  27029. * Default value : true. The SPS is faster when it's set to false.
  27030. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27031. */
  27032. set computeParticleRotation(val: boolean);
  27033. /**
  27034. * Tells to `setParticles()` to compute the particle colors or not.
  27035. * Default value : true. The SPS is faster when it's set to false.
  27036. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27037. */
  27038. set computeParticleColor(val: boolean);
  27039. set computeParticleTexture(val: boolean);
  27040. /**
  27041. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27042. * Default value : false. The SPS is faster when it's set to false.
  27043. * Note : the particle custom vertex positions aren't stored values.
  27044. */
  27045. set computeParticleVertex(val: boolean);
  27046. /**
  27047. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27048. */
  27049. set computeBoundingBox(val: boolean);
  27050. /**
  27051. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27052. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27053. * Default : `true`
  27054. */
  27055. set depthSortParticles(val: boolean);
  27056. /**
  27057. * Gets if `setParticles()` computes the particle rotations or not.
  27058. * Default value : true. The SPS is faster when it's set to false.
  27059. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27060. */
  27061. get computeParticleRotation(): boolean;
  27062. /**
  27063. * Gets if `setParticles()` computes the particle colors or not.
  27064. * Default value : true. The SPS is faster when it's set to false.
  27065. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27066. */
  27067. get computeParticleColor(): boolean;
  27068. /**
  27069. * Gets if `setParticles()` computes the particle textures or not.
  27070. * Default value : true. The SPS is faster when it's set to false.
  27071. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27072. */
  27073. get computeParticleTexture(): boolean;
  27074. /**
  27075. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27076. * Default value : false. The SPS is faster when it's set to false.
  27077. * Note : the particle custom vertex positions aren't stored values.
  27078. */
  27079. get computeParticleVertex(): boolean;
  27080. /**
  27081. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27082. */
  27083. get computeBoundingBox(): boolean;
  27084. /**
  27085. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27086. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27087. * Default : `true`
  27088. */
  27089. get depthSortParticles(): boolean;
  27090. /**
  27091. * Gets if the SPS is created as expandable at construction time.
  27092. * Default : `false`
  27093. */
  27094. get expandable(): boolean;
  27095. /**
  27096. * Gets if the SPS supports the Multi Materials
  27097. */
  27098. get multimaterialEnabled(): boolean;
  27099. /**
  27100. * Gets if the SPS uses the model materials for its own multimaterial.
  27101. */
  27102. get useModelMaterial(): boolean;
  27103. /**
  27104. * The SPS used material array.
  27105. */
  27106. get materials(): Material[];
  27107. /**
  27108. * Sets the SPS MultiMaterial from the passed materials.
  27109. * Note : the passed array is internally copied and not used then by reference.
  27110. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27111. */
  27112. setMultiMaterial(materials: Material[]): void;
  27113. /**
  27114. * The SPS computed multimaterial object
  27115. */
  27116. get multimaterial(): MultiMaterial;
  27117. set multimaterial(mm: MultiMaterial);
  27118. /**
  27119. * If the subMeshes must be updated on the next call to setParticles()
  27120. */
  27121. get autoUpdateSubMeshes(): boolean;
  27122. set autoUpdateSubMeshes(val: boolean);
  27123. /**
  27124. * This function does nothing. It may be overwritten to set all the particle first values.
  27125. * The SPS doesn't call this function, you may have to call it by your own.
  27126. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27127. */
  27128. initParticles(): void;
  27129. /**
  27130. * This function does nothing. It may be overwritten to recycle a particle.
  27131. * The SPS doesn't call this function, you may have to call it by your own.
  27132. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27133. * @param particle The particle to recycle
  27134. * @returns the recycled particle
  27135. */
  27136. recycleParticle(particle: SolidParticle): SolidParticle;
  27137. /**
  27138. * Updates a particle : this function should be overwritten by the user.
  27139. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27140. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27141. * @example : just set a particle position or velocity and recycle conditions
  27142. * @param particle The particle to update
  27143. * @returns the updated particle
  27144. */
  27145. updateParticle(particle: SolidParticle): SolidParticle;
  27146. /**
  27147. * Updates a vertex of a particle : it can be overwritten by the user.
  27148. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27149. * @param particle the current particle
  27150. * @param vertex the current index of the current particle
  27151. * @param pt the index of the current vertex in the particle shape
  27152. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27153. * @example : just set a vertex particle position
  27154. * @returns the updated vertex
  27155. */
  27156. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27157. /**
  27158. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27159. * This does nothing and may be overwritten by the user.
  27160. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27161. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27162. * @param update the boolean update value actually passed to setParticles()
  27163. */
  27164. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27165. /**
  27166. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27167. * This will be passed three parameters.
  27168. * This does nothing and may be overwritten by the user.
  27169. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27170. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27171. * @param update the boolean update value actually passed to setParticles()
  27172. */
  27173. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27174. }
  27175. }
  27176. declare module BABYLON {
  27177. /**
  27178. * Represents one particle of a solid particle system.
  27179. */
  27180. export class SolidParticle {
  27181. /**
  27182. * particle global index
  27183. */
  27184. idx: number;
  27185. /**
  27186. * particle identifier
  27187. */
  27188. id: number;
  27189. /**
  27190. * The color of the particle
  27191. */
  27192. color: Nullable<Color4>;
  27193. /**
  27194. * The world space position of the particle.
  27195. */
  27196. position: Vector3;
  27197. /**
  27198. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27199. */
  27200. rotation: Vector3;
  27201. /**
  27202. * The world space rotation quaternion of the particle.
  27203. */
  27204. rotationQuaternion: Nullable<Quaternion>;
  27205. /**
  27206. * The scaling of the particle.
  27207. */
  27208. scaling: Vector3;
  27209. /**
  27210. * The uvs of the particle.
  27211. */
  27212. uvs: Vector4;
  27213. /**
  27214. * The current speed of the particle.
  27215. */
  27216. velocity: Vector3;
  27217. /**
  27218. * The pivot point in the particle local space.
  27219. */
  27220. pivot: Vector3;
  27221. /**
  27222. * Must the particle be translated from its pivot point in its local space ?
  27223. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27224. * Default : false
  27225. */
  27226. translateFromPivot: boolean;
  27227. /**
  27228. * Is the particle active or not ?
  27229. */
  27230. alive: boolean;
  27231. /**
  27232. * Is the particle visible or not ?
  27233. */
  27234. isVisible: boolean;
  27235. /**
  27236. * Index of this particle in the global "positions" array (Internal use)
  27237. * @hidden
  27238. */
  27239. _pos: number;
  27240. /**
  27241. * @hidden Index of this particle in the global "indices" array (Internal use)
  27242. */
  27243. _ind: number;
  27244. /**
  27245. * @hidden ModelShape of this particle (Internal use)
  27246. */
  27247. _model: ModelShape;
  27248. /**
  27249. * ModelShape id of this particle
  27250. */
  27251. shapeId: number;
  27252. /**
  27253. * Index of the particle in its shape id
  27254. */
  27255. idxInShape: number;
  27256. /**
  27257. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27258. */
  27259. _modelBoundingInfo: BoundingInfo;
  27260. /**
  27261. * @hidden Particle BoundingInfo object (Internal use)
  27262. */
  27263. _boundingInfo: BoundingInfo;
  27264. /**
  27265. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27266. */
  27267. _sps: SolidParticleSystem;
  27268. /**
  27269. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27270. */
  27271. _stillInvisible: boolean;
  27272. /**
  27273. * @hidden Last computed particle rotation matrix
  27274. */
  27275. _rotationMatrix: number[];
  27276. /**
  27277. * Parent particle Id, if any.
  27278. * Default null.
  27279. */
  27280. parentId: Nullable<number>;
  27281. /**
  27282. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27283. */
  27284. materialIndex: Nullable<number>;
  27285. /**
  27286. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27287. * The possible values are :
  27288. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27289. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27290. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27291. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27292. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27293. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27294. * */
  27295. cullingStrategy: number;
  27296. /**
  27297. * @hidden Internal global position in the SPS.
  27298. */
  27299. _globalPosition: Vector3;
  27300. /**
  27301. * Creates a Solid Particle object.
  27302. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27303. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27304. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27305. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27306. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27307. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27308. * @param shapeId (integer) is the model shape identifier in the SPS.
  27309. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27310. * @param sps defines the sps it is associated to
  27311. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27312. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27313. */
  27314. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27315. /**
  27316. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27317. * @param target the particle target
  27318. * @returns the current particle
  27319. */
  27320. copyToRef(target: SolidParticle): SolidParticle;
  27321. /**
  27322. * Legacy support, changed scale to scaling
  27323. */
  27324. get scale(): Vector3;
  27325. /**
  27326. * Legacy support, changed scale to scaling
  27327. */
  27328. set scale(scale: Vector3);
  27329. /**
  27330. * Legacy support, changed quaternion to rotationQuaternion
  27331. */
  27332. get quaternion(): Nullable<Quaternion>;
  27333. /**
  27334. * Legacy support, changed quaternion to rotationQuaternion
  27335. */
  27336. set quaternion(q: Nullable<Quaternion>);
  27337. /**
  27338. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27339. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27340. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27341. * @returns true if it intersects
  27342. */
  27343. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27344. /**
  27345. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27346. * A particle is in the frustum if its bounding box intersects the frustum
  27347. * @param frustumPlanes defines the frustum to test
  27348. * @returns true if the particle is in the frustum planes
  27349. */
  27350. isInFrustum(frustumPlanes: Plane[]): boolean;
  27351. /**
  27352. * get the rotation matrix of the particle
  27353. * @hidden
  27354. */
  27355. getRotationMatrix(m: Matrix): void;
  27356. }
  27357. /**
  27358. * Represents the shape of the model used by one particle of a solid particle system.
  27359. * SPS internal tool, don't use it manually.
  27360. */
  27361. export class ModelShape {
  27362. /**
  27363. * The shape id
  27364. * @hidden
  27365. */
  27366. shapeID: number;
  27367. /**
  27368. * flat array of model positions (internal use)
  27369. * @hidden
  27370. */
  27371. _shape: Vector3[];
  27372. /**
  27373. * flat array of model UVs (internal use)
  27374. * @hidden
  27375. */
  27376. _shapeUV: number[];
  27377. /**
  27378. * color array of the model
  27379. * @hidden
  27380. */
  27381. _shapeColors: number[];
  27382. /**
  27383. * indices array of the model
  27384. * @hidden
  27385. */
  27386. _indices: number[];
  27387. /**
  27388. * normals array of the model
  27389. * @hidden
  27390. */
  27391. _normals: number[];
  27392. /**
  27393. * length of the shape in the model indices array (internal use)
  27394. * @hidden
  27395. */
  27396. _indicesLength: number;
  27397. /**
  27398. * Custom position function (internal use)
  27399. * @hidden
  27400. */
  27401. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27402. /**
  27403. * Custom vertex function (internal use)
  27404. * @hidden
  27405. */
  27406. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27407. /**
  27408. * Model material (internal use)
  27409. * @hidden
  27410. */
  27411. _material: Nullable<Material>;
  27412. /**
  27413. * 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.
  27414. * SPS internal tool, don't use it manually.
  27415. * @hidden
  27416. */
  27417. 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>);
  27418. }
  27419. /**
  27420. * Represents a Depth Sorted Particle in the solid particle system.
  27421. * @hidden
  27422. */
  27423. export class DepthSortedParticle {
  27424. /**
  27425. * Index of the particle in the "indices" array
  27426. */
  27427. ind: number;
  27428. /**
  27429. * Length of the particle shape in the "indices" array
  27430. */
  27431. indicesLength: number;
  27432. /**
  27433. * Squared distance from the particle to the camera
  27434. */
  27435. sqDistance: number;
  27436. /**
  27437. * Material index when used with MultiMaterials
  27438. */
  27439. materialIndex: number;
  27440. /**
  27441. * Creates a new sorted particle
  27442. * @param materialIndex
  27443. */
  27444. constructor(ind: number, indLength: number, materialIndex: number);
  27445. }
  27446. }
  27447. declare module BABYLON {
  27448. /**
  27449. * @hidden
  27450. */
  27451. export class _MeshCollisionData {
  27452. _checkCollisions: boolean;
  27453. _collisionMask: number;
  27454. _collisionGroup: number;
  27455. _collider: Nullable<Collider>;
  27456. _oldPositionForCollisions: Vector3;
  27457. _diffPositionForCollisions: Vector3;
  27458. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27459. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27460. }
  27461. }
  27462. declare module BABYLON {
  27463. /** @hidden */
  27464. class _FacetDataStorage {
  27465. facetPositions: Vector3[];
  27466. facetNormals: Vector3[];
  27467. facetPartitioning: number[][];
  27468. facetNb: number;
  27469. partitioningSubdivisions: number;
  27470. partitioningBBoxRatio: number;
  27471. facetDataEnabled: boolean;
  27472. facetParameters: any;
  27473. bbSize: Vector3;
  27474. subDiv: {
  27475. max: number;
  27476. X: number;
  27477. Y: number;
  27478. Z: number;
  27479. };
  27480. facetDepthSort: boolean;
  27481. facetDepthSortEnabled: boolean;
  27482. depthSortedIndices: IndicesArray;
  27483. depthSortedFacets: {
  27484. ind: number;
  27485. sqDistance: number;
  27486. }[];
  27487. facetDepthSortFunction: (f1: {
  27488. ind: number;
  27489. sqDistance: number;
  27490. }, f2: {
  27491. ind: number;
  27492. sqDistance: number;
  27493. }) => number;
  27494. facetDepthSortFrom: Vector3;
  27495. facetDepthSortOrigin: Vector3;
  27496. invertedMatrix: Matrix;
  27497. }
  27498. /**
  27499. * @hidden
  27500. **/
  27501. class _InternalAbstractMeshDataInfo {
  27502. _hasVertexAlpha: boolean;
  27503. _useVertexColors: boolean;
  27504. _numBoneInfluencers: number;
  27505. _applyFog: boolean;
  27506. _receiveShadows: boolean;
  27507. _facetData: _FacetDataStorage;
  27508. _visibility: number;
  27509. _skeleton: Nullable<Skeleton>;
  27510. _layerMask: number;
  27511. _computeBonesUsingShaders: boolean;
  27512. _isActive: boolean;
  27513. _onlyForInstances: boolean;
  27514. _isActiveIntermediate: boolean;
  27515. _onlyForInstancesIntermediate: boolean;
  27516. _actAsRegularMesh: boolean;
  27517. }
  27518. /**
  27519. * Class used to store all common mesh properties
  27520. */
  27521. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27522. /** No occlusion */
  27523. static OCCLUSION_TYPE_NONE: number;
  27524. /** Occlusion set to optimisitic */
  27525. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27526. /** Occlusion set to strict */
  27527. static OCCLUSION_TYPE_STRICT: number;
  27528. /** Use an accurante occlusion algorithm */
  27529. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27530. /** Use a conservative occlusion algorithm */
  27531. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27532. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27533. * Test order :
  27534. * Is the bounding sphere outside the frustum ?
  27535. * If not, are the bounding box vertices outside the frustum ?
  27536. * It not, then the cullable object is in the frustum.
  27537. */
  27538. static readonly CULLINGSTRATEGY_STANDARD: number;
  27539. /** Culling strategy : Bounding Sphere Only.
  27540. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27541. * It's also less accurate than the standard because some not visible objects can still be selected.
  27542. * Test : is the bounding sphere outside the frustum ?
  27543. * If not, then the cullable object is in the frustum.
  27544. */
  27545. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27546. /** Culling strategy : Optimistic Inclusion.
  27547. * This in an inclusion test first, then the standard exclusion test.
  27548. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27549. * 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.
  27550. * Anyway, it's as accurate as the standard strategy.
  27551. * Test :
  27552. * Is the cullable object bounding sphere center in the frustum ?
  27553. * If not, apply the default culling strategy.
  27554. */
  27555. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27556. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27557. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27558. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27559. * 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.
  27560. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27561. * Test :
  27562. * Is the cullable object bounding sphere center in the frustum ?
  27563. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27564. */
  27565. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27566. /**
  27567. * No billboard
  27568. */
  27569. static get BILLBOARDMODE_NONE(): number;
  27570. /** Billboard on X axis */
  27571. static get BILLBOARDMODE_X(): number;
  27572. /** Billboard on Y axis */
  27573. static get BILLBOARDMODE_Y(): number;
  27574. /** Billboard on Z axis */
  27575. static get BILLBOARDMODE_Z(): number;
  27576. /** Billboard on all axes */
  27577. static get BILLBOARDMODE_ALL(): number;
  27578. /** Billboard on using position instead of orientation */
  27579. static get BILLBOARDMODE_USE_POSITION(): number;
  27580. /** @hidden */
  27581. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27582. /**
  27583. * The culling strategy to use to check whether the mesh must be rendered or not.
  27584. * This value can be changed at any time and will be used on the next render mesh selection.
  27585. * The possible values are :
  27586. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27587. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27588. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27589. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27590. * Please read each static variable documentation to get details about the culling process.
  27591. * */
  27592. cullingStrategy: number;
  27593. /**
  27594. * Gets the number of facets in the mesh
  27595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27596. */
  27597. get facetNb(): number;
  27598. /**
  27599. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27601. */
  27602. get partitioningSubdivisions(): number;
  27603. set partitioningSubdivisions(nb: number);
  27604. /**
  27605. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27606. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27608. */
  27609. get partitioningBBoxRatio(): number;
  27610. set partitioningBBoxRatio(ratio: number);
  27611. /**
  27612. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27613. * Works only for updatable meshes.
  27614. * Doesn't work with multi-materials
  27615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27616. */
  27617. get mustDepthSortFacets(): boolean;
  27618. set mustDepthSortFacets(sort: boolean);
  27619. /**
  27620. * The location (Vector3) where the facet depth sort must be computed from.
  27621. * By default, the active camera position.
  27622. * Used only when facet depth sort is enabled
  27623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27624. */
  27625. get facetDepthSortFrom(): Vector3;
  27626. set facetDepthSortFrom(location: Vector3);
  27627. /**
  27628. * gets a boolean indicating if facetData is enabled
  27629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27630. */
  27631. get isFacetDataEnabled(): boolean;
  27632. /** @hidden */
  27633. _updateNonUniformScalingState(value: boolean): boolean;
  27634. /**
  27635. * An event triggered when this mesh collides with another one
  27636. */
  27637. onCollideObservable: Observable<AbstractMesh>;
  27638. /** Set a function to call when this mesh collides with another one */
  27639. set onCollide(callback: () => void);
  27640. /**
  27641. * An event triggered when the collision's position changes
  27642. */
  27643. onCollisionPositionChangeObservable: Observable<Vector3>;
  27644. /** Set a function to call when the collision's position changes */
  27645. set onCollisionPositionChange(callback: () => void);
  27646. /**
  27647. * An event triggered when material is changed
  27648. */
  27649. onMaterialChangedObservable: Observable<AbstractMesh>;
  27650. /**
  27651. * Gets or sets the orientation for POV movement & rotation
  27652. */
  27653. definedFacingForward: boolean;
  27654. /** @hidden */
  27655. _occlusionQuery: Nullable<WebGLQuery>;
  27656. /** @hidden */
  27657. _renderingGroup: Nullable<RenderingGroup>;
  27658. /**
  27659. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27660. */
  27661. get visibility(): number;
  27662. /**
  27663. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27664. */
  27665. set visibility(value: number);
  27666. /** Gets or sets the alpha index used to sort transparent meshes
  27667. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27668. */
  27669. alphaIndex: number;
  27670. /**
  27671. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27672. */
  27673. isVisible: boolean;
  27674. /**
  27675. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27676. */
  27677. isPickable: boolean;
  27678. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27679. showSubMeshesBoundingBox: boolean;
  27680. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27681. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27682. */
  27683. isBlocker: boolean;
  27684. /**
  27685. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27686. */
  27687. enablePointerMoveEvents: boolean;
  27688. /**
  27689. * Specifies the rendering group id for this mesh (0 by default)
  27690. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27691. */
  27692. renderingGroupId: number;
  27693. private _material;
  27694. /** Gets or sets current material */
  27695. get material(): Nullable<Material>;
  27696. set material(value: Nullable<Material>);
  27697. /**
  27698. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27699. * @see http://doc.babylonjs.com/babylon101/shadows
  27700. */
  27701. get receiveShadows(): boolean;
  27702. set receiveShadows(value: boolean);
  27703. /** Defines color to use when rendering outline */
  27704. outlineColor: Color3;
  27705. /** Define width to use when rendering outline */
  27706. outlineWidth: number;
  27707. /** Defines color to use when rendering overlay */
  27708. overlayColor: Color3;
  27709. /** Defines alpha to use when rendering overlay */
  27710. overlayAlpha: number;
  27711. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27712. get hasVertexAlpha(): boolean;
  27713. set hasVertexAlpha(value: boolean);
  27714. /** 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) */
  27715. get useVertexColors(): boolean;
  27716. set useVertexColors(value: boolean);
  27717. /**
  27718. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27719. */
  27720. get computeBonesUsingShaders(): boolean;
  27721. set computeBonesUsingShaders(value: boolean);
  27722. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27723. get numBoneInfluencers(): number;
  27724. set numBoneInfluencers(value: number);
  27725. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27726. get applyFog(): boolean;
  27727. set applyFog(value: boolean);
  27728. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27729. useOctreeForRenderingSelection: boolean;
  27730. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27731. useOctreeForPicking: boolean;
  27732. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27733. useOctreeForCollisions: boolean;
  27734. /**
  27735. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27736. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27737. */
  27738. get layerMask(): number;
  27739. set layerMask(value: number);
  27740. /**
  27741. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27742. */
  27743. alwaysSelectAsActiveMesh: boolean;
  27744. /**
  27745. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27746. */
  27747. doNotSyncBoundingInfo: boolean;
  27748. /**
  27749. * Gets or sets the current action manager
  27750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27751. */
  27752. actionManager: Nullable<AbstractActionManager>;
  27753. private _meshCollisionData;
  27754. /**
  27755. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27756. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27757. */
  27758. ellipsoid: Vector3;
  27759. /**
  27760. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27761. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27762. */
  27763. ellipsoidOffset: Vector3;
  27764. /**
  27765. * Gets or sets a collision mask used to mask collisions (default is -1).
  27766. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27767. */
  27768. get collisionMask(): number;
  27769. set collisionMask(mask: number);
  27770. /**
  27771. * Gets or sets the current collision group mask (-1 by default).
  27772. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27773. */
  27774. get collisionGroup(): number;
  27775. set collisionGroup(mask: number);
  27776. /**
  27777. * Defines edge width used when edgesRenderer is enabled
  27778. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27779. */
  27780. edgesWidth: number;
  27781. /**
  27782. * Defines edge color used when edgesRenderer is enabled
  27783. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27784. */
  27785. edgesColor: Color4;
  27786. /** @hidden */
  27787. _edgesRenderer: Nullable<IEdgesRenderer>;
  27788. /** @hidden */
  27789. _masterMesh: Nullable<AbstractMesh>;
  27790. /** @hidden */
  27791. _boundingInfo: Nullable<BoundingInfo>;
  27792. /** @hidden */
  27793. _renderId: number;
  27794. /**
  27795. * Gets or sets the list of subMeshes
  27796. * @see http://doc.babylonjs.com/how_to/multi_materials
  27797. */
  27798. subMeshes: SubMesh[];
  27799. /** @hidden */
  27800. _intersectionsInProgress: AbstractMesh[];
  27801. /** @hidden */
  27802. _unIndexed: boolean;
  27803. /** @hidden */
  27804. _lightSources: Light[];
  27805. /** Gets the list of lights affecting that mesh */
  27806. get lightSources(): Light[];
  27807. /** @hidden */
  27808. get _positions(): Nullable<Vector3[]>;
  27809. /** @hidden */
  27810. _waitingData: {
  27811. lods: Nullable<any>;
  27812. actions: Nullable<any>;
  27813. freezeWorldMatrix: Nullable<boolean>;
  27814. };
  27815. /** @hidden */
  27816. _bonesTransformMatrices: Nullable<Float32Array>;
  27817. /** @hidden */
  27818. _transformMatrixTexture: Nullable<RawTexture>;
  27819. /**
  27820. * Gets or sets a skeleton to apply skining transformations
  27821. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27822. */
  27823. set skeleton(value: Nullable<Skeleton>);
  27824. get skeleton(): Nullable<Skeleton>;
  27825. /**
  27826. * An event triggered when the mesh is rebuilt.
  27827. */
  27828. onRebuildObservable: Observable<AbstractMesh>;
  27829. /**
  27830. * Creates a new AbstractMesh
  27831. * @param name defines the name of the mesh
  27832. * @param scene defines the hosting scene
  27833. */
  27834. constructor(name: string, scene?: Nullable<Scene>);
  27835. /**
  27836. * Returns the string "AbstractMesh"
  27837. * @returns "AbstractMesh"
  27838. */
  27839. getClassName(): string;
  27840. /**
  27841. * Gets a string representation of the current mesh
  27842. * @param fullDetails defines a boolean indicating if full details must be included
  27843. * @returns a string representation of the current mesh
  27844. */
  27845. toString(fullDetails?: boolean): string;
  27846. /**
  27847. * @hidden
  27848. */
  27849. protected _getEffectiveParent(): Nullable<Node>;
  27850. /** @hidden */
  27851. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27852. /** @hidden */
  27853. _rebuild(): void;
  27854. /** @hidden */
  27855. _resyncLightSources(): void;
  27856. /** @hidden */
  27857. _resyncLightSource(light: Light): void;
  27858. /** @hidden */
  27859. _unBindEffect(): void;
  27860. /** @hidden */
  27861. _removeLightSource(light: Light, dispose: boolean): void;
  27862. private _markSubMeshesAsDirty;
  27863. /** @hidden */
  27864. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27865. /** @hidden */
  27866. _markSubMeshesAsAttributesDirty(): void;
  27867. /** @hidden */
  27868. _markSubMeshesAsMiscDirty(): void;
  27869. /**
  27870. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27871. */
  27872. get scaling(): Vector3;
  27873. set scaling(newScaling: Vector3);
  27874. /**
  27875. * Returns true if the mesh is blocked. Implemented by child classes
  27876. */
  27877. get isBlocked(): boolean;
  27878. /**
  27879. * Returns the mesh itself by default. Implemented by child classes
  27880. * @param camera defines the camera to use to pick the right LOD level
  27881. * @returns the currentAbstractMesh
  27882. */
  27883. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27884. /**
  27885. * Returns 0 by default. Implemented by child classes
  27886. * @returns an integer
  27887. */
  27888. getTotalVertices(): number;
  27889. /**
  27890. * Returns a positive integer : the total number of indices in this mesh geometry.
  27891. * @returns the numner of indices or zero if the mesh has no geometry.
  27892. */
  27893. getTotalIndices(): number;
  27894. /**
  27895. * Returns null by default. Implemented by child classes
  27896. * @returns null
  27897. */
  27898. getIndices(): Nullable<IndicesArray>;
  27899. /**
  27900. * Returns the array of the requested vertex data kind. Implemented by child classes
  27901. * @param kind defines the vertex data kind to use
  27902. * @returns null
  27903. */
  27904. getVerticesData(kind: string): Nullable<FloatArray>;
  27905. /**
  27906. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27907. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27908. * Note that a new underlying VertexBuffer object is created each call.
  27909. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27910. * @param kind defines vertex data kind:
  27911. * * VertexBuffer.PositionKind
  27912. * * VertexBuffer.UVKind
  27913. * * VertexBuffer.UV2Kind
  27914. * * VertexBuffer.UV3Kind
  27915. * * VertexBuffer.UV4Kind
  27916. * * VertexBuffer.UV5Kind
  27917. * * VertexBuffer.UV6Kind
  27918. * * VertexBuffer.ColorKind
  27919. * * VertexBuffer.MatricesIndicesKind
  27920. * * VertexBuffer.MatricesIndicesExtraKind
  27921. * * VertexBuffer.MatricesWeightsKind
  27922. * * VertexBuffer.MatricesWeightsExtraKind
  27923. * @param data defines the data source
  27924. * @param updatable defines if the data must be flagged as updatable (or static)
  27925. * @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
  27926. * @returns the current mesh
  27927. */
  27928. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27929. /**
  27930. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27931. * If the mesh has no geometry, it is simply returned as it is.
  27932. * @param kind defines vertex data kind:
  27933. * * VertexBuffer.PositionKind
  27934. * * VertexBuffer.UVKind
  27935. * * VertexBuffer.UV2Kind
  27936. * * VertexBuffer.UV3Kind
  27937. * * VertexBuffer.UV4Kind
  27938. * * VertexBuffer.UV5Kind
  27939. * * VertexBuffer.UV6Kind
  27940. * * VertexBuffer.ColorKind
  27941. * * VertexBuffer.MatricesIndicesKind
  27942. * * VertexBuffer.MatricesIndicesExtraKind
  27943. * * VertexBuffer.MatricesWeightsKind
  27944. * * VertexBuffer.MatricesWeightsExtraKind
  27945. * @param data defines the data source
  27946. * @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
  27947. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27948. * @returns the current mesh
  27949. */
  27950. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27951. /**
  27952. * Sets the mesh indices,
  27953. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27954. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27955. * @param totalVertices Defines the total number of vertices
  27956. * @returns the current mesh
  27957. */
  27958. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27959. /**
  27960. * Gets a boolean indicating if specific vertex data is present
  27961. * @param kind defines the vertex data kind to use
  27962. * @returns true is data kind is present
  27963. */
  27964. isVerticesDataPresent(kind: string): boolean;
  27965. /**
  27966. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27967. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27968. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27969. * @returns a BoundingInfo
  27970. */
  27971. getBoundingInfo(): BoundingInfo;
  27972. /**
  27973. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27974. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27975. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27976. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27977. * @returns the current mesh
  27978. */
  27979. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27980. /**
  27981. * Overwrite the current bounding info
  27982. * @param boundingInfo defines the new bounding info
  27983. * @returns the current mesh
  27984. */
  27985. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27986. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27987. get useBones(): boolean;
  27988. /** @hidden */
  27989. _preActivate(): void;
  27990. /** @hidden */
  27991. _preActivateForIntermediateRendering(renderId: number): void;
  27992. /** @hidden */
  27993. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27994. /** @hidden */
  27995. _postActivate(): void;
  27996. /** @hidden */
  27997. _freeze(): void;
  27998. /** @hidden */
  27999. _unFreeze(): void;
  28000. /**
  28001. * Gets the current world matrix
  28002. * @returns a Matrix
  28003. */
  28004. getWorldMatrix(): Matrix;
  28005. /** @hidden */
  28006. _getWorldMatrixDeterminant(): number;
  28007. /**
  28008. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28009. */
  28010. get isAnInstance(): boolean;
  28011. /**
  28012. * Gets a boolean indicating if this mesh has instances
  28013. */
  28014. get hasInstances(): boolean;
  28015. /**
  28016. * Perform relative position change from the point of view of behind the front of the mesh.
  28017. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28018. * Supports definition of mesh facing forward or backward
  28019. * @param amountRight defines the distance on the right axis
  28020. * @param amountUp defines the distance on the up axis
  28021. * @param amountForward defines the distance on the forward axis
  28022. * @returns the current mesh
  28023. */
  28024. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28025. /**
  28026. * Calculate relative position change from the point of view of behind the front of the mesh.
  28027. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28028. * Supports definition of mesh facing forward or backward
  28029. * @param amountRight defines the distance on the right axis
  28030. * @param amountUp defines the distance on the up axis
  28031. * @param amountForward defines the distance on the forward axis
  28032. * @returns the new displacement vector
  28033. */
  28034. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28035. /**
  28036. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28037. * Supports definition of mesh facing forward or backward
  28038. * @param flipBack defines the flip
  28039. * @param twirlClockwise defines the twirl
  28040. * @param tiltRight defines the tilt
  28041. * @returns the current mesh
  28042. */
  28043. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28044. /**
  28045. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28046. * Supports definition of mesh facing forward or backward.
  28047. * @param flipBack defines the flip
  28048. * @param twirlClockwise defines the twirl
  28049. * @param tiltRight defines the tilt
  28050. * @returns the new rotation vector
  28051. */
  28052. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28053. /**
  28054. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28055. * This means the mesh underlying bounding box and sphere are recomputed.
  28056. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28057. * @returns the current mesh
  28058. */
  28059. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28060. /** @hidden */
  28061. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28062. /** @hidden */
  28063. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28064. /** @hidden */
  28065. _updateBoundingInfo(): AbstractMesh;
  28066. /** @hidden */
  28067. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28068. /** @hidden */
  28069. protected _afterComputeWorldMatrix(): void;
  28070. /** @hidden */
  28071. get _effectiveMesh(): AbstractMesh;
  28072. /**
  28073. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28074. * A mesh is in the frustum if its bounding box intersects the frustum
  28075. * @param frustumPlanes defines the frustum to test
  28076. * @returns true if the mesh is in the frustum planes
  28077. */
  28078. isInFrustum(frustumPlanes: Plane[]): boolean;
  28079. /**
  28080. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28081. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28082. * @param frustumPlanes defines the frustum to test
  28083. * @returns true if the mesh is completely in the frustum planes
  28084. */
  28085. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28086. /**
  28087. * True if the mesh intersects another mesh or a SolidParticle object
  28088. * @param mesh defines a target mesh or SolidParticle to test
  28089. * @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)
  28090. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28091. * @returns true if there is an intersection
  28092. */
  28093. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28094. /**
  28095. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28096. * @param point defines the point to test
  28097. * @returns true if there is an intersection
  28098. */
  28099. intersectsPoint(point: Vector3): boolean;
  28100. /**
  28101. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28103. */
  28104. get checkCollisions(): boolean;
  28105. set checkCollisions(collisionEnabled: boolean);
  28106. /**
  28107. * Gets Collider object used to compute collisions (not physics)
  28108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28109. */
  28110. get collider(): Nullable<Collider>;
  28111. /**
  28112. * Move the mesh using collision engine
  28113. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28114. * @param displacement defines the requested displacement vector
  28115. * @returns the current mesh
  28116. */
  28117. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28118. private _onCollisionPositionChange;
  28119. /** @hidden */
  28120. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28121. /** @hidden */
  28122. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28123. /** @hidden */
  28124. _checkCollision(collider: Collider): AbstractMesh;
  28125. /** @hidden */
  28126. _generatePointsArray(): boolean;
  28127. /**
  28128. * Checks if the passed Ray intersects with the mesh
  28129. * @param ray defines the ray to use
  28130. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28131. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28132. * @returns the picking info
  28133. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28134. */
  28135. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28136. /**
  28137. * Clones the current mesh
  28138. * @param name defines the mesh name
  28139. * @param newParent defines the new mesh parent
  28140. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28141. * @returns the new mesh
  28142. */
  28143. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28144. /**
  28145. * Disposes all the submeshes of the current meshnp
  28146. * @returns the current mesh
  28147. */
  28148. releaseSubMeshes(): AbstractMesh;
  28149. /**
  28150. * Releases resources associated with this abstract mesh.
  28151. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28152. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28153. */
  28154. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28155. /**
  28156. * Adds the passed mesh as a child to the current mesh
  28157. * @param mesh defines the child mesh
  28158. * @returns the current mesh
  28159. */
  28160. addChild(mesh: AbstractMesh): AbstractMesh;
  28161. /**
  28162. * Removes the passed mesh from the current mesh children list
  28163. * @param mesh defines the child mesh
  28164. * @returns the current mesh
  28165. */
  28166. removeChild(mesh: AbstractMesh): AbstractMesh;
  28167. /** @hidden */
  28168. private _initFacetData;
  28169. /**
  28170. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28171. * This method can be called within the render loop.
  28172. * 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
  28173. * @returns the current mesh
  28174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28175. */
  28176. updateFacetData(): AbstractMesh;
  28177. /**
  28178. * Returns the facetLocalNormals array.
  28179. * The normals are expressed in the mesh local spac
  28180. * @returns an array of Vector3
  28181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28182. */
  28183. getFacetLocalNormals(): Vector3[];
  28184. /**
  28185. * Returns the facetLocalPositions array.
  28186. * The facet positions are expressed in the mesh local space
  28187. * @returns an array of Vector3
  28188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28189. */
  28190. getFacetLocalPositions(): Vector3[];
  28191. /**
  28192. * Returns the facetLocalPartioning array
  28193. * @returns an array of array of numbers
  28194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28195. */
  28196. getFacetLocalPartitioning(): number[][];
  28197. /**
  28198. * Returns the i-th facet position in the world system.
  28199. * This method allocates a new Vector3 per call
  28200. * @param i defines the facet index
  28201. * @returns a new Vector3
  28202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28203. */
  28204. getFacetPosition(i: number): Vector3;
  28205. /**
  28206. * Sets the reference Vector3 with the i-th facet position in the world system
  28207. * @param i defines the facet index
  28208. * @param ref defines the target vector
  28209. * @returns the current mesh
  28210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28211. */
  28212. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28213. /**
  28214. * Returns the i-th facet normal in the world system.
  28215. * This method allocates a new Vector3 per call
  28216. * @param i defines the facet index
  28217. * @returns a new Vector3
  28218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28219. */
  28220. getFacetNormal(i: number): Vector3;
  28221. /**
  28222. * Sets the reference Vector3 with the i-th facet normal in the world system
  28223. * @param i defines the facet index
  28224. * @param ref defines the target vector
  28225. * @returns the current mesh
  28226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28227. */
  28228. getFacetNormalToRef(i: number, ref: Vector3): this;
  28229. /**
  28230. * 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)
  28231. * @param x defines x coordinate
  28232. * @param y defines y coordinate
  28233. * @param z defines z coordinate
  28234. * @returns the array of facet indexes
  28235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28236. */
  28237. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28238. /**
  28239. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28240. * @param projected sets as the (x,y,z) world projection on the facet
  28241. * @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
  28242. * @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
  28243. * @param x defines x coordinate
  28244. * @param y defines y coordinate
  28245. * @param z defines z coordinate
  28246. * @returns the face index if found (or null instead)
  28247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28248. */
  28249. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28250. /**
  28251. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28252. * @param projected sets as the (x,y,z) local projection on the facet
  28253. * @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
  28254. * @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
  28255. * @param x defines x coordinate
  28256. * @param y defines y coordinate
  28257. * @param z defines z coordinate
  28258. * @returns the face index if found (or null instead)
  28259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28260. */
  28261. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28262. /**
  28263. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28264. * @returns the parameters
  28265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28266. */
  28267. getFacetDataParameters(): any;
  28268. /**
  28269. * Disables the feature FacetData and frees the related memory
  28270. * @returns the current mesh
  28271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28272. */
  28273. disableFacetData(): AbstractMesh;
  28274. /**
  28275. * Updates the AbstractMesh indices array
  28276. * @param indices defines the data source
  28277. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28278. * @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)
  28279. * @returns the current mesh
  28280. */
  28281. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28282. /**
  28283. * Creates new normals data for the mesh
  28284. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28285. * @returns the current mesh
  28286. */
  28287. createNormals(updatable: boolean): AbstractMesh;
  28288. /**
  28289. * Align the mesh with a normal
  28290. * @param normal defines the normal to use
  28291. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28292. * @returns the current mesh
  28293. */
  28294. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28295. /** @hidden */
  28296. _checkOcclusionQuery(): boolean;
  28297. /**
  28298. * Disables the mesh edge rendering mode
  28299. * @returns the currentAbstractMesh
  28300. */
  28301. disableEdgesRendering(): AbstractMesh;
  28302. /**
  28303. * Enables the edge rendering mode on the mesh.
  28304. * This mode makes the mesh edges visible
  28305. * @param epsilon defines the maximal distance between two angles to detect a face
  28306. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28307. * @returns the currentAbstractMesh
  28308. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28309. */
  28310. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28311. }
  28312. }
  28313. declare module BABYLON {
  28314. /**
  28315. * Interface used to define ActionEvent
  28316. */
  28317. export interface IActionEvent {
  28318. /** The mesh or sprite that triggered the action */
  28319. source: any;
  28320. /** The X mouse cursor position at the time of the event */
  28321. pointerX: number;
  28322. /** The Y mouse cursor position at the time of the event */
  28323. pointerY: number;
  28324. /** The mesh that is currently pointed at (can be null) */
  28325. meshUnderPointer: Nullable<AbstractMesh>;
  28326. /** the original (browser) event that triggered the ActionEvent */
  28327. sourceEvent?: any;
  28328. /** additional data for the event */
  28329. additionalData?: any;
  28330. }
  28331. /**
  28332. * ActionEvent is the event being sent when an action is triggered.
  28333. */
  28334. export class ActionEvent implements IActionEvent {
  28335. /** The mesh or sprite that triggered the action */
  28336. source: any;
  28337. /** The X mouse cursor position at the time of the event */
  28338. pointerX: number;
  28339. /** The Y mouse cursor position at the time of the event */
  28340. pointerY: number;
  28341. /** The mesh that is currently pointed at (can be null) */
  28342. meshUnderPointer: Nullable<AbstractMesh>;
  28343. /** the original (browser) event that triggered the ActionEvent */
  28344. sourceEvent?: any;
  28345. /** additional data for the event */
  28346. additionalData?: any;
  28347. /**
  28348. * Creates a new ActionEvent
  28349. * @param source The mesh or sprite that triggered the action
  28350. * @param pointerX The X mouse cursor position at the time of the event
  28351. * @param pointerY The Y mouse cursor position at the time of the event
  28352. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28353. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28354. * @param additionalData additional data for the event
  28355. */
  28356. constructor(
  28357. /** The mesh or sprite that triggered the action */
  28358. source: any,
  28359. /** The X mouse cursor position at the time of the event */
  28360. pointerX: number,
  28361. /** The Y mouse cursor position at the time of the event */
  28362. pointerY: number,
  28363. /** The mesh that is currently pointed at (can be null) */
  28364. meshUnderPointer: Nullable<AbstractMesh>,
  28365. /** the original (browser) event that triggered the ActionEvent */
  28366. sourceEvent?: any,
  28367. /** additional data for the event */
  28368. additionalData?: any);
  28369. /**
  28370. * Helper function to auto-create an ActionEvent from a source mesh.
  28371. * @param source The source mesh that triggered the event
  28372. * @param evt The original (browser) event
  28373. * @param additionalData additional data for the event
  28374. * @returns the new ActionEvent
  28375. */
  28376. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28377. /**
  28378. * Helper function to auto-create an ActionEvent from a source sprite
  28379. * @param source The source sprite that triggered the event
  28380. * @param scene Scene associated with the sprite
  28381. * @param evt The original (browser) event
  28382. * @param additionalData additional data for the event
  28383. * @returns the new ActionEvent
  28384. */
  28385. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28386. /**
  28387. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28388. * @param scene the scene where the event occurred
  28389. * @param evt The original (browser) event
  28390. * @returns the new ActionEvent
  28391. */
  28392. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28393. /**
  28394. * Helper function to auto-create an ActionEvent from a primitive
  28395. * @param prim defines the target primitive
  28396. * @param pointerPos defines the pointer position
  28397. * @param evt The original (browser) event
  28398. * @param additionalData additional data for the event
  28399. * @returns the new ActionEvent
  28400. */
  28401. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28402. }
  28403. }
  28404. declare module BABYLON {
  28405. /**
  28406. * Abstract class used to decouple action Manager from scene and meshes.
  28407. * Do not instantiate.
  28408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28409. */
  28410. export abstract class AbstractActionManager implements IDisposable {
  28411. /** Gets the list of active triggers */
  28412. static Triggers: {
  28413. [key: string]: number;
  28414. };
  28415. /** Gets the cursor to use when hovering items */
  28416. hoverCursor: string;
  28417. /** Gets the list of actions */
  28418. actions: IAction[];
  28419. /**
  28420. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28421. */
  28422. isRecursive: boolean;
  28423. /**
  28424. * Releases all associated resources
  28425. */
  28426. abstract dispose(): void;
  28427. /**
  28428. * Does this action manager has pointer triggers
  28429. */
  28430. abstract get hasPointerTriggers(): boolean;
  28431. /**
  28432. * Does this action manager has pick triggers
  28433. */
  28434. abstract get hasPickTriggers(): boolean;
  28435. /**
  28436. * Process a specific trigger
  28437. * @param trigger defines the trigger to process
  28438. * @param evt defines the event details to be processed
  28439. */
  28440. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28441. /**
  28442. * Does this action manager handles actions of any of the given triggers
  28443. * @param triggers defines the triggers to be tested
  28444. * @return a boolean indicating whether one (or more) of the triggers is handled
  28445. */
  28446. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28447. /**
  28448. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28449. * speed.
  28450. * @param triggerA defines the trigger to be tested
  28451. * @param triggerB defines the trigger to be tested
  28452. * @return a boolean indicating whether one (or more) of the triggers is handled
  28453. */
  28454. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28455. /**
  28456. * Does this action manager handles actions of a given trigger
  28457. * @param trigger defines the trigger to be tested
  28458. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28459. * @return whether the trigger is handled
  28460. */
  28461. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28462. /**
  28463. * Serialize this manager to a JSON object
  28464. * @param name defines the property name to store this manager
  28465. * @returns a JSON representation of this manager
  28466. */
  28467. abstract serialize(name: string): any;
  28468. /**
  28469. * Registers an action to this action manager
  28470. * @param action defines the action to be registered
  28471. * @return the action amended (prepared) after registration
  28472. */
  28473. abstract registerAction(action: IAction): Nullable<IAction>;
  28474. /**
  28475. * Unregisters an action to this action manager
  28476. * @param action defines the action to be unregistered
  28477. * @return a boolean indicating whether the action has been unregistered
  28478. */
  28479. abstract unregisterAction(action: IAction): Boolean;
  28480. /**
  28481. * Does exist one action manager with at least one trigger
  28482. **/
  28483. static get HasTriggers(): boolean;
  28484. /**
  28485. * Does exist one action manager with at least one pick trigger
  28486. **/
  28487. static get HasPickTriggers(): boolean;
  28488. /**
  28489. * Does exist one action manager that handles actions of a given trigger
  28490. * @param trigger defines the trigger to be tested
  28491. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28492. **/
  28493. static HasSpecificTrigger(trigger: number): boolean;
  28494. }
  28495. }
  28496. declare module BABYLON {
  28497. /**
  28498. * Defines how a node can be built from a string name.
  28499. */
  28500. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28501. /**
  28502. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28503. */
  28504. export class Node implements IBehaviorAware<Node> {
  28505. /** @hidden */
  28506. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28507. private static _NodeConstructors;
  28508. /**
  28509. * Add a new node constructor
  28510. * @param type defines the type name of the node to construct
  28511. * @param constructorFunc defines the constructor function
  28512. */
  28513. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28514. /**
  28515. * Returns a node constructor based on type name
  28516. * @param type defines the type name
  28517. * @param name defines the new node name
  28518. * @param scene defines the hosting scene
  28519. * @param options defines optional options to transmit to constructors
  28520. * @returns the new constructor or null
  28521. */
  28522. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28523. /**
  28524. * Gets or sets the name of the node
  28525. */
  28526. name: string;
  28527. /**
  28528. * Gets or sets the id of the node
  28529. */
  28530. id: string;
  28531. /**
  28532. * Gets or sets the unique id of the node
  28533. */
  28534. uniqueId: number;
  28535. /**
  28536. * Gets or sets a string used to store user defined state for the node
  28537. */
  28538. state: string;
  28539. /**
  28540. * Gets or sets an object used to store user defined information for the node
  28541. */
  28542. metadata: any;
  28543. /**
  28544. * For internal use only. Please do not use.
  28545. */
  28546. reservedDataStore: any;
  28547. /**
  28548. * List of inspectable custom properties (used by the Inspector)
  28549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28550. */
  28551. inspectableCustomProperties: IInspectable[];
  28552. private _doNotSerialize;
  28553. /**
  28554. * Gets or sets a boolean used to define if the node must be serialized
  28555. */
  28556. get doNotSerialize(): boolean;
  28557. set doNotSerialize(value: boolean);
  28558. /** @hidden */
  28559. _isDisposed: boolean;
  28560. /**
  28561. * Gets a list of Animations associated with the node
  28562. */
  28563. animations: Animation[];
  28564. protected _ranges: {
  28565. [name: string]: Nullable<AnimationRange>;
  28566. };
  28567. /**
  28568. * Callback raised when the node is ready to be used
  28569. */
  28570. onReady: Nullable<(node: Node) => void>;
  28571. private _isEnabled;
  28572. private _isParentEnabled;
  28573. private _isReady;
  28574. /** @hidden */
  28575. _currentRenderId: number;
  28576. private _parentUpdateId;
  28577. /** @hidden */
  28578. _childUpdateId: number;
  28579. /** @hidden */
  28580. _waitingParentId: Nullable<string>;
  28581. /** @hidden */
  28582. _scene: Scene;
  28583. /** @hidden */
  28584. _cache: any;
  28585. private _parentNode;
  28586. private _children;
  28587. /** @hidden */
  28588. _worldMatrix: Matrix;
  28589. /** @hidden */
  28590. _worldMatrixDeterminant: number;
  28591. /** @hidden */
  28592. _worldMatrixDeterminantIsDirty: boolean;
  28593. /** @hidden */
  28594. private _sceneRootNodesIndex;
  28595. /**
  28596. * Gets a boolean indicating if the node has been disposed
  28597. * @returns true if the node was disposed
  28598. */
  28599. isDisposed(): boolean;
  28600. /**
  28601. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28602. * @see https://doc.babylonjs.com/how_to/parenting
  28603. */
  28604. set parent(parent: Nullable<Node>);
  28605. get parent(): Nullable<Node>;
  28606. /** @hidden */
  28607. _addToSceneRootNodes(): void;
  28608. /** @hidden */
  28609. _removeFromSceneRootNodes(): void;
  28610. private _animationPropertiesOverride;
  28611. /**
  28612. * Gets or sets the animation properties override
  28613. */
  28614. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28615. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28616. /**
  28617. * Gets a string idenfifying the name of the class
  28618. * @returns "Node" string
  28619. */
  28620. getClassName(): string;
  28621. /** @hidden */
  28622. readonly _isNode: boolean;
  28623. /**
  28624. * An event triggered when the mesh is disposed
  28625. */
  28626. onDisposeObservable: Observable<Node>;
  28627. private _onDisposeObserver;
  28628. /**
  28629. * Sets a callback that will be raised when the node will be disposed
  28630. */
  28631. set onDispose(callback: () => void);
  28632. /**
  28633. * Creates a new Node
  28634. * @param name the name and id to be given to this node
  28635. * @param scene the scene this node will be added to
  28636. */
  28637. constructor(name: string, scene?: Nullable<Scene>);
  28638. /**
  28639. * Gets the scene of the node
  28640. * @returns a scene
  28641. */
  28642. getScene(): Scene;
  28643. /**
  28644. * Gets the engine of the node
  28645. * @returns a Engine
  28646. */
  28647. getEngine(): Engine;
  28648. private _behaviors;
  28649. /**
  28650. * Attach a behavior to the node
  28651. * @see http://doc.babylonjs.com/features/behaviour
  28652. * @param behavior defines the behavior to attach
  28653. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28654. * @returns the current Node
  28655. */
  28656. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28657. /**
  28658. * Remove an attached behavior
  28659. * @see http://doc.babylonjs.com/features/behaviour
  28660. * @param behavior defines the behavior to attach
  28661. * @returns the current Node
  28662. */
  28663. removeBehavior(behavior: Behavior<Node>): Node;
  28664. /**
  28665. * Gets the list of attached behaviors
  28666. * @see http://doc.babylonjs.com/features/behaviour
  28667. */
  28668. get behaviors(): Behavior<Node>[];
  28669. /**
  28670. * Gets an attached behavior by name
  28671. * @param name defines the name of the behavior to look for
  28672. * @see http://doc.babylonjs.com/features/behaviour
  28673. * @returns null if behavior was not found else the requested behavior
  28674. */
  28675. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28676. /**
  28677. * Returns the latest update of the World matrix
  28678. * @returns a Matrix
  28679. */
  28680. getWorldMatrix(): Matrix;
  28681. /** @hidden */
  28682. _getWorldMatrixDeterminant(): number;
  28683. /**
  28684. * Returns directly the latest state of the mesh World matrix.
  28685. * A Matrix is returned.
  28686. */
  28687. get worldMatrixFromCache(): Matrix;
  28688. /** @hidden */
  28689. _initCache(): void;
  28690. /** @hidden */
  28691. updateCache(force?: boolean): void;
  28692. /** @hidden */
  28693. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28694. /** @hidden */
  28695. _updateCache(ignoreParentClass?: boolean): void;
  28696. /** @hidden */
  28697. _isSynchronized(): boolean;
  28698. /** @hidden */
  28699. _markSyncedWithParent(): void;
  28700. /** @hidden */
  28701. isSynchronizedWithParent(): boolean;
  28702. /** @hidden */
  28703. isSynchronized(): boolean;
  28704. /**
  28705. * Is this node ready to be used/rendered
  28706. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28707. * @return true if the node is ready
  28708. */
  28709. isReady(completeCheck?: boolean): boolean;
  28710. /**
  28711. * Is this node enabled?
  28712. * 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
  28713. * @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
  28714. * @return whether this node (and its parent) is enabled
  28715. */
  28716. isEnabled(checkAncestors?: boolean): boolean;
  28717. /** @hidden */
  28718. protected _syncParentEnabledState(): void;
  28719. /**
  28720. * Set the enabled state of this node
  28721. * @param value defines the new enabled state
  28722. */
  28723. setEnabled(value: boolean): void;
  28724. /**
  28725. * Is this node a descendant of the given node?
  28726. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28727. * @param ancestor defines the parent node to inspect
  28728. * @returns a boolean indicating if this node is a descendant of the given node
  28729. */
  28730. isDescendantOf(ancestor: Node): boolean;
  28731. /** @hidden */
  28732. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28733. /**
  28734. * Will return all nodes that have this node as ascendant
  28735. * @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
  28736. * @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
  28737. * @return all children nodes of all types
  28738. */
  28739. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28740. /**
  28741. * Get all child-meshes of this node
  28742. * @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)
  28743. * @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
  28744. * @returns an array of AbstractMesh
  28745. */
  28746. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28747. /**
  28748. * Get all direct children of this node
  28749. * @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
  28750. * @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)
  28751. * @returns an array of Node
  28752. */
  28753. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28754. /** @hidden */
  28755. _setReady(state: boolean): void;
  28756. /**
  28757. * Get an animation by name
  28758. * @param name defines the name of the animation to look for
  28759. * @returns null if not found else the requested animation
  28760. */
  28761. getAnimationByName(name: string): Nullable<Animation>;
  28762. /**
  28763. * Creates an animation range for this node
  28764. * @param name defines the name of the range
  28765. * @param from defines the starting key
  28766. * @param to defines the end key
  28767. */
  28768. createAnimationRange(name: string, from: number, to: number): void;
  28769. /**
  28770. * Delete a specific animation range
  28771. * @param name defines the name of the range to delete
  28772. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28773. */
  28774. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28775. /**
  28776. * Get an animation range by name
  28777. * @param name defines the name of the animation range to look for
  28778. * @returns null if not found else the requested animation range
  28779. */
  28780. getAnimationRange(name: string): Nullable<AnimationRange>;
  28781. /**
  28782. * Gets the list of all animation ranges defined on this node
  28783. * @returns an array
  28784. */
  28785. getAnimationRanges(): Nullable<AnimationRange>[];
  28786. /**
  28787. * Will start the animation sequence
  28788. * @param name defines the range frames for animation sequence
  28789. * @param loop defines if the animation should loop (false by default)
  28790. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28791. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28792. * @returns the object created for this animation. If range does not exist, it will return null
  28793. */
  28794. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28795. /**
  28796. * Serialize animation ranges into a JSON compatible object
  28797. * @returns serialization object
  28798. */
  28799. serializeAnimationRanges(): any;
  28800. /**
  28801. * Computes the world matrix of the node
  28802. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28803. * @returns the world matrix
  28804. */
  28805. computeWorldMatrix(force?: boolean): Matrix;
  28806. /**
  28807. * Releases resources associated with this node.
  28808. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28809. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28810. */
  28811. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28812. /**
  28813. * Parse animation range data from a serialization object and store them into a given node
  28814. * @param node defines where to store the animation ranges
  28815. * @param parsedNode defines the serialization object to read data from
  28816. * @param scene defines the hosting scene
  28817. */
  28818. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28819. /**
  28820. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28821. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28822. * @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
  28823. * @returns the new bounding vectors
  28824. */
  28825. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28826. min: Vector3;
  28827. max: Vector3;
  28828. };
  28829. }
  28830. }
  28831. declare module BABYLON {
  28832. /**
  28833. * @hidden
  28834. */
  28835. export class _IAnimationState {
  28836. key: number;
  28837. repeatCount: number;
  28838. workValue?: any;
  28839. loopMode?: number;
  28840. offsetValue?: any;
  28841. highLimitValue?: any;
  28842. }
  28843. /**
  28844. * Class used to store any kind of animation
  28845. */
  28846. export class Animation {
  28847. /**Name of the animation */
  28848. name: string;
  28849. /**Property to animate */
  28850. targetProperty: string;
  28851. /**The frames per second of the animation */
  28852. framePerSecond: number;
  28853. /**The data type of the animation */
  28854. dataType: number;
  28855. /**The loop mode of the animation */
  28856. loopMode?: number | undefined;
  28857. /**Specifies if blending should be enabled */
  28858. enableBlending?: boolean | undefined;
  28859. /**
  28860. * Use matrix interpolation instead of using direct key value when animating matrices
  28861. */
  28862. static AllowMatricesInterpolation: boolean;
  28863. /**
  28864. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28865. */
  28866. static AllowMatrixDecomposeForInterpolation: boolean;
  28867. /**
  28868. * Stores the key frames of the animation
  28869. */
  28870. private _keys;
  28871. /**
  28872. * Stores the easing function of the animation
  28873. */
  28874. private _easingFunction;
  28875. /**
  28876. * @hidden Internal use only
  28877. */
  28878. _runtimeAnimations: RuntimeAnimation[];
  28879. /**
  28880. * The set of event that will be linked to this animation
  28881. */
  28882. private _events;
  28883. /**
  28884. * Stores an array of target property paths
  28885. */
  28886. targetPropertyPath: string[];
  28887. /**
  28888. * Stores the blending speed of the animation
  28889. */
  28890. blendingSpeed: number;
  28891. /**
  28892. * Stores the animation ranges for the animation
  28893. */
  28894. private _ranges;
  28895. /**
  28896. * @hidden Internal use
  28897. */
  28898. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28899. /**
  28900. * Sets up an animation
  28901. * @param property The property to animate
  28902. * @param animationType The animation type to apply
  28903. * @param framePerSecond The frames per second of the animation
  28904. * @param easingFunction The easing function used in the animation
  28905. * @returns The created animation
  28906. */
  28907. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28908. /**
  28909. * Create and start an animation on a node
  28910. * @param name defines the name of the global animation that will be run on all nodes
  28911. * @param node defines the root node where the animation will take place
  28912. * @param targetProperty defines property to animate
  28913. * @param framePerSecond defines the number of frame per second yo use
  28914. * @param totalFrame defines the number of frames in total
  28915. * @param from defines the initial value
  28916. * @param to defines the final value
  28917. * @param loopMode defines which loop mode you want to use (off by default)
  28918. * @param easingFunction defines the easing function to use (linear by default)
  28919. * @param onAnimationEnd defines the callback to call when animation end
  28920. * @returns the animatable created for this animation
  28921. */
  28922. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28923. /**
  28924. * Create and start an animation on a node and its descendants
  28925. * @param name defines the name of the global animation that will be run on all nodes
  28926. * @param node defines the root node where the animation will take place
  28927. * @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
  28928. * @param targetProperty defines property to animate
  28929. * @param framePerSecond defines the number of frame per second to use
  28930. * @param totalFrame defines the number of frames in total
  28931. * @param from defines the initial value
  28932. * @param to defines the final value
  28933. * @param loopMode defines which loop mode you want to use (off by default)
  28934. * @param easingFunction defines the easing function to use (linear by default)
  28935. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28936. * @returns the list of animatables created for all nodes
  28937. * @example https://www.babylonjs-playground.com/#MH0VLI
  28938. */
  28939. 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[]>;
  28940. /**
  28941. * Creates a new animation, merges it with the existing animations and starts it
  28942. * @param name Name of the animation
  28943. * @param node Node which contains the scene that begins the animations
  28944. * @param targetProperty Specifies which property to animate
  28945. * @param framePerSecond The frames per second of the animation
  28946. * @param totalFrame The total number of frames
  28947. * @param from The frame at the beginning of the animation
  28948. * @param to The frame at the end of the animation
  28949. * @param loopMode Specifies the loop mode of the animation
  28950. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28951. * @param onAnimationEnd Callback to run once the animation is complete
  28952. * @returns Nullable animation
  28953. */
  28954. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28955. /**
  28956. * Transition property of an host to the target Value
  28957. * @param property The property to transition
  28958. * @param targetValue The target Value of the property
  28959. * @param host The object where the property to animate belongs
  28960. * @param scene Scene used to run the animation
  28961. * @param frameRate Framerate (in frame/s) to use
  28962. * @param transition The transition type we want to use
  28963. * @param duration The duration of the animation, in milliseconds
  28964. * @param onAnimationEnd Callback trigger at the end of the animation
  28965. * @returns Nullable animation
  28966. */
  28967. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28968. /**
  28969. * Return the array of runtime animations currently using this animation
  28970. */
  28971. get runtimeAnimations(): RuntimeAnimation[];
  28972. /**
  28973. * Specifies if any of the runtime animations are currently running
  28974. */
  28975. get hasRunningRuntimeAnimations(): boolean;
  28976. /**
  28977. * Initializes the animation
  28978. * @param name Name of the animation
  28979. * @param targetProperty Property to animate
  28980. * @param framePerSecond The frames per second of the animation
  28981. * @param dataType The data type of the animation
  28982. * @param loopMode The loop mode of the animation
  28983. * @param enableBlending Specifies if blending should be enabled
  28984. */
  28985. constructor(
  28986. /**Name of the animation */
  28987. name: string,
  28988. /**Property to animate */
  28989. targetProperty: string,
  28990. /**The frames per second of the animation */
  28991. framePerSecond: number,
  28992. /**The data type of the animation */
  28993. dataType: number,
  28994. /**The loop mode of the animation */
  28995. loopMode?: number | undefined,
  28996. /**Specifies if blending should be enabled */
  28997. enableBlending?: boolean | undefined);
  28998. /**
  28999. * Converts the animation to a string
  29000. * @param fullDetails support for multiple levels of logging within scene loading
  29001. * @returns String form of the animation
  29002. */
  29003. toString(fullDetails?: boolean): string;
  29004. /**
  29005. * Add an event to this animation
  29006. * @param event Event to add
  29007. */
  29008. addEvent(event: AnimationEvent): void;
  29009. /**
  29010. * Remove all events found at the given frame
  29011. * @param frame The frame to remove events from
  29012. */
  29013. removeEvents(frame: number): void;
  29014. /**
  29015. * Retrieves all the events from the animation
  29016. * @returns Events from the animation
  29017. */
  29018. getEvents(): AnimationEvent[];
  29019. /**
  29020. * Creates an animation range
  29021. * @param name Name of the animation range
  29022. * @param from Starting frame of the animation range
  29023. * @param to Ending frame of the animation
  29024. */
  29025. createRange(name: string, from: number, to: number): void;
  29026. /**
  29027. * Deletes an animation range by name
  29028. * @param name Name of the animation range to delete
  29029. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29030. */
  29031. deleteRange(name: string, deleteFrames?: boolean): void;
  29032. /**
  29033. * Gets the animation range by name, or null if not defined
  29034. * @param name Name of the animation range
  29035. * @returns Nullable animation range
  29036. */
  29037. getRange(name: string): Nullable<AnimationRange>;
  29038. /**
  29039. * Gets the key frames from the animation
  29040. * @returns The key frames of the animation
  29041. */
  29042. getKeys(): Array<IAnimationKey>;
  29043. /**
  29044. * Gets the highest frame rate of the animation
  29045. * @returns Highest frame rate of the animation
  29046. */
  29047. getHighestFrame(): number;
  29048. /**
  29049. * Gets the easing function of the animation
  29050. * @returns Easing function of the animation
  29051. */
  29052. getEasingFunction(): IEasingFunction;
  29053. /**
  29054. * Sets the easing function of the animation
  29055. * @param easingFunction A custom mathematical formula for animation
  29056. */
  29057. setEasingFunction(easingFunction: EasingFunction): void;
  29058. /**
  29059. * Interpolates a scalar linearly
  29060. * @param startValue Start value of the animation curve
  29061. * @param endValue End value of the animation curve
  29062. * @param gradient Scalar amount to interpolate
  29063. * @returns Interpolated scalar value
  29064. */
  29065. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29066. /**
  29067. * Interpolates a scalar cubically
  29068. * @param startValue Start value of the animation curve
  29069. * @param outTangent End tangent of the animation
  29070. * @param endValue End value of the animation curve
  29071. * @param inTangent Start tangent of the animation curve
  29072. * @param gradient Scalar amount to interpolate
  29073. * @returns Interpolated scalar value
  29074. */
  29075. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29076. /**
  29077. * Interpolates a quaternion using a spherical linear interpolation
  29078. * @param startValue Start value of the animation curve
  29079. * @param endValue End value of the animation curve
  29080. * @param gradient Scalar amount to interpolate
  29081. * @returns Interpolated quaternion value
  29082. */
  29083. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29084. /**
  29085. * Interpolates a quaternion cubically
  29086. * @param startValue Start value of the animation curve
  29087. * @param outTangent End tangent of the animation curve
  29088. * @param endValue End value of the animation curve
  29089. * @param inTangent Start tangent of the animation curve
  29090. * @param gradient Scalar amount to interpolate
  29091. * @returns Interpolated quaternion value
  29092. */
  29093. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29094. /**
  29095. * Interpolates a Vector3 linearl
  29096. * @param startValue Start value of the animation curve
  29097. * @param endValue End value of the animation curve
  29098. * @param gradient Scalar amount to interpolate
  29099. * @returns Interpolated scalar value
  29100. */
  29101. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29102. /**
  29103. * Interpolates a Vector3 cubically
  29104. * @param startValue Start value of the animation curve
  29105. * @param outTangent End tangent of the animation
  29106. * @param endValue End value of the animation curve
  29107. * @param inTangent Start tangent of the animation curve
  29108. * @param gradient Scalar amount to interpolate
  29109. * @returns InterpolatedVector3 value
  29110. */
  29111. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29112. /**
  29113. * Interpolates a Vector2 linearly
  29114. * @param startValue Start value of the animation curve
  29115. * @param endValue End value of the animation curve
  29116. * @param gradient Scalar amount to interpolate
  29117. * @returns Interpolated Vector2 value
  29118. */
  29119. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29120. /**
  29121. * Interpolates a Vector2 cubically
  29122. * @param startValue Start value of the animation curve
  29123. * @param outTangent End tangent of the animation
  29124. * @param endValue End value of the animation curve
  29125. * @param inTangent Start tangent of the animation curve
  29126. * @param gradient Scalar amount to interpolate
  29127. * @returns Interpolated Vector2 value
  29128. */
  29129. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29130. /**
  29131. * Interpolates a size linearly
  29132. * @param startValue Start value of the animation curve
  29133. * @param endValue End value of the animation curve
  29134. * @param gradient Scalar amount to interpolate
  29135. * @returns Interpolated Size value
  29136. */
  29137. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29138. /**
  29139. * Interpolates a Color3 linearly
  29140. * @param startValue Start value of the animation curve
  29141. * @param endValue End value of the animation curve
  29142. * @param gradient Scalar amount to interpolate
  29143. * @returns Interpolated Color3 value
  29144. */
  29145. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29146. /**
  29147. * Interpolates a Color4 linearly
  29148. * @param startValue Start value of the animation curve
  29149. * @param endValue End value of the animation curve
  29150. * @param gradient Scalar amount to interpolate
  29151. * @returns Interpolated Color3 value
  29152. */
  29153. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29154. /**
  29155. * @hidden Internal use only
  29156. */
  29157. _getKeyValue(value: any): any;
  29158. /**
  29159. * @hidden Internal use only
  29160. */
  29161. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29162. /**
  29163. * Defines the function to use to interpolate matrices
  29164. * @param startValue defines the start matrix
  29165. * @param endValue defines the end matrix
  29166. * @param gradient defines the gradient between both matrices
  29167. * @param result defines an optional target matrix where to store the interpolation
  29168. * @returns the interpolated matrix
  29169. */
  29170. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29171. /**
  29172. * Makes a copy of the animation
  29173. * @returns Cloned animation
  29174. */
  29175. clone(): Animation;
  29176. /**
  29177. * Sets the key frames of the animation
  29178. * @param values The animation key frames to set
  29179. */
  29180. setKeys(values: Array<IAnimationKey>): void;
  29181. /**
  29182. * Serializes the animation to an object
  29183. * @returns Serialized object
  29184. */
  29185. serialize(): any;
  29186. /**
  29187. * Float animation type
  29188. */
  29189. static readonly ANIMATIONTYPE_FLOAT: number;
  29190. /**
  29191. * Vector3 animation type
  29192. */
  29193. static readonly ANIMATIONTYPE_VECTOR3: number;
  29194. /**
  29195. * Quaternion animation type
  29196. */
  29197. static readonly ANIMATIONTYPE_QUATERNION: number;
  29198. /**
  29199. * Matrix animation type
  29200. */
  29201. static readonly ANIMATIONTYPE_MATRIX: number;
  29202. /**
  29203. * Color3 animation type
  29204. */
  29205. static readonly ANIMATIONTYPE_COLOR3: number;
  29206. /**
  29207. * Color3 animation type
  29208. */
  29209. static readonly ANIMATIONTYPE_COLOR4: number;
  29210. /**
  29211. * Vector2 animation type
  29212. */
  29213. static readonly ANIMATIONTYPE_VECTOR2: number;
  29214. /**
  29215. * Size animation type
  29216. */
  29217. static readonly ANIMATIONTYPE_SIZE: number;
  29218. /**
  29219. * Relative Loop Mode
  29220. */
  29221. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29222. /**
  29223. * Cycle Loop Mode
  29224. */
  29225. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29226. /**
  29227. * Constant Loop Mode
  29228. */
  29229. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29230. /** @hidden */
  29231. static _UniversalLerp(left: any, right: any, amount: number): any;
  29232. /**
  29233. * Parses an animation object and creates an animation
  29234. * @param parsedAnimation Parsed animation object
  29235. * @returns Animation object
  29236. */
  29237. static Parse(parsedAnimation: any): Animation;
  29238. /**
  29239. * Appends the serialized animations from the source animations
  29240. * @param source Source containing the animations
  29241. * @param destination Target to store the animations
  29242. */
  29243. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29244. }
  29245. }
  29246. declare module BABYLON {
  29247. /**
  29248. * Interface containing an array of animations
  29249. */
  29250. export interface IAnimatable {
  29251. /**
  29252. * Array of animations
  29253. */
  29254. animations: Nullable<Array<Animation>>;
  29255. }
  29256. }
  29257. declare module BABYLON {
  29258. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29259. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29260. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29261. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29262. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29263. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29264. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29265. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29266. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29267. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29268. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29269. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29270. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29271. /**
  29272. * Decorator used to define property that can be serialized as reference to a camera
  29273. * @param sourceName defines the name of the property to decorate
  29274. */
  29275. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29276. /**
  29277. * Class used to help serialization objects
  29278. */
  29279. export class SerializationHelper {
  29280. /** @hidden */
  29281. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29282. /** @hidden */
  29283. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29284. /** @hidden */
  29285. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29286. /** @hidden */
  29287. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29288. /**
  29289. * Appends the serialized animations from the source animations
  29290. * @param source Source containing the animations
  29291. * @param destination Target to store the animations
  29292. */
  29293. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29294. /**
  29295. * Static function used to serialized a specific entity
  29296. * @param entity defines the entity to serialize
  29297. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29298. * @returns a JSON compatible object representing the serialization of the entity
  29299. */
  29300. static Serialize<T>(entity: T, serializationObject?: any): any;
  29301. /**
  29302. * Creates a new entity from a serialization data object
  29303. * @param creationFunction defines a function used to instanciated the new entity
  29304. * @param source defines the source serialization data
  29305. * @param scene defines the hosting scene
  29306. * @param rootUrl defines the root url for resources
  29307. * @returns a new entity
  29308. */
  29309. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29310. /**
  29311. * Clones an object
  29312. * @param creationFunction defines the function used to instanciate the new object
  29313. * @param source defines the source object
  29314. * @returns the cloned object
  29315. */
  29316. static Clone<T>(creationFunction: () => T, source: T): T;
  29317. /**
  29318. * Instanciates a new object based on a source one (some data will be shared between both object)
  29319. * @param creationFunction defines the function used to instanciate the new object
  29320. * @param source defines the source object
  29321. * @returns the new object
  29322. */
  29323. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29324. }
  29325. }
  29326. declare module BABYLON {
  29327. /**
  29328. * Class used to manipulate GUIDs
  29329. */
  29330. export class GUID {
  29331. /**
  29332. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29333. * Be aware Math.random() could cause collisions, but:
  29334. * "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"
  29335. * @returns a pseudo random id
  29336. */
  29337. static RandomId(): string;
  29338. }
  29339. }
  29340. declare module BABYLON {
  29341. /**
  29342. * Base class of all the textures in babylon.
  29343. * It groups all the common properties the materials, post process, lights... might need
  29344. * in order to make a correct use of the texture.
  29345. */
  29346. export class BaseTexture implements IAnimatable {
  29347. /**
  29348. * Default anisotropic filtering level for the application.
  29349. * It is set to 4 as a good tradeoff between perf and quality.
  29350. */
  29351. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29352. /**
  29353. * Gets or sets the unique id of the texture
  29354. */
  29355. uniqueId: number;
  29356. /**
  29357. * Define the name of the texture.
  29358. */
  29359. name: string;
  29360. /**
  29361. * Gets or sets an object used to store user defined information.
  29362. */
  29363. metadata: any;
  29364. /**
  29365. * For internal use only. Please do not use.
  29366. */
  29367. reservedDataStore: any;
  29368. private _hasAlpha;
  29369. /**
  29370. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29371. */
  29372. set hasAlpha(value: boolean);
  29373. get hasAlpha(): boolean;
  29374. /**
  29375. * Defines if the alpha value should be determined via the rgb values.
  29376. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29377. */
  29378. getAlphaFromRGB: boolean;
  29379. /**
  29380. * Intensity or strength of the texture.
  29381. * It is commonly used by materials to fine tune the intensity of the texture
  29382. */
  29383. level: number;
  29384. /**
  29385. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29386. * This is part of the texture as textures usually maps to one uv set.
  29387. */
  29388. coordinatesIndex: number;
  29389. private _coordinatesMode;
  29390. /**
  29391. * How a texture is mapped.
  29392. *
  29393. * | Value | Type | Description |
  29394. * | ----- | ----------------------------------- | ----------- |
  29395. * | 0 | EXPLICIT_MODE | |
  29396. * | 1 | SPHERICAL_MODE | |
  29397. * | 2 | PLANAR_MODE | |
  29398. * | 3 | CUBIC_MODE | |
  29399. * | 4 | PROJECTION_MODE | |
  29400. * | 5 | SKYBOX_MODE | |
  29401. * | 6 | INVCUBIC_MODE | |
  29402. * | 7 | EQUIRECTANGULAR_MODE | |
  29403. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29404. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29405. */
  29406. set coordinatesMode(value: number);
  29407. get coordinatesMode(): number;
  29408. /**
  29409. * | Value | Type | Description |
  29410. * | ----- | ------------------ | ----------- |
  29411. * | 0 | CLAMP_ADDRESSMODE | |
  29412. * | 1 | WRAP_ADDRESSMODE | |
  29413. * | 2 | MIRROR_ADDRESSMODE | |
  29414. */
  29415. wrapU: number;
  29416. /**
  29417. * | Value | Type | Description |
  29418. * | ----- | ------------------ | ----------- |
  29419. * | 0 | CLAMP_ADDRESSMODE | |
  29420. * | 1 | WRAP_ADDRESSMODE | |
  29421. * | 2 | MIRROR_ADDRESSMODE | |
  29422. */
  29423. wrapV: number;
  29424. /**
  29425. * | Value | Type | Description |
  29426. * | ----- | ------------------ | ----------- |
  29427. * | 0 | CLAMP_ADDRESSMODE | |
  29428. * | 1 | WRAP_ADDRESSMODE | |
  29429. * | 2 | MIRROR_ADDRESSMODE | |
  29430. */
  29431. wrapR: number;
  29432. /**
  29433. * With compliant hardware and browser (supporting anisotropic filtering)
  29434. * this defines the level of anisotropic filtering in the texture.
  29435. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29436. */
  29437. anisotropicFilteringLevel: number;
  29438. /**
  29439. * Define if the texture is a cube texture or if false a 2d texture.
  29440. */
  29441. get isCube(): boolean;
  29442. set isCube(value: boolean);
  29443. /**
  29444. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29445. */
  29446. get is3D(): boolean;
  29447. set is3D(value: boolean);
  29448. /**
  29449. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29450. */
  29451. get is2DArray(): boolean;
  29452. set is2DArray(value: boolean);
  29453. /**
  29454. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29455. * HDR texture are usually stored in linear space.
  29456. * This only impacts the PBR and Background materials
  29457. */
  29458. gammaSpace: boolean;
  29459. /**
  29460. * Gets or sets whether or not the texture contains RGBD data.
  29461. */
  29462. get isRGBD(): boolean;
  29463. set isRGBD(value: boolean);
  29464. /**
  29465. * Is Z inverted in the texture (useful in a cube texture).
  29466. */
  29467. invertZ: boolean;
  29468. /**
  29469. * Are mip maps generated for this texture or not.
  29470. */
  29471. get noMipmap(): boolean;
  29472. /**
  29473. * @hidden
  29474. */
  29475. lodLevelInAlpha: boolean;
  29476. /**
  29477. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29478. */
  29479. get lodGenerationOffset(): number;
  29480. set lodGenerationOffset(value: number);
  29481. /**
  29482. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29483. */
  29484. get lodGenerationScale(): number;
  29485. set lodGenerationScale(value: number);
  29486. /**
  29487. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29488. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29489. * average roughness values.
  29490. */
  29491. get linearSpecularLOD(): boolean;
  29492. set linearSpecularLOD(value: boolean);
  29493. /**
  29494. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29495. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29496. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29497. */
  29498. get irradianceTexture(): Nullable<BaseTexture>;
  29499. set irradianceTexture(value: Nullable<BaseTexture>);
  29500. /**
  29501. * Define if the texture is a render target.
  29502. */
  29503. isRenderTarget: boolean;
  29504. /**
  29505. * Define the unique id of the texture in the scene.
  29506. */
  29507. get uid(): string;
  29508. /**
  29509. * Return a string representation of the texture.
  29510. * @returns the texture as a string
  29511. */
  29512. toString(): string;
  29513. /**
  29514. * Get the class name of the texture.
  29515. * @returns "BaseTexture"
  29516. */
  29517. getClassName(): string;
  29518. /**
  29519. * Define the list of animation attached to the texture.
  29520. */
  29521. animations: Animation[];
  29522. /**
  29523. * An event triggered when the texture is disposed.
  29524. */
  29525. onDisposeObservable: Observable<BaseTexture>;
  29526. private _onDisposeObserver;
  29527. /**
  29528. * Callback triggered when the texture has been disposed.
  29529. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29530. */
  29531. set onDispose(callback: () => void);
  29532. /**
  29533. * Define the current state of the loading sequence when in delayed load mode.
  29534. */
  29535. delayLoadState: number;
  29536. private _scene;
  29537. /** @hidden */
  29538. _texture: Nullable<InternalTexture>;
  29539. private _uid;
  29540. /**
  29541. * Define if the texture is preventinga material to render or not.
  29542. * If not and the texture is not ready, the engine will use a default black texture instead.
  29543. */
  29544. get isBlocking(): boolean;
  29545. /**
  29546. * Instantiates a new BaseTexture.
  29547. * Base class of all the textures in babylon.
  29548. * It groups all the common properties the materials, post process, lights... might need
  29549. * in order to make a correct use of the texture.
  29550. * @param scene Define the scene the texture blongs to
  29551. */
  29552. constructor(scene: Nullable<Scene>);
  29553. /**
  29554. * Get the scene the texture belongs to.
  29555. * @returns the scene or null if undefined
  29556. */
  29557. getScene(): Nullable<Scene>;
  29558. /**
  29559. * Get the texture transform matrix used to offset tile the texture for istance.
  29560. * @returns the transformation matrix
  29561. */
  29562. getTextureMatrix(): Matrix;
  29563. /**
  29564. * Get the texture reflection matrix used to rotate/transform the reflection.
  29565. * @returns the reflection matrix
  29566. */
  29567. getReflectionTextureMatrix(): Matrix;
  29568. /**
  29569. * Get the underlying lower level texture from Babylon.
  29570. * @returns the insternal texture
  29571. */
  29572. getInternalTexture(): Nullable<InternalTexture>;
  29573. /**
  29574. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29575. * @returns true if ready or not blocking
  29576. */
  29577. isReadyOrNotBlocking(): boolean;
  29578. /**
  29579. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29580. * @returns true if fully ready
  29581. */
  29582. isReady(): boolean;
  29583. private _cachedSize;
  29584. /**
  29585. * Get the size of the texture.
  29586. * @returns the texture size.
  29587. */
  29588. getSize(): ISize;
  29589. /**
  29590. * Get the base size of the texture.
  29591. * It can be different from the size if the texture has been resized for POT for instance
  29592. * @returns the base size
  29593. */
  29594. getBaseSize(): ISize;
  29595. /**
  29596. * Update the sampling mode of the texture.
  29597. * Default is Trilinear mode.
  29598. *
  29599. * | Value | Type | Description |
  29600. * | ----- | ------------------ | ----------- |
  29601. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29602. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29603. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29604. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29605. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29606. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29607. * | 7 | NEAREST_LINEAR | |
  29608. * | 8 | NEAREST_NEAREST | |
  29609. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29610. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29611. * | 11 | LINEAR_LINEAR | |
  29612. * | 12 | LINEAR_NEAREST | |
  29613. *
  29614. * > _mag_: magnification filter (close to the viewer)
  29615. * > _min_: minification filter (far from the viewer)
  29616. * > _mip_: filter used between mip map levels
  29617. *@param samplingMode Define the new sampling mode of the texture
  29618. */
  29619. updateSamplingMode(samplingMode: number): void;
  29620. /**
  29621. * Scales the texture if is `canRescale()`
  29622. * @param ratio the resize factor we want to use to rescale
  29623. */
  29624. scale(ratio: number): void;
  29625. /**
  29626. * Get if the texture can rescale.
  29627. */
  29628. get canRescale(): boolean;
  29629. /** @hidden */
  29630. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29631. /** @hidden */
  29632. _rebuild(): void;
  29633. /**
  29634. * Triggers the load sequence in delayed load mode.
  29635. */
  29636. delayLoad(): void;
  29637. /**
  29638. * Clones the texture.
  29639. * @returns the cloned texture
  29640. */
  29641. clone(): Nullable<BaseTexture>;
  29642. /**
  29643. * Get the texture underlying type (INT, FLOAT...)
  29644. */
  29645. get textureType(): number;
  29646. /**
  29647. * Get the texture underlying format (RGB, RGBA...)
  29648. */
  29649. get textureFormat(): number;
  29650. /**
  29651. * Indicates that textures need to be re-calculated for all materials
  29652. */
  29653. protected _markAllSubMeshesAsTexturesDirty(): void;
  29654. /**
  29655. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29656. * This will returns an RGBA array buffer containing either in values (0-255) or
  29657. * float values (0-1) depending of the underlying buffer type.
  29658. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29659. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29660. * @param buffer defines a user defined buffer to fill with data (can be null)
  29661. * @returns The Array buffer containing the pixels data.
  29662. */
  29663. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29664. /**
  29665. * Release and destroy the underlying lower level texture aka internalTexture.
  29666. */
  29667. releaseInternalTexture(): void;
  29668. /** @hidden */
  29669. get _lodTextureHigh(): Nullable<BaseTexture>;
  29670. /** @hidden */
  29671. get _lodTextureMid(): Nullable<BaseTexture>;
  29672. /** @hidden */
  29673. get _lodTextureLow(): Nullable<BaseTexture>;
  29674. /**
  29675. * Dispose the texture and release its associated resources.
  29676. */
  29677. dispose(): void;
  29678. /**
  29679. * Serialize the texture into a JSON representation that can be parsed later on.
  29680. * @returns the JSON representation of the texture
  29681. */
  29682. serialize(): any;
  29683. /**
  29684. * Helper function to be called back once a list of texture contains only ready textures.
  29685. * @param textures Define the list of textures to wait for
  29686. * @param callback Define the callback triggered once the entire list will be ready
  29687. */
  29688. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29689. }
  29690. }
  29691. declare module BABYLON {
  29692. /**
  29693. * Options to be used when creating an effect.
  29694. */
  29695. export interface IEffectCreationOptions {
  29696. /**
  29697. * Atrributes that will be used in the shader.
  29698. */
  29699. attributes: string[];
  29700. /**
  29701. * Uniform varible names that will be set in the shader.
  29702. */
  29703. uniformsNames: string[];
  29704. /**
  29705. * Uniform buffer variable names that will be set in the shader.
  29706. */
  29707. uniformBuffersNames: string[];
  29708. /**
  29709. * Sampler texture variable names that will be set in the shader.
  29710. */
  29711. samplers: string[];
  29712. /**
  29713. * Define statements that will be set in the shader.
  29714. */
  29715. defines: any;
  29716. /**
  29717. * Possible fallbacks for this effect to improve performance when needed.
  29718. */
  29719. fallbacks: Nullable<IEffectFallbacks>;
  29720. /**
  29721. * Callback that will be called when the shader is compiled.
  29722. */
  29723. onCompiled: Nullable<(effect: Effect) => void>;
  29724. /**
  29725. * Callback that will be called if an error occurs during shader compilation.
  29726. */
  29727. onError: Nullable<(effect: Effect, errors: string) => void>;
  29728. /**
  29729. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29730. */
  29731. indexParameters?: any;
  29732. /**
  29733. * Max number of lights that can be used in the shader.
  29734. */
  29735. maxSimultaneousLights?: number;
  29736. /**
  29737. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29738. */
  29739. transformFeedbackVaryings?: Nullable<string[]>;
  29740. }
  29741. /**
  29742. * Effect containing vertex and fragment shader that can be executed on an object.
  29743. */
  29744. export class Effect implements IDisposable {
  29745. /**
  29746. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29747. */
  29748. static ShadersRepository: string;
  29749. /**
  29750. * Name of the effect.
  29751. */
  29752. name: any;
  29753. /**
  29754. * String container all the define statements that should be set on the shader.
  29755. */
  29756. defines: string;
  29757. /**
  29758. * Callback that will be called when the shader is compiled.
  29759. */
  29760. onCompiled: Nullable<(effect: Effect) => void>;
  29761. /**
  29762. * Callback that will be called if an error occurs during shader compilation.
  29763. */
  29764. onError: Nullable<(effect: Effect, errors: string) => void>;
  29765. /**
  29766. * Callback that will be called when effect is bound.
  29767. */
  29768. onBind: Nullable<(effect: Effect) => void>;
  29769. /**
  29770. * Unique ID of the effect.
  29771. */
  29772. uniqueId: number;
  29773. /**
  29774. * Observable that will be called when the shader is compiled.
  29775. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29776. */
  29777. onCompileObservable: Observable<Effect>;
  29778. /**
  29779. * Observable that will be called if an error occurs during shader compilation.
  29780. */
  29781. onErrorObservable: Observable<Effect>;
  29782. /** @hidden */
  29783. _onBindObservable: Nullable<Observable<Effect>>;
  29784. /**
  29785. * Observable that will be called when effect is bound.
  29786. */
  29787. get onBindObservable(): Observable<Effect>;
  29788. /** @hidden */
  29789. _bonesComputationForcedToCPU: boolean;
  29790. private static _uniqueIdSeed;
  29791. private _engine;
  29792. private _uniformBuffersNames;
  29793. private _uniformsNames;
  29794. private _samplerList;
  29795. private _samplers;
  29796. private _isReady;
  29797. private _compilationError;
  29798. private _allFallbacksProcessed;
  29799. private _attributesNames;
  29800. private _attributes;
  29801. private _attributeLocationByName;
  29802. private _uniforms;
  29803. /**
  29804. * Key for the effect.
  29805. * @hidden
  29806. */
  29807. _key: string;
  29808. private _indexParameters;
  29809. private _fallbacks;
  29810. private _vertexSourceCode;
  29811. private _fragmentSourceCode;
  29812. private _vertexSourceCodeOverride;
  29813. private _fragmentSourceCodeOverride;
  29814. private _transformFeedbackVaryings;
  29815. /**
  29816. * Compiled shader to webGL program.
  29817. * @hidden
  29818. */
  29819. _pipelineContext: Nullable<IPipelineContext>;
  29820. private _valueCache;
  29821. private static _baseCache;
  29822. /**
  29823. * Instantiates an effect.
  29824. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29825. * @param baseName Name of the effect.
  29826. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29827. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29828. * @param samplers List of sampler variables that will be passed to the shader.
  29829. * @param engine Engine to be used to render the effect
  29830. * @param defines Define statements to be added to the shader.
  29831. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29832. * @param onCompiled Callback that will be called when the shader is compiled.
  29833. * @param onError Callback that will be called if an error occurs during shader compilation.
  29834. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29835. */
  29836. 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);
  29837. private _useFinalCode;
  29838. /**
  29839. * Unique key for this effect
  29840. */
  29841. get key(): string;
  29842. /**
  29843. * If the effect has been compiled and prepared.
  29844. * @returns if the effect is compiled and prepared.
  29845. */
  29846. isReady(): boolean;
  29847. private _isReadyInternal;
  29848. /**
  29849. * The engine the effect was initialized with.
  29850. * @returns the engine.
  29851. */
  29852. getEngine(): Engine;
  29853. /**
  29854. * The pipeline context for this effect
  29855. * @returns the associated pipeline context
  29856. */
  29857. getPipelineContext(): Nullable<IPipelineContext>;
  29858. /**
  29859. * The set of names of attribute variables for the shader.
  29860. * @returns An array of attribute names.
  29861. */
  29862. getAttributesNames(): string[];
  29863. /**
  29864. * Returns the attribute at the given index.
  29865. * @param index The index of the attribute.
  29866. * @returns The location of the attribute.
  29867. */
  29868. getAttributeLocation(index: number): number;
  29869. /**
  29870. * Returns the attribute based on the name of the variable.
  29871. * @param name of the attribute to look up.
  29872. * @returns the attribute location.
  29873. */
  29874. getAttributeLocationByName(name: string): number;
  29875. /**
  29876. * The number of attributes.
  29877. * @returns the numnber of attributes.
  29878. */
  29879. getAttributesCount(): number;
  29880. /**
  29881. * Gets the index of a uniform variable.
  29882. * @param uniformName of the uniform to look up.
  29883. * @returns the index.
  29884. */
  29885. getUniformIndex(uniformName: string): number;
  29886. /**
  29887. * Returns the attribute based on the name of the variable.
  29888. * @param uniformName of the uniform to look up.
  29889. * @returns the location of the uniform.
  29890. */
  29891. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29892. /**
  29893. * Returns an array of sampler variable names
  29894. * @returns The array of sampler variable neames.
  29895. */
  29896. getSamplers(): string[];
  29897. /**
  29898. * The error from the last compilation.
  29899. * @returns the error string.
  29900. */
  29901. getCompilationError(): string;
  29902. /**
  29903. * Gets a boolean indicating that all fallbacks were used during compilation
  29904. * @returns true if all fallbacks were used
  29905. */
  29906. allFallbacksProcessed(): boolean;
  29907. /**
  29908. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29909. * @param func The callback to be used.
  29910. */
  29911. executeWhenCompiled(func: (effect: Effect) => void): void;
  29912. private _checkIsReady;
  29913. private _loadShader;
  29914. /**
  29915. * Recompiles the webGL program
  29916. * @param vertexSourceCode The source code for the vertex shader.
  29917. * @param fragmentSourceCode The source code for the fragment shader.
  29918. * @param onCompiled Callback called when completed.
  29919. * @param onError Callback called on error.
  29920. * @hidden
  29921. */
  29922. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29923. /**
  29924. * Prepares the effect
  29925. * @hidden
  29926. */
  29927. _prepareEffect(): void;
  29928. private _processCompilationErrors;
  29929. /**
  29930. * Checks if the effect is supported. (Must be called after compilation)
  29931. */
  29932. get isSupported(): boolean;
  29933. /**
  29934. * Binds a texture to the engine to be used as output of the shader.
  29935. * @param channel Name of the output variable.
  29936. * @param texture Texture to bind.
  29937. * @hidden
  29938. */
  29939. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29940. /**
  29941. * Sets a texture on the engine to be used in the shader.
  29942. * @param channel Name of the sampler variable.
  29943. * @param texture Texture to set.
  29944. */
  29945. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29946. /**
  29947. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29948. * @param channel Name of the sampler variable.
  29949. * @param texture Texture to set.
  29950. */
  29951. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29952. /**
  29953. * Sets an array of textures on the engine to be used in the shader.
  29954. * @param channel Name of the variable.
  29955. * @param textures Textures to set.
  29956. */
  29957. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29958. /**
  29959. * 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)
  29960. * @param channel Name of the sampler variable.
  29961. * @param postProcess Post process to get the input texture from.
  29962. */
  29963. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29964. /**
  29965. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29966. * 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)
  29967. * @param channel Name of the sampler variable.
  29968. * @param postProcess Post process to get the output texture from.
  29969. */
  29970. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29971. /** @hidden */
  29972. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29973. /** @hidden */
  29974. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29975. /** @hidden */
  29976. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29977. /** @hidden */
  29978. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29979. /**
  29980. * Binds a buffer to a uniform.
  29981. * @param buffer Buffer to bind.
  29982. * @param name Name of the uniform variable to bind to.
  29983. */
  29984. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29985. /**
  29986. * Binds block to a uniform.
  29987. * @param blockName Name of the block to bind.
  29988. * @param index Index to bind.
  29989. */
  29990. bindUniformBlock(blockName: string, index: number): void;
  29991. /**
  29992. * Sets an interger value on a uniform variable.
  29993. * @param uniformName Name of the variable.
  29994. * @param value Value to be set.
  29995. * @returns this effect.
  29996. */
  29997. setInt(uniformName: string, value: number): Effect;
  29998. /**
  29999. * Sets an int array on a uniform variable.
  30000. * @param uniformName Name of the variable.
  30001. * @param array array to be set.
  30002. * @returns this effect.
  30003. */
  30004. setIntArray(uniformName: string, array: Int32Array): Effect;
  30005. /**
  30006. * 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)
  30007. * @param uniformName Name of the variable.
  30008. * @param array array to be set.
  30009. * @returns this effect.
  30010. */
  30011. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30012. /**
  30013. * 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)
  30014. * @param uniformName Name of the variable.
  30015. * @param array array to be set.
  30016. * @returns this effect.
  30017. */
  30018. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30019. /**
  30020. * 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)
  30021. * @param uniformName Name of the variable.
  30022. * @param array array to be set.
  30023. * @returns this effect.
  30024. */
  30025. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30026. /**
  30027. * Sets an float array on a uniform variable.
  30028. * @param uniformName Name of the variable.
  30029. * @param array array to be set.
  30030. * @returns this effect.
  30031. */
  30032. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30033. /**
  30034. * 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)
  30035. * @param uniformName Name of the variable.
  30036. * @param array array to be set.
  30037. * @returns this effect.
  30038. */
  30039. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30040. /**
  30041. * 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)
  30042. * @param uniformName Name of the variable.
  30043. * @param array array to be set.
  30044. * @returns this effect.
  30045. */
  30046. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30047. /**
  30048. * 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)
  30049. * @param uniformName Name of the variable.
  30050. * @param array array to be set.
  30051. * @returns this effect.
  30052. */
  30053. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30054. /**
  30055. * Sets an array on a uniform variable.
  30056. * @param uniformName Name of the variable.
  30057. * @param array array to be set.
  30058. * @returns this effect.
  30059. */
  30060. setArray(uniformName: string, array: number[]): Effect;
  30061. /**
  30062. * 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)
  30063. * @param uniformName Name of the variable.
  30064. * @param array array to be set.
  30065. * @returns this effect.
  30066. */
  30067. setArray2(uniformName: string, array: number[]): Effect;
  30068. /**
  30069. * 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)
  30070. * @param uniformName Name of the variable.
  30071. * @param array array to be set.
  30072. * @returns this effect.
  30073. */
  30074. setArray3(uniformName: string, array: number[]): Effect;
  30075. /**
  30076. * 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)
  30077. * @param uniformName Name of the variable.
  30078. * @param array array to be set.
  30079. * @returns this effect.
  30080. */
  30081. setArray4(uniformName: string, array: number[]): Effect;
  30082. /**
  30083. * Sets matrices on a uniform variable.
  30084. * @param uniformName Name of the variable.
  30085. * @param matrices matrices to be set.
  30086. * @returns this effect.
  30087. */
  30088. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30089. /**
  30090. * Sets matrix on a uniform variable.
  30091. * @param uniformName Name of the variable.
  30092. * @param matrix matrix to be set.
  30093. * @returns this effect.
  30094. */
  30095. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30096. /**
  30097. * 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)
  30098. * @param uniformName Name of the variable.
  30099. * @param matrix matrix to be set.
  30100. * @returns this effect.
  30101. */
  30102. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30103. /**
  30104. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30105. * @param uniformName Name of the variable.
  30106. * @param matrix matrix to be set.
  30107. * @returns this effect.
  30108. */
  30109. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30110. /**
  30111. * Sets a float on a uniform variable.
  30112. * @param uniformName Name of the variable.
  30113. * @param value value to be set.
  30114. * @returns this effect.
  30115. */
  30116. setFloat(uniformName: string, value: number): Effect;
  30117. /**
  30118. * Sets a boolean on a uniform variable.
  30119. * @param uniformName Name of the variable.
  30120. * @param bool value to be set.
  30121. * @returns this effect.
  30122. */
  30123. setBool(uniformName: string, bool: boolean): Effect;
  30124. /**
  30125. * Sets a Vector2 on a uniform variable.
  30126. * @param uniformName Name of the variable.
  30127. * @param vector2 vector2 to be set.
  30128. * @returns this effect.
  30129. */
  30130. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30131. /**
  30132. * Sets a float2 on a uniform variable.
  30133. * @param uniformName Name of the variable.
  30134. * @param x First float in float2.
  30135. * @param y Second float in float2.
  30136. * @returns this effect.
  30137. */
  30138. setFloat2(uniformName: string, x: number, y: number): Effect;
  30139. /**
  30140. * Sets a Vector3 on a uniform variable.
  30141. * @param uniformName Name of the variable.
  30142. * @param vector3 Value to be set.
  30143. * @returns this effect.
  30144. */
  30145. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30146. /**
  30147. * Sets a float3 on a uniform variable.
  30148. * @param uniformName Name of the variable.
  30149. * @param x First float in float3.
  30150. * @param y Second float in float3.
  30151. * @param z Third float in float3.
  30152. * @returns this effect.
  30153. */
  30154. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30155. /**
  30156. * Sets a Vector4 on a uniform variable.
  30157. * @param uniformName Name of the variable.
  30158. * @param vector4 Value to be set.
  30159. * @returns this effect.
  30160. */
  30161. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30162. /**
  30163. * Sets a float4 on a uniform variable.
  30164. * @param uniformName Name of the variable.
  30165. * @param x First float in float4.
  30166. * @param y Second float in float4.
  30167. * @param z Third float in float4.
  30168. * @param w Fourth float in float4.
  30169. * @returns this effect.
  30170. */
  30171. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30172. /**
  30173. * Sets a Color3 on a uniform variable.
  30174. * @param uniformName Name of the variable.
  30175. * @param color3 Value to be set.
  30176. * @returns this effect.
  30177. */
  30178. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30179. /**
  30180. * Sets a Color4 on a uniform variable.
  30181. * @param uniformName Name of the variable.
  30182. * @param color3 Value to be set.
  30183. * @param alpha Alpha value to be set.
  30184. * @returns this effect.
  30185. */
  30186. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30187. /**
  30188. * Sets a Color4 on a uniform variable
  30189. * @param uniformName defines the name of the variable
  30190. * @param color4 defines the value to be set
  30191. * @returns this effect.
  30192. */
  30193. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30194. /** Release all associated resources */
  30195. dispose(): void;
  30196. /**
  30197. * This function will add a new shader to the shader store
  30198. * @param name the name of the shader
  30199. * @param pixelShader optional pixel shader content
  30200. * @param vertexShader optional vertex shader content
  30201. */
  30202. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30203. /**
  30204. * Store of each shader (The can be looked up using effect.key)
  30205. */
  30206. static ShadersStore: {
  30207. [key: string]: string;
  30208. };
  30209. /**
  30210. * Store of each included file for a shader (The can be looked up using effect.key)
  30211. */
  30212. static IncludesShadersStore: {
  30213. [key: string]: string;
  30214. };
  30215. /**
  30216. * Resets the cache of effects.
  30217. */
  30218. static ResetCache(): void;
  30219. }
  30220. }
  30221. declare module BABYLON {
  30222. /**
  30223. * Interface used to describe the capabilities of the engine relatively to the current browser
  30224. */
  30225. export interface EngineCapabilities {
  30226. /** Maximum textures units per fragment shader */
  30227. maxTexturesImageUnits: number;
  30228. /** Maximum texture units per vertex shader */
  30229. maxVertexTextureImageUnits: number;
  30230. /** Maximum textures units in the entire pipeline */
  30231. maxCombinedTexturesImageUnits: number;
  30232. /** Maximum texture size */
  30233. maxTextureSize: number;
  30234. /** Maximum texture samples */
  30235. maxSamples?: number;
  30236. /** Maximum cube texture size */
  30237. maxCubemapTextureSize: number;
  30238. /** Maximum render texture size */
  30239. maxRenderTextureSize: number;
  30240. /** Maximum number of vertex attributes */
  30241. maxVertexAttribs: number;
  30242. /** Maximum number of varyings */
  30243. maxVaryingVectors: number;
  30244. /** Maximum number of uniforms per vertex shader */
  30245. maxVertexUniformVectors: number;
  30246. /** Maximum number of uniforms per fragment shader */
  30247. maxFragmentUniformVectors: number;
  30248. /** Defines if standard derivates (dx/dy) are supported */
  30249. standardDerivatives: boolean;
  30250. /** Defines if s3tc texture compression is supported */
  30251. s3tc?: WEBGL_compressed_texture_s3tc;
  30252. /** Defines if pvrtc texture compression is supported */
  30253. pvrtc: any;
  30254. /** Defines if etc1 texture compression is supported */
  30255. etc1: any;
  30256. /** Defines if etc2 texture compression is supported */
  30257. etc2: any;
  30258. /** Defines if astc texture compression is supported */
  30259. astc: any;
  30260. /** Defines if float textures are supported */
  30261. textureFloat: boolean;
  30262. /** Defines if vertex array objects are supported */
  30263. vertexArrayObject: boolean;
  30264. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30265. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30266. /** Gets the maximum level of anisotropy supported */
  30267. maxAnisotropy: number;
  30268. /** Defines if instancing is supported */
  30269. instancedArrays: boolean;
  30270. /** Defines if 32 bits indices are supported */
  30271. uintIndices: boolean;
  30272. /** Defines if high precision shaders are supported */
  30273. highPrecisionShaderSupported: boolean;
  30274. /** Defines if depth reading in the fragment shader is supported */
  30275. fragmentDepthSupported: boolean;
  30276. /** Defines if float texture linear filtering is supported*/
  30277. textureFloatLinearFiltering: boolean;
  30278. /** Defines if rendering to float textures is supported */
  30279. textureFloatRender: boolean;
  30280. /** Defines if half float textures are supported*/
  30281. textureHalfFloat: boolean;
  30282. /** Defines if half float texture linear filtering is supported*/
  30283. textureHalfFloatLinearFiltering: boolean;
  30284. /** Defines if rendering to half float textures is supported */
  30285. textureHalfFloatRender: boolean;
  30286. /** Defines if textureLOD shader command is supported */
  30287. textureLOD: boolean;
  30288. /** Defines if draw buffers extension is supported */
  30289. drawBuffersExtension: boolean;
  30290. /** Defines if depth textures are supported */
  30291. depthTextureExtension: boolean;
  30292. /** Defines if float color buffer are supported */
  30293. colorBufferFloat: boolean;
  30294. /** Gets disjoint timer query extension (null if not supported) */
  30295. timerQuery?: EXT_disjoint_timer_query;
  30296. /** Defines if timestamp can be used with timer query */
  30297. canUseTimestampForTimerQuery: boolean;
  30298. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30299. multiview?: any;
  30300. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30301. oculusMultiview?: any;
  30302. /** Function used to let the system compiles shaders in background */
  30303. parallelShaderCompile?: {
  30304. COMPLETION_STATUS_KHR: number;
  30305. };
  30306. /** Max number of texture samples for MSAA */
  30307. maxMSAASamples: number;
  30308. /** Defines if the blend min max extension is supported */
  30309. blendMinMax: boolean;
  30310. }
  30311. }
  30312. declare module BABYLON {
  30313. /**
  30314. * @hidden
  30315. **/
  30316. export class DepthCullingState {
  30317. private _isDepthTestDirty;
  30318. private _isDepthMaskDirty;
  30319. private _isDepthFuncDirty;
  30320. private _isCullFaceDirty;
  30321. private _isCullDirty;
  30322. private _isZOffsetDirty;
  30323. private _isFrontFaceDirty;
  30324. private _depthTest;
  30325. private _depthMask;
  30326. private _depthFunc;
  30327. private _cull;
  30328. private _cullFace;
  30329. private _zOffset;
  30330. private _frontFace;
  30331. /**
  30332. * Initializes the state.
  30333. */
  30334. constructor();
  30335. get isDirty(): boolean;
  30336. get zOffset(): number;
  30337. set zOffset(value: number);
  30338. get cullFace(): Nullable<number>;
  30339. set cullFace(value: Nullable<number>);
  30340. get cull(): Nullable<boolean>;
  30341. set cull(value: Nullable<boolean>);
  30342. get depthFunc(): Nullable<number>;
  30343. set depthFunc(value: Nullable<number>);
  30344. get depthMask(): boolean;
  30345. set depthMask(value: boolean);
  30346. get depthTest(): boolean;
  30347. set depthTest(value: boolean);
  30348. get frontFace(): Nullable<number>;
  30349. set frontFace(value: Nullable<number>);
  30350. reset(): void;
  30351. apply(gl: WebGLRenderingContext): void;
  30352. }
  30353. }
  30354. declare module BABYLON {
  30355. /**
  30356. * @hidden
  30357. **/
  30358. export class StencilState {
  30359. /** 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 */
  30360. static readonly ALWAYS: number;
  30361. /** Passed to stencilOperation to specify that stencil value must be kept */
  30362. static readonly KEEP: number;
  30363. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30364. static readonly REPLACE: number;
  30365. private _isStencilTestDirty;
  30366. private _isStencilMaskDirty;
  30367. private _isStencilFuncDirty;
  30368. private _isStencilOpDirty;
  30369. private _stencilTest;
  30370. private _stencilMask;
  30371. private _stencilFunc;
  30372. private _stencilFuncRef;
  30373. private _stencilFuncMask;
  30374. private _stencilOpStencilFail;
  30375. private _stencilOpDepthFail;
  30376. private _stencilOpStencilDepthPass;
  30377. get isDirty(): boolean;
  30378. get stencilFunc(): number;
  30379. set stencilFunc(value: number);
  30380. get stencilFuncRef(): number;
  30381. set stencilFuncRef(value: number);
  30382. get stencilFuncMask(): number;
  30383. set stencilFuncMask(value: number);
  30384. get stencilOpStencilFail(): number;
  30385. set stencilOpStencilFail(value: number);
  30386. get stencilOpDepthFail(): number;
  30387. set stencilOpDepthFail(value: number);
  30388. get stencilOpStencilDepthPass(): number;
  30389. set stencilOpStencilDepthPass(value: number);
  30390. get stencilMask(): number;
  30391. set stencilMask(value: number);
  30392. get stencilTest(): boolean;
  30393. set stencilTest(value: boolean);
  30394. constructor();
  30395. reset(): void;
  30396. apply(gl: WebGLRenderingContext): void;
  30397. }
  30398. }
  30399. declare module BABYLON {
  30400. /**
  30401. * @hidden
  30402. **/
  30403. export class AlphaState {
  30404. private _isAlphaBlendDirty;
  30405. private _isBlendFunctionParametersDirty;
  30406. private _isBlendEquationParametersDirty;
  30407. private _isBlendConstantsDirty;
  30408. private _alphaBlend;
  30409. private _blendFunctionParameters;
  30410. private _blendEquationParameters;
  30411. private _blendConstants;
  30412. /**
  30413. * Initializes the state.
  30414. */
  30415. constructor();
  30416. get isDirty(): boolean;
  30417. get alphaBlend(): boolean;
  30418. set alphaBlend(value: boolean);
  30419. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30420. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30421. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30422. reset(): void;
  30423. apply(gl: WebGLRenderingContext): void;
  30424. }
  30425. }
  30426. declare module BABYLON {
  30427. /** @hidden */
  30428. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30429. attributeProcessor(attribute: string): string;
  30430. varyingProcessor(varying: string, isFragment: boolean): string;
  30431. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30432. }
  30433. }
  30434. declare module BABYLON {
  30435. /**
  30436. * Interface for attribute information associated with buffer instanciation
  30437. */
  30438. export interface InstancingAttributeInfo {
  30439. /**
  30440. * Name of the GLSL attribute
  30441. * if attribute index is not specified, this is used to retrieve the index from the effect
  30442. */
  30443. attributeName: string;
  30444. /**
  30445. * Index/offset of the attribute in the vertex shader
  30446. * if not specified, this will be computes from the name.
  30447. */
  30448. index?: number;
  30449. /**
  30450. * size of the attribute, 1, 2, 3 or 4
  30451. */
  30452. attributeSize: number;
  30453. /**
  30454. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30455. */
  30456. offset: number;
  30457. /**
  30458. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30459. * default to 1
  30460. */
  30461. divisor?: number;
  30462. /**
  30463. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30464. * default is FLOAT
  30465. */
  30466. attributeType?: number;
  30467. /**
  30468. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30469. */
  30470. normalized?: boolean;
  30471. }
  30472. }
  30473. declare module BABYLON {
  30474. interface ThinEngine {
  30475. /**
  30476. * Update a video texture
  30477. * @param texture defines the texture to update
  30478. * @param video defines the video element to use
  30479. * @param invertY defines if data must be stored with Y axis inverted
  30480. */
  30481. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30482. }
  30483. }
  30484. declare module BABYLON {
  30485. /**
  30486. * Settings for finer control over video usage
  30487. */
  30488. export interface VideoTextureSettings {
  30489. /**
  30490. * Applies `autoplay` to video, if specified
  30491. */
  30492. autoPlay?: boolean;
  30493. /**
  30494. * Applies `loop` to video, if specified
  30495. */
  30496. loop?: boolean;
  30497. /**
  30498. * Automatically updates internal texture from video at every frame in the render loop
  30499. */
  30500. autoUpdateTexture: boolean;
  30501. /**
  30502. * Image src displayed during the video loading or until the user interacts with the video.
  30503. */
  30504. poster?: string;
  30505. }
  30506. /**
  30507. * If you want to display a video in your scene, this is the special texture for that.
  30508. * This special texture works similar to other textures, with the exception of a few parameters.
  30509. * @see https://doc.babylonjs.com/how_to/video_texture
  30510. */
  30511. export class VideoTexture extends Texture {
  30512. /**
  30513. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30514. */
  30515. readonly autoUpdateTexture: boolean;
  30516. /**
  30517. * The video instance used by the texture internally
  30518. */
  30519. readonly video: HTMLVideoElement;
  30520. private _onUserActionRequestedObservable;
  30521. /**
  30522. * Event triggerd when a dom action is required by the user to play the video.
  30523. * This happens due to recent changes in browser policies preventing video to auto start.
  30524. */
  30525. get onUserActionRequestedObservable(): Observable<Texture>;
  30526. private _generateMipMaps;
  30527. private _engine;
  30528. private _stillImageCaptured;
  30529. private _displayingPosterTexture;
  30530. private _settings;
  30531. private _createInternalTextureOnEvent;
  30532. private _frameId;
  30533. /**
  30534. * Creates a video texture.
  30535. * If you want to display a video in your scene, this is the special texture for that.
  30536. * This special texture works similar to other textures, with the exception of a few parameters.
  30537. * @see https://doc.babylonjs.com/how_to/video_texture
  30538. * @param name optional name, will detect from video source, if not defined
  30539. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30540. * @param scene is obviously the current scene.
  30541. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30542. * @param invertY is false by default but can be used to invert video on Y axis
  30543. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30544. * @param settings allows finer control over video usage
  30545. */
  30546. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30547. private _getName;
  30548. private _getVideo;
  30549. private _createInternalTexture;
  30550. private reset;
  30551. /**
  30552. * @hidden Internal method to initiate `update`.
  30553. */
  30554. _rebuild(): void;
  30555. /**
  30556. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30557. */
  30558. update(): void;
  30559. /**
  30560. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30561. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30562. */
  30563. updateTexture(isVisible: boolean): void;
  30564. protected _updateInternalTexture: () => void;
  30565. /**
  30566. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30567. * @param url New url.
  30568. */
  30569. updateURL(url: string): void;
  30570. /**
  30571. * Dispose the texture and release its associated resources.
  30572. */
  30573. dispose(): void;
  30574. /**
  30575. * Creates a video texture straight from a stream.
  30576. * @param scene Define the scene the texture should be created in
  30577. * @param stream Define the stream the texture should be created from
  30578. * @returns The created video texture as a promise
  30579. */
  30580. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30581. /**
  30582. * Creates a video texture straight from your WebCam video feed.
  30583. * @param scene Define the scene the texture should be created in
  30584. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30585. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30586. * @returns The created video texture as a promise
  30587. */
  30588. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30589. minWidth: number;
  30590. maxWidth: number;
  30591. minHeight: number;
  30592. maxHeight: number;
  30593. deviceId: string;
  30594. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30595. /**
  30596. * Creates a video texture straight from your WebCam video feed.
  30597. * @param scene Define the scene the texture should be created in
  30598. * @param onReady Define a callback to triggered once the texture will be ready
  30599. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30600. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30601. */
  30602. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30603. minWidth: number;
  30604. maxWidth: number;
  30605. minHeight: number;
  30606. maxHeight: number;
  30607. deviceId: string;
  30608. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30609. }
  30610. }
  30611. declare module BABYLON {
  30612. /**
  30613. * Defines the interface used by objects working like Scene
  30614. * @hidden
  30615. */
  30616. interface ISceneLike {
  30617. _addPendingData(data: any): void;
  30618. _removePendingData(data: any): void;
  30619. offlineProvider: IOfflineProvider;
  30620. }
  30621. /** Interface defining initialization parameters for Engine class */
  30622. export interface EngineOptions extends WebGLContextAttributes {
  30623. /**
  30624. * Defines if the engine should no exceed a specified device ratio
  30625. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30626. */
  30627. limitDeviceRatio?: number;
  30628. /**
  30629. * Defines if webvr should be enabled automatically
  30630. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30631. */
  30632. autoEnableWebVR?: boolean;
  30633. /**
  30634. * Defines if webgl2 should be turned off even if supported
  30635. * @see http://doc.babylonjs.com/features/webgl2
  30636. */
  30637. disableWebGL2Support?: boolean;
  30638. /**
  30639. * Defines if webaudio should be initialized as well
  30640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30641. */
  30642. audioEngine?: boolean;
  30643. /**
  30644. * Defines if animations should run using a deterministic lock step
  30645. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30646. */
  30647. deterministicLockstep?: boolean;
  30648. /** Defines the maximum steps to use with deterministic lock step mode */
  30649. lockstepMaxSteps?: number;
  30650. /** Defines the seconds between each deterministic lock step */
  30651. timeStep?: number;
  30652. /**
  30653. * Defines that engine should ignore context lost events
  30654. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30655. */
  30656. doNotHandleContextLost?: boolean;
  30657. /**
  30658. * Defines that engine should ignore modifying touch action attribute and style
  30659. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30660. */
  30661. doNotHandleTouchAction?: boolean;
  30662. /**
  30663. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30664. */
  30665. useHighPrecisionFloats?: boolean;
  30666. }
  30667. /**
  30668. * The base engine class (root of all engines)
  30669. */
  30670. export class ThinEngine {
  30671. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30672. static ExceptionList: ({
  30673. key: string;
  30674. capture: string;
  30675. captureConstraint: number;
  30676. targets: string[];
  30677. } | {
  30678. key: string;
  30679. capture: null;
  30680. captureConstraint: null;
  30681. targets: string[];
  30682. })[];
  30683. /** @hidden */
  30684. static _TextureLoaders: IInternalTextureLoader[];
  30685. /**
  30686. * Returns the current npm package of the sdk
  30687. */
  30688. static get NpmPackage(): string;
  30689. /**
  30690. * Returns the current version of the framework
  30691. */
  30692. static get Version(): string;
  30693. /**
  30694. * Returns a string describing the current engine
  30695. */
  30696. get description(): string;
  30697. /**
  30698. * Gets or sets the epsilon value used by collision engine
  30699. */
  30700. static CollisionsEpsilon: number;
  30701. /**
  30702. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30703. */
  30704. static get ShadersRepository(): string;
  30705. static set ShadersRepository(value: string);
  30706. /**
  30707. * Gets or sets the textures that the engine should not attempt to load as compressed
  30708. */
  30709. protected _excludedCompressedTextures: string[];
  30710. /**
  30711. * Filters the compressed texture formats to only include
  30712. * files that are not included in the skippable list
  30713. *
  30714. * @param url the current extension
  30715. * @param textureFormatInUse the current compressed texture format
  30716. * @returns "format" string
  30717. */
  30718. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30719. /** @hidden */
  30720. _shaderProcessor: IShaderProcessor;
  30721. /**
  30722. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30723. */
  30724. forcePOTTextures: boolean;
  30725. /**
  30726. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30727. */
  30728. isFullscreen: boolean;
  30729. /**
  30730. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30731. */
  30732. cullBackFaces: boolean;
  30733. /**
  30734. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30735. */
  30736. renderEvenInBackground: boolean;
  30737. /**
  30738. * Gets or sets a boolean indicating that cache can be kept between frames
  30739. */
  30740. preventCacheWipeBetweenFrames: boolean;
  30741. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30742. validateShaderPrograms: boolean;
  30743. /**
  30744. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30745. * This can provide greater z depth for distant objects.
  30746. */
  30747. useReverseDepthBuffer: boolean;
  30748. /**
  30749. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30750. */
  30751. disableUniformBuffers: boolean;
  30752. /** @hidden */
  30753. _uniformBuffers: UniformBuffer[];
  30754. /**
  30755. * Gets a boolean indicating that the engine supports uniform buffers
  30756. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30757. */
  30758. get supportsUniformBuffers(): boolean;
  30759. /** @hidden */
  30760. _gl: WebGLRenderingContext;
  30761. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30762. protected _windowIsBackground: boolean;
  30763. protected _webGLVersion: number;
  30764. protected _creationOptions: EngineOptions;
  30765. protected _highPrecisionShadersAllowed: boolean;
  30766. /** @hidden */
  30767. get _shouldUseHighPrecisionShader(): boolean;
  30768. /**
  30769. * Gets a boolean indicating that only power of 2 textures are supported
  30770. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30771. */
  30772. get needPOTTextures(): boolean;
  30773. /** @hidden */
  30774. _badOS: boolean;
  30775. /** @hidden */
  30776. _badDesktopOS: boolean;
  30777. private _hardwareScalingLevel;
  30778. /** @hidden */
  30779. _caps: EngineCapabilities;
  30780. private _isStencilEnable;
  30781. private _glVersion;
  30782. private _glRenderer;
  30783. private _glVendor;
  30784. /** @hidden */
  30785. _videoTextureSupported: boolean;
  30786. protected _renderingQueueLaunched: boolean;
  30787. protected _activeRenderLoops: (() => void)[];
  30788. /**
  30789. * Observable signaled when a context lost event is raised
  30790. */
  30791. onContextLostObservable: Observable<ThinEngine>;
  30792. /**
  30793. * Observable signaled when a context restored event is raised
  30794. */
  30795. onContextRestoredObservable: Observable<ThinEngine>;
  30796. private _onContextLost;
  30797. private _onContextRestored;
  30798. protected _contextWasLost: boolean;
  30799. /** @hidden */
  30800. _doNotHandleContextLost: boolean;
  30801. /**
  30802. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30804. */
  30805. get doNotHandleContextLost(): boolean;
  30806. set doNotHandleContextLost(value: boolean);
  30807. /**
  30808. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30809. */
  30810. disableVertexArrayObjects: boolean;
  30811. /** @hidden */
  30812. protected _colorWrite: boolean;
  30813. /** @hidden */
  30814. protected _colorWriteChanged: boolean;
  30815. /** @hidden */
  30816. protected _depthCullingState: DepthCullingState;
  30817. /** @hidden */
  30818. protected _stencilState: StencilState;
  30819. /** @hidden */
  30820. _alphaState: AlphaState;
  30821. /** @hidden */
  30822. _alphaMode: number;
  30823. /** @hidden */
  30824. _alphaEquation: number;
  30825. /** @hidden */
  30826. _internalTexturesCache: InternalTexture[];
  30827. /** @hidden */
  30828. protected _activeChannel: number;
  30829. private _currentTextureChannel;
  30830. /** @hidden */
  30831. protected _boundTexturesCache: {
  30832. [key: string]: Nullable<InternalTexture>;
  30833. };
  30834. /** @hidden */
  30835. protected _currentEffect: Nullable<Effect>;
  30836. /** @hidden */
  30837. protected _currentProgram: Nullable<WebGLProgram>;
  30838. private _compiledEffects;
  30839. private _vertexAttribArraysEnabled;
  30840. /** @hidden */
  30841. protected _cachedViewport: Nullable<IViewportLike>;
  30842. private _cachedVertexArrayObject;
  30843. /** @hidden */
  30844. protected _cachedVertexBuffers: any;
  30845. /** @hidden */
  30846. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30847. /** @hidden */
  30848. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30849. /** @hidden */
  30850. _currentRenderTarget: Nullable<InternalTexture>;
  30851. private _uintIndicesCurrentlySet;
  30852. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30853. /** @hidden */
  30854. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30855. private _currentBufferPointers;
  30856. private _currentInstanceLocations;
  30857. private _currentInstanceBuffers;
  30858. private _textureUnits;
  30859. /** @hidden */
  30860. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30861. /** @hidden */
  30862. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30863. /** @hidden */
  30864. _boundRenderFunction: any;
  30865. private _vaoRecordInProgress;
  30866. private _mustWipeVertexAttributes;
  30867. private _emptyTexture;
  30868. private _emptyCubeTexture;
  30869. private _emptyTexture3D;
  30870. private _emptyTexture2DArray;
  30871. /** @hidden */
  30872. _frameHandler: number;
  30873. private _nextFreeTextureSlots;
  30874. private _maxSimultaneousTextures;
  30875. private _activeRequests;
  30876. protected _texturesSupported: string[];
  30877. /** @hidden */
  30878. _textureFormatInUse: Nullable<string>;
  30879. protected get _supportsHardwareTextureRescaling(): boolean;
  30880. /**
  30881. * Gets the list of texture formats supported
  30882. */
  30883. get texturesSupported(): Array<string>;
  30884. /**
  30885. * Gets the list of texture formats in use
  30886. */
  30887. get textureFormatInUse(): Nullable<string>;
  30888. /**
  30889. * Gets the current viewport
  30890. */
  30891. get currentViewport(): Nullable<IViewportLike>;
  30892. /**
  30893. * Gets the default empty texture
  30894. */
  30895. get emptyTexture(): InternalTexture;
  30896. /**
  30897. * Gets the default empty 3D texture
  30898. */
  30899. get emptyTexture3D(): InternalTexture;
  30900. /**
  30901. * Gets the default empty 2D array texture
  30902. */
  30903. get emptyTexture2DArray(): InternalTexture;
  30904. /**
  30905. * Gets the default empty cube texture
  30906. */
  30907. get emptyCubeTexture(): InternalTexture;
  30908. /**
  30909. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30910. */
  30911. readonly premultipliedAlpha: boolean;
  30912. /**
  30913. * Observable event triggered before each texture is initialized
  30914. */
  30915. onBeforeTextureInitObservable: Observable<Texture>;
  30916. /**
  30917. * Creates a new engine
  30918. * @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
  30919. * @param antialias defines enable antialiasing (default: false)
  30920. * @param options defines further options to be sent to the getContext() function
  30921. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30922. */
  30923. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30924. private _rebuildInternalTextures;
  30925. private _rebuildEffects;
  30926. /**
  30927. * Gets a boolean indicating if all created effects are ready
  30928. * @returns true if all effects are ready
  30929. */
  30930. areAllEffectsReady(): boolean;
  30931. protected _rebuildBuffers(): void;
  30932. private _initGLContext;
  30933. /**
  30934. * Gets version of the current webGL context
  30935. */
  30936. get webGLVersion(): number;
  30937. /**
  30938. * Gets a string idenfifying the name of the class
  30939. * @returns "Engine" string
  30940. */
  30941. getClassName(): string;
  30942. /**
  30943. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30944. */
  30945. get isStencilEnable(): boolean;
  30946. /** @hidden */
  30947. _prepareWorkingCanvas(): void;
  30948. /**
  30949. * Reset the texture cache to empty state
  30950. */
  30951. resetTextureCache(): void;
  30952. /**
  30953. * Gets an object containing information about the current webGL context
  30954. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30955. */
  30956. getGlInfo(): {
  30957. vendor: string;
  30958. renderer: string;
  30959. version: string;
  30960. };
  30961. /**
  30962. * Defines the hardware scaling level.
  30963. * By default the hardware scaling level is computed from the window device ratio.
  30964. * 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.
  30965. * @param level defines the level to use
  30966. */
  30967. setHardwareScalingLevel(level: number): void;
  30968. /**
  30969. * Gets the current hardware scaling level.
  30970. * By default the hardware scaling level is computed from the window device ratio.
  30971. * 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.
  30972. * @returns a number indicating the current hardware scaling level
  30973. */
  30974. getHardwareScalingLevel(): number;
  30975. /**
  30976. * Gets the list of loaded textures
  30977. * @returns an array containing all loaded textures
  30978. */
  30979. getLoadedTexturesCache(): InternalTexture[];
  30980. /**
  30981. * Gets the object containing all engine capabilities
  30982. * @returns the EngineCapabilities object
  30983. */
  30984. getCaps(): EngineCapabilities;
  30985. /**
  30986. * stop executing a render loop function and remove it from the execution array
  30987. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30988. */
  30989. stopRenderLoop(renderFunction?: () => void): void;
  30990. /** @hidden */
  30991. _renderLoop(): void;
  30992. /**
  30993. * Gets the HTML canvas attached with the current webGL context
  30994. * @returns a HTML canvas
  30995. */
  30996. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30997. /**
  30998. * Gets host window
  30999. * @returns the host window object
  31000. */
  31001. getHostWindow(): Nullable<Window>;
  31002. /**
  31003. * Gets the current render width
  31004. * @param useScreen defines if screen size must be used (or the current render target if any)
  31005. * @returns a number defining the current render width
  31006. */
  31007. getRenderWidth(useScreen?: boolean): number;
  31008. /**
  31009. * Gets the current render height
  31010. * @param useScreen defines if screen size must be used (or the current render target if any)
  31011. * @returns a number defining the current render height
  31012. */
  31013. getRenderHeight(useScreen?: boolean): number;
  31014. /**
  31015. * Can be used to override the current requestAnimationFrame requester.
  31016. * @hidden
  31017. */
  31018. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31019. /**
  31020. * Register and execute a render loop. The engine can have more than one render function
  31021. * @param renderFunction defines the function to continuously execute
  31022. */
  31023. runRenderLoop(renderFunction: () => void): void;
  31024. /**
  31025. * Clear the current render buffer or the current render target (if any is set up)
  31026. * @param color defines the color to use
  31027. * @param backBuffer defines if the back buffer must be cleared
  31028. * @param depth defines if the depth buffer must be cleared
  31029. * @param stencil defines if the stencil buffer must be cleared
  31030. */
  31031. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31032. private _viewportCached;
  31033. /** @hidden */
  31034. _viewport(x: number, y: number, width: number, height: number): void;
  31035. /**
  31036. * Set the WebGL's viewport
  31037. * @param viewport defines the viewport element to be used
  31038. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31039. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31040. */
  31041. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31042. /**
  31043. * Begin a new frame
  31044. */
  31045. beginFrame(): void;
  31046. /**
  31047. * Enf the current frame
  31048. */
  31049. endFrame(): void;
  31050. /**
  31051. * Resize the view according to the canvas' size
  31052. */
  31053. resize(): void;
  31054. /**
  31055. * Force a specific size of the canvas
  31056. * @param width defines the new canvas' width
  31057. * @param height defines the new canvas' height
  31058. */
  31059. setSize(width: number, height: number): void;
  31060. /**
  31061. * Binds the frame buffer to the specified texture.
  31062. * @param texture The texture to render to or null for the default canvas
  31063. * @param faceIndex The face of the texture to render to in case of cube texture
  31064. * @param requiredWidth The width of the target to render to
  31065. * @param requiredHeight The height of the target to render to
  31066. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31067. * @param depthStencilTexture The depth stencil texture to use to render
  31068. * @param lodLevel defines le lod level to bind to the frame buffer
  31069. */
  31070. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31071. /** @hidden */
  31072. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31073. /**
  31074. * Unbind the current render target texture from the webGL context
  31075. * @param texture defines the render target texture to unbind
  31076. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31077. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31078. */
  31079. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31080. /**
  31081. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31082. */
  31083. flushFramebuffer(): void;
  31084. /**
  31085. * Unbind the current render target and bind the default framebuffer
  31086. */
  31087. restoreDefaultFramebuffer(): void;
  31088. /** @hidden */
  31089. protected _resetVertexBufferBinding(): void;
  31090. /**
  31091. * Creates a vertex buffer
  31092. * @param data the data for the vertex buffer
  31093. * @returns the new WebGL static buffer
  31094. */
  31095. createVertexBuffer(data: DataArray): DataBuffer;
  31096. private _createVertexBuffer;
  31097. /**
  31098. * Creates a dynamic vertex buffer
  31099. * @param data the data for the dynamic vertex buffer
  31100. * @returns the new WebGL dynamic buffer
  31101. */
  31102. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31103. protected _resetIndexBufferBinding(): void;
  31104. /**
  31105. * Creates a new index buffer
  31106. * @param indices defines the content of the index buffer
  31107. * @param updatable defines if the index buffer must be updatable
  31108. * @returns a new webGL buffer
  31109. */
  31110. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31111. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31112. /**
  31113. * Bind a webGL buffer to the webGL context
  31114. * @param buffer defines the buffer to bind
  31115. */
  31116. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31117. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31118. private bindBuffer;
  31119. /**
  31120. * update the bound buffer with the given data
  31121. * @param data defines the data to update
  31122. */
  31123. updateArrayBuffer(data: Float32Array): void;
  31124. private _vertexAttribPointer;
  31125. private _bindIndexBufferWithCache;
  31126. private _bindVertexBuffersAttributes;
  31127. /**
  31128. * Records a vertex array object
  31129. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31130. * @param vertexBuffers defines the list of vertex buffers to store
  31131. * @param indexBuffer defines the index buffer to store
  31132. * @param effect defines the effect to store
  31133. * @returns the new vertex array object
  31134. */
  31135. recordVertexArrayObject(vertexBuffers: {
  31136. [key: string]: VertexBuffer;
  31137. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31138. /**
  31139. * Bind a specific vertex array object
  31140. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31141. * @param vertexArrayObject defines the vertex array object to bind
  31142. * @param indexBuffer defines the index buffer to bind
  31143. */
  31144. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31145. /**
  31146. * Bind webGl buffers directly to the webGL context
  31147. * @param vertexBuffer defines the vertex buffer to bind
  31148. * @param indexBuffer defines the index buffer to bind
  31149. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31150. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31151. * @param effect defines the effect associated with the vertex buffer
  31152. */
  31153. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31154. private _unbindVertexArrayObject;
  31155. /**
  31156. * Bind a list of vertex buffers to the webGL context
  31157. * @param vertexBuffers defines the list of vertex buffers to bind
  31158. * @param indexBuffer defines the index buffer to bind
  31159. * @param effect defines the effect associated with the vertex buffers
  31160. */
  31161. bindBuffers(vertexBuffers: {
  31162. [key: string]: Nullable<VertexBuffer>;
  31163. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31164. /**
  31165. * Unbind all instance attributes
  31166. */
  31167. unbindInstanceAttributes(): void;
  31168. /**
  31169. * Release and free the memory of a vertex array object
  31170. * @param vao defines the vertex array object to delete
  31171. */
  31172. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31173. /** @hidden */
  31174. _releaseBuffer(buffer: DataBuffer): boolean;
  31175. protected _deleteBuffer(buffer: DataBuffer): void;
  31176. /**
  31177. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31178. * @param instancesBuffer defines the webGL buffer to update and bind
  31179. * @param data defines the data to store in the buffer
  31180. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31181. */
  31182. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31183. /**
  31184. * Bind the content of a webGL buffer used with instanciation
  31185. * @param instancesBuffer defines the webGL buffer to bind
  31186. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31187. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31188. */
  31189. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31190. /**
  31191. * Disable the instance attribute corresponding to the name in parameter
  31192. * @param name defines the name of the attribute to disable
  31193. */
  31194. disableInstanceAttributeByName(name: string): void;
  31195. /**
  31196. * Disable the instance attribute corresponding to the location in parameter
  31197. * @param attributeLocation defines the attribute location of the attribute to disable
  31198. */
  31199. disableInstanceAttribute(attributeLocation: number): void;
  31200. /**
  31201. * Disable the attribute corresponding to the location in parameter
  31202. * @param attributeLocation defines the attribute location of the attribute to disable
  31203. */
  31204. disableAttributeByIndex(attributeLocation: number): void;
  31205. /**
  31206. * Send a draw order
  31207. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31208. * @param indexStart defines the starting index
  31209. * @param indexCount defines the number of index to draw
  31210. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31211. */
  31212. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31213. /**
  31214. * Draw a list of points
  31215. * @param verticesStart defines the index of first vertex to draw
  31216. * @param verticesCount defines the count of vertices to draw
  31217. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31218. */
  31219. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31220. /**
  31221. * Draw a list of unindexed primitives
  31222. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31223. * @param verticesStart defines the index of first vertex to draw
  31224. * @param verticesCount defines the count of vertices to draw
  31225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31226. */
  31227. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31228. /**
  31229. * Draw a list of indexed primitives
  31230. * @param fillMode defines the primitive to use
  31231. * @param indexStart defines the starting index
  31232. * @param indexCount defines the number of index to draw
  31233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31234. */
  31235. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31236. /**
  31237. * Draw a list of unindexed primitives
  31238. * @param fillMode defines the primitive to use
  31239. * @param verticesStart defines the index of first vertex to draw
  31240. * @param verticesCount defines the count of vertices to draw
  31241. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31242. */
  31243. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31244. private _drawMode;
  31245. /** @hidden */
  31246. protected _reportDrawCall(): void;
  31247. /** @hidden */
  31248. _releaseEffect(effect: Effect): void;
  31249. /** @hidden */
  31250. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31251. /**
  31252. * Create a new effect (used to store vertex/fragment shaders)
  31253. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31254. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31255. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31256. * @param samplers defines an array of string used to represent textures
  31257. * @param defines defines the string containing the defines to use to compile the shaders
  31258. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31259. * @param onCompiled defines a function to call when the effect creation is successful
  31260. * @param onError defines a function to call when the effect creation has failed
  31261. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31262. * @returns the new Effect
  31263. */
  31264. 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;
  31265. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31266. private _compileShader;
  31267. private _compileRawShader;
  31268. /**
  31269. * Directly creates a webGL program
  31270. * @param pipelineContext defines the pipeline context to attach to
  31271. * @param vertexCode defines the vertex shader code to use
  31272. * @param fragmentCode defines the fragment shader code to use
  31273. * @param context defines the webGL context to use (if not set, the current one will be used)
  31274. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31275. * @returns the new webGL program
  31276. */
  31277. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31278. /**
  31279. * Creates a webGL program
  31280. * @param pipelineContext defines the pipeline context to attach to
  31281. * @param vertexCode defines the vertex shader code to use
  31282. * @param fragmentCode defines the fragment shader code to use
  31283. * @param defines defines the string containing the defines to use to compile the shaders
  31284. * @param context defines the webGL context to use (if not set, the current one will be used)
  31285. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31286. * @returns the new webGL program
  31287. */
  31288. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31289. /**
  31290. * Creates a new pipeline context
  31291. * @returns the new pipeline
  31292. */
  31293. createPipelineContext(): IPipelineContext;
  31294. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31295. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31296. /** @hidden */
  31297. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31298. /** @hidden */
  31299. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31300. /** @hidden */
  31301. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31302. /**
  31303. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31304. * @param pipelineContext defines the pipeline context to use
  31305. * @param uniformsNames defines the list of uniform names
  31306. * @returns an array of webGL uniform locations
  31307. */
  31308. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31309. /**
  31310. * Gets the lsit of active attributes for a given webGL program
  31311. * @param pipelineContext defines the pipeline context to use
  31312. * @param attributesNames defines the list of attribute names to get
  31313. * @returns an array of indices indicating the offset of each attribute
  31314. */
  31315. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31316. /**
  31317. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31318. * @param effect defines the effect to activate
  31319. */
  31320. enableEffect(effect: Nullable<Effect>): void;
  31321. /**
  31322. * Set the value of an uniform to a number (int)
  31323. * @param uniform defines the webGL uniform location where to store the value
  31324. * @param value defines the int number to store
  31325. */
  31326. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31327. /**
  31328. * Set the value of an uniform to an array of int32
  31329. * @param uniform defines the webGL uniform location where to store the value
  31330. * @param array defines the array of int32 to store
  31331. */
  31332. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31333. /**
  31334. * Set the value of an uniform to an array of int32 (stored as vec2)
  31335. * @param uniform defines the webGL uniform location where to store the value
  31336. * @param array defines the array of int32 to store
  31337. */
  31338. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31339. /**
  31340. * Set the value of an uniform to an array of int32 (stored as vec3)
  31341. * @param uniform defines the webGL uniform location where to store the value
  31342. * @param array defines the array of int32 to store
  31343. */
  31344. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31345. /**
  31346. * Set the value of an uniform to an array of int32 (stored as vec4)
  31347. * @param uniform defines the webGL uniform location where to store the value
  31348. * @param array defines the array of int32 to store
  31349. */
  31350. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31351. /**
  31352. * Set the value of an uniform to an array of number
  31353. * @param uniform defines the webGL uniform location where to store the value
  31354. * @param array defines the array of number to store
  31355. */
  31356. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31357. /**
  31358. * Set the value of an uniform to an array of number (stored as vec2)
  31359. * @param uniform defines the webGL uniform location where to store the value
  31360. * @param array defines the array of number to store
  31361. */
  31362. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31363. /**
  31364. * Set the value of an uniform to an array of number (stored as vec3)
  31365. * @param uniform defines the webGL uniform location where to store the value
  31366. * @param array defines the array of number to store
  31367. */
  31368. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31369. /**
  31370. * Set the value of an uniform to an array of number (stored as vec4)
  31371. * @param uniform defines the webGL uniform location where to store the value
  31372. * @param array defines the array of number to store
  31373. */
  31374. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31375. /**
  31376. * Set the value of an uniform to an array of float32 (stored as matrices)
  31377. * @param uniform defines the webGL uniform location where to store the value
  31378. * @param matrices defines the array of float32 to store
  31379. */
  31380. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31381. /**
  31382. * Set the value of an uniform to a matrix (3x3)
  31383. * @param uniform defines the webGL uniform location where to store the value
  31384. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31385. */
  31386. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31387. /**
  31388. * Set the value of an uniform to a matrix (2x2)
  31389. * @param uniform defines the webGL uniform location where to store the value
  31390. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31391. */
  31392. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31393. /**
  31394. * Set the value of an uniform to a number (float)
  31395. * @param uniform defines the webGL uniform location where to store the value
  31396. * @param value defines the float number to store
  31397. */
  31398. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31399. /**
  31400. * Set the value of an uniform to a vec2
  31401. * @param uniform defines the webGL uniform location where to store the value
  31402. * @param x defines the 1st component of the value
  31403. * @param y defines the 2nd component of the value
  31404. */
  31405. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31406. /**
  31407. * Set the value of an uniform to a vec3
  31408. * @param uniform defines the webGL uniform location where to store the value
  31409. * @param x defines the 1st component of the value
  31410. * @param y defines the 2nd component of the value
  31411. * @param z defines the 3rd component of the value
  31412. */
  31413. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31414. /**
  31415. * Set the value of an uniform to a vec4
  31416. * @param uniform defines the webGL uniform location where to store the value
  31417. * @param x defines the 1st component of the value
  31418. * @param y defines the 2nd component of the value
  31419. * @param z defines the 3rd component of the value
  31420. * @param w defines the 4th component of the value
  31421. */
  31422. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31423. /**
  31424. * Apply all cached states (depth, culling, stencil and alpha)
  31425. */
  31426. applyStates(): void;
  31427. /**
  31428. * Enable or disable color writing
  31429. * @param enable defines the state to set
  31430. */
  31431. setColorWrite(enable: boolean): void;
  31432. /**
  31433. * Gets a boolean indicating if color writing is enabled
  31434. * @returns the current color writing state
  31435. */
  31436. getColorWrite(): boolean;
  31437. /**
  31438. * Gets the depth culling state manager
  31439. */
  31440. get depthCullingState(): DepthCullingState;
  31441. /**
  31442. * Gets the alpha state manager
  31443. */
  31444. get alphaState(): AlphaState;
  31445. /**
  31446. * Gets the stencil state manager
  31447. */
  31448. get stencilState(): StencilState;
  31449. /**
  31450. * Clears the list of texture accessible through engine.
  31451. * This can help preventing texture load conflict due to name collision.
  31452. */
  31453. clearInternalTexturesCache(): void;
  31454. /**
  31455. * Force the entire cache to be cleared
  31456. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31457. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31458. */
  31459. wipeCaches(bruteForce?: boolean): void;
  31460. /** @hidden */
  31461. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31462. min: number;
  31463. mag: number;
  31464. };
  31465. /** @hidden */
  31466. _createTexture(): WebGLTexture;
  31467. /**
  31468. * Usually called from Texture.ts.
  31469. * Passed information to create a WebGLTexture
  31470. * @param urlArg defines a value which contains one of the following:
  31471. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31472. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31473. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31474. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31475. * @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)
  31476. * @param scene needed for loading to the correct scene
  31477. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31478. * @param onLoad optional callback to be called upon successful completion
  31479. * @param onError optional callback to be called upon failure
  31480. * @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
  31481. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31482. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31483. * @param forcedExtension defines the extension to use to pick the right loader
  31484. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31485. * @param mimeType defines an optional mime type
  31486. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31487. */
  31488. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31489. /**
  31490. * @hidden
  31491. */
  31492. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31493. /**
  31494. * Creates a raw texture
  31495. * @param data defines the data to store in the texture
  31496. * @param width defines the width of the texture
  31497. * @param height defines the height of the texture
  31498. * @param format defines the format of the data
  31499. * @param generateMipMaps defines if the engine should generate the mip levels
  31500. * @param invertY defines if data must be stored with Y axis inverted
  31501. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31502. * @param compression defines the compression used (null by default)
  31503. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31504. * @returns the raw texture inside an InternalTexture
  31505. */
  31506. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31507. /**
  31508. * Creates a new raw cube texture
  31509. * @param data defines the array of data to use to create each face
  31510. * @param size defines the size of the textures
  31511. * @param format defines the format of the data
  31512. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31513. * @param generateMipMaps defines if the engine should generate the mip levels
  31514. * @param invertY defines if data must be stored with Y axis inverted
  31515. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31516. * @param compression defines the compression used (null by default)
  31517. * @returns the cube texture as an InternalTexture
  31518. */
  31519. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31520. /**
  31521. * Creates a new raw 3D texture
  31522. * @param data defines the data used to create the texture
  31523. * @param width defines the width of the texture
  31524. * @param height defines the height of the texture
  31525. * @param depth defines the depth of the texture
  31526. * @param format defines the format of the texture
  31527. * @param generateMipMaps defines if the engine must generate mip levels
  31528. * @param invertY defines if data must be stored with Y axis inverted
  31529. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31530. * @param compression defines the compressed used (can be null)
  31531. * @param textureType defines the compressed used (can be null)
  31532. * @returns a new raw 3D texture (stored in an InternalTexture)
  31533. */
  31534. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31535. /**
  31536. * Creates a new raw 2D array texture
  31537. * @param data defines the data used to create the texture
  31538. * @param width defines the width of the texture
  31539. * @param height defines the height of the texture
  31540. * @param depth defines the number of layers of the texture
  31541. * @param format defines the format of the texture
  31542. * @param generateMipMaps defines if the engine must generate mip levels
  31543. * @param invertY defines if data must be stored with Y axis inverted
  31544. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31545. * @param compression defines the compressed used (can be null)
  31546. * @param textureType defines the compressed used (can be null)
  31547. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31548. */
  31549. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31550. private _unpackFlipYCached;
  31551. /**
  31552. * In case you are sharing the context with other applications, it might
  31553. * be interested to not cache the unpack flip y state to ensure a consistent
  31554. * value would be set.
  31555. */
  31556. enableUnpackFlipYCached: boolean;
  31557. /** @hidden */
  31558. _unpackFlipY(value: boolean): void;
  31559. /** @hidden */
  31560. _getUnpackAlignement(): number;
  31561. private _getTextureTarget;
  31562. /**
  31563. * Update the sampling mode of a given texture
  31564. * @param samplingMode defines the required sampling mode
  31565. * @param texture defines the texture to update
  31566. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31567. */
  31568. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31569. /**
  31570. * Update the sampling mode of a given texture
  31571. * @param texture defines the texture to update
  31572. * @param wrapU defines the texture wrap mode of the u coordinates
  31573. * @param wrapV defines the texture wrap mode of the v coordinates
  31574. * @param wrapR defines the texture wrap mode of the r coordinates
  31575. */
  31576. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31577. /** @hidden */
  31578. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31579. width: number;
  31580. height: number;
  31581. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31582. /** @hidden */
  31583. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31584. /** @hidden */
  31585. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31586. /** @hidden */
  31587. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31588. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31589. private _prepareWebGLTexture;
  31590. /** @hidden */
  31591. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31592. private _getDepthStencilBuffer;
  31593. /** @hidden */
  31594. _releaseFramebufferObjects(texture: InternalTexture): void;
  31595. /** @hidden */
  31596. _releaseTexture(texture: InternalTexture): void;
  31597. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31598. protected _setProgram(program: WebGLProgram): void;
  31599. protected _boundUniforms: {
  31600. [key: number]: WebGLUniformLocation;
  31601. };
  31602. /**
  31603. * Binds an effect to the webGL context
  31604. * @param effect defines the effect to bind
  31605. */
  31606. bindSamplers(effect: Effect): void;
  31607. private _activateCurrentTexture;
  31608. /** @hidden */
  31609. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31610. /** @hidden */
  31611. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31612. /**
  31613. * Unbind all textures from the webGL context
  31614. */
  31615. unbindAllTextures(): void;
  31616. /**
  31617. * Sets a texture to the according uniform.
  31618. * @param channel The texture channel
  31619. * @param uniform The uniform to set
  31620. * @param texture The texture to apply
  31621. */
  31622. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31623. private _bindSamplerUniformToChannel;
  31624. private _getTextureWrapMode;
  31625. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31626. /**
  31627. * Sets an array of texture to the webGL context
  31628. * @param channel defines the channel where the texture array must be set
  31629. * @param uniform defines the associated uniform location
  31630. * @param textures defines the array of textures to bind
  31631. */
  31632. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31633. /** @hidden */
  31634. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31635. private _setTextureParameterFloat;
  31636. private _setTextureParameterInteger;
  31637. /**
  31638. * Unbind all vertex attributes from the webGL context
  31639. */
  31640. unbindAllAttributes(): void;
  31641. /**
  31642. * 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
  31643. */
  31644. releaseEffects(): void;
  31645. /**
  31646. * Dispose and release all associated resources
  31647. */
  31648. dispose(): void;
  31649. /**
  31650. * Attach a new callback raised when context lost event is fired
  31651. * @param callback defines the callback to call
  31652. */
  31653. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31654. /**
  31655. * Attach a new callback raised when context restored event is fired
  31656. * @param callback defines the callback to call
  31657. */
  31658. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31659. /**
  31660. * Get the current error code of the webGL context
  31661. * @returns the error code
  31662. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31663. */
  31664. getError(): number;
  31665. private _canRenderToFloatFramebuffer;
  31666. private _canRenderToHalfFloatFramebuffer;
  31667. private _canRenderToFramebuffer;
  31668. /** @hidden */
  31669. _getWebGLTextureType(type: number): number;
  31670. /** @hidden */
  31671. _getInternalFormat(format: number): number;
  31672. /** @hidden */
  31673. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31674. /** @hidden */
  31675. _getRGBAMultiSampleBufferFormat(type: number): number;
  31676. /** @hidden */
  31677. _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;
  31678. /**
  31679. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31680. * @param x defines the x coordinate of the rectangle where pixels must be read
  31681. * @param y defines the y coordinate of the rectangle where pixels must be read
  31682. * @param width defines the width of the rectangle where pixels must be read
  31683. * @param height defines the height of the rectangle where pixels must be read
  31684. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31685. * @returns a Uint8Array containing RGBA colors
  31686. */
  31687. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31688. private static _isSupported;
  31689. /**
  31690. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31691. * @returns true if the engine can be created
  31692. * @ignorenaming
  31693. */
  31694. static isSupported(): boolean;
  31695. /**
  31696. * Find the next highest power of two.
  31697. * @param x Number to start search from.
  31698. * @return Next highest power of two.
  31699. */
  31700. static CeilingPOT(x: number): number;
  31701. /**
  31702. * Find the next lowest power of two.
  31703. * @param x Number to start search from.
  31704. * @return Next lowest power of two.
  31705. */
  31706. static FloorPOT(x: number): number;
  31707. /**
  31708. * Find the nearest power of two.
  31709. * @param x Number to start search from.
  31710. * @return Next nearest power of two.
  31711. */
  31712. static NearestPOT(x: number): number;
  31713. /**
  31714. * Get the closest exponent of two
  31715. * @param value defines the value to approximate
  31716. * @param max defines the maximum value to return
  31717. * @param mode defines how to define the closest value
  31718. * @returns closest exponent of two of the given value
  31719. */
  31720. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31721. /**
  31722. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31723. * @param func - the function to be called
  31724. * @param requester - the object that will request the next frame. Falls back to window.
  31725. * @returns frame number
  31726. */
  31727. static QueueNewFrame(func: () => void, requester?: any): number;
  31728. /**
  31729. * Gets host document
  31730. * @returns the host document object
  31731. */
  31732. getHostDocument(): Nullable<Document>;
  31733. }
  31734. }
  31735. declare module BABYLON {
  31736. /**
  31737. * Class representing spherical harmonics coefficients to the 3rd degree
  31738. */
  31739. export class SphericalHarmonics {
  31740. /**
  31741. * Defines whether or not the harmonics have been prescaled for rendering.
  31742. */
  31743. preScaled: boolean;
  31744. /**
  31745. * The l0,0 coefficients of the spherical harmonics
  31746. */
  31747. l00: Vector3;
  31748. /**
  31749. * The l1,-1 coefficients of the spherical harmonics
  31750. */
  31751. l1_1: Vector3;
  31752. /**
  31753. * The l1,0 coefficients of the spherical harmonics
  31754. */
  31755. l10: Vector3;
  31756. /**
  31757. * The l1,1 coefficients of the spherical harmonics
  31758. */
  31759. l11: Vector3;
  31760. /**
  31761. * The l2,-2 coefficients of the spherical harmonics
  31762. */
  31763. l2_2: Vector3;
  31764. /**
  31765. * The l2,-1 coefficients of the spherical harmonics
  31766. */
  31767. l2_1: Vector3;
  31768. /**
  31769. * The l2,0 coefficients of the spherical harmonics
  31770. */
  31771. l20: Vector3;
  31772. /**
  31773. * The l2,1 coefficients of the spherical harmonics
  31774. */
  31775. l21: Vector3;
  31776. /**
  31777. * The l2,2 coefficients of the spherical harmonics
  31778. */
  31779. l22: Vector3;
  31780. /**
  31781. * Adds a light to the spherical harmonics
  31782. * @param direction the direction of the light
  31783. * @param color the color of the light
  31784. * @param deltaSolidAngle the delta solid angle of the light
  31785. */
  31786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31787. /**
  31788. * Scales the spherical harmonics by the given amount
  31789. * @param scale the amount to scale
  31790. */
  31791. scaleInPlace(scale: number): void;
  31792. /**
  31793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31794. *
  31795. * ```
  31796. * E_lm = A_l * L_lm
  31797. * ```
  31798. *
  31799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31801. * the scaling factors are given in equation 9.
  31802. */
  31803. convertIncidentRadianceToIrradiance(): void;
  31804. /**
  31805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31806. *
  31807. * ```
  31808. * L = (1/pi) * E * rho
  31809. * ```
  31810. *
  31811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31812. */
  31813. convertIrradianceToLambertianRadiance(): void;
  31814. /**
  31815. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31816. * required operations at run time.
  31817. *
  31818. * This is simply done by scaling back the SH with Ylm constants parameter.
  31819. * The trigonometric part being applied by the shader at run time.
  31820. */
  31821. preScaleForRendering(): void;
  31822. /**
  31823. * Constructs a spherical harmonics from an array.
  31824. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31825. * @returns the spherical harmonics
  31826. */
  31827. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31828. /**
  31829. * Gets the spherical harmonics from polynomial
  31830. * @param polynomial the spherical polynomial
  31831. * @returns the spherical harmonics
  31832. */
  31833. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31834. }
  31835. /**
  31836. * Class representing spherical polynomial coefficients to the 3rd degree
  31837. */
  31838. export class SphericalPolynomial {
  31839. private _harmonics;
  31840. /**
  31841. * The spherical harmonics used to create the polynomials.
  31842. */
  31843. get preScaledHarmonics(): SphericalHarmonics;
  31844. /**
  31845. * The x coefficients of the spherical polynomial
  31846. */
  31847. x: Vector3;
  31848. /**
  31849. * The y coefficients of the spherical polynomial
  31850. */
  31851. y: Vector3;
  31852. /**
  31853. * The z coefficients of the spherical polynomial
  31854. */
  31855. z: Vector3;
  31856. /**
  31857. * The xx coefficients of the spherical polynomial
  31858. */
  31859. xx: Vector3;
  31860. /**
  31861. * The yy coefficients of the spherical polynomial
  31862. */
  31863. yy: Vector3;
  31864. /**
  31865. * The zz coefficients of the spherical polynomial
  31866. */
  31867. zz: Vector3;
  31868. /**
  31869. * The xy coefficients of the spherical polynomial
  31870. */
  31871. xy: Vector3;
  31872. /**
  31873. * The yz coefficients of the spherical polynomial
  31874. */
  31875. yz: Vector3;
  31876. /**
  31877. * The zx coefficients of the spherical polynomial
  31878. */
  31879. zx: Vector3;
  31880. /**
  31881. * Adds an ambient color to the spherical polynomial
  31882. * @param color the color to add
  31883. */
  31884. addAmbient(color: Color3): void;
  31885. /**
  31886. * Scales the spherical polynomial by the given amount
  31887. * @param scale the amount to scale
  31888. */
  31889. scaleInPlace(scale: number): void;
  31890. /**
  31891. * Gets the spherical polynomial from harmonics
  31892. * @param harmonics the spherical harmonics
  31893. * @returns the spherical polynomial
  31894. */
  31895. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31896. /**
  31897. * Constructs a spherical polynomial from an array.
  31898. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31899. * @returns the spherical polynomial
  31900. */
  31901. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31902. }
  31903. }
  31904. declare module BABYLON {
  31905. /**
  31906. * Defines the source of the internal texture
  31907. */
  31908. export enum InternalTextureSource {
  31909. /**
  31910. * The source of the texture data is unknown
  31911. */
  31912. Unknown = 0,
  31913. /**
  31914. * Texture data comes from an URL
  31915. */
  31916. Url = 1,
  31917. /**
  31918. * Texture data is only used for temporary storage
  31919. */
  31920. Temp = 2,
  31921. /**
  31922. * Texture data comes from raw data (ArrayBuffer)
  31923. */
  31924. Raw = 3,
  31925. /**
  31926. * Texture content is dynamic (video or dynamic texture)
  31927. */
  31928. Dynamic = 4,
  31929. /**
  31930. * Texture content is generated by rendering to it
  31931. */
  31932. RenderTarget = 5,
  31933. /**
  31934. * Texture content is part of a multi render target process
  31935. */
  31936. MultiRenderTarget = 6,
  31937. /**
  31938. * Texture data comes from a cube data file
  31939. */
  31940. Cube = 7,
  31941. /**
  31942. * Texture data comes from a raw cube data
  31943. */
  31944. CubeRaw = 8,
  31945. /**
  31946. * Texture data come from a prefiltered cube data file
  31947. */
  31948. CubePrefiltered = 9,
  31949. /**
  31950. * Texture content is raw 3D data
  31951. */
  31952. Raw3D = 10,
  31953. /**
  31954. * Texture content is raw 2D array data
  31955. */
  31956. Raw2DArray = 11,
  31957. /**
  31958. * Texture content is a depth texture
  31959. */
  31960. Depth = 12,
  31961. /**
  31962. * Texture data comes from a raw cube data encoded with RGBD
  31963. */
  31964. CubeRawRGBD = 13
  31965. }
  31966. /**
  31967. * Class used to store data associated with WebGL texture data for the engine
  31968. * This class should not be used directly
  31969. */
  31970. export class InternalTexture {
  31971. /** @hidden */
  31972. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31973. /**
  31974. * Defines if the texture is ready
  31975. */
  31976. isReady: boolean;
  31977. /**
  31978. * Defines if the texture is a cube texture
  31979. */
  31980. isCube: boolean;
  31981. /**
  31982. * Defines if the texture contains 3D data
  31983. */
  31984. is3D: boolean;
  31985. /**
  31986. * Defines if the texture contains 2D array data
  31987. */
  31988. is2DArray: boolean;
  31989. /**
  31990. * Defines if the texture contains multiview data
  31991. */
  31992. isMultiview: boolean;
  31993. /**
  31994. * Gets the URL used to load this texture
  31995. */
  31996. url: string;
  31997. /**
  31998. * Gets the sampling mode of the texture
  31999. */
  32000. samplingMode: number;
  32001. /**
  32002. * Gets a boolean indicating if the texture needs mipmaps generation
  32003. */
  32004. generateMipMaps: boolean;
  32005. /**
  32006. * Gets the number of samples used by the texture (WebGL2+ only)
  32007. */
  32008. samples: number;
  32009. /**
  32010. * Gets the type of the texture (int, float...)
  32011. */
  32012. type: number;
  32013. /**
  32014. * Gets the format of the texture (RGB, RGBA...)
  32015. */
  32016. format: number;
  32017. /**
  32018. * Observable called when the texture is loaded
  32019. */
  32020. onLoadedObservable: Observable<InternalTexture>;
  32021. /**
  32022. * Gets the width of the texture
  32023. */
  32024. width: number;
  32025. /**
  32026. * Gets the height of the texture
  32027. */
  32028. height: number;
  32029. /**
  32030. * Gets the depth of the texture
  32031. */
  32032. depth: number;
  32033. /**
  32034. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32035. */
  32036. baseWidth: number;
  32037. /**
  32038. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32039. */
  32040. baseHeight: number;
  32041. /**
  32042. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32043. */
  32044. baseDepth: number;
  32045. /**
  32046. * Gets a boolean indicating if the texture is inverted on Y axis
  32047. */
  32048. invertY: boolean;
  32049. /** @hidden */
  32050. _invertVScale: boolean;
  32051. /** @hidden */
  32052. _associatedChannel: number;
  32053. /** @hidden */
  32054. _source: InternalTextureSource;
  32055. /** @hidden */
  32056. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32057. /** @hidden */
  32058. _bufferView: Nullable<ArrayBufferView>;
  32059. /** @hidden */
  32060. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32061. /** @hidden */
  32062. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32063. /** @hidden */
  32064. _size: number;
  32065. /** @hidden */
  32066. _extension: string;
  32067. /** @hidden */
  32068. _files: Nullable<string[]>;
  32069. /** @hidden */
  32070. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32071. /** @hidden */
  32072. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32073. /** @hidden */
  32074. _framebuffer: Nullable<WebGLFramebuffer>;
  32075. /** @hidden */
  32076. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32077. /** @hidden */
  32078. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32079. /** @hidden */
  32080. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32081. /** @hidden */
  32082. _attachments: Nullable<number[]>;
  32083. /** @hidden */
  32084. _cachedCoordinatesMode: Nullable<number>;
  32085. /** @hidden */
  32086. _cachedWrapU: Nullable<number>;
  32087. /** @hidden */
  32088. _cachedWrapV: Nullable<number>;
  32089. /** @hidden */
  32090. _cachedWrapR: Nullable<number>;
  32091. /** @hidden */
  32092. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32093. /** @hidden */
  32094. _isDisabled: boolean;
  32095. /** @hidden */
  32096. _compression: Nullable<string>;
  32097. /** @hidden */
  32098. _generateStencilBuffer: boolean;
  32099. /** @hidden */
  32100. _generateDepthBuffer: boolean;
  32101. /** @hidden */
  32102. _comparisonFunction: number;
  32103. /** @hidden */
  32104. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32105. /** @hidden */
  32106. _lodGenerationScale: number;
  32107. /** @hidden */
  32108. _lodGenerationOffset: number;
  32109. /** @hidden */
  32110. _colorTextureArray: Nullable<WebGLTexture>;
  32111. /** @hidden */
  32112. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32113. /** @hidden */
  32114. _lodTextureHigh: Nullable<BaseTexture>;
  32115. /** @hidden */
  32116. _lodTextureMid: Nullable<BaseTexture>;
  32117. /** @hidden */
  32118. _lodTextureLow: Nullable<BaseTexture>;
  32119. /** @hidden */
  32120. _isRGBD: boolean;
  32121. /** @hidden */
  32122. _linearSpecularLOD: boolean;
  32123. /** @hidden */
  32124. _irradianceTexture: Nullable<BaseTexture>;
  32125. /** @hidden */
  32126. _webGLTexture: Nullable<WebGLTexture>;
  32127. /** @hidden */
  32128. _references: number;
  32129. private _engine;
  32130. /**
  32131. * Gets the Engine the texture belongs to.
  32132. * @returns The babylon engine
  32133. */
  32134. getEngine(): ThinEngine;
  32135. /**
  32136. * Gets the data source type of the texture
  32137. */
  32138. get source(): InternalTextureSource;
  32139. /**
  32140. * Creates a new InternalTexture
  32141. * @param engine defines the engine to use
  32142. * @param source defines the type of data that will be used
  32143. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32144. */
  32145. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32146. /**
  32147. * Increments the number of references (ie. the number of Texture that point to it)
  32148. */
  32149. incrementReferences(): void;
  32150. /**
  32151. * Change the size of the texture (not the size of the content)
  32152. * @param width defines the new width
  32153. * @param height defines the new height
  32154. * @param depth defines the new depth (1 by default)
  32155. */
  32156. updateSize(width: int, height: int, depth?: int): void;
  32157. /** @hidden */
  32158. _rebuild(): void;
  32159. /** @hidden */
  32160. _swapAndDie(target: InternalTexture): void;
  32161. /**
  32162. * Dispose the current allocated resources
  32163. */
  32164. dispose(): void;
  32165. }
  32166. }
  32167. declare module BABYLON {
  32168. /**
  32169. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32171. */
  32172. export class Analyser {
  32173. /**
  32174. * Gets or sets the smoothing
  32175. * @ignorenaming
  32176. */
  32177. SMOOTHING: number;
  32178. /**
  32179. * Gets or sets the FFT table size
  32180. * @ignorenaming
  32181. */
  32182. FFT_SIZE: number;
  32183. /**
  32184. * Gets or sets the bar graph amplitude
  32185. * @ignorenaming
  32186. */
  32187. BARGRAPHAMPLITUDE: number;
  32188. /**
  32189. * Gets or sets the position of the debug canvas
  32190. * @ignorenaming
  32191. */
  32192. DEBUGCANVASPOS: {
  32193. x: number;
  32194. y: number;
  32195. };
  32196. /**
  32197. * Gets or sets the debug canvas size
  32198. * @ignorenaming
  32199. */
  32200. DEBUGCANVASSIZE: {
  32201. width: number;
  32202. height: number;
  32203. };
  32204. private _byteFreqs;
  32205. private _byteTime;
  32206. private _floatFreqs;
  32207. private _webAudioAnalyser;
  32208. private _debugCanvas;
  32209. private _debugCanvasContext;
  32210. private _scene;
  32211. private _registerFunc;
  32212. private _audioEngine;
  32213. /**
  32214. * Creates a new analyser
  32215. * @param scene defines hosting scene
  32216. */
  32217. constructor(scene: Scene);
  32218. /**
  32219. * Get the number of data values you will have to play with for the visualization
  32220. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32221. * @returns a number
  32222. */
  32223. getFrequencyBinCount(): number;
  32224. /**
  32225. * Gets the current frequency data as a byte array
  32226. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32227. * @returns a Uint8Array
  32228. */
  32229. getByteFrequencyData(): Uint8Array;
  32230. /**
  32231. * Gets the current waveform as a byte array
  32232. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32233. * @returns a Uint8Array
  32234. */
  32235. getByteTimeDomainData(): Uint8Array;
  32236. /**
  32237. * Gets the current frequency data as a float array
  32238. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32239. * @returns a Float32Array
  32240. */
  32241. getFloatFrequencyData(): Float32Array;
  32242. /**
  32243. * Renders the debug canvas
  32244. */
  32245. drawDebugCanvas(): void;
  32246. /**
  32247. * Stops rendering the debug canvas and removes it
  32248. */
  32249. stopDebugCanvas(): void;
  32250. /**
  32251. * Connects two audio nodes
  32252. * @param inputAudioNode defines first node to connect
  32253. * @param outputAudioNode defines second node to connect
  32254. */
  32255. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32256. /**
  32257. * Releases all associated resources
  32258. */
  32259. dispose(): void;
  32260. }
  32261. }
  32262. declare module BABYLON {
  32263. /**
  32264. * This represents an audio engine and it is responsible
  32265. * to play, synchronize and analyse sounds throughout the application.
  32266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32267. */
  32268. export interface IAudioEngine extends IDisposable {
  32269. /**
  32270. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32271. */
  32272. readonly canUseWebAudio: boolean;
  32273. /**
  32274. * Gets the current AudioContext if available.
  32275. */
  32276. readonly audioContext: Nullable<AudioContext>;
  32277. /**
  32278. * The master gain node defines the global audio volume of your audio engine.
  32279. */
  32280. readonly masterGain: GainNode;
  32281. /**
  32282. * Gets whether or not mp3 are supported by your browser.
  32283. */
  32284. readonly isMP3supported: boolean;
  32285. /**
  32286. * Gets whether or not ogg are supported by your browser.
  32287. */
  32288. readonly isOGGsupported: boolean;
  32289. /**
  32290. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32291. * @ignoreNaming
  32292. */
  32293. WarnedWebAudioUnsupported: boolean;
  32294. /**
  32295. * Defines if the audio engine relies on a custom unlocked button.
  32296. * In this case, the embedded button will not be displayed.
  32297. */
  32298. useCustomUnlockedButton: boolean;
  32299. /**
  32300. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32301. */
  32302. readonly unlocked: boolean;
  32303. /**
  32304. * Event raised when audio has been unlocked on the browser.
  32305. */
  32306. onAudioUnlockedObservable: Observable<AudioEngine>;
  32307. /**
  32308. * Event raised when audio has been locked on the browser.
  32309. */
  32310. onAudioLockedObservable: Observable<AudioEngine>;
  32311. /**
  32312. * Flags the audio engine in Locked state.
  32313. * This happens due to new browser policies preventing audio to autoplay.
  32314. */
  32315. lock(): void;
  32316. /**
  32317. * Unlocks the audio engine once a user action has been done on the dom.
  32318. * This is helpful to resume play once browser policies have been satisfied.
  32319. */
  32320. unlock(): void;
  32321. }
  32322. /**
  32323. * This represents the default audio engine used in babylon.
  32324. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32326. */
  32327. export class AudioEngine implements IAudioEngine {
  32328. private _audioContext;
  32329. private _audioContextInitialized;
  32330. private _muteButton;
  32331. private _hostElement;
  32332. /**
  32333. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32334. */
  32335. canUseWebAudio: boolean;
  32336. /**
  32337. * The master gain node defines the global audio volume of your audio engine.
  32338. */
  32339. masterGain: GainNode;
  32340. /**
  32341. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32342. * @ignoreNaming
  32343. */
  32344. WarnedWebAudioUnsupported: boolean;
  32345. /**
  32346. * Gets whether or not mp3 are supported by your browser.
  32347. */
  32348. isMP3supported: boolean;
  32349. /**
  32350. * Gets whether or not ogg are supported by your browser.
  32351. */
  32352. isOGGsupported: boolean;
  32353. /**
  32354. * Gets whether audio has been unlocked on the device.
  32355. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32356. * a user interaction has happened.
  32357. */
  32358. unlocked: boolean;
  32359. /**
  32360. * Defines if the audio engine relies on a custom unlocked button.
  32361. * In this case, the embedded button will not be displayed.
  32362. */
  32363. useCustomUnlockedButton: boolean;
  32364. /**
  32365. * Event raised when audio has been unlocked on the browser.
  32366. */
  32367. onAudioUnlockedObservable: Observable<AudioEngine>;
  32368. /**
  32369. * Event raised when audio has been locked on the browser.
  32370. */
  32371. onAudioLockedObservable: Observable<AudioEngine>;
  32372. /**
  32373. * Gets the current AudioContext if available.
  32374. */
  32375. get audioContext(): Nullable<AudioContext>;
  32376. private _connectedAnalyser;
  32377. /**
  32378. * Instantiates a new audio engine.
  32379. *
  32380. * There should be only one per page as some browsers restrict the number
  32381. * of audio contexts you can create.
  32382. * @param hostElement defines the host element where to display the mute icon if necessary
  32383. */
  32384. constructor(hostElement?: Nullable<HTMLElement>);
  32385. /**
  32386. * Flags the audio engine in Locked state.
  32387. * This happens due to new browser policies preventing audio to autoplay.
  32388. */
  32389. lock(): void;
  32390. /**
  32391. * Unlocks the audio engine once a user action has been done on the dom.
  32392. * This is helpful to resume play once browser policies have been satisfied.
  32393. */
  32394. unlock(): void;
  32395. private _resumeAudioContext;
  32396. private _initializeAudioContext;
  32397. private _tryToRun;
  32398. private _triggerRunningState;
  32399. private _triggerSuspendedState;
  32400. private _displayMuteButton;
  32401. private _moveButtonToTopLeft;
  32402. private _onResize;
  32403. private _hideMuteButton;
  32404. /**
  32405. * Destroy and release the resources associated with the audio ccontext.
  32406. */
  32407. dispose(): void;
  32408. /**
  32409. * Gets the global volume sets on the master gain.
  32410. * @returns the global volume if set or -1 otherwise
  32411. */
  32412. getGlobalVolume(): number;
  32413. /**
  32414. * Sets the global volume of your experience (sets on the master gain).
  32415. * @param newVolume Defines the new global volume of the application
  32416. */
  32417. setGlobalVolume(newVolume: number): void;
  32418. /**
  32419. * Connect the audio engine to an audio analyser allowing some amazing
  32420. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32422. * @param analyser The analyser to connect to the engine
  32423. */
  32424. connectToAnalyser(analyser: Analyser): void;
  32425. }
  32426. }
  32427. declare module BABYLON {
  32428. /**
  32429. * Interface used to present a loading screen while loading a scene
  32430. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32431. */
  32432. export interface ILoadingScreen {
  32433. /**
  32434. * Function called to display the loading screen
  32435. */
  32436. displayLoadingUI: () => void;
  32437. /**
  32438. * Function called to hide the loading screen
  32439. */
  32440. hideLoadingUI: () => void;
  32441. /**
  32442. * Gets or sets the color to use for the background
  32443. */
  32444. loadingUIBackgroundColor: string;
  32445. /**
  32446. * Gets or sets the text to display while loading
  32447. */
  32448. loadingUIText: string;
  32449. }
  32450. /**
  32451. * Class used for the default loading screen
  32452. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32453. */
  32454. export class DefaultLoadingScreen implements ILoadingScreen {
  32455. private _renderingCanvas;
  32456. private _loadingText;
  32457. private _loadingDivBackgroundColor;
  32458. private _loadingDiv;
  32459. private _loadingTextDiv;
  32460. /** Gets or sets the logo url to use for the default loading screen */
  32461. static DefaultLogoUrl: string;
  32462. /** Gets or sets the spinner url to use for the default loading screen */
  32463. static DefaultSpinnerUrl: string;
  32464. /**
  32465. * Creates a new default loading screen
  32466. * @param _renderingCanvas defines the canvas used to render the scene
  32467. * @param _loadingText defines the default text to display
  32468. * @param _loadingDivBackgroundColor defines the default background color
  32469. */
  32470. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32471. /**
  32472. * Function called to display the loading screen
  32473. */
  32474. displayLoadingUI(): void;
  32475. /**
  32476. * Function called to hide the loading screen
  32477. */
  32478. hideLoadingUI(): void;
  32479. /**
  32480. * Gets or sets the text to display while loading
  32481. */
  32482. set loadingUIText(text: string);
  32483. get loadingUIText(): string;
  32484. /**
  32485. * Gets or sets the color to use for the background
  32486. */
  32487. get loadingUIBackgroundColor(): string;
  32488. set loadingUIBackgroundColor(color: string);
  32489. private _resizeLoadingUI;
  32490. }
  32491. }
  32492. declare module BABYLON {
  32493. /**
  32494. * Interface for any object that can request an animation frame
  32495. */
  32496. export interface ICustomAnimationFrameRequester {
  32497. /**
  32498. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32499. */
  32500. renderFunction?: Function;
  32501. /**
  32502. * Called to request the next frame to render to
  32503. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32504. */
  32505. requestAnimationFrame: Function;
  32506. /**
  32507. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32508. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32509. */
  32510. requestID?: number;
  32511. }
  32512. }
  32513. declare module BABYLON {
  32514. /**
  32515. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32516. */
  32517. export class PerformanceMonitor {
  32518. private _enabled;
  32519. private _rollingFrameTime;
  32520. private _lastFrameTimeMs;
  32521. /**
  32522. * constructor
  32523. * @param frameSampleSize The number of samples required to saturate the sliding window
  32524. */
  32525. constructor(frameSampleSize?: number);
  32526. /**
  32527. * Samples current frame
  32528. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32529. */
  32530. sampleFrame(timeMs?: number): void;
  32531. /**
  32532. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32533. */
  32534. get averageFrameTime(): number;
  32535. /**
  32536. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32537. */
  32538. get averageFrameTimeVariance(): number;
  32539. /**
  32540. * Returns the frame time of the most recent frame
  32541. */
  32542. get instantaneousFrameTime(): number;
  32543. /**
  32544. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32545. */
  32546. get averageFPS(): number;
  32547. /**
  32548. * Returns the average framerate in frames per second using the most recent frame time
  32549. */
  32550. get instantaneousFPS(): number;
  32551. /**
  32552. * Returns true if enough samples have been taken to completely fill the sliding window
  32553. */
  32554. get isSaturated(): boolean;
  32555. /**
  32556. * Enables contributions to the sliding window sample set
  32557. */
  32558. enable(): void;
  32559. /**
  32560. * Disables contributions to the sliding window sample set
  32561. * Samples will not be interpolated over the disabled period
  32562. */
  32563. disable(): void;
  32564. /**
  32565. * Returns true if sampling is enabled
  32566. */
  32567. get isEnabled(): boolean;
  32568. /**
  32569. * Resets performance monitor
  32570. */
  32571. reset(): void;
  32572. }
  32573. /**
  32574. * RollingAverage
  32575. *
  32576. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32577. */
  32578. export class RollingAverage {
  32579. /**
  32580. * Current average
  32581. */
  32582. average: number;
  32583. /**
  32584. * Current variance
  32585. */
  32586. variance: number;
  32587. protected _samples: Array<number>;
  32588. protected _sampleCount: number;
  32589. protected _pos: number;
  32590. protected _m2: number;
  32591. /**
  32592. * constructor
  32593. * @param length The number of samples required to saturate the sliding window
  32594. */
  32595. constructor(length: number);
  32596. /**
  32597. * Adds a sample to the sample set
  32598. * @param v The sample value
  32599. */
  32600. add(v: number): void;
  32601. /**
  32602. * Returns previously added values or null if outside of history or outside the sliding window domain
  32603. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32604. * @return Value previously recorded with add() or null if outside of range
  32605. */
  32606. history(i: number): number;
  32607. /**
  32608. * Returns true if enough samples have been taken to completely fill the sliding window
  32609. * @return true if sample-set saturated
  32610. */
  32611. isSaturated(): boolean;
  32612. /**
  32613. * Resets the rolling average (equivalent to 0 samples taken so far)
  32614. */
  32615. reset(): void;
  32616. /**
  32617. * Wraps a value around the sample range boundaries
  32618. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32619. * @return Wrapped position in sample range
  32620. */
  32621. protected _wrapPosition(i: number): number;
  32622. }
  32623. }
  32624. declare module BABYLON {
  32625. /**
  32626. * This class is used to track a performance counter which is number based.
  32627. * The user has access to many properties which give statistics of different nature.
  32628. *
  32629. * The implementer can track two kinds of Performance Counter: time and count.
  32630. * 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.
  32631. * 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.
  32632. */
  32633. export class PerfCounter {
  32634. /**
  32635. * Gets or sets a global boolean to turn on and off all the counters
  32636. */
  32637. static Enabled: boolean;
  32638. /**
  32639. * Returns the smallest value ever
  32640. */
  32641. get min(): number;
  32642. /**
  32643. * Returns the biggest value ever
  32644. */
  32645. get max(): number;
  32646. /**
  32647. * Returns the average value since the performance counter is running
  32648. */
  32649. get average(): number;
  32650. /**
  32651. * Returns the average value of the last second the counter was monitored
  32652. */
  32653. get lastSecAverage(): number;
  32654. /**
  32655. * Returns the current value
  32656. */
  32657. get current(): number;
  32658. /**
  32659. * Gets the accumulated total
  32660. */
  32661. get total(): number;
  32662. /**
  32663. * Gets the total value count
  32664. */
  32665. get count(): number;
  32666. /**
  32667. * Creates a new counter
  32668. */
  32669. constructor();
  32670. /**
  32671. * Call this method to start monitoring a new frame.
  32672. * 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.
  32673. */
  32674. fetchNewFrame(): void;
  32675. /**
  32676. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32677. * @param newCount the count value to add to the monitored count
  32678. * @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.
  32679. */
  32680. addCount(newCount: number, fetchResult: boolean): void;
  32681. /**
  32682. * Start monitoring this performance counter
  32683. */
  32684. beginMonitoring(): void;
  32685. /**
  32686. * Compute the time lapsed since the previous beginMonitoring() call.
  32687. * @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
  32688. */
  32689. endMonitoring(newFrame?: boolean): void;
  32690. private _fetchResult;
  32691. private _startMonitoringTime;
  32692. private _min;
  32693. private _max;
  32694. private _average;
  32695. private _current;
  32696. private _totalValueCount;
  32697. private _totalAccumulated;
  32698. private _lastSecAverage;
  32699. private _lastSecAccumulated;
  32700. private _lastSecTime;
  32701. private _lastSecValueCount;
  32702. }
  32703. }
  32704. declare module BABYLON {
  32705. interface ThinEngine {
  32706. /**
  32707. * Sets alpha constants used by some alpha blending modes
  32708. * @param r defines the red component
  32709. * @param g defines the green component
  32710. * @param b defines the blue component
  32711. * @param a defines the alpha component
  32712. */
  32713. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32714. /**
  32715. * Sets the current alpha mode
  32716. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32717. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32718. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32719. */
  32720. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32721. /**
  32722. * Gets the current alpha mode
  32723. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32724. * @returns the current alpha mode
  32725. */
  32726. getAlphaMode(): number;
  32727. /**
  32728. * Sets the current alpha equation
  32729. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32730. */
  32731. setAlphaEquation(equation: number): void;
  32732. /**
  32733. * Gets the current alpha equation.
  32734. * @returns the current alpha equation
  32735. */
  32736. getAlphaEquation(): number;
  32737. }
  32738. }
  32739. declare module BABYLON {
  32740. /**
  32741. * Defines the interface used by display changed events
  32742. */
  32743. export interface IDisplayChangedEventArgs {
  32744. /** Gets the vrDisplay object (if any) */
  32745. vrDisplay: Nullable<any>;
  32746. /** Gets a boolean indicating if webVR is supported */
  32747. vrSupported: boolean;
  32748. }
  32749. /**
  32750. * Defines the interface used by objects containing a viewport (like a camera)
  32751. */
  32752. interface IViewportOwnerLike {
  32753. /**
  32754. * Gets or sets the viewport
  32755. */
  32756. viewport: IViewportLike;
  32757. }
  32758. /**
  32759. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32760. */
  32761. export class Engine extends ThinEngine {
  32762. /** Defines that alpha blending is disabled */
  32763. static readonly ALPHA_DISABLE: number;
  32764. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32765. static readonly ALPHA_ADD: number;
  32766. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32767. static readonly ALPHA_COMBINE: number;
  32768. /** Defines that alpha blending to DEST - SRC * DEST */
  32769. static readonly ALPHA_SUBTRACT: number;
  32770. /** Defines that alpha blending to SRC * DEST */
  32771. static readonly ALPHA_MULTIPLY: number;
  32772. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32773. static readonly ALPHA_MAXIMIZED: number;
  32774. /** Defines that alpha blending to SRC + DEST */
  32775. static readonly ALPHA_ONEONE: number;
  32776. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32777. static readonly ALPHA_PREMULTIPLIED: number;
  32778. /**
  32779. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32780. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32781. */
  32782. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32783. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32784. static readonly ALPHA_INTERPOLATE: number;
  32785. /**
  32786. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32787. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32788. */
  32789. static readonly ALPHA_SCREENMODE: number;
  32790. /** Defines that the ressource is not delayed*/
  32791. static readonly DELAYLOADSTATE_NONE: number;
  32792. /** Defines that the ressource was successfully delay loaded */
  32793. static readonly DELAYLOADSTATE_LOADED: number;
  32794. /** Defines that the ressource is currently delay loading */
  32795. static readonly DELAYLOADSTATE_LOADING: number;
  32796. /** Defines that the ressource is delayed and has not started loading */
  32797. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32798. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32799. static readonly NEVER: number;
  32800. /** 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 */
  32801. static readonly ALWAYS: number;
  32802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32803. static readonly LESS: number;
  32804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32805. static readonly EQUAL: number;
  32806. /** 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 */
  32807. static readonly LEQUAL: number;
  32808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32809. static readonly GREATER: number;
  32810. /** 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 */
  32811. static readonly GEQUAL: number;
  32812. /** 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 */
  32813. static readonly NOTEQUAL: number;
  32814. /** Passed to stencilOperation to specify that stencil value must be kept */
  32815. static readonly KEEP: number;
  32816. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32817. static readonly REPLACE: number;
  32818. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32819. static readonly INCR: number;
  32820. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32821. static readonly DECR: number;
  32822. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32823. static readonly INVERT: number;
  32824. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32825. static readonly INCR_WRAP: number;
  32826. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32827. static readonly DECR_WRAP: number;
  32828. /** Texture is not repeating outside of 0..1 UVs */
  32829. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32830. /** Texture is repeating outside of 0..1 UVs */
  32831. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32832. /** Texture is repeating and mirrored */
  32833. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32834. /** ALPHA */
  32835. static readonly TEXTUREFORMAT_ALPHA: number;
  32836. /** LUMINANCE */
  32837. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32838. /** LUMINANCE_ALPHA */
  32839. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32840. /** RGB */
  32841. static readonly TEXTUREFORMAT_RGB: number;
  32842. /** RGBA */
  32843. static readonly TEXTUREFORMAT_RGBA: number;
  32844. /** RED */
  32845. static readonly TEXTUREFORMAT_RED: number;
  32846. /** RED (2nd reference) */
  32847. static readonly TEXTUREFORMAT_R: number;
  32848. /** RG */
  32849. static readonly TEXTUREFORMAT_RG: number;
  32850. /** RED_INTEGER */
  32851. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32852. /** RED_INTEGER (2nd reference) */
  32853. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32854. /** RG_INTEGER */
  32855. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32856. /** RGB_INTEGER */
  32857. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32858. /** RGBA_INTEGER */
  32859. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32860. /** UNSIGNED_BYTE */
  32861. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32862. /** UNSIGNED_BYTE (2nd reference) */
  32863. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32864. /** FLOAT */
  32865. static readonly TEXTURETYPE_FLOAT: number;
  32866. /** HALF_FLOAT */
  32867. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32868. /** BYTE */
  32869. static readonly TEXTURETYPE_BYTE: number;
  32870. /** SHORT */
  32871. static readonly TEXTURETYPE_SHORT: number;
  32872. /** UNSIGNED_SHORT */
  32873. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32874. /** INT */
  32875. static readonly TEXTURETYPE_INT: number;
  32876. /** UNSIGNED_INT */
  32877. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32878. /** UNSIGNED_SHORT_4_4_4_4 */
  32879. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32880. /** UNSIGNED_SHORT_5_5_5_1 */
  32881. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32882. /** UNSIGNED_SHORT_5_6_5 */
  32883. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32884. /** UNSIGNED_INT_2_10_10_10_REV */
  32885. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32886. /** UNSIGNED_INT_24_8 */
  32887. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32888. /** UNSIGNED_INT_10F_11F_11F_REV */
  32889. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32890. /** UNSIGNED_INT_5_9_9_9_REV */
  32891. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32892. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32893. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32894. /** nearest is mag = nearest and min = nearest and mip = linear */
  32895. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32896. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32897. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32898. /** Trilinear is mag = linear and min = linear and mip = linear */
  32899. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32900. /** nearest is mag = nearest and min = nearest and mip = linear */
  32901. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32902. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32903. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32904. /** Trilinear is mag = linear and min = linear and mip = linear */
  32905. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32906. /** mag = nearest and min = nearest and mip = nearest */
  32907. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32908. /** mag = nearest and min = linear and mip = nearest */
  32909. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32910. /** mag = nearest and min = linear and mip = linear */
  32911. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32912. /** mag = nearest and min = linear and mip = none */
  32913. static readonly TEXTURE_NEAREST_LINEAR: number;
  32914. /** mag = nearest and min = nearest and mip = none */
  32915. static readonly TEXTURE_NEAREST_NEAREST: number;
  32916. /** mag = linear and min = nearest and mip = nearest */
  32917. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32918. /** mag = linear and min = nearest and mip = linear */
  32919. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32920. /** mag = linear and min = linear and mip = none */
  32921. static readonly TEXTURE_LINEAR_LINEAR: number;
  32922. /** mag = linear and min = nearest and mip = none */
  32923. static readonly TEXTURE_LINEAR_NEAREST: number;
  32924. /** Explicit coordinates mode */
  32925. static readonly TEXTURE_EXPLICIT_MODE: number;
  32926. /** Spherical coordinates mode */
  32927. static readonly TEXTURE_SPHERICAL_MODE: number;
  32928. /** Planar coordinates mode */
  32929. static readonly TEXTURE_PLANAR_MODE: number;
  32930. /** Cubic coordinates mode */
  32931. static readonly TEXTURE_CUBIC_MODE: number;
  32932. /** Projection coordinates mode */
  32933. static readonly TEXTURE_PROJECTION_MODE: number;
  32934. /** Skybox coordinates mode */
  32935. static readonly TEXTURE_SKYBOX_MODE: number;
  32936. /** Inverse Cubic coordinates mode */
  32937. static readonly TEXTURE_INVCUBIC_MODE: number;
  32938. /** Equirectangular coordinates mode */
  32939. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32940. /** Equirectangular Fixed coordinates mode */
  32941. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32942. /** Equirectangular Fixed Mirrored coordinates mode */
  32943. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32944. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32945. static readonly SCALEMODE_FLOOR: number;
  32946. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32947. static readonly SCALEMODE_NEAREST: number;
  32948. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32949. static readonly SCALEMODE_CEILING: number;
  32950. /**
  32951. * Returns the current npm package of the sdk
  32952. */
  32953. static get NpmPackage(): string;
  32954. /**
  32955. * Returns the current version of the framework
  32956. */
  32957. static get Version(): string;
  32958. /** Gets the list of created engines */
  32959. static get Instances(): Engine[];
  32960. /**
  32961. * Gets the latest created engine
  32962. */
  32963. static get LastCreatedEngine(): Nullable<Engine>;
  32964. /**
  32965. * Gets the latest created scene
  32966. */
  32967. static get LastCreatedScene(): Nullable<Scene>;
  32968. /**
  32969. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32970. * @param flag defines which part of the materials must be marked as dirty
  32971. * @param predicate defines a predicate used to filter which materials should be affected
  32972. */
  32973. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32974. /**
  32975. * Method called to create the default loading screen.
  32976. * This can be overriden in your own app.
  32977. * @param canvas The rendering canvas element
  32978. * @returns The loading screen
  32979. */
  32980. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32981. /**
  32982. * Method called to create the default rescale post process on each engine.
  32983. */
  32984. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32985. /**
  32986. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32987. **/
  32988. enableOfflineSupport: boolean;
  32989. /**
  32990. * 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)
  32991. **/
  32992. disableManifestCheck: boolean;
  32993. /**
  32994. * Gets the list of created scenes
  32995. */
  32996. scenes: Scene[];
  32997. /**
  32998. * Event raised when a new scene is created
  32999. */
  33000. onNewSceneAddedObservable: Observable<Scene>;
  33001. /**
  33002. * Gets the list of created postprocesses
  33003. */
  33004. postProcesses: PostProcess[];
  33005. /**
  33006. * Gets a boolean indicating if the pointer is currently locked
  33007. */
  33008. isPointerLock: boolean;
  33009. /**
  33010. * Observable event triggered each time the rendering canvas is resized
  33011. */
  33012. onResizeObservable: Observable<Engine>;
  33013. /**
  33014. * Observable event triggered each time the canvas loses focus
  33015. */
  33016. onCanvasBlurObservable: Observable<Engine>;
  33017. /**
  33018. * Observable event triggered each time the canvas gains focus
  33019. */
  33020. onCanvasFocusObservable: Observable<Engine>;
  33021. /**
  33022. * Observable event triggered each time the canvas receives pointerout event
  33023. */
  33024. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33025. /**
  33026. * Observable raised when the engine begins a new frame
  33027. */
  33028. onBeginFrameObservable: Observable<Engine>;
  33029. /**
  33030. * If set, will be used to request the next animation frame for the render loop
  33031. */
  33032. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33033. /**
  33034. * Observable raised when the engine ends the current frame
  33035. */
  33036. onEndFrameObservable: Observable<Engine>;
  33037. /**
  33038. * Observable raised when the engine is about to compile a shader
  33039. */
  33040. onBeforeShaderCompilationObservable: Observable<Engine>;
  33041. /**
  33042. * Observable raised when the engine has jsut compiled a shader
  33043. */
  33044. onAfterShaderCompilationObservable: Observable<Engine>;
  33045. /**
  33046. * Gets the audio engine
  33047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33048. * @ignorenaming
  33049. */
  33050. static audioEngine: IAudioEngine;
  33051. /**
  33052. * Default AudioEngine factory responsible of creating the Audio Engine.
  33053. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33054. */
  33055. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33056. /**
  33057. * Default offline support factory responsible of creating a tool used to store data locally.
  33058. * By default, this will create a Database object if the workload has been embedded.
  33059. */
  33060. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33061. private _loadingScreen;
  33062. private _pointerLockRequested;
  33063. private _dummyFramebuffer;
  33064. private _rescalePostProcess;
  33065. private _deterministicLockstep;
  33066. private _lockstepMaxSteps;
  33067. private _timeStep;
  33068. protected get _supportsHardwareTextureRescaling(): boolean;
  33069. private _fps;
  33070. private _deltaTime;
  33071. /** @hidden */
  33072. _drawCalls: PerfCounter;
  33073. /**
  33074. * Turn this value on if you want to pause FPS computation when in background
  33075. */
  33076. disablePerformanceMonitorInBackground: boolean;
  33077. private _performanceMonitor;
  33078. /**
  33079. * Gets the performance monitor attached to this engine
  33080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33081. */
  33082. get performanceMonitor(): PerformanceMonitor;
  33083. private _onFocus;
  33084. private _onBlur;
  33085. private _onCanvasPointerOut;
  33086. private _onCanvasBlur;
  33087. private _onCanvasFocus;
  33088. private _onFullscreenChange;
  33089. private _onPointerLockChange;
  33090. /**
  33091. * Gets the HTML element used to attach event listeners
  33092. * @returns a HTML element
  33093. */
  33094. getInputElement(): Nullable<HTMLElement>;
  33095. /**
  33096. * Creates a new engine
  33097. * @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
  33098. * @param antialias defines enable antialiasing (default: false)
  33099. * @param options defines further options to be sent to the getContext() function
  33100. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33101. */
  33102. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33103. /**
  33104. * Gets current aspect ratio
  33105. * @param viewportOwner defines the camera to use to get the aspect ratio
  33106. * @param useScreen defines if screen size must be used (or the current render target if any)
  33107. * @returns a number defining the aspect ratio
  33108. */
  33109. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33110. /**
  33111. * Gets current screen aspect ratio
  33112. * @returns a number defining the aspect ratio
  33113. */
  33114. getScreenAspectRatio(): number;
  33115. /**
  33116. * Gets the client rect of the HTML canvas attached with the current webGL context
  33117. * @returns a client rectanglee
  33118. */
  33119. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33120. /**
  33121. * Gets the client rect of the HTML element used for events
  33122. * @returns a client rectanglee
  33123. */
  33124. getInputElementClientRect(): Nullable<ClientRect>;
  33125. /**
  33126. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33127. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33128. * @returns true if engine is in deterministic lock step mode
  33129. */
  33130. isDeterministicLockStep(): boolean;
  33131. /**
  33132. * Gets the max steps when engine is running in deterministic lock step
  33133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33134. * @returns the max steps
  33135. */
  33136. getLockstepMaxSteps(): number;
  33137. /**
  33138. * Returns the time in ms between steps when using deterministic lock step.
  33139. * @returns time step in (ms)
  33140. */
  33141. getTimeStep(): number;
  33142. /**
  33143. * Force the mipmap generation for the given render target texture
  33144. * @param texture defines the render target texture to use
  33145. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33146. */
  33147. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33148. /** States */
  33149. /**
  33150. * Set various states to the webGL context
  33151. * @param culling defines backface culling state
  33152. * @param zOffset defines the value to apply to zOffset (0 by default)
  33153. * @param force defines if states must be applied even if cache is up to date
  33154. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33155. */
  33156. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33157. /**
  33158. * Set the z offset to apply to current rendering
  33159. * @param value defines the offset to apply
  33160. */
  33161. setZOffset(value: number): void;
  33162. /**
  33163. * Gets the current value of the zOffset
  33164. * @returns the current zOffset state
  33165. */
  33166. getZOffset(): number;
  33167. /**
  33168. * Enable or disable depth buffering
  33169. * @param enable defines the state to set
  33170. */
  33171. setDepthBuffer(enable: boolean): void;
  33172. /**
  33173. * Gets a boolean indicating if depth writing is enabled
  33174. * @returns the current depth writing state
  33175. */
  33176. getDepthWrite(): boolean;
  33177. /**
  33178. * Enable or disable depth writing
  33179. * @param enable defines the state to set
  33180. */
  33181. setDepthWrite(enable: boolean): void;
  33182. /**
  33183. * Gets a boolean indicating if stencil buffer is enabled
  33184. * @returns the current stencil buffer state
  33185. */
  33186. getStencilBuffer(): boolean;
  33187. /**
  33188. * Enable or disable the stencil buffer
  33189. * @param enable defines if the stencil buffer must be enabled or disabled
  33190. */
  33191. setStencilBuffer(enable: boolean): void;
  33192. /**
  33193. * Gets the current stencil mask
  33194. * @returns a number defining the new stencil mask to use
  33195. */
  33196. getStencilMask(): number;
  33197. /**
  33198. * Sets the current stencil mask
  33199. * @param mask defines the new stencil mask to use
  33200. */
  33201. setStencilMask(mask: number): void;
  33202. /**
  33203. * Gets the current stencil function
  33204. * @returns a number defining the stencil function to use
  33205. */
  33206. getStencilFunction(): number;
  33207. /**
  33208. * Gets the current stencil reference value
  33209. * @returns a number defining the stencil reference value to use
  33210. */
  33211. getStencilFunctionReference(): number;
  33212. /**
  33213. * Gets the current stencil mask
  33214. * @returns a number defining the stencil mask to use
  33215. */
  33216. getStencilFunctionMask(): number;
  33217. /**
  33218. * Sets the current stencil function
  33219. * @param stencilFunc defines the new stencil function to use
  33220. */
  33221. setStencilFunction(stencilFunc: number): void;
  33222. /**
  33223. * Sets the current stencil reference
  33224. * @param reference defines the new stencil reference to use
  33225. */
  33226. setStencilFunctionReference(reference: number): void;
  33227. /**
  33228. * Sets the current stencil mask
  33229. * @param mask defines the new stencil mask to use
  33230. */
  33231. setStencilFunctionMask(mask: number): void;
  33232. /**
  33233. * Gets the current stencil operation when stencil fails
  33234. * @returns a number defining stencil operation to use when stencil fails
  33235. */
  33236. getStencilOperationFail(): number;
  33237. /**
  33238. * Gets the current stencil operation when depth fails
  33239. * @returns a number defining stencil operation to use when depth fails
  33240. */
  33241. getStencilOperationDepthFail(): number;
  33242. /**
  33243. * Gets the current stencil operation when stencil passes
  33244. * @returns a number defining stencil operation to use when stencil passes
  33245. */
  33246. getStencilOperationPass(): number;
  33247. /**
  33248. * Sets the stencil operation to use when stencil fails
  33249. * @param operation defines the stencil operation to use when stencil fails
  33250. */
  33251. setStencilOperationFail(operation: number): void;
  33252. /**
  33253. * Sets the stencil operation to use when depth fails
  33254. * @param operation defines the stencil operation to use when depth fails
  33255. */
  33256. setStencilOperationDepthFail(operation: number): void;
  33257. /**
  33258. * Sets the stencil operation to use when stencil passes
  33259. * @param operation defines the stencil operation to use when stencil passes
  33260. */
  33261. setStencilOperationPass(operation: number): void;
  33262. /**
  33263. * Sets a boolean indicating if the dithering state is enabled or disabled
  33264. * @param value defines the dithering state
  33265. */
  33266. setDitheringState(value: boolean): void;
  33267. /**
  33268. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33269. * @param value defines the rasterizer state
  33270. */
  33271. setRasterizerState(value: boolean): void;
  33272. /**
  33273. * Gets the current depth function
  33274. * @returns a number defining the depth function
  33275. */
  33276. getDepthFunction(): Nullable<number>;
  33277. /**
  33278. * Sets the current depth function
  33279. * @param depthFunc defines the function to use
  33280. */
  33281. setDepthFunction(depthFunc: number): void;
  33282. /**
  33283. * Sets the current depth function to GREATER
  33284. */
  33285. setDepthFunctionToGreater(): void;
  33286. /**
  33287. * Sets the current depth function to GEQUAL
  33288. */
  33289. setDepthFunctionToGreaterOrEqual(): void;
  33290. /**
  33291. * Sets the current depth function to LESS
  33292. */
  33293. setDepthFunctionToLess(): void;
  33294. /**
  33295. * Sets the current depth function to LEQUAL
  33296. */
  33297. setDepthFunctionToLessOrEqual(): void;
  33298. private _cachedStencilBuffer;
  33299. private _cachedStencilFunction;
  33300. private _cachedStencilMask;
  33301. private _cachedStencilOperationPass;
  33302. private _cachedStencilOperationFail;
  33303. private _cachedStencilOperationDepthFail;
  33304. private _cachedStencilReference;
  33305. /**
  33306. * Caches the the state of the stencil buffer
  33307. */
  33308. cacheStencilState(): void;
  33309. /**
  33310. * Restores the state of the stencil buffer
  33311. */
  33312. restoreStencilState(): void;
  33313. /**
  33314. * Directly set the WebGL Viewport
  33315. * @param x defines the x coordinate of the viewport (in screen space)
  33316. * @param y defines the y coordinate of the viewport (in screen space)
  33317. * @param width defines the width of the viewport (in screen space)
  33318. * @param height defines the height of the viewport (in screen space)
  33319. * @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
  33320. */
  33321. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33322. /**
  33323. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33324. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33325. * @param y defines the y-coordinate of the corner of the clear rectangle
  33326. * @param width defines the width of the clear rectangle
  33327. * @param height defines the height of the clear rectangle
  33328. * @param clearColor defines the clear color
  33329. */
  33330. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33331. /**
  33332. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33333. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33334. * @param y defines the y-coordinate of the corner of the clear rectangle
  33335. * @param width defines the width of the clear rectangle
  33336. * @param height defines the height of the clear rectangle
  33337. */
  33338. enableScissor(x: number, y: number, width: number, height: number): void;
  33339. /**
  33340. * Disable previously set scissor test rectangle
  33341. */
  33342. disableScissor(): void;
  33343. protected _reportDrawCall(): void;
  33344. /**
  33345. * Initializes a webVR display and starts listening to display change events
  33346. * The onVRDisplayChangedObservable will be notified upon these changes
  33347. * @returns The onVRDisplayChangedObservable
  33348. */
  33349. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33350. /** @hidden */
  33351. _prepareVRComponent(): void;
  33352. /** @hidden */
  33353. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33354. /** @hidden */
  33355. _submitVRFrame(): void;
  33356. /**
  33357. * Call this function to leave webVR mode
  33358. * Will do nothing if webVR is not supported or if there is no webVR device
  33359. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33360. */
  33361. disableVR(): void;
  33362. /**
  33363. * Gets a boolean indicating that the system is in VR mode and is presenting
  33364. * @returns true if VR mode is engaged
  33365. */
  33366. isVRPresenting(): boolean;
  33367. /** @hidden */
  33368. _requestVRFrame(): void;
  33369. /** @hidden */
  33370. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33371. /**
  33372. * Gets the source code of the vertex shader associated with a specific webGL program
  33373. * @param program defines the program to use
  33374. * @returns a string containing the source code of the vertex shader associated with the program
  33375. */
  33376. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33377. /**
  33378. * Gets the source code of the fragment shader associated with a specific webGL program
  33379. * @param program defines the program to use
  33380. * @returns a string containing the source code of the fragment shader associated with the program
  33381. */
  33382. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33383. /**
  33384. * Sets a depth stencil texture from a render target to the according uniform.
  33385. * @param channel The texture channel
  33386. * @param uniform The uniform to set
  33387. * @param texture The render target texture containing the depth stencil texture to apply
  33388. */
  33389. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33390. /**
  33391. * Sets a texture to the webGL context from a postprocess
  33392. * @param channel defines the channel to use
  33393. * @param postProcess defines the source postprocess
  33394. */
  33395. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33396. /**
  33397. * Binds the output of the passed in post process to the texture channel specified
  33398. * @param channel The channel the texture should be bound to
  33399. * @param postProcess The post process which's output should be bound
  33400. */
  33401. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33402. /** @hidden */
  33403. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33404. protected _rebuildBuffers(): void;
  33405. /** @hidden */
  33406. _renderFrame(): void;
  33407. _renderLoop(): void;
  33408. /** @hidden */
  33409. _renderViews(): boolean;
  33410. /**
  33411. * Toggle full screen mode
  33412. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33413. */
  33414. switchFullscreen(requestPointerLock: boolean): void;
  33415. /**
  33416. * Enters full screen mode
  33417. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33418. */
  33419. enterFullscreen(requestPointerLock: boolean): void;
  33420. /**
  33421. * Exits full screen mode
  33422. */
  33423. exitFullscreen(): void;
  33424. /**
  33425. * Enters Pointerlock mode
  33426. */
  33427. enterPointerlock(): void;
  33428. /**
  33429. * Exits Pointerlock mode
  33430. */
  33431. exitPointerlock(): void;
  33432. /**
  33433. * Begin a new frame
  33434. */
  33435. beginFrame(): void;
  33436. /**
  33437. * Enf the current frame
  33438. */
  33439. endFrame(): void;
  33440. resize(): void;
  33441. /**
  33442. * Set the compressed texture format to use, based on the formats you have, and the formats
  33443. * supported by the hardware / browser.
  33444. *
  33445. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33446. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33447. * to API arguments needed to compressed textures. This puts the burden on the container
  33448. * generator to house the arcane code for determining these for current & future formats.
  33449. *
  33450. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33451. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33452. *
  33453. * Note: The result of this call is not taken into account when a texture is base64.
  33454. *
  33455. * @param formatsAvailable defines the list of those format families you have created
  33456. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33457. *
  33458. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33459. * @returns The extension selected.
  33460. */
  33461. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33462. /**
  33463. * Set the compressed texture extensions or file names to skip.
  33464. *
  33465. * @param skippedFiles defines the list of those texture files you want to skip
  33466. * Example: [".dds", ".env", "myfile.png"]
  33467. */
  33468. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33469. /**
  33470. * Force a specific size of the canvas
  33471. * @param width defines the new canvas' width
  33472. * @param height defines the new canvas' height
  33473. */
  33474. setSize(width: number, height: number): void;
  33475. /**
  33476. * Updates a dynamic vertex buffer.
  33477. * @param vertexBuffer the vertex buffer to update
  33478. * @param data the data used to update the vertex buffer
  33479. * @param byteOffset the byte offset of the data
  33480. * @param byteLength the byte length of the data
  33481. */
  33482. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33483. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33484. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33485. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33486. _releaseTexture(texture: InternalTexture): void;
  33487. /**
  33488. * @hidden
  33489. * Rescales a texture
  33490. * @param source input texutre
  33491. * @param destination destination texture
  33492. * @param scene scene to use to render the resize
  33493. * @param internalFormat format to use when resizing
  33494. * @param onComplete callback to be called when resize has completed
  33495. */
  33496. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33497. /**
  33498. * Gets the current framerate
  33499. * @returns a number representing the framerate
  33500. */
  33501. getFps(): number;
  33502. /**
  33503. * Gets the time spent between current and previous frame
  33504. * @returns a number representing the delta time in ms
  33505. */
  33506. getDeltaTime(): number;
  33507. private _measureFps;
  33508. /** @hidden */
  33509. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33510. /**
  33511. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33512. * @param renderTarget The render target to set the frame buffer for
  33513. */
  33514. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33515. /**
  33516. * Update a dynamic index buffer
  33517. * @param indexBuffer defines the target index buffer
  33518. * @param indices defines the data to update
  33519. * @param offset defines the offset in the target index buffer where update should start
  33520. */
  33521. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33522. /**
  33523. * Updates the sample count of a render target texture
  33524. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33525. * @param texture defines the texture to update
  33526. * @param samples defines the sample count to set
  33527. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33528. */
  33529. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33530. /**
  33531. * Updates a depth texture Comparison Mode and Function.
  33532. * If the comparison Function is equal to 0, the mode will be set to none.
  33533. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33534. * @param texture The texture to set the comparison function for
  33535. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33536. */
  33537. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33538. /**
  33539. * Creates a webGL buffer to use with instanciation
  33540. * @param capacity defines the size of the buffer
  33541. * @returns the webGL buffer
  33542. */
  33543. createInstancesBuffer(capacity: number): DataBuffer;
  33544. /**
  33545. * Delete a webGL buffer used with instanciation
  33546. * @param buffer defines the webGL buffer to delete
  33547. */
  33548. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33549. /** @hidden */
  33550. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33551. dispose(): void;
  33552. private _disableTouchAction;
  33553. /**
  33554. * Display the loading screen
  33555. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33556. */
  33557. displayLoadingUI(): void;
  33558. /**
  33559. * Hide the loading screen
  33560. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33561. */
  33562. hideLoadingUI(): void;
  33563. /**
  33564. * Gets the current loading screen object
  33565. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33566. */
  33567. get loadingScreen(): ILoadingScreen;
  33568. /**
  33569. * Sets the current loading screen object
  33570. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33571. */
  33572. set loadingScreen(loadingScreen: ILoadingScreen);
  33573. /**
  33574. * Sets the current loading screen text
  33575. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33576. */
  33577. set loadingUIText(text: string);
  33578. /**
  33579. * Sets the current loading screen background color
  33580. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33581. */
  33582. set loadingUIBackgroundColor(color: string);
  33583. /** Pointerlock and fullscreen */
  33584. /**
  33585. * Ask the browser to promote the current element to pointerlock mode
  33586. * @param element defines the DOM element to promote
  33587. */
  33588. static _RequestPointerlock(element: HTMLElement): void;
  33589. /**
  33590. * Asks the browser to exit pointerlock mode
  33591. */
  33592. static _ExitPointerlock(): void;
  33593. /**
  33594. * Ask the browser to promote the current element to fullscreen rendering mode
  33595. * @param element defines the DOM element to promote
  33596. */
  33597. static _RequestFullscreen(element: HTMLElement): void;
  33598. /**
  33599. * Asks the browser to exit fullscreen mode
  33600. */
  33601. static _ExitFullscreen(): void;
  33602. }
  33603. }
  33604. declare module BABYLON {
  33605. /**
  33606. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33607. * during the life time of the application.
  33608. */
  33609. export class EngineStore {
  33610. /** Gets the list of created engines */
  33611. static Instances: Engine[];
  33612. /** @hidden */
  33613. static _LastCreatedScene: Nullable<Scene>;
  33614. /**
  33615. * Gets the latest created engine
  33616. */
  33617. static get LastCreatedEngine(): Nullable<Engine>;
  33618. /**
  33619. * Gets the latest created scene
  33620. */
  33621. static get LastCreatedScene(): Nullable<Scene>;
  33622. /**
  33623. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33624. * @ignorenaming
  33625. */
  33626. static UseFallbackTexture: boolean;
  33627. /**
  33628. * Texture content used if a texture cannot loaded
  33629. * @ignorenaming
  33630. */
  33631. static FallbackTexture: string;
  33632. }
  33633. }
  33634. declare module BABYLON {
  33635. /**
  33636. * Helper class that provides a small promise polyfill
  33637. */
  33638. export class PromisePolyfill {
  33639. /**
  33640. * Static function used to check if the polyfill is required
  33641. * If this is the case then the function will inject the polyfill to window.Promise
  33642. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33643. */
  33644. static Apply(force?: boolean): void;
  33645. }
  33646. }
  33647. declare module BABYLON {
  33648. /**
  33649. * Interface for screenshot methods with describe argument called `size` as object with options
  33650. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33651. */
  33652. export interface IScreenshotSize {
  33653. /**
  33654. * number in pixels for canvas height
  33655. */
  33656. height?: number;
  33657. /**
  33658. * multiplier allowing render at a higher or lower resolution
  33659. * If value is defined then height and width will be ignored and taken from camera
  33660. */
  33661. precision?: number;
  33662. /**
  33663. * number in pixels for canvas width
  33664. */
  33665. width?: number;
  33666. }
  33667. }
  33668. declare module BABYLON {
  33669. interface IColor4Like {
  33670. r: float;
  33671. g: float;
  33672. b: float;
  33673. a: float;
  33674. }
  33675. /**
  33676. * Class containing a set of static utilities functions
  33677. */
  33678. export class Tools {
  33679. /**
  33680. * Gets or sets the base URL to use to load assets
  33681. */
  33682. static get BaseUrl(): string;
  33683. static set BaseUrl(value: string);
  33684. /**
  33685. * Enable/Disable Custom HTTP Request Headers globally.
  33686. * default = false
  33687. * @see CustomRequestHeaders
  33688. */
  33689. static UseCustomRequestHeaders: boolean;
  33690. /**
  33691. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33692. * i.e. when loading files, where the server/service expects an Authorization header
  33693. */
  33694. static CustomRequestHeaders: {
  33695. [key: string]: string;
  33696. };
  33697. /**
  33698. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33699. */
  33700. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33701. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33702. /**
  33703. * Default behaviour for cors in the application.
  33704. * It can be a string if the expected behavior is identical in the entire app.
  33705. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33706. */
  33707. static CorsBehavior: string | ((url: string | string[]) => string);
  33708. /**
  33709. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33710. * @ignorenaming
  33711. */
  33712. static get UseFallbackTexture(): boolean;
  33713. static set UseFallbackTexture(value: boolean);
  33714. /**
  33715. * Use this object to register external classes like custom textures or material
  33716. * to allow the laoders to instantiate them
  33717. */
  33718. static get RegisteredExternalClasses(): {
  33719. [key: string]: Object;
  33720. };
  33721. static set RegisteredExternalClasses(classes: {
  33722. [key: string]: Object;
  33723. });
  33724. /**
  33725. * Texture content used if a texture cannot loaded
  33726. * @ignorenaming
  33727. */
  33728. static get fallbackTexture(): string;
  33729. static set fallbackTexture(value: string);
  33730. /**
  33731. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33732. * @param u defines the coordinate on X axis
  33733. * @param v defines the coordinate on Y axis
  33734. * @param width defines the width of the source data
  33735. * @param height defines the height of the source data
  33736. * @param pixels defines the source byte array
  33737. * @param color defines the output color
  33738. */
  33739. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33740. /**
  33741. * Interpolates between a and b via alpha
  33742. * @param a The lower value (returned when alpha = 0)
  33743. * @param b The upper value (returned when alpha = 1)
  33744. * @param alpha The interpolation-factor
  33745. * @return The mixed value
  33746. */
  33747. static Mix(a: number, b: number, alpha: number): number;
  33748. /**
  33749. * Tries to instantiate a new object from a given class name
  33750. * @param className defines the class name to instantiate
  33751. * @returns the new object or null if the system was not able to do the instantiation
  33752. */
  33753. static Instantiate(className: string): any;
  33754. /**
  33755. * Provides a slice function that will work even on IE
  33756. * @param data defines the array to slice
  33757. * @param start defines the start of the data (optional)
  33758. * @param end defines the end of the data (optional)
  33759. * @returns the new sliced array
  33760. */
  33761. static Slice<T>(data: T, start?: number, end?: number): T;
  33762. /**
  33763. * Polyfill for setImmediate
  33764. * @param action defines the action to execute after the current execution block
  33765. */
  33766. static SetImmediate(action: () => void): void;
  33767. /**
  33768. * Function indicating if a number is an exponent of 2
  33769. * @param value defines the value to test
  33770. * @returns true if the value is an exponent of 2
  33771. */
  33772. static IsExponentOfTwo(value: number): boolean;
  33773. private static _tmpFloatArray;
  33774. /**
  33775. * Returns the nearest 32-bit single precision float representation of a Number
  33776. * @param value A Number. If the parameter is of a different type, it will get converted
  33777. * to a number or to NaN if it cannot be converted
  33778. * @returns number
  33779. */
  33780. static FloatRound(value: number): number;
  33781. /**
  33782. * Extracts the filename from a path
  33783. * @param path defines the path to use
  33784. * @returns the filename
  33785. */
  33786. static GetFilename(path: string): string;
  33787. /**
  33788. * Extracts the "folder" part of a path (everything before the filename).
  33789. * @param uri The URI to extract the info from
  33790. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33791. * @returns The "folder" part of the path
  33792. */
  33793. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33794. /**
  33795. * Extracts text content from a DOM element hierarchy
  33796. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33797. */
  33798. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33799. /**
  33800. * Convert an angle in radians to degrees
  33801. * @param angle defines the angle to convert
  33802. * @returns the angle in degrees
  33803. */
  33804. static ToDegrees(angle: number): number;
  33805. /**
  33806. * Convert an angle in degrees to radians
  33807. * @param angle defines the angle to convert
  33808. * @returns the angle in radians
  33809. */
  33810. static ToRadians(angle: number): number;
  33811. /**
  33812. * Returns an array if obj is not an array
  33813. * @param obj defines the object to evaluate as an array
  33814. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33815. * @returns either obj directly if obj is an array or a new array containing obj
  33816. */
  33817. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33818. /**
  33819. * Gets the pointer prefix to use
  33820. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33821. */
  33822. static GetPointerPrefix(): string;
  33823. /**
  33824. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33825. * @param url define the url we are trying
  33826. * @param element define the dom element where to configure the cors policy
  33827. */
  33828. static SetCorsBehavior(url: string | string[], element: {
  33829. crossOrigin: string | null;
  33830. }): void;
  33831. /**
  33832. * Removes unwanted characters from an url
  33833. * @param url defines the url to clean
  33834. * @returns the cleaned url
  33835. */
  33836. static CleanUrl(url: string): string;
  33837. /**
  33838. * Gets or sets a function used to pre-process url before using them to load assets
  33839. */
  33840. static get PreprocessUrl(): (url: string) => string;
  33841. static set PreprocessUrl(processor: (url: string) => string);
  33842. /**
  33843. * Loads an image as an HTMLImageElement.
  33844. * @param input url string, ArrayBuffer, or Blob to load
  33845. * @param onLoad callback called when the image successfully loads
  33846. * @param onError callback called when the image fails to load
  33847. * @param offlineProvider offline provider for caching
  33848. * @param mimeType optional mime type
  33849. * @returns the HTMLImageElement of the loaded image
  33850. */
  33851. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33852. /**
  33853. * Loads a file from a url
  33854. * @param url url string, ArrayBuffer, or Blob to load
  33855. * @param onSuccess callback called when the file successfully loads
  33856. * @param onProgress callback called while file is loading (if the server supports this mode)
  33857. * @param offlineProvider defines the offline provider for caching
  33858. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33859. * @param onError callback called when the file fails to load
  33860. * @returns a file request object
  33861. */
  33862. 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;
  33863. /**
  33864. * Loads a file from a url
  33865. * @param url the file url to load
  33866. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33867. */
  33868. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33869. /**
  33870. * Load a script (identified by an url). When the url returns, the
  33871. * content of this file is added into a new script element, attached to the DOM (body element)
  33872. * @param scriptUrl defines the url of the script to laod
  33873. * @param onSuccess defines the callback called when the script is loaded
  33874. * @param onError defines the callback to call if an error occurs
  33875. * @param scriptId defines the id of the script element
  33876. */
  33877. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33878. /**
  33879. * Load an asynchronous script (identified by an url). When the url returns, the
  33880. * content of this file is added into a new script element, attached to the DOM (body element)
  33881. * @param scriptUrl defines the url of the script to laod
  33882. * @param scriptId defines the id of the script element
  33883. * @returns a promise request object
  33884. */
  33885. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33886. /**
  33887. * Loads a file from a blob
  33888. * @param fileToLoad defines the blob to use
  33889. * @param callback defines the callback to call when data is loaded
  33890. * @param progressCallback defines the callback to call during loading process
  33891. * @returns a file request object
  33892. */
  33893. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33894. /**
  33895. * Reads a file from a File object
  33896. * @param file defines the file to load
  33897. * @param onSuccess defines the callback to call when data is loaded
  33898. * @param onProgress defines the callback to call during loading process
  33899. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33900. * @param onError defines the callback to call when an error occurs
  33901. * @returns a file request object
  33902. */
  33903. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33904. /**
  33905. * Creates a data url from a given string content
  33906. * @param content defines the content to convert
  33907. * @returns the new data url link
  33908. */
  33909. static FileAsURL(content: string): string;
  33910. /**
  33911. * Format the given number to a specific decimal format
  33912. * @param value defines the number to format
  33913. * @param decimals defines the number of decimals to use
  33914. * @returns the formatted string
  33915. */
  33916. static Format(value: number, decimals?: number): string;
  33917. /**
  33918. * Tries to copy an object by duplicating every property
  33919. * @param source defines the source object
  33920. * @param destination defines the target object
  33921. * @param doNotCopyList defines a list of properties to avoid
  33922. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33923. */
  33924. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33925. /**
  33926. * Gets a boolean indicating if the given object has no own property
  33927. * @param obj defines the object to test
  33928. * @returns true if object has no own property
  33929. */
  33930. static IsEmpty(obj: any): boolean;
  33931. /**
  33932. * Function used to register events at window level
  33933. * @param windowElement defines the Window object to use
  33934. * @param events defines the events to register
  33935. */
  33936. static RegisterTopRootEvents(windowElement: Window, events: {
  33937. name: string;
  33938. handler: Nullable<(e: FocusEvent) => any>;
  33939. }[]): void;
  33940. /**
  33941. * Function used to unregister events from window level
  33942. * @param windowElement defines the Window object to use
  33943. * @param events defines the events to unregister
  33944. */
  33945. static UnregisterTopRootEvents(windowElement: Window, events: {
  33946. name: string;
  33947. handler: Nullable<(e: FocusEvent) => any>;
  33948. }[]): void;
  33949. /**
  33950. * @ignore
  33951. */
  33952. static _ScreenshotCanvas: HTMLCanvasElement;
  33953. /**
  33954. * Dumps the current bound framebuffer
  33955. * @param width defines the rendering width
  33956. * @param height defines the rendering height
  33957. * @param engine defines the hosting engine
  33958. * @param successCallback defines the callback triggered once the data are available
  33959. * @param mimeType defines the mime type of the result
  33960. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33961. */
  33962. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33963. /**
  33964. * Converts the canvas data to blob.
  33965. * This acts as a polyfill for browsers not supporting the to blob function.
  33966. * @param canvas Defines the canvas to extract the data from
  33967. * @param successCallback Defines the callback triggered once the data are available
  33968. * @param mimeType Defines the mime type of the result
  33969. */
  33970. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33971. /**
  33972. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33973. * @param successCallback defines the callback triggered once the data are available
  33974. * @param mimeType defines the mime type of the result
  33975. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33976. */
  33977. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33978. /**
  33979. * Downloads a blob in the browser
  33980. * @param blob defines the blob to download
  33981. * @param fileName defines the name of the downloaded file
  33982. */
  33983. static Download(blob: Blob, fileName: string): void;
  33984. /**
  33985. * Captures a screenshot of the current rendering
  33986. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33987. * @param engine defines the rendering engine
  33988. * @param camera defines the source camera
  33989. * @param size This parameter can be set to a single number or to an object with the
  33990. * following (optional) properties: precision, width, height. If a single number is passed,
  33991. * it will be used for both width and height. If an object is passed, the screenshot size
  33992. * will be derived from the parameters. The precision property is a multiplier allowing
  33993. * rendering at a higher or lower resolution
  33994. * @param successCallback defines the callback receives a single parameter which contains the
  33995. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33996. * src parameter of an <img> to display it
  33997. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33998. * Check your browser for supported MIME types
  33999. */
  34000. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34001. /**
  34002. * Captures a screenshot of the current rendering
  34003. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34004. * @param engine defines the rendering engine
  34005. * @param camera defines the source camera
  34006. * @param size This parameter can be set to a single number or to an object with the
  34007. * following (optional) properties: precision, width, height. If a single number is passed,
  34008. * it will be used for both width and height. If an object is passed, the screenshot size
  34009. * will be derived from the parameters. The precision property is a multiplier allowing
  34010. * rendering at a higher or lower resolution
  34011. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34012. * Check your browser for supported MIME types
  34013. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34014. * to the src parameter of an <img> to display it
  34015. */
  34016. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34017. /**
  34018. * Generates an image screenshot from the specified camera.
  34019. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34020. * @param engine The engine to use for rendering
  34021. * @param camera The camera to use for rendering
  34022. * @param size This parameter can be set to a single number or to an object with the
  34023. * following (optional) properties: precision, width, height. If a single number is passed,
  34024. * it will be used for both width and height. If an object is passed, the screenshot size
  34025. * will be derived from the parameters. The precision property is a multiplier allowing
  34026. * rendering at a higher or lower resolution
  34027. * @param successCallback The callback receives a single parameter which contains the
  34028. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34029. * src parameter of an <img> to display it
  34030. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34031. * Check your browser for supported MIME types
  34032. * @param samples Texture samples (default: 1)
  34033. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34034. * @param fileName A name for for the downloaded file.
  34035. */
  34036. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34037. /**
  34038. * Generates an image screenshot from the specified camera.
  34039. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34040. * @param engine The engine to use for rendering
  34041. * @param camera The camera to use for rendering
  34042. * @param size This parameter can be set to a single number or to an object with the
  34043. * following (optional) properties: precision, width, height. If a single number is passed,
  34044. * it will be used for both width and height. If an object is passed, the screenshot size
  34045. * will be derived from the parameters. The precision property is a multiplier allowing
  34046. * rendering at a higher or lower resolution
  34047. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34048. * Check your browser for supported MIME types
  34049. * @param samples Texture samples (default: 1)
  34050. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34051. * @param fileName A name for for the downloaded file.
  34052. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34053. * to the src parameter of an <img> to display it
  34054. */
  34055. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34056. /**
  34057. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34058. * Be aware Math.random() could cause collisions, but:
  34059. * "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"
  34060. * @returns a pseudo random id
  34061. */
  34062. static RandomId(): string;
  34063. /**
  34064. * Test if the given uri is a base64 string
  34065. * @param uri The uri to test
  34066. * @return True if the uri is a base64 string or false otherwise
  34067. */
  34068. static IsBase64(uri: string): boolean;
  34069. /**
  34070. * Decode the given base64 uri.
  34071. * @param uri The uri to decode
  34072. * @return The decoded base64 data.
  34073. */
  34074. static DecodeBase64(uri: string): ArrayBuffer;
  34075. /**
  34076. * Gets the absolute url.
  34077. * @param url the input url
  34078. * @return the absolute url
  34079. */
  34080. static GetAbsoluteUrl(url: string): string;
  34081. /**
  34082. * No log
  34083. */
  34084. static readonly NoneLogLevel: number;
  34085. /**
  34086. * Only message logs
  34087. */
  34088. static readonly MessageLogLevel: number;
  34089. /**
  34090. * Only warning logs
  34091. */
  34092. static readonly WarningLogLevel: number;
  34093. /**
  34094. * Only error logs
  34095. */
  34096. static readonly ErrorLogLevel: number;
  34097. /**
  34098. * All logs
  34099. */
  34100. static readonly AllLogLevel: number;
  34101. /**
  34102. * Gets a value indicating the number of loading errors
  34103. * @ignorenaming
  34104. */
  34105. static get errorsCount(): number;
  34106. /**
  34107. * Callback called when a new log is added
  34108. */
  34109. static OnNewCacheEntry: (entry: string) => void;
  34110. /**
  34111. * Log a message to the console
  34112. * @param message defines the message to log
  34113. */
  34114. static Log(message: string): void;
  34115. /**
  34116. * Write a warning message to the console
  34117. * @param message defines the message to log
  34118. */
  34119. static Warn(message: string): void;
  34120. /**
  34121. * Write an error message to the console
  34122. * @param message defines the message to log
  34123. */
  34124. static Error(message: string): void;
  34125. /**
  34126. * Gets current log cache (list of logs)
  34127. */
  34128. static get LogCache(): string;
  34129. /**
  34130. * Clears the log cache
  34131. */
  34132. static ClearLogCache(): void;
  34133. /**
  34134. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34135. */
  34136. static set LogLevels(level: number);
  34137. /**
  34138. * Checks if the window object exists
  34139. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34140. */
  34141. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34142. /**
  34143. * No performance log
  34144. */
  34145. static readonly PerformanceNoneLogLevel: number;
  34146. /**
  34147. * Use user marks to log performance
  34148. */
  34149. static readonly PerformanceUserMarkLogLevel: number;
  34150. /**
  34151. * Log performance to the console
  34152. */
  34153. static readonly PerformanceConsoleLogLevel: number;
  34154. private static _performance;
  34155. /**
  34156. * Sets the current performance log level
  34157. */
  34158. static set PerformanceLogLevel(level: number);
  34159. private static _StartPerformanceCounterDisabled;
  34160. private static _EndPerformanceCounterDisabled;
  34161. private static _StartUserMark;
  34162. private static _EndUserMark;
  34163. private static _StartPerformanceConsole;
  34164. private static _EndPerformanceConsole;
  34165. /**
  34166. * Starts a performance counter
  34167. */
  34168. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34169. /**
  34170. * Ends a specific performance coutner
  34171. */
  34172. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34173. /**
  34174. * Gets either window.performance.now() if supported or Date.now() else
  34175. */
  34176. static get Now(): number;
  34177. /**
  34178. * This method will return the name of the class used to create the instance of the given object.
  34179. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34180. * @param object the object to get the class name from
  34181. * @param isType defines if the object is actually a type
  34182. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34183. */
  34184. static GetClassName(object: any, isType?: boolean): string;
  34185. /**
  34186. * Gets the first element of an array satisfying a given predicate
  34187. * @param array defines the array to browse
  34188. * @param predicate defines the predicate to use
  34189. * @returns null if not found or the element
  34190. */
  34191. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34192. /**
  34193. * This method will return the name of the full name of the class, including its owning module (if any).
  34194. * 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).
  34195. * @param object the object to get the class name from
  34196. * @param isType defines if the object is actually a type
  34197. * @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.
  34198. * @ignorenaming
  34199. */
  34200. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34201. /**
  34202. * Returns a promise that resolves after the given amount of time.
  34203. * @param delay Number of milliseconds to delay
  34204. * @returns Promise that resolves after the given amount of time
  34205. */
  34206. static DelayAsync(delay: number): Promise<void>;
  34207. }
  34208. /**
  34209. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34210. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34211. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34212. * @param name The name of the class, case should be preserved
  34213. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34214. */
  34215. export function className(name: string, module?: string): (target: Object) => void;
  34216. /**
  34217. * An implementation of a loop for asynchronous functions.
  34218. */
  34219. export class AsyncLoop {
  34220. /**
  34221. * Defines the number of iterations for the loop
  34222. */
  34223. iterations: number;
  34224. /**
  34225. * Defines the current index of the loop.
  34226. */
  34227. index: number;
  34228. private _done;
  34229. private _fn;
  34230. private _successCallback;
  34231. /**
  34232. * Constructor.
  34233. * @param iterations the number of iterations.
  34234. * @param func the function to run each iteration
  34235. * @param successCallback the callback that will be called upon succesful execution
  34236. * @param offset starting offset.
  34237. */
  34238. constructor(
  34239. /**
  34240. * Defines the number of iterations for the loop
  34241. */
  34242. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34243. /**
  34244. * Execute the next iteration. Must be called after the last iteration was finished.
  34245. */
  34246. executeNext(): void;
  34247. /**
  34248. * Break the loop and run the success callback.
  34249. */
  34250. breakLoop(): void;
  34251. /**
  34252. * Create and run an async loop.
  34253. * @param iterations the number of iterations.
  34254. * @param fn the function to run each iteration
  34255. * @param successCallback the callback that will be called upon succesful execution
  34256. * @param offset starting offset.
  34257. * @returns the created async loop object
  34258. */
  34259. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34260. /**
  34261. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34262. * @param iterations total number of iterations
  34263. * @param syncedIterations number of synchronous iterations in each async iteration.
  34264. * @param fn the function to call each iteration.
  34265. * @param callback a success call back that will be called when iterating stops.
  34266. * @param breakFunction a break condition (optional)
  34267. * @param timeout timeout settings for the setTimeout function. default - 0.
  34268. * @returns the created async loop object
  34269. */
  34270. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34271. }
  34272. }
  34273. declare module BABYLON {
  34274. /**
  34275. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34276. * The underlying implementation relies on an associative array to ensure the best performances.
  34277. * The value can be anything including 'null' but except 'undefined'
  34278. */
  34279. export class StringDictionary<T> {
  34280. /**
  34281. * This will clear this dictionary and copy the content from the 'source' one.
  34282. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34283. * @param source the dictionary to take the content from and copy to this dictionary
  34284. */
  34285. copyFrom(source: StringDictionary<T>): void;
  34286. /**
  34287. * Get a value based from its key
  34288. * @param key the given key to get the matching value from
  34289. * @return the value if found, otherwise undefined is returned
  34290. */
  34291. get(key: string): T | undefined;
  34292. /**
  34293. * Get a value from its key or add it if it doesn't exist.
  34294. * This method will ensure you that a given key/data will be present in the dictionary.
  34295. * @param key the given key to get the matching value from
  34296. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34297. * The factory will only be invoked if there's no data for the given key.
  34298. * @return the value corresponding to the key.
  34299. */
  34300. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34301. /**
  34302. * Get a value from its key if present in the dictionary otherwise add it
  34303. * @param key the key to get the value from
  34304. * @param val if there's no such key/value pair in the dictionary add it with this value
  34305. * @return the value corresponding to the key
  34306. */
  34307. getOrAdd(key: string, val: T): T;
  34308. /**
  34309. * Check if there's a given key in the dictionary
  34310. * @param key the key to check for
  34311. * @return true if the key is present, false otherwise
  34312. */
  34313. contains(key: string): boolean;
  34314. /**
  34315. * Add a new key and its corresponding value
  34316. * @param key the key to add
  34317. * @param value the value corresponding to the key
  34318. * @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
  34319. */
  34320. add(key: string, value: T): boolean;
  34321. /**
  34322. * Update a specific value associated to a key
  34323. * @param key defines the key to use
  34324. * @param value defines the value to store
  34325. * @returns true if the value was updated (or false if the key was not found)
  34326. */
  34327. set(key: string, value: T): boolean;
  34328. /**
  34329. * Get the element of the given key and remove it from the dictionary
  34330. * @param key defines the key to search
  34331. * @returns the value associated with the key or null if not found
  34332. */
  34333. getAndRemove(key: string): Nullable<T>;
  34334. /**
  34335. * Remove a key/value from the dictionary.
  34336. * @param key the key to remove
  34337. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34338. */
  34339. remove(key: string): boolean;
  34340. /**
  34341. * Clear the whole content of the dictionary
  34342. */
  34343. clear(): void;
  34344. /**
  34345. * Gets the current count
  34346. */
  34347. get count(): number;
  34348. /**
  34349. * Execute a callback on each key/val of the dictionary.
  34350. * Note that you can remove any element in this dictionary in the callback implementation
  34351. * @param callback the callback to execute on a given key/value pair
  34352. */
  34353. forEach(callback: (key: string, val: T) => void): void;
  34354. /**
  34355. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34356. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34357. * Note that you can remove any element in this dictionary in the callback implementation
  34358. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34359. * @returns the first item
  34360. */
  34361. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34362. private _count;
  34363. private _data;
  34364. }
  34365. }
  34366. declare module BABYLON {
  34367. /** @hidden */
  34368. export interface ICollisionCoordinator {
  34369. createCollider(): Collider;
  34370. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34371. init(scene: Scene): void;
  34372. }
  34373. /** @hidden */
  34374. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34375. private _scene;
  34376. private _scaledPosition;
  34377. private _scaledVelocity;
  34378. private _finalPosition;
  34379. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34380. createCollider(): Collider;
  34381. init(scene: Scene): void;
  34382. private _collideWithWorld;
  34383. }
  34384. }
  34385. declare module BABYLON {
  34386. /**
  34387. * Class used to manage all inputs for the scene.
  34388. */
  34389. export class InputManager {
  34390. /** The distance in pixel that you have to move to prevent some events */
  34391. static DragMovementThreshold: number;
  34392. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34393. static LongPressDelay: number;
  34394. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34395. static DoubleClickDelay: number;
  34396. /** If you need to check double click without raising a single click at first click, enable this flag */
  34397. static ExclusiveDoubleClickMode: boolean;
  34398. private _wheelEventName;
  34399. private _onPointerMove;
  34400. private _onPointerDown;
  34401. private _onPointerUp;
  34402. private _initClickEvent;
  34403. private _initActionManager;
  34404. private _delayedSimpleClick;
  34405. private _delayedSimpleClickTimeout;
  34406. private _previousDelayedSimpleClickTimeout;
  34407. private _meshPickProceed;
  34408. private _previousButtonPressed;
  34409. private _currentPickResult;
  34410. private _previousPickResult;
  34411. private _totalPointersPressed;
  34412. private _doubleClickOccured;
  34413. private _pointerOverMesh;
  34414. private _pickedDownMesh;
  34415. private _pickedUpMesh;
  34416. private _pointerX;
  34417. private _pointerY;
  34418. private _unTranslatedPointerX;
  34419. private _unTranslatedPointerY;
  34420. private _startingPointerPosition;
  34421. private _previousStartingPointerPosition;
  34422. private _startingPointerTime;
  34423. private _previousStartingPointerTime;
  34424. private _pointerCaptures;
  34425. private _onKeyDown;
  34426. private _onKeyUp;
  34427. private _onCanvasFocusObserver;
  34428. private _onCanvasBlurObserver;
  34429. private _scene;
  34430. /**
  34431. * Creates a new InputManager
  34432. * @param scene defines the hosting scene
  34433. */
  34434. constructor(scene: Scene);
  34435. /**
  34436. * Gets the mesh that is currently under the pointer
  34437. */
  34438. get meshUnderPointer(): Nullable<AbstractMesh>;
  34439. /**
  34440. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34441. */
  34442. get unTranslatedPointer(): Vector2;
  34443. /**
  34444. * Gets or sets the current on-screen X position of the pointer
  34445. */
  34446. get pointerX(): number;
  34447. set pointerX(value: number);
  34448. /**
  34449. * Gets or sets the current on-screen Y position of the pointer
  34450. */
  34451. get pointerY(): number;
  34452. set pointerY(value: number);
  34453. private _updatePointerPosition;
  34454. private _processPointerMove;
  34455. private _setRayOnPointerInfo;
  34456. private _checkPrePointerObservable;
  34457. /**
  34458. * Use this method to simulate a pointer move on a mesh
  34459. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34460. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34461. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34462. */
  34463. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34464. /**
  34465. * Use this method to simulate a pointer down on a mesh
  34466. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34467. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34468. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34469. */
  34470. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34471. private _processPointerDown;
  34472. /** @hidden */
  34473. _isPointerSwiping(): boolean;
  34474. /**
  34475. * Use this method to simulate a pointer up on a mesh
  34476. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34477. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34478. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34479. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34480. */
  34481. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34482. private _processPointerUp;
  34483. /**
  34484. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34485. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34486. * @returns true if the pointer was captured
  34487. */
  34488. isPointerCaptured(pointerId?: number): boolean;
  34489. /**
  34490. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34491. * @param attachUp defines if you want to attach events to pointerup
  34492. * @param attachDown defines if you want to attach events to pointerdown
  34493. * @param attachMove defines if you want to attach events to pointermove
  34494. */
  34495. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34496. /**
  34497. * Detaches all event handlers
  34498. */
  34499. detachControl(): void;
  34500. /**
  34501. * Force the value of meshUnderPointer
  34502. * @param mesh defines the mesh to use
  34503. */
  34504. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34505. /**
  34506. * Gets the mesh under the pointer
  34507. * @returns a Mesh or null if no mesh is under the pointer
  34508. */
  34509. getPointerOverMesh(): Nullable<AbstractMesh>;
  34510. }
  34511. }
  34512. declare module BABYLON {
  34513. /**
  34514. * Helper class used to generate session unique ID
  34515. */
  34516. export class UniqueIdGenerator {
  34517. private static _UniqueIdCounter;
  34518. /**
  34519. * Gets an unique (relatively to the current scene) Id
  34520. */
  34521. static get UniqueId(): number;
  34522. }
  34523. }
  34524. declare module BABYLON {
  34525. /**
  34526. * This class defines the direct association between an animation and a target
  34527. */
  34528. export class TargetedAnimation {
  34529. /**
  34530. * Animation to perform
  34531. */
  34532. animation: Animation;
  34533. /**
  34534. * Target to animate
  34535. */
  34536. target: any;
  34537. /**
  34538. * Serialize the object
  34539. * @returns the JSON object representing the current entity
  34540. */
  34541. serialize(): any;
  34542. }
  34543. /**
  34544. * Use this class to create coordinated animations on multiple targets
  34545. */
  34546. export class AnimationGroup implements IDisposable {
  34547. /** The name of the animation group */
  34548. name: string;
  34549. private _scene;
  34550. private _targetedAnimations;
  34551. private _animatables;
  34552. private _from;
  34553. private _to;
  34554. private _isStarted;
  34555. private _isPaused;
  34556. private _speedRatio;
  34557. private _loopAnimation;
  34558. /**
  34559. * Gets or sets the unique id of the node
  34560. */
  34561. uniqueId: number;
  34562. /**
  34563. * This observable will notify when one animation have ended
  34564. */
  34565. onAnimationEndObservable: Observable<TargetedAnimation>;
  34566. /**
  34567. * Observer raised when one animation loops
  34568. */
  34569. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34570. /**
  34571. * Observer raised when all animations have looped
  34572. */
  34573. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34574. /**
  34575. * This observable will notify when all animations have ended.
  34576. */
  34577. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34578. /**
  34579. * This observable will notify when all animations have paused.
  34580. */
  34581. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34582. /**
  34583. * This observable will notify when all animations are playing.
  34584. */
  34585. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34586. /**
  34587. * Gets the first frame
  34588. */
  34589. get from(): number;
  34590. /**
  34591. * Gets the last frame
  34592. */
  34593. get to(): number;
  34594. /**
  34595. * Define if the animations are started
  34596. */
  34597. get isStarted(): boolean;
  34598. /**
  34599. * Gets a value indicating that the current group is playing
  34600. */
  34601. get isPlaying(): boolean;
  34602. /**
  34603. * Gets or sets the speed ratio to use for all animations
  34604. */
  34605. get speedRatio(): number;
  34606. /**
  34607. * Gets or sets the speed ratio to use for all animations
  34608. */
  34609. set speedRatio(value: number);
  34610. /**
  34611. * Gets or sets if all animations should loop or not
  34612. */
  34613. get loopAnimation(): boolean;
  34614. set loopAnimation(value: boolean);
  34615. /**
  34616. * Gets the targeted animations for this animation group
  34617. */
  34618. get targetedAnimations(): Array<TargetedAnimation>;
  34619. /**
  34620. * returning the list of animatables controlled by this animation group.
  34621. */
  34622. get animatables(): Array<Animatable>;
  34623. /**
  34624. * Instantiates a new Animation Group.
  34625. * This helps managing several animations at once.
  34626. * @see http://doc.babylonjs.com/how_to/group
  34627. * @param name Defines the name of the group
  34628. * @param scene Defines the scene the group belongs to
  34629. */
  34630. constructor(
  34631. /** The name of the animation group */
  34632. name: string, scene?: Nullable<Scene>);
  34633. /**
  34634. * Add an animation (with its target) in the group
  34635. * @param animation defines the animation we want to add
  34636. * @param target defines the target of the animation
  34637. * @returns the TargetedAnimation object
  34638. */
  34639. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34640. /**
  34641. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34642. * It can add constant keys at begin or end
  34643. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34644. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34645. * @returns the animation group
  34646. */
  34647. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34648. private _animationLoopCount;
  34649. private _animationLoopFlags;
  34650. private _processLoop;
  34651. /**
  34652. * Start all animations on given targets
  34653. * @param loop defines if animations must loop
  34654. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34655. * @param from defines the from key (optional)
  34656. * @param to defines the to key (optional)
  34657. * @returns the current animation group
  34658. */
  34659. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34660. /**
  34661. * Pause all animations
  34662. * @returns the animation group
  34663. */
  34664. pause(): AnimationGroup;
  34665. /**
  34666. * Play all animations to initial state
  34667. * This function will start() the animations if they were not started or will restart() them if they were paused
  34668. * @param loop defines if animations must loop
  34669. * @returns the animation group
  34670. */
  34671. play(loop?: boolean): AnimationGroup;
  34672. /**
  34673. * Reset all animations to initial state
  34674. * @returns the animation group
  34675. */
  34676. reset(): AnimationGroup;
  34677. /**
  34678. * Restart animations from key 0
  34679. * @returns the animation group
  34680. */
  34681. restart(): AnimationGroup;
  34682. /**
  34683. * Stop all animations
  34684. * @returns the animation group
  34685. */
  34686. stop(): AnimationGroup;
  34687. /**
  34688. * Set animation weight for all animatables
  34689. * @param weight defines the weight to use
  34690. * @return the animationGroup
  34691. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34692. */
  34693. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34694. /**
  34695. * Synchronize and normalize all animatables with a source animatable
  34696. * @param root defines the root animatable to synchronize with
  34697. * @return the animationGroup
  34698. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34699. */
  34700. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34701. /**
  34702. * Goes to a specific frame in this animation group
  34703. * @param frame the frame number to go to
  34704. * @return the animationGroup
  34705. */
  34706. goToFrame(frame: number): AnimationGroup;
  34707. /**
  34708. * Dispose all associated resources
  34709. */
  34710. dispose(): void;
  34711. private _checkAnimationGroupEnded;
  34712. /**
  34713. * Clone the current animation group and returns a copy
  34714. * @param newName defines the name of the new group
  34715. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34716. * @returns the new aniamtion group
  34717. */
  34718. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34719. /**
  34720. * Serializes the animationGroup to an object
  34721. * @returns Serialized object
  34722. */
  34723. serialize(): any;
  34724. /**
  34725. * Returns a new AnimationGroup object parsed from the source provided.
  34726. * @param parsedAnimationGroup defines the source
  34727. * @param scene defines the scene that will receive the animationGroup
  34728. * @returns a new AnimationGroup
  34729. */
  34730. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34731. /**
  34732. * Returns the string "AnimationGroup"
  34733. * @returns "AnimationGroup"
  34734. */
  34735. getClassName(): string;
  34736. /**
  34737. * Creates a detailled string about the object
  34738. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34739. * @returns a string representing the object
  34740. */
  34741. toString(fullDetails?: boolean): string;
  34742. }
  34743. }
  34744. declare module BABYLON {
  34745. /**
  34746. * Define an interface for all classes that will hold resources
  34747. */
  34748. export interface IDisposable {
  34749. /**
  34750. * Releases all held resources
  34751. */
  34752. dispose(): void;
  34753. }
  34754. /** Interface defining initialization parameters for Scene class */
  34755. export interface SceneOptions {
  34756. /**
  34757. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34758. * It will improve performance when the number of geometries becomes important.
  34759. */
  34760. useGeometryUniqueIdsMap?: boolean;
  34761. /**
  34762. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34763. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34764. */
  34765. useMaterialMeshMap?: boolean;
  34766. /**
  34767. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34768. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34769. */
  34770. useClonedMeshhMap?: boolean;
  34771. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34772. virtual?: boolean;
  34773. }
  34774. /**
  34775. * Represents a scene to be rendered by the engine.
  34776. * @see http://doc.babylonjs.com/features/scene
  34777. */
  34778. export class Scene extends AbstractScene implements IAnimatable {
  34779. /** The fog is deactivated */
  34780. static readonly FOGMODE_NONE: number;
  34781. /** The fog density is following an exponential function */
  34782. static readonly FOGMODE_EXP: number;
  34783. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34784. static readonly FOGMODE_EXP2: number;
  34785. /** The fog density is following a linear function. */
  34786. static readonly FOGMODE_LINEAR: number;
  34787. /**
  34788. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34789. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34790. */
  34791. static MinDeltaTime: number;
  34792. /**
  34793. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34794. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34795. */
  34796. static MaxDeltaTime: number;
  34797. /**
  34798. * Factory used to create the default material.
  34799. * @param name The name of the material to create
  34800. * @param scene The scene to create the material for
  34801. * @returns The default material
  34802. */
  34803. static DefaultMaterialFactory(scene: Scene): Material;
  34804. /**
  34805. * Factory used to create the a collision coordinator.
  34806. * @returns The collision coordinator
  34807. */
  34808. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34809. /** @hidden */
  34810. _inputManager: InputManager;
  34811. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34812. cameraToUseForPointers: Nullable<Camera>;
  34813. /** @hidden */
  34814. readonly _isScene: boolean;
  34815. /**
  34816. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34817. */
  34818. autoClear: boolean;
  34819. /**
  34820. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34821. */
  34822. autoClearDepthAndStencil: boolean;
  34823. /**
  34824. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34825. */
  34826. clearColor: Color4;
  34827. /**
  34828. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34829. */
  34830. ambientColor: Color3;
  34831. /**
  34832. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34833. * It should only be one of the following (if not the default embedded one):
  34834. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34835. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34836. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34837. * The material properties need to be setup according to the type of texture in use.
  34838. */
  34839. environmentBRDFTexture: BaseTexture;
  34840. /** @hidden */
  34841. protected _environmentTexture: Nullable<BaseTexture>;
  34842. /**
  34843. * Texture used in all pbr material as the reflection texture.
  34844. * As in the majority of the scene they are the same (exception for multi room and so on),
  34845. * this is easier to reference from here than from all the materials.
  34846. */
  34847. get environmentTexture(): Nullable<BaseTexture>;
  34848. /**
  34849. * Texture used in all pbr material as the reflection texture.
  34850. * As in the majority of the scene they are the same (exception for multi room and so on),
  34851. * this is easier to set here than in all the materials.
  34852. */
  34853. set environmentTexture(value: Nullable<BaseTexture>);
  34854. /** @hidden */
  34855. protected _environmentIntensity: number;
  34856. /**
  34857. * Intensity of the environment in all pbr material.
  34858. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34859. * As in the majority of the scene they are the same (exception for multi room and so on),
  34860. * this is easier to reference from here than from all the materials.
  34861. */
  34862. get environmentIntensity(): number;
  34863. /**
  34864. * Intensity of the environment in all pbr material.
  34865. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34866. * As in the majority of the scene they are the same (exception for multi room and so on),
  34867. * this is easier to set here than in all the materials.
  34868. */
  34869. set environmentIntensity(value: number);
  34870. /** @hidden */
  34871. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34872. /**
  34873. * Default image processing configuration used either in the rendering
  34874. * Forward main pass or through the imageProcessingPostProcess if present.
  34875. * As in the majority of the scene they are the same (exception for multi camera),
  34876. * this is easier to reference from here than from all the materials and post process.
  34877. *
  34878. * No setter as we it is a shared configuration, you can set the values instead.
  34879. */
  34880. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  34881. private _forceWireframe;
  34882. /**
  34883. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34884. */
  34885. set forceWireframe(value: boolean);
  34886. get forceWireframe(): boolean;
  34887. private _forcePointsCloud;
  34888. /**
  34889. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34890. */
  34891. set forcePointsCloud(value: boolean);
  34892. get forcePointsCloud(): boolean;
  34893. /**
  34894. * Gets or sets the active clipplane 1
  34895. */
  34896. clipPlane: Nullable<Plane>;
  34897. /**
  34898. * Gets or sets the active clipplane 2
  34899. */
  34900. clipPlane2: Nullable<Plane>;
  34901. /**
  34902. * Gets or sets the active clipplane 3
  34903. */
  34904. clipPlane3: Nullable<Plane>;
  34905. /**
  34906. * Gets or sets the active clipplane 4
  34907. */
  34908. clipPlane4: Nullable<Plane>;
  34909. /**
  34910. * Gets or sets a boolean indicating if animations are enabled
  34911. */
  34912. animationsEnabled: boolean;
  34913. private _animationPropertiesOverride;
  34914. /**
  34915. * Gets or sets the animation properties override
  34916. */
  34917. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34918. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34919. /**
  34920. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34921. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34922. */
  34923. useConstantAnimationDeltaTime: boolean;
  34924. /**
  34925. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34926. * Please note that it requires to run a ray cast through the scene on every frame
  34927. */
  34928. constantlyUpdateMeshUnderPointer: boolean;
  34929. /**
  34930. * Defines the HTML cursor to use when hovering over interactive elements
  34931. */
  34932. hoverCursor: string;
  34933. /**
  34934. * Defines the HTML default cursor to use (empty by default)
  34935. */
  34936. defaultCursor: string;
  34937. /**
  34938. * Defines wether cursors are handled by the scene.
  34939. */
  34940. doNotHandleCursors: boolean;
  34941. /**
  34942. * This is used to call preventDefault() on pointer down
  34943. * in order to block unwanted artifacts like system double clicks
  34944. */
  34945. preventDefaultOnPointerDown: boolean;
  34946. /**
  34947. * This is used to call preventDefault() on pointer up
  34948. * in order to block unwanted artifacts like system double clicks
  34949. */
  34950. preventDefaultOnPointerUp: boolean;
  34951. /**
  34952. * Gets or sets user defined metadata
  34953. */
  34954. metadata: any;
  34955. /**
  34956. * For internal use only. Please do not use.
  34957. */
  34958. reservedDataStore: any;
  34959. /**
  34960. * Gets the name of the plugin used to load this scene (null by default)
  34961. */
  34962. loadingPluginName: string;
  34963. /**
  34964. * Use this array to add regular expressions used to disable offline support for specific urls
  34965. */
  34966. disableOfflineSupportExceptionRules: RegExp[];
  34967. /**
  34968. * An event triggered when the scene is disposed.
  34969. */
  34970. onDisposeObservable: Observable<Scene>;
  34971. private _onDisposeObserver;
  34972. /** Sets a function to be executed when this scene is disposed. */
  34973. set onDispose(callback: () => void);
  34974. /**
  34975. * An event triggered before rendering the scene (right after animations and physics)
  34976. */
  34977. onBeforeRenderObservable: Observable<Scene>;
  34978. private _onBeforeRenderObserver;
  34979. /** Sets a function to be executed before rendering this scene */
  34980. set beforeRender(callback: Nullable<() => void>);
  34981. /**
  34982. * An event triggered after rendering the scene
  34983. */
  34984. onAfterRenderObservable: Observable<Scene>;
  34985. /**
  34986. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34987. */
  34988. onAfterRenderCameraObservable: Observable<Camera>;
  34989. private _onAfterRenderObserver;
  34990. /** Sets a function to be executed after rendering this scene */
  34991. set afterRender(callback: Nullable<() => void>);
  34992. /**
  34993. * An event triggered before animating the scene
  34994. */
  34995. onBeforeAnimationsObservable: Observable<Scene>;
  34996. /**
  34997. * An event triggered after animations processing
  34998. */
  34999. onAfterAnimationsObservable: Observable<Scene>;
  35000. /**
  35001. * An event triggered before draw calls are ready to be sent
  35002. */
  35003. onBeforeDrawPhaseObservable: Observable<Scene>;
  35004. /**
  35005. * An event triggered after draw calls have been sent
  35006. */
  35007. onAfterDrawPhaseObservable: Observable<Scene>;
  35008. /**
  35009. * An event triggered when the scene is ready
  35010. */
  35011. onReadyObservable: Observable<Scene>;
  35012. /**
  35013. * An event triggered before rendering a camera
  35014. */
  35015. onBeforeCameraRenderObservable: Observable<Camera>;
  35016. private _onBeforeCameraRenderObserver;
  35017. /** Sets a function to be executed before rendering a camera*/
  35018. set beforeCameraRender(callback: () => void);
  35019. /**
  35020. * An event triggered after rendering a camera
  35021. */
  35022. onAfterCameraRenderObservable: Observable<Camera>;
  35023. private _onAfterCameraRenderObserver;
  35024. /** Sets a function to be executed after rendering a camera*/
  35025. set afterCameraRender(callback: () => void);
  35026. /**
  35027. * An event triggered when active meshes evaluation is about to start
  35028. */
  35029. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35030. /**
  35031. * An event triggered when active meshes evaluation is done
  35032. */
  35033. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35034. /**
  35035. * An event triggered when particles rendering is about to start
  35036. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35037. */
  35038. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35039. /**
  35040. * An event triggered when particles rendering is done
  35041. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35042. */
  35043. onAfterParticlesRenderingObservable: Observable<Scene>;
  35044. /**
  35045. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35046. */
  35047. onDataLoadedObservable: Observable<Scene>;
  35048. /**
  35049. * An event triggered when a camera is created
  35050. */
  35051. onNewCameraAddedObservable: Observable<Camera>;
  35052. /**
  35053. * An event triggered when a camera is removed
  35054. */
  35055. onCameraRemovedObservable: Observable<Camera>;
  35056. /**
  35057. * An event triggered when a light is created
  35058. */
  35059. onNewLightAddedObservable: Observable<Light>;
  35060. /**
  35061. * An event triggered when a light is removed
  35062. */
  35063. onLightRemovedObservable: Observable<Light>;
  35064. /**
  35065. * An event triggered when a geometry is created
  35066. */
  35067. onNewGeometryAddedObservable: Observable<Geometry>;
  35068. /**
  35069. * An event triggered when a geometry is removed
  35070. */
  35071. onGeometryRemovedObservable: Observable<Geometry>;
  35072. /**
  35073. * An event triggered when a transform node is created
  35074. */
  35075. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35076. /**
  35077. * An event triggered when a transform node is removed
  35078. */
  35079. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35080. /**
  35081. * An event triggered when a mesh is created
  35082. */
  35083. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35084. /**
  35085. * An event triggered when a mesh is removed
  35086. */
  35087. onMeshRemovedObservable: Observable<AbstractMesh>;
  35088. /**
  35089. * An event triggered when a skeleton is created
  35090. */
  35091. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35092. /**
  35093. * An event triggered when a skeleton is removed
  35094. */
  35095. onSkeletonRemovedObservable: Observable<Skeleton>;
  35096. /**
  35097. * An event triggered when a material is created
  35098. */
  35099. onNewMaterialAddedObservable: Observable<Material>;
  35100. /**
  35101. * An event triggered when a material is removed
  35102. */
  35103. onMaterialRemovedObservable: Observable<Material>;
  35104. /**
  35105. * An event triggered when a texture is created
  35106. */
  35107. onNewTextureAddedObservable: Observable<BaseTexture>;
  35108. /**
  35109. * An event triggered when a texture is removed
  35110. */
  35111. onTextureRemovedObservable: Observable<BaseTexture>;
  35112. /**
  35113. * An event triggered when render targets are about to be rendered
  35114. * Can happen multiple times per frame.
  35115. */
  35116. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35117. /**
  35118. * An event triggered when render targets were rendered.
  35119. * Can happen multiple times per frame.
  35120. */
  35121. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35122. /**
  35123. * An event triggered before calculating deterministic simulation step
  35124. */
  35125. onBeforeStepObservable: Observable<Scene>;
  35126. /**
  35127. * An event triggered after calculating deterministic simulation step
  35128. */
  35129. onAfterStepObservable: Observable<Scene>;
  35130. /**
  35131. * An event triggered when the activeCamera property is updated
  35132. */
  35133. onActiveCameraChanged: Observable<Scene>;
  35134. /**
  35135. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35136. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35137. * 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)
  35138. */
  35139. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35140. /**
  35141. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35142. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35143. * 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)
  35144. */
  35145. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35146. /**
  35147. * This Observable will when a mesh has been imported into the scene.
  35148. */
  35149. onMeshImportedObservable: Observable<AbstractMesh>;
  35150. /**
  35151. * This Observable will when an animation file has been imported into the scene.
  35152. */
  35153. onAnimationFileImportedObservable: Observable<Scene>;
  35154. /**
  35155. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35156. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35157. */
  35158. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35159. /** @hidden */
  35160. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35161. /**
  35162. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35163. */
  35164. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35165. /**
  35166. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35167. */
  35168. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35169. /**
  35170. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35171. */
  35172. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35173. /** Callback called when a pointer move is detected */
  35174. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35175. /** Callback called when a pointer down is detected */
  35176. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35177. /** Callback called when a pointer up is detected */
  35178. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35179. /** Callback called when a pointer pick is detected */
  35180. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35181. /**
  35182. * 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).
  35183. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35184. */
  35185. onPrePointerObservable: Observable<PointerInfoPre>;
  35186. /**
  35187. * Observable event triggered each time an input event is received from the rendering canvas
  35188. */
  35189. onPointerObservable: Observable<PointerInfo>;
  35190. /**
  35191. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35192. */
  35193. get unTranslatedPointer(): Vector2;
  35194. /**
  35195. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35196. */
  35197. static get DragMovementThreshold(): number;
  35198. static set DragMovementThreshold(value: number);
  35199. /**
  35200. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35201. */
  35202. static get LongPressDelay(): number;
  35203. static set LongPressDelay(value: number);
  35204. /**
  35205. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35206. */
  35207. static get DoubleClickDelay(): number;
  35208. static set DoubleClickDelay(value: number);
  35209. /** If you need to check double click without raising a single click at first click, enable this flag */
  35210. static get ExclusiveDoubleClickMode(): boolean;
  35211. static set ExclusiveDoubleClickMode(value: boolean);
  35212. /** @hidden */
  35213. _mirroredCameraPosition: Nullable<Vector3>;
  35214. /**
  35215. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35216. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35217. */
  35218. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35219. /**
  35220. * Observable event triggered each time an keyboard event is received from the hosting window
  35221. */
  35222. onKeyboardObservable: Observable<KeyboardInfo>;
  35223. private _useRightHandedSystem;
  35224. /**
  35225. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35226. */
  35227. set useRightHandedSystem(value: boolean);
  35228. get useRightHandedSystem(): boolean;
  35229. private _timeAccumulator;
  35230. private _currentStepId;
  35231. private _currentInternalStep;
  35232. /**
  35233. * Sets the step Id used by deterministic lock step
  35234. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35235. * @param newStepId defines the step Id
  35236. */
  35237. setStepId(newStepId: number): void;
  35238. /**
  35239. * Gets the step Id used by deterministic lock step
  35240. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35241. * @returns the step Id
  35242. */
  35243. getStepId(): number;
  35244. /**
  35245. * Gets the internal step used by deterministic lock step
  35246. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35247. * @returns the internal step
  35248. */
  35249. getInternalStep(): number;
  35250. private _fogEnabled;
  35251. /**
  35252. * Gets or sets a boolean indicating if fog is enabled on this scene
  35253. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35254. * (Default is true)
  35255. */
  35256. set fogEnabled(value: boolean);
  35257. get fogEnabled(): boolean;
  35258. private _fogMode;
  35259. /**
  35260. * Gets or sets the fog mode to use
  35261. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35262. * | mode | value |
  35263. * | --- | --- |
  35264. * | FOGMODE_NONE | 0 |
  35265. * | FOGMODE_EXP | 1 |
  35266. * | FOGMODE_EXP2 | 2 |
  35267. * | FOGMODE_LINEAR | 3 |
  35268. */
  35269. set fogMode(value: number);
  35270. get fogMode(): number;
  35271. /**
  35272. * Gets or sets the fog color to use
  35273. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35274. * (Default is Color3(0.2, 0.2, 0.3))
  35275. */
  35276. fogColor: Color3;
  35277. /**
  35278. * Gets or sets the fog density to use
  35279. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35280. * (Default is 0.1)
  35281. */
  35282. fogDensity: number;
  35283. /**
  35284. * Gets or sets the fog start distance to use
  35285. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35286. * (Default is 0)
  35287. */
  35288. fogStart: number;
  35289. /**
  35290. * Gets or sets the fog end distance to use
  35291. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35292. * (Default is 1000)
  35293. */
  35294. fogEnd: number;
  35295. private _shadowsEnabled;
  35296. /**
  35297. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35298. */
  35299. set shadowsEnabled(value: boolean);
  35300. get shadowsEnabled(): boolean;
  35301. private _lightsEnabled;
  35302. /**
  35303. * Gets or sets a boolean indicating if lights are enabled on this scene
  35304. */
  35305. set lightsEnabled(value: boolean);
  35306. get lightsEnabled(): boolean;
  35307. /** All of the active cameras added to this scene. */
  35308. activeCameras: Camera[];
  35309. /** @hidden */
  35310. _activeCamera: Nullable<Camera>;
  35311. /** Gets or sets the current active camera */
  35312. get activeCamera(): Nullable<Camera>;
  35313. set activeCamera(value: Nullable<Camera>);
  35314. private _defaultMaterial;
  35315. /** The default material used on meshes when no material is affected */
  35316. get defaultMaterial(): Material;
  35317. /** The default material used on meshes when no material is affected */
  35318. set defaultMaterial(value: Material);
  35319. private _texturesEnabled;
  35320. /**
  35321. * Gets or sets a boolean indicating if textures are enabled on this scene
  35322. */
  35323. set texturesEnabled(value: boolean);
  35324. get texturesEnabled(): boolean;
  35325. /**
  35326. * Gets or sets a boolean indicating if particles are enabled on this scene
  35327. */
  35328. particlesEnabled: boolean;
  35329. /**
  35330. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35331. */
  35332. spritesEnabled: boolean;
  35333. private _skeletonsEnabled;
  35334. /**
  35335. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35336. */
  35337. set skeletonsEnabled(value: boolean);
  35338. get skeletonsEnabled(): boolean;
  35339. /**
  35340. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35341. */
  35342. lensFlaresEnabled: boolean;
  35343. /**
  35344. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35345. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35346. */
  35347. collisionsEnabled: boolean;
  35348. private _collisionCoordinator;
  35349. /** @hidden */
  35350. get collisionCoordinator(): ICollisionCoordinator;
  35351. /**
  35352. * Defines the gravity applied to this scene (used only for collisions)
  35353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35354. */
  35355. gravity: Vector3;
  35356. /**
  35357. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35358. */
  35359. postProcessesEnabled: boolean;
  35360. /**
  35361. * The list of postprocesses added to the scene
  35362. */
  35363. postProcesses: PostProcess[];
  35364. /**
  35365. * Gets the current postprocess manager
  35366. */
  35367. postProcessManager: PostProcessManager;
  35368. /**
  35369. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35370. */
  35371. renderTargetsEnabled: boolean;
  35372. /**
  35373. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35374. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35375. */
  35376. dumpNextRenderTargets: boolean;
  35377. /**
  35378. * The list of user defined render targets added to the scene
  35379. */
  35380. customRenderTargets: RenderTargetTexture[];
  35381. /**
  35382. * Defines if texture loading must be delayed
  35383. * If true, textures will only be loaded when they need to be rendered
  35384. */
  35385. useDelayedTextureLoading: boolean;
  35386. /**
  35387. * Gets the list of meshes imported to the scene through SceneLoader
  35388. */
  35389. importedMeshesFiles: String[];
  35390. /**
  35391. * Gets or sets a boolean indicating if probes are enabled on this scene
  35392. */
  35393. probesEnabled: boolean;
  35394. /**
  35395. * Gets or sets the current offline provider to use to store scene data
  35396. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35397. */
  35398. offlineProvider: IOfflineProvider;
  35399. /**
  35400. * Gets or sets the action manager associated with the scene
  35401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35402. */
  35403. actionManager: AbstractActionManager;
  35404. private _meshesForIntersections;
  35405. /**
  35406. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35407. */
  35408. proceduralTexturesEnabled: boolean;
  35409. private _engine;
  35410. private _totalVertices;
  35411. /** @hidden */
  35412. _activeIndices: PerfCounter;
  35413. /** @hidden */
  35414. _activeParticles: PerfCounter;
  35415. /** @hidden */
  35416. _activeBones: PerfCounter;
  35417. private _animationRatio;
  35418. /** @hidden */
  35419. _animationTimeLast: number;
  35420. /** @hidden */
  35421. _animationTime: number;
  35422. /**
  35423. * Gets or sets a general scale for animation speed
  35424. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35425. */
  35426. animationTimeScale: number;
  35427. /** @hidden */
  35428. _cachedMaterial: Nullable<Material>;
  35429. /** @hidden */
  35430. _cachedEffect: Nullable<Effect>;
  35431. /** @hidden */
  35432. _cachedVisibility: Nullable<number>;
  35433. private _renderId;
  35434. private _frameId;
  35435. private _executeWhenReadyTimeoutId;
  35436. private _intermediateRendering;
  35437. private _viewUpdateFlag;
  35438. private _projectionUpdateFlag;
  35439. /** @hidden */
  35440. _toBeDisposed: Nullable<IDisposable>[];
  35441. private _activeRequests;
  35442. /** @hidden */
  35443. _pendingData: any[];
  35444. private _isDisposed;
  35445. /**
  35446. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35447. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35448. */
  35449. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35450. private _activeMeshes;
  35451. private _processedMaterials;
  35452. private _renderTargets;
  35453. /** @hidden */
  35454. _activeParticleSystems: SmartArray<IParticleSystem>;
  35455. private _activeSkeletons;
  35456. private _softwareSkinnedMeshes;
  35457. private _renderingManager;
  35458. /** @hidden */
  35459. _activeAnimatables: Animatable[];
  35460. private _transformMatrix;
  35461. private _sceneUbo;
  35462. /** @hidden */
  35463. _viewMatrix: Matrix;
  35464. private _projectionMatrix;
  35465. /** @hidden */
  35466. _forcedViewPosition: Nullable<Vector3>;
  35467. /** @hidden */
  35468. _frustumPlanes: Plane[];
  35469. /**
  35470. * Gets the list of frustum planes (built from the active camera)
  35471. */
  35472. get frustumPlanes(): Plane[];
  35473. /**
  35474. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35475. * This is useful if there are more lights that the maximum simulteanous authorized
  35476. */
  35477. requireLightSorting: boolean;
  35478. /** @hidden */
  35479. readonly useMaterialMeshMap: boolean;
  35480. /** @hidden */
  35481. readonly useClonedMeshhMap: boolean;
  35482. private _externalData;
  35483. private _uid;
  35484. /**
  35485. * @hidden
  35486. * Backing store of defined scene components.
  35487. */
  35488. _components: ISceneComponent[];
  35489. /**
  35490. * @hidden
  35491. * Backing store of defined scene components.
  35492. */
  35493. _serializableComponents: ISceneSerializableComponent[];
  35494. /**
  35495. * List of components to register on the next registration step.
  35496. */
  35497. private _transientComponents;
  35498. /**
  35499. * Registers the transient components if needed.
  35500. */
  35501. private _registerTransientComponents;
  35502. /**
  35503. * @hidden
  35504. * Add a component to the scene.
  35505. * Note that the ccomponent could be registered on th next frame if this is called after
  35506. * the register component stage.
  35507. * @param component Defines the component to add to the scene
  35508. */
  35509. _addComponent(component: ISceneComponent): void;
  35510. /**
  35511. * @hidden
  35512. * Gets a component from the scene.
  35513. * @param name defines the name of the component to retrieve
  35514. * @returns the component or null if not present
  35515. */
  35516. _getComponent(name: string): Nullable<ISceneComponent>;
  35517. /**
  35518. * @hidden
  35519. * Defines the actions happening before camera updates.
  35520. */
  35521. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35522. /**
  35523. * @hidden
  35524. * Defines the actions happening before clear the canvas.
  35525. */
  35526. _beforeClearStage: Stage<SimpleStageAction>;
  35527. /**
  35528. * @hidden
  35529. * Defines the actions when collecting render targets for the frame.
  35530. */
  35531. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35532. /**
  35533. * @hidden
  35534. * Defines the actions happening for one camera in the frame.
  35535. */
  35536. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35537. /**
  35538. * @hidden
  35539. * Defines the actions happening during the per mesh ready checks.
  35540. */
  35541. _isReadyForMeshStage: Stage<MeshStageAction>;
  35542. /**
  35543. * @hidden
  35544. * Defines the actions happening before evaluate active mesh checks.
  35545. */
  35546. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35547. /**
  35548. * @hidden
  35549. * Defines the actions happening during the evaluate sub mesh checks.
  35550. */
  35551. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35552. /**
  35553. * @hidden
  35554. * Defines the actions happening during the active mesh stage.
  35555. */
  35556. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35557. /**
  35558. * @hidden
  35559. * Defines the actions happening during the per camera render target step.
  35560. */
  35561. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35562. /**
  35563. * @hidden
  35564. * Defines the actions happening just before the active camera is drawing.
  35565. */
  35566. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35567. /**
  35568. * @hidden
  35569. * Defines the actions happening just before a render target is drawing.
  35570. */
  35571. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35572. /**
  35573. * @hidden
  35574. * Defines the actions happening just before a rendering group is drawing.
  35575. */
  35576. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35577. /**
  35578. * @hidden
  35579. * Defines the actions happening just before a mesh is drawing.
  35580. */
  35581. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35582. /**
  35583. * @hidden
  35584. * Defines the actions happening just after a mesh has been drawn.
  35585. */
  35586. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35587. /**
  35588. * @hidden
  35589. * Defines the actions happening just after a rendering group has been drawn.
  35590. */
  35591. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35592. /**
  35593. * @hidden
  35594. * Defines the actions happening just after the active camera has been drawn.
  35595. */
  35596. _afterCameraDrawStage: Stage<CameraStageAction>;
  35597. /**
  35598. * @hidden
  35599. * Defines the actions happening just after a render target has been drawn.
  35600. */
  35601. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35602. /**
  35603. * @hidden
  35604. * Defines the actions happening just after rendering all cameras and computing intersections.
  35605. */
  35606. _afterRenderStage: Stage<SimpleStageAction>;
  35607. /**
  35608. * @hidden
  35609. * Defines the actions happening when a pointer move event happens.
  35610. */
  35611. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35612. /**
  35613. * @hidden
  35614. * Defines the actions happening when a pointer down event happens.
  35615. */
  35616. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35617. /**
  35618. * @hidden
  35619. * Defines the actions happening when a pointer up event happens.
  35620. */
  35621. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35622. /**
  35623. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35624. */
  35625. private geometriesByUniqueId;
  35626. /**
  35627. * Creates a new Scene
  35628. * @param engine defines the engine to use to render this scene
  35629. * @param options defines the scene options
  35630. */
  35631. constructor(engine: Engine, options?: SceneOptions);
  35632. /**
  35633. * Gets a string idenfifying the name of the class
  35634. * @returns "Scene" string
  35635. */
  35636. getClassName(): string;
  35637. private _defaultMeshCandidates;
  35638. /**
  35639. * @hidden
  35640. */
  35641. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35642. private _defaultSubMeshCandidates;
  35643. /**
  35644. * @hidden
  35645. */
  35646. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35647. /**
  35648. * Sets the default candidate providers for the scene.
  35649. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35650. * and getCollidingSubMeshCandidates to their default function
  35651. */
  35652. setDefaultCandidateProviders(): void;
  35653. /**
  35654. * Gets the mesh that is currently under the pointer
  35655. */
  35656. get meshUnderPointer(): Nullable<AbstractMesh>;
  35657. /**
  35658. * Gets or sets the current on-screen X position of the pointer
  35659. */
  35660. get pointerX(): number;
  35661. set pointerX(value: number);
  35662. /**
  35663. * Gets or sets the current on-screen Y position of the pointer
  35664. */
  35665. get pointerY(): number;
  35666. set pointerY(value: number);
  35667. /**
  35668. * Gets the cached material (ie. the latest rendered one)
  35669. * @returns the cached material
  35670. */
  35671. getCachedMaterial(): Nullable<Material>;
  35672. /**
  35673. * Gets the cached effect (ie. the latest rendered one)
  35674. * @returns the cached effect
  35675. */
  35676. getCachedEffect(): Nullable<Effect>;
  35677. /**
  35678. * Gets the cached visibility state (ie. the latest rendered one)
  35679. * @returns the cached visibility state
  35680. */
  35681. getCachedVisibility(): Nullable<number>;
  35682. /**
  35683. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35684. * @param material defines the current material
  35685. * @param effect defines the current effect
  35686. * @param visibility defines the current visibility state
  35687. * @returns true if one parameter is not cached
  35688. */
  35689. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35690. /**
  35691. * Gets the engine associated with the scene
  35692. * @returns an Engine
  35693. */
  35694. getEngine(): Engine;
  35695. /**
  35696. * Gets the total number of vertices rendered per frame
  35697. * @returns the total number of vertices rendered per frame
  35698. */
  35699. getTotalVertices(): number;
  35700. /**
  35701. * Gets the performance counter for total vertices
  35702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35703. */
  35704. get totalVerticesPerfCounter(): PerfCounter;
  35705. /**
  35706. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35707. * @returns the total number of active indices rendered per frame
  35708. */
  35709. getActiveIndices(): number;
  35710. /**
  35711. * Gets the performance counter for active indices
  35712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35713. */
  35714. get totalActiveIndicesPerfCounter(): PerfCounter;
  35715. /**
  35716. * Gets the total number of active particles rendered per frame
  35717. * @returns the total number of active particles rendered per frame
  35718. */
  35719. getActiveParticles(): number;
  35720. /**
  35721. * Gets the performance counter for active particles
  35722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35723. */
  35724. get activeParticlesPerfCounter(): PerfCounter;
  35725. /**
  35726. * Gets the total number of active bones rendered per frame
  35727. * @returns the total number of active bones rendered per frame
  35728. */
  35729. getActiveBones(): number;
  35730. /**
  35731. * Gets the performance counter for active bones
  35732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35733. */
  35734. get activeBonesPerfCounter(): PerfCounter;
  35735. /**
  35736. * Gets the array of active meshes
  35737. * @returns an array of AbstractMesh
  35738. */
  35739. getActiveMeshes(): SmartArray<AbstractMesh>;
  35740. /**
  35741. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35742. * @returns a number
  35743. */
  35744. getAnimationRatio(): number;
  35745. /**
  35746. * Gets an unique Id for the current render phase
  35747. * @returns a number
  35748. */
  35749. getRenderId(): number;
  35750. /**
  35751. * Gets an unique Id for the current frame
  35752. * @returns a number
  35753. */
  35754. getFrameId(): number;
  35755. /** Call this function if you want to manually increment the render Id*/
  35756. incrementRenderId(): void;
  35757. private _createUbo;
  35758. /**
  35759. * Use this method to simulate a pointer move on a mesh
  35760. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35761. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35762. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35763. * @returns the current scene
  35764. */
  35765. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35766. /**
  35767. * Use this method to simulate a pointer down on a mesh
  35768. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35769. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35770. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35771. * @returns the current scene
  35772. */
  35773. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35774. /**
  35775. * Use this method to simulate a pointer up on a mesh
  35776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35779. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35780. * @returns the current scene
  35781. */
  35782. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35783. /**
  35784. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35785. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35786. * @returns true if the pointer was captured
  35787. */
  35788. isPointerCaptured(pointerId?: number): boolean;
  35789. /**
  35790. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35791. * @param attachUp defines if you want to attach events to pointerup
  35792. * @param attachDown defines if you want to attach events to pointerdown
  35793. * @param attachMove defines if you want to attach events to pointermove
  35794. */
  35795. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35796. /** Detaches all event handlers*/
  35797. detachControl(): void;
  35798. /**
  35799. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35800. * Delay loaded resources are not taking in account
  35801. * @return true if all required resources are ready
  35802. */
  35803. isReady(): boolean;
  35804. /** Resets all cached information relative to material (including effect and visibility) */
  35805. resetCachedMaterial(): void;
  35806. /**
  35807. * Registers a function to be called before every frame render
  35808. * @param func defines the function to register
  35809. */
  35810. registerBeforeRender(func: () => void): void;
  35811. /**
  35812. * Unregisters a function called before every frame render
  35813. * @param func defines the function to unregister
  35814. */
  35815. unregisterBeforeRender(func: () => void): void;
  35816. /**
  35817. * Registers a function to be called after every frame render
  35818. * @param func defines the function to register
  35819. */
  35820. registerAfterRender(func: () => void): void;
  35821. /**
  35822. * Unregisters a function called after every frame render
  35823. * @param func defines the function to unregister
  35824. */
  35825. unregisterAfterRender(func: () => void): void;
  35826. private _executeOnceBeforeRender;
  35827. /**
  35828. * The provided function will run before render once and will be disposed afterwards.
  35829. * A timeout delay can be provided so that the function will be executed in N ms.
  35830. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35831. * @param func The function to be executed.
  35832. * @param timeout optional delay in ms
  35833. */
  35834. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35835. /** @hidden */
  35836. _addPendingData(data: any): void;
  35837. /** @hidden */
  35838. _removePendingData(data: any): void;
  35839. /**
  35840. * Returns the number of items waiting to be loaded
  35841. * @returns the number of items waiting to be loaded
  35842. */
  35843. getWaitingItemsCount(): number;
  35844. /**
  35845. * Returns a boolean indicating if the scene is still loading data
  35846. */
  35847. get isLoading(): boolean;
  35848. /**
  35849. * Registers a function to be executed when the scene is ready
  35850. * @param {Function} func - the function to be executed
  35851. */
  35852. executeWhenReady(func: () => void): void;
  35853. /**
  35854. * Returns a promise that resolves when the scene is ready
  35855. * @returns A promise that resolves when the scene is ready
  35856. */
  35857. whenReadyAsync(): Promise<void>;
  35858. /** @hidden */
  35859. _checkIsReady(): void;
  35860. /**
  35861. * Gets all animatable attached to the scene
  35862. */
  35863. get animatables(): Animatable[];
  35864. /**
  35865. * Resets the last animation time frame.
  35866. * Useful to override when animations start running when loading a scene for the first time.
  35867. */
  35868. resetLastAnimationTimeFrame(): void;
  35869. /**
  35870. * Gets the current view matrix
  35871. * @returns a Matrix
  35872. */
  35873. getViewMatrix(): Matrix;
  35874. /**
  35875. * Gets the current projection matrix
  35876. * @returns a Matrix
  35877. */
  35878. getProjectionMatrix(): Matrix;
  35879. /**
  35880. * Gets the current transform matrix
  35881. * @returns a Matrix made of View * Projection
  35882. */
  35883. getTransformMatrix(): Matrix;
  35884. /**
  35885. * Sets the current transform matrix
  35886. * @param viewL defines the View matrix to use
  35887. * @param projectionL defines the Projection matrix to use
  35888. * @param viewR defines the right View matrix to use (if provided)
  35889. * @param projectionR defines the right Projection matrix to use (if provided)
  35890. */
  35891. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35892. /**
  35893. * Gets the uniform buffer used to store scene data
  35894. * @returns a UniformBuffer
  35895. */
  35896. getSceneUniformBuffer(): UniformBuffer;
  35897. /**
  35898. * Gets an unique (relatively to the current scene) Id
  35899. * @returns an unique number for the scene
  35900. */
  35901. getUniqueId(): number;
  35902. /**
  35903. * Add a mesh to the list of scene's meshes
  35904. * @param newMesh defines the mesh to add
  35905. * @param recursive if all child meshes should also be added to the scene
  35906. */
  35907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35908. /**
  35909. * Remove a mesh for the list of scene's meshes
  35910. * @param toRemove defines the mesh to remove
  35911. * @param recursive if all child meshes should also be removed from the scene
  35912. * @returns the index where the mesh was in the mesh list
  35913. */
  35914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35915. /**
  35916. * Add a transform node to the list of scene's transform nodes
  35917. * @param newTransformNode defines the transform node to add
  35918. */
  35919. addTransformNode(newTransformNode: TransformNode): void;
  35920. /**
  35921. * Remove a transform node for the list of scene's transform nodes
  35922. * @param toRemove defines the transform node to remove
  35923. * @returns the index where the transform node was in the transform node list
  35924. */
  35925. removeTransformNode(toRemove: TransformNode): number;
  35926. /**
  35927. * Remove a skeleton for the list of scene's skeletons
  35928. * @param toRemove defines the skeleton to remove
  35929. * @returns the index where the skeleton was in the skeleton list
  35930. */
  35931. removeSkeleton(toRemove: Skeleton): number;
  35932. /**
  35933. * Remove a morph target for the list of scene's morph targets
  35934. * @param toRemove defines the morph target to remove
  35935. * @returns the index where the morph target was in the morph target list
  35936. */
  35937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35938. /**
  35939. * Remove a light for the list of scene's lights
  35940. * @param toRemove defines the light to remove
  35941. * @returns the index where the light was in the light list
  35942. */
  35943. removeLight(toRemove: Light): number;
  35944. /**
  35945. * Remove a camera for the list of scene's cameras
  35946. * @param toRemove defines the camera to remove
  35947. * @returns the index where the camera was in the camera list
  35948. */
  35949. removeCamera(toRemove: Camera): number;
  35950. /**
  35951. * Remove a particle system for the list of scene's particle systems
  35952. * @param toRemove defines the particle system to remove
  35953. * @returns the index where the particle system was in the particle system list
  35954. */
  35955. removeParticleSystem(toRemove: IParticleSystem): number;
  35956. /**
  35957. * Remove a animation for the list of scene's animations
  35958. * @param toRemove defines the animation to remove
  35959. * @returns the index where the animation was in the animation list
  35960. */
  35961. removeAnimation(toRemove: Animation): number;
  35962. /**
  35963. * Will stop the animation of the given target
  35964. * @param target - the target
  35965. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35966. * @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)
  35967. */
  35968. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35969. /**
  35970. * Removes the given animation group from this scene.
  35971. * @param toRemove The animation group to remove
  35972. * @returns The index of the removed animation group
  35973. */
  35974. removeAnimationGroup(toRemove: AnimationGroup): number;
  35975. /**
  35976. * Removes the given multi-material from this scene.
  35977. * @param toRemove The multi-material to remove
  35978. * @returns The index of the removed multi-material
  35979. */
  35980. removeMultiMaterial(toRemove: MultiMaterial): number;
  35981. /**
  35982. * Removes the given material from this scene.
  35983. * @param toRemove The material to remove
  35984. * @returns The index of the removed material
  35985. */
  35986. removeMaterial(toRemove: Material): number;
  35987. /**
  35988. * Removes the given action manager from this scene.
  35989. * @param toRemove The action manager to remove
  35990. * @returns The index of the removed action manager
  35991. */
  35992. removeActionManager(toRemove: AbstractActionManager): number;
  35993. /**
  35994. * Removes the given texture from this scene.
  35995. * @param toRemove The texture to remove
  35996. * @returns The index of the removed texture
  35997. */
  35998. removeTexture(toRemove: BaseTexture): number;
  35999. /**
  36000. * Adds the given light to this scene
  36001. * @param newLight The light to add
  36002. */
  36003. addLight(newLight: Light): void;
  36004. /**
  36005. * Sorts the list list based on light priorities
  36006. */
  36007. sortLightsByPriority(): void;
  36008. /**
  36009. * Adds the given camera to this scene
  36010. * @param newCamera The camera to add
  36011. */
  36012. addCamera(newCamera: Camera): void;
  36013. /**
  36014. * Adds the given skeleton to this scene
  36015. * @param newSkeleton The skeleton to add
  36016. */
  36017. addSkeleton(newSkeleton: Skeleton): void;
  36018. /**
  36019. * Adds the given particle system to this scene
  36020. * @param newParticleSystem The particle system to add
  36021. */
  36022. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36023. /**
  36024. * Adds the given animation to this scene
  36025. * @param newAnimation The animation to add
  36026. */
  36027. addAnimation(newAnimation: Animation): void;
  36028. /**
  36029. * Adds the given animation group to this scene.
  36030. * @param newAnimationGroup The animation group to add
  36031. */
  36032. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36033. /**
  36034. * Adds the given multi-material to this scene
  36035. * @param newMultiMaterial The multi-material to add
  36036. */
  36037. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36038. /**
  36039. * Adds the given material to this scene
  36040. * @param newMaterial The material to add
  36041. */
  36042. addMaterial(newMaterial: Material): void;
  36043. /**
  36044. * Adds the given morph target to this scene
  36045. * @param newMorphTargetManager The morph target to add
  36046. */
  36047. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36048. /**
  36049. * Adds the given geometry to this scene
  36050. * @param newGeometry The geometry to add
  36051. */
  36052. addGeometry(newGeometry: Geometry): void;
  36053. /**
  36054. * Adds the given action manager to this scene
  36055. * @param newActionManager The action manager to add
  36056. */
  36057. addActionManager(newActionManager: AbstractActionManager): void;
  36058. /**
  36059. * Adds the given texture to this scene.
  36060. * @param newTexture The texture to add
  36061. */
  36062. addTexture(newTexture: BaseTexture): void;
  36063. /**
  36064. * Switch active camera
  36065. * @param newCamera defines the new active camera
  36066. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36067. */
  36068. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36069. /**
  36070. * sets the active camera of the scene using its ID
  36071. * @param id defines the camera's ID
  36072. * @return the new active camera or null if none found.
  36073. */
  36074. setActiveCameraByID(id: string): Nullable<Camera>;
  36075. /**
  36076. * sets the active camera of the scene using its name
  36077. * @param name defines the camera's name
  36078. * @returns the new active camera or null if none found.
  36079. */
  36080. setActiveCameraByName(name: string): Nullable<Camera>;
  36081. /**
  36082. * get an animation group using its name
  36083. * @param name defines the material's name
  36084. * @return the animation group or null if none found.
  36085. */
  36086. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36087. /**
  36088. * Get a material using its unique id
  36089. * @param uniqueId defines the material's unique id
  36090. * @return the material or null if none found.
  36091. */
  36092. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36093. /**
  36094. * get a material using its id
  36095. * @param id defines the material's ID
  36096. * @return the material or null if none found.
  36097. */
  36098. getMaterialByID(id: string): Nullable<Material>;
  36099. /**
  36100. * Gets a the last added material using a given id
  36101. * @param id defines the material's ID
  36102. * @return the last material with the given id or null if none found.
  36103. */
  36104. getLastMaterialByID(id: string): Nullable<Material>;
  36105. /**
  36106. * Gets a material using its name
  36107. * @param name defines the material's name
  36108. * @return the material or null if none found.
  36109. */
  36110. getMaterialByName(name: string): Nullable<Material>;
  36111. /**
  36112. * Get a texture using its unique id
  36113. * @param uniqueId defines the texture's unique id
  36114. * @return the texture or null if none found.
  36115. */
  36116. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36117. /**
  36118. * Gets a camera using its id
  36119. * @param id defines the id to look for
  36120. * @returns the camera or null if not found
  36121. */
  36122. getCameraByID(id: string): Nullable<Camera>;
  36123. /**
  36124. * Gets a camera using its unique id
  36125. * @param uniqueId defines the unique id to look for
  36126. * @returns the camera or null if not found
  36127. */
  36128. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36129. /**
  36130. * Gets a camera using its name
  36131. * @param name defines the camera's name
  36132. * @return the camera or null if none found.
  36133. */
  36134. getCameraByName(name: string): Nullable<Camera>;
  36135. /**
  36136. * Gets a bone using its id
  36137. * @param id defines the bone's id
  36138. * @return the bone or null if not found
  36139. */
  36140. getBoneByID(id: string): Nullable<Bone>;
  36141. /**
  36142. * Gets a bone using its id
  36143. * @param name defines the bone's name
  36144. * @return the bone or null if not found
  36145. */
  36146. getBoneByName(name: string): Nullable<Bone>;
  36147. /**
  36148. * Gets a light node using its name
  36149. * @param name defines the the light's name
  36150. * @return the light or null if none found.
  36151. */
  36152. getLightByName(name: string): Nullable<Light>;
  36153. /**
  36154. * Gets a light node using its id
  36155. * @param id defines the light's id
  36156. * @return the light or null if none found.
  36157. */
  36158. getLightByID(id: string): Nullable<Light>;
  36159. /**
  36160. * Gets a light node using its scene-generated unique ID
  36161. * @param uniqueId defines the light's unique id
  36162. * @return the light or null if none found.
  36163. */
  36164. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36165. /**
  36166. * Gets a particle system by id
  36167. * @param id defines the particle system id
  36168. * @return the corresponding system or null if none found
  36169. */
  36170. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36171. /**
  36172. * Gets a geometry using its ID
  36173. * @param id defines the geometry's id
  36174. * @return the geometry or null if none found.
  36175. */
  36176. getGeometryByID(id: string): Nullable<Geometry>;
  36177. private _getGeometryByUniqueID;
  36178. /**
  36179. * Add a new geometry to this scene
  36180. * @param geometry defines the geometry to be added to the scene.
  36181. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36182. * @return a boolean defining if the geometry was added or not
  36183. */
  36184. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36185. /**
  36186. * Removes an existing geometry
  36187. * @param geometry defines the geometry to be removed from the scene
  36188. * @return a boolean defining if the geometry was removed or not
  36189. */
  36190. removeGeometry(geometry: Geometry): boolean;
  36191. /**
  36192. * Gets the list of geometries attached to the scene
  36193. * @returns an array of Geometry
  36194. */
  36195. getGeometries(): Geometry[];
  36196. /**
  36197. * Gets the first added mesh found of a given ID
  36198. * @param id defines the id to search for
  36199. * @return the mesh found or null if not found at all
  36200. */
  36201. getMeshByID(id: string): Nullable<AbstractMesh>;
  36202. /**
  36203. * Gets a list of meshes using their id
  36204. * @param id defines the id to search for
  36205. * @returns a list of meshes
  36206. */
  36207. getMeshesByID(id: string): Array<AbstractMesh>;
  36208. /**
  36209. * Gets the first added transform node found of a given ID
  36210. * @param id defines the id to search for
  36211. * @return the found transform node or null if not found at all.
  36212. */
  36213. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36214. /**
  36215. * Gets a transform node with its auto-generated unique id
  36216. * @param uniqueId efines the unique id to search for
  36217. * @return the found transform node or null if not found at all.
  36218. */
  36219. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36220. /**
  36221. * Gets a list of transform nodes using their id
  36222. * @param id defines the id to search for
  36223. * @returns a list of transform nodes
  36224. */
  36225. getTransformNodesByID(id: string): Array<TransformNode>;
  36226. /**
  36227. * Gets a mesh with its auto-generated unique id
  36228. * @param uniqueId defines the unique id to search for
  36229. * @return the found mesh or null if not found at all.
  36230. */
  36231. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36232. /**
  36233. * Gets a the last added mesh using a given id
  36234. * @param id defines the id to search for
  36235. * @return the found mesh or null if not found at all.
  36236. */
  36237. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36238. /**
  36239. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36240. * @param id defines the id to search for
  36241. * @return the found node or null if not found at all
  36242. */
  36243. getLastEntryByID(id: string): Nullable<Node>;
  36244. /**
  36245. * Gets a node (Mesh, Camera, Light) using a given id
  36246. * @param id defines the id to search for
  36247. * @return the found node or null if not found at all
  36248. */
  36249. getNodeByID(id: string): Nullable<Node>;
  36250. /**
  36251. * Gets a node (Mesh, Camera, Light) using a given name
  36252. * @param name defines the name to search for
  36253. * @return the found node or null if not found at all.
  36254. */
  36255. getNodeByName(name: string): Nullable<Node>;
  36256. /**
  36257. * Gets a mesh using a given name
  36258. * @param name defines the name to search for
  36259. * @return the found mesh or null if not found at all.
  36260. */
  36261. getMeshByName(name: string): Nullable<AbstractMesh>;
  36262. /**
  36263. * Gets a transform node using a given name
  36264. * @param name defines the name to search for
  36265. * @return the found transform node or null if not found at all.
  36266. */
  36267. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36268. /**
  36269. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36270. * @param id defines the id to search for
  36271. * @return the found skeleton or null if not found at all.
  36272. */
  36273. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36274. /**
  36275. * Gets a skeleton using a given auto generated unique id
  36276. * @param uniqueId defines the unique id to search for
  36277. * @return the found skeleton or null if not found at all.
  36278. */
  36279. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36280. /**
  36281. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36282. * @param id defines the id to search for
  36283. * @return the found skeleton or null if not found at all.
  36284. */
  36285. getSkeletonById(id: string): Nullable<Skeleton>;
  36286. /**
  36287. * Gets a skeleton using a given name
  36288. * @param name defines the name to search for
  36289. * @return the found skeleton or null if not found at all.
  36290. */
  36291. getSkeletonByName(name: string): Nullable<Skeleton>;
  36292. /**
  36293. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36294. * @param id defines the id to search for
  36295. * @return the found morph target manager or null if not found at all.
  36296. */
  36297. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36298. /**
  36299. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36300. * @param id defines the id to search for
  36301. * @return the found morph target or null if not found at all.
  36302. */
  36303. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36304. /**
  36305. * Gets a boolean indicating if the given mesh is active
  36306. * @param mesh defines the mesh to look for
  36307. * @returns true if the mesh is in the active list
  36308. */
  36309. isActiveMesh(mesh: AbstractMesh): boolean;
  36310. /**
  36311. * Return a unique id as a string which can serve as an identifier for the scene
  36312. */
  36313. get uid(): string;
  36314. /**
  36315. * Add an externaly attached data from its key.
  36316. * This method call will fail and return false, if such key already exists.
  36317. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36318. * @param key the unique key that identifies the data
  36319. * @param data the data object to associate to the key for this Engine instance
  36320. * @return true if no such key were already present and the data was added successfully, false otherwise
  36321. */
  36322. addExternalData<T>(key: string, data: T): boolean;
  36323. /**
  36324. * Get an externaly attached data from its key
  36325. * @param key the unique key that identifies the data
  36326. * @return the associated data, if present (can be null), or undefined if not present
  36327. */
  36328. getExternalData<T>(key: string): Nullable<T>;
  36329. /**
  36330. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36331. * @param key the unique key that identifies the data
  36332. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36333. * @return the associated data, can be null if the factory returned null.
  36334. */
  36335. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36336. /**
  36337. * Remove an externaly attached data from the Engine instance
  36338. * @param key the unique key that identifies the data
  36339. * @return true if the data was successfully removed, false if it doesn't exist
  36340. */
  36341. removeExternalData(key: string): boolean;
  36342. private _evaluateSubMesh;
  36343. /**
  36344. * Clear the processed materials smart array preventing retention point in material dispose.
  36345. */
  36346. freeProcessedMaterials(): void;
  36347. private _preventFreeActiveMeshesAndRenderingGroups;
  36348. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36349. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36350. * when disposing several meshes in a row or a hierarchy of meshes.
  36351. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36352. */
  36353. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36354. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36355. /**
  36356. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36357. */
  36358. freeActiveMeshes(): void;
  36359. /**
  36360. * Clear the info related to rendering groups preventing retention points during dispose.
  36361. */
  36362. freeRenderingGroups(): void;
  36363. /** @hidden */
  36364. _isInIntermediateRendering(): boolean;
  36365. /**
  36366. * Lambda returning the list of potentially active meshes.
  36367. */
  36368. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36369. /**
  36370. * Lambda returning the list of potentially active sub meshes.
  36371. */
  36372. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36373. /**
  36374. * Lambda returning the list of potentially intersecting sub meshes.
  36375. */
  36376. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36377. /**
  36378. * Lambda returning the list of potentially colliding sub meshes.
  36379. */
  36380. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36381. private _activeMeshesFrozen;
  36382. private _skipEvaluateActiveMeshesCompletely;
  36383. /**
  36384. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36385. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36386. * @returns the current scene
  36387. */
  36388. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36389. /**
  36390. * Use this function to restart evaluating active meshes on every frame
  36391. * @returns the current scene
  36392. */
  36393. unfreezeActiveMeshes(): Scene;
  36394. private _evaluateActiveMeshes;
  36395. private _activeMesh;
  36396. /**
  36397. * Update the transform matrix to update from the current active camera
  36398. * @param force defines a boolean used to force the update even if cache is up to date
  36399. */
  36400. updateTransformMatrix(force?: boolean): void;
  36401. private _bindFrameBuffer;
  36402. /** @hidden */
  36403. _allowPostProcessClearColor: boolean;
  36404. /** @hidden */
  36405. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36406. private _processSubCameras;
  36407. private _checkIntersections;
  36408. /** @hidden */
  36409. _advancePhysicsEngineStep(step: number): void;
  36410. /**
  36411. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36412. */
  36413. getDeterministicFrameTime: () => number;
  36414. /** @hidden */
  36415. _animate(): void;
  36416. /** Execute all animations (for a frame) */
  36417. animate(): void;
  36418. /**
  36419. * Render the scene
  36420. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36421. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36422. */
  36423. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36424. /**
  36425. * Freeze all materials
  36426. * A frozen material will not be updatable but should be faster to render
  36427. */
  36428. freezeMaterials(): void;
  36429. /**
  36430. * Unfreeze all materials
  36431. * A frozen material will not be updatable but should be faster to render
  36432. */
  36433. unfreezeMaterials(): void;
  36434. /**
  36435. * Releases all held ressources
  36436. */
  36437. dispose(): void;
  36438. /**
  36439. * Gets if the scene is already disposed
  36440. */
  36441. get isDisposed(): boolean;
  36442. /**
  36443. * Call this function to reduce memory footprint of the scene.
  36444. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36445. */
  36446. clearCachedVertexData(): void;
  36447. /**
  36448. * This function will remove the local cached buffer data from texture.
  36449. * It will save memory but will prevent the texture from being rebuilt
  36450. */
  36451. cleanCachedTextureBuffer(): void;
  36452. /**
  36453. * Get the world extend vectors with an optional filter
  36454. *
  36455. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36456. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36457. */
  36458. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36459. min: Vector3;
  36460. max: Vector3;
  36461. };
  36462. /**
  36463. * Creates a ray that can be used to pick in the scene
  36464. * @param x defines the x coordinate of the origin (on-screen)
  36465. * @param y defines the y coordinate of the origin (on-screen)
  36466. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36467. * @param camera defines the camera to use for the picking
  36468. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36469. * @returns a Ray
  36470. */
  36471. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36472. /**
  36473. * Creates a ray that can be used to pick in the scene
  36474. * @param x defines the x coordinate of the origin (on-screen)
  36475. * @param y defines the y coordinate of the origin (on-screen)
  36476. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36477. * @param result defines the ray where to store the picking ray
  36478. * @param camera defines the camera to use for the picking
  36479. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36480. * @returns the current scene
  36481. */
  36482. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36483. /**
  36484. * Creates a ray that can be used to pick in the scene
  36485. * @param x defines the x coordinate of the origin (on-screen)
  36486. * @param y defines the y coordinate of the origin (on-screen)
  36487. * @param camera defines the camera to use for the picking
  36488. * @returns a Ray
  36489. */
  36490. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36491. /**
  36492. * Creates a ray that can be used to pick in the scene
  36493. * @param x defines the x coordinate of the origin (on-screen)
  36494. * @param y defines the y coordinate of the origin (on-screen)
  36495. * @param result defines the ray where to store the picking ray
  36496. * @param camera defines the camera to use for the picking
  36497. * @returns the current scene
  36498. */
  36499. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36500. /** Launch a ray to try to pick a mesh in the scene
  36501. * @param x position on screen
  36502. * @param y position on screen
  36503. * @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
  36504. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36505. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36506. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36507. * @returns a PickingInfo
  36508. */
  36509. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36510. /** Use the given ray to pick a mesh in the scene
  36511. * @param ray The ray to use to pick meshes
  36512. * @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
  36513. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36514. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36515. * @returns a PickingInfo
  36516. */
  36517. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36518. /**
  36519. * Launch a ray to try to pick a mesh in the scene
  36520. * @param x X position on screen
  36521. * @param y Y position on screen
  36522. * @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
  36523. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36525. * @returns an array of PickingInfo
  36526. */
  36527. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36528. /**
  36529. * Launch a ray to try to pick a mesh in the scene
  36530. * @param ray Ray to use
  36531. * @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
  36532. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36533. * @returns an array of PickingInfo
  36534. */
  36535. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36536. /**
  36537. * Force the value of meshUnderPointer
  36538. * @param mesh defines the mesh to use
  36539. */
  36540. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36541. /**
  36542. * Gets the mesh under the pointer
  36543. * @returns a Mesh or null if no mesh is under the pointer
  36544. */
  36545. getPointerOverMesh(): Nullable<AbstractMesh>;
  36546. /** @hidden */
  36547. _rebuildGeometries(): void;
  36548. /** @hidden */
  36549. _rebuildTextures(): void;
  36550. private _getByTags;
  36551. /**
  36552. * Get a list of meshes by tags
  36553. * @param tagsQuery defines the tags query to use
  36554. * @param forEach defines a predicate used to filter results
  36555. * @returns an array of Mesh
  36556. */
  36557. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36558. /**
  36559. * Get a list of cameras by tags
  36560. * @param tagsQuery defines the tags query to use
  36561. * @param forEach defines a predicate used to filter results
  36562. * @returns an array of Camera
  36563. */
  36564. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36565. /**
  36566. * Get a list of lights by tags
  36567. * @param tagsQuery defines the tags query to use
  36568. * @param forEach defines a predicate used to filter results
  36569. * @returns an array of Light
  36570. */
  36571. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36572. /**
  36573. * Get a list of materials by tags
  36574. * @param tagsQuery defines the tags query to use
  36575. * @param forEach defines a predicate used to filter results
  36576. * @returns an array of Material
  36577. */
  36578. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36579. /**
  36580. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36581. * This allowed control for front to back rendering or reversly depending of the special needs.
  36582. *
  36583. * @param renderingGroupId The rendering group id corresponding to its index
  36584. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36585. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36586. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36587. */
  36588. 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;
  36589. /**
  36590. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36591. *
  36592. * @param renderingGroupId The rendering group id corresponding to its index
  36593. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36594. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36595. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36596. */
  36597. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36598. /**
  36599. * Gets the current auto clear configuration for one rendering group of the rendering
  36600. * manager.
  36601. * @param index the rendering group index to get the information for
  36602. * @returns The auto clear setup for the requested rendering group
  36603. */
  36604. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36605. private _blockMaterialDirtyMechanism;
  36606. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36607. get blockMaterialDirtyMechanism(): boolean;
  36608. set blockMaterialDirtyMechanism(value: boolean);
  36609. /**
  36610. * Will flag all materials as dirty to trigger new shader compilation
  36611. * @param flag defines the flag used to specify which material part must be marked as dirty
  36612. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36613. */
  36614. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36615. /** @hidden */
  36616. _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;
  36617. /** @hidden */
  36618. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36619. /** @hidden */
  36620. _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;
  36621. /** @hidden */
  36622. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36623. /** @hidden */
  36624. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36625. /** @hidden */
  36626. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36627. }
  36628. }
  36629. declare module BABYLON {
  36630. /**
  36631. * Set of assets to keep when moving a scene into an asset container.
  36632. */
  36633. export class KeepAssets extends AbstractScene {
  36634. }
  36635. /**
  36636. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36637. */
  36638. export class InstantiatedEntries {
  36639. /**
  36640. * List of new root nodes (eg. nodes with no parent)
  36641. */
  36642. rootNodes: TransformNode[];
  36643. /**
  36644. * List of new skeletons
  36645. */
  36646. skeletons: Skeleton[];
  36647. /**
  36648. * List of new animation groups
  36649. */
  36650. animationGroups: AnimationGroup[];
  36651. }
  36652. /**
  36653. * Container with a set of assets that can be added or removed from a scene.
  36654. */
  36655. export class AssetContainer extends AbstractScene {
  36656. /**
  36657. * The scene the AssetContainer belongs to.
  36658. */
  36659. scene: Scene;
  36660. /**
  36661. * Instantiates an AssetContainer.
  36662. * @param scene The scene the AssetContainer belongs to.
  36663. */
  36664. constructor(scene: Scene);
  36665. /**
  36666. * Instantiate or clone all meshes and add the new ones to the scene.
  36667. * Skeletons and animation groups will all be cloned
  36668. * @param nameFunction defines an optional function used to get new names for clones
  36669. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36670. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36671. */
  36672. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36673. /**
  36674. * Adds all the assets from the container to the scene.
  36675. */
  36676. addAllToScene(): void;
  36677. /**
  36678. * Removes all the assets in the container from the scene
  36679. */
  36680. removeAllFromScene(): void;
  36681. /**
  36682. * Disposes all the assets in the container
  36683. */
  36684. dispose(): void;
  36685. private _moveAssets;
  36686. /**
  36687. * Removes all the assets contained in the scene and adds them to the container.
  36688. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36689. */
  36690. moveAllFromScene(keepAssets?: KeepAssets): void;
  36691. /**
  36692. * 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.
  36693. * @returns the root mesh
  36694. */
  36695. createRootMesh(): Mesh;
  36696. /**
  36697. * Merge animations from this asset container into a scene
  36698. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36699. * @param animatables set of animatables to retarget to a node from the scene
  36700. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36701. */
  36702. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36703. }
  36704. }
  36705. declare module BABYLON {
  36706. /**
  36707. * Defines how the parser contract is defined.
  36708. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36709. */
  36710. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36711. /**
  36712. * Defines how the individual parser contract is defined.
  36713. * These parser can parse an individual asset
  36714. */
  36715. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36716. /**
  36717. * Base class of the scene acting as a container for the different elements composing a scene.
  36718. * This class is dynamically extended by the different components of the scene increasing
  36719. * flexibility and reducing coupling
  36720. */
  36721. export abstract class AbstractScene {
  36722. /**
  36723. * Stores the list of available parsers in the application.
  36724. */
  36725. private static _BabylonFileParsers;
  36726. /**
  36727. * Stores the list of available individual parsers in the application.
  36728. */
  36729. private static _IndividualBabylonFileParsers;
  36730. /**
  36731. * Adds a parser in the list of available ones
  36732. * @param name Defines the name of the parser
  36733. * @param parser Defines the parser to add
  36734. */
  36735. static AddParser(name: string, parser: BabylonFileParser): void;
  36736. /**
  36737. * Gets a general parser from the list of avaialble ones
  36738. * @param name Defines the name of the parser
  36739. * @returns the requested parser or null
  36740. */
  36741. static GetParser(name: string): Nullable<BabylonFileParser>;
  36742. /**
  36743. * Adds n individual parser in the list of available ones
  36744. * @param name Defines the name of the parser
  36745. * @param parser Defines the parser to add
  36746. */
  36747. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36748. /**
  36749. * Gets an individual parser from the list of avaialble ones
  36750. * @param name Defines the name of the parser
  36751. * @returns the requested parser or null
  36752. */
  36753. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36754. /**
  36755. * Parser json data and populate both a scene and its associated container object
  36756. * @param jsonData Defines the data to parse
  36757. * @param scene Defines the scene to parse the data for
  36758. * @param container Defines the container attached to the parsing sequence
  36759. * @param rootUrl Defines the root url of the data
  36760. */
  36761. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36762. /**
  36763. * Gets the list of root nodes (ie. nodes with no parent)
  36764. */
  36765. rootNodes: Node[];
  36766. /** All of the cameras added to this scene
  36767. * @see http://doc.babylonjs.com/babylon101/cameras
  36768. */
  36769. cameras: Camera[];
  36770. /**
  36771. * All of the lights added to this scene
  36772. * @see http://doc.babylonjs.com/babylon101/lights
  36773. */
  36774. lights: Light[];
  36775. /**
  36776. * All of the (abstract) meshes added to this scene
  36777. */
  36778. meshes: AbstractMesh[];
  36779. /**
  36780. * The list of skeletons added to the scene
  36781. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36782. */
  36783. skeletons: Skeleton[];
  36784. /**
  36785. * All of the particle systems added to this scene
  36786. * @see http://doc.babylonjs.com/babylon101/particles
  36787. */
  36788. particleSystems: IParticleSystem[];
  36789. /**
  36790. * Gets a list of Animations associated with the scene
  36791. */
  36792. animations: Animation[];
  36793. /**
  36794. * All of the animation groups added to this scene
  36795. * @see http://doc.babylonjs.com/how_to/group
  36796. */
  36797. animationGroups: AnimationGroup[];
  36798. /**
  36799. * All of the multi-materials added to this scene
  36800. * @see http://doc.babylonjs.com/how_to/multi_materials
  36801. */
  36802. multiMaterials: MultiMaterial[];
  36803. /**
  36804. * All of the materials added to this scene
  36805. * In the context of a Scene, it is not supposed to be modified manually.
  36806. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36807. * Note also that the order of the Material within the array is not significant and might change.
  36808. * @see http://doc.babylonjs.com/babylon101/materials
  36809. */
  36810. materials: Material[];
  36811. /**
  36812. * The list of morph target managers added to the scene
  36813. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36814. */
  36815. morphTargetManagers: MorphTargetManager[];
  36816. /**
  36817. * The list of geometries used in the scene.
  36818. */
  36819. geometries: Geometry[];
  36820. /**
  36821. * All of the tranform nodes added to this scene
  36822. * In the context of a Scene, it is not supposed to be modified manually.
  36823. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36824. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36825. * @see http://doc.babylonjs.com/how_to/transformnode
  36826. */
  36827. transformNodes: TransformNode[];
  36828. /**
  36829. * ActionManagers available on the scene.
  36830. */
  36831. actionManagers: AbstractActionManager[];
  36832. /**
  36833. * Textures to keep.
  36834. */
  36835. textures: BaseTexture[];
  36836. /**
  36837. * Environment texture for the scene
  36838. */
  36839. environmentTexture: Nullable<BaseTexture>;
  36840. /**
  36841. * @returns all meshes, lights, cameras, transformNodes and bones
  36842. */
  36843. getNodes(): Array<Node>;
  36844. }
  36845. }
  36846. declare module BABYLON {
  36847. /**
  36848. * Interface used to define options for Sound class
  36849. */
  36850. export interface ISoundOptions {
  36851. /**
  36852. * Does the sound autoplay once loaded.
  36853. */
  36854. autoplay?: boolean;
  36855. /**
  36856. * Does the sound loop after it finishes playing once.
  36857. */
  36858. loop?: boolean;
  36859. /**
  36860. * Sound's volume
  36861. */
  36862. volume?: number;
  36863. /**
  36864. * Is it a spatial sound?
  36865. */
  36866. spatialSound?: boolean;
  36867. /**
  36868. * Maximum distance to hear that sound
  36869. */
  36870. maxDistance?: number;
  36871. /**
  36872. * Uses user defined attenuation function
  36873. */
  36874. useCustomAttenuation?: boolean;
  36875. /**
  36876. * Define the roll off factor of spatial sounds.
  36877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36878. */
  36879. rolloffFactor?: number;
  36880. /**
  36881. * Define the reference distance the sound should be heard perfectly.
  36882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36883. */
  36884. refDistance?: number;
  36885. /**
  36886. * Define the distance attenuation model the sound will follow.
  36887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36888. */
  36889. distanceModel?: string;
  36890. /**
  36891. * Defines the playback speed (1 by default)
  36892. */
  36893. playbackRate?: number;
  36894. /**
  36895. * Defines if the sound is from a streaming source
  36896. */
  36897. streaming?: boolean;
  36898. /**
  36899. * Defines an optional length (in seconds) inside the sound file
  36900. */
  36901. length?: number;
  36902. /**
  36903. * Defines an optional offset (in seconds) inside the sound file
  36904. */
  36905. offset?: number;
  36906. /**
  36907. * If true, URLs will not be required to state the audio file codec to use.
  36908. */
  36909. skipCodecCheck?: boolean;
  36910. }
  36911. /**
  36912. * Defines a sound that can be played in the application.
  36913. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36915. */
  36916. export class Sound {
  36917. /**
  36918. * The name of the sound in the scene.
  36919. */
  36920. name: string;
  36921. /**
  36922. * Does the sound autoplay once loaded.
  36923. */
  36924. autoplay: boolean;
  36925. /**
  36926. * Does the sound loop after it finishes playing once.
  36927. */
  36928. loop: boolean;
  36929. /**
  36930. * Does the sound use a custom attenuation curve to simulate the falloff
  36931. * happening when the source gets further away from the camera.
  36932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36933. */
  36934. useCustomAttenuation: boolean;
  36935. /**
  36936. * The sound track id this sound belongs to.
  36937. */
  36938. soundTrackId: number;
  36939. /**
  36940. * Is this sound currently played.
  36941. */
  36942. isPlaying: boolean;
  36943. /**
  36944. * Is this sound currently paused.
  36945. */
  36946. isPaused: boolean;
  36947. /**
  36948. * Does this sound enables spatial sound.
  36949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36950. */
  36951. spatialSound: boolean;
  36952. /**
  36953. * Define the reference distance the sound should be heard perfectly.
  36954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36955. */
  36956. refDistance: number;
  36957. /**
  36958. * Define the roll off factor of spatial sounds.
  36959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36960. */
  36961. rolloffFactor: number;
  36962. /**
  36963. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36965. */
  36966. maxDistance: number;
  36967. /**
  36968. * Define the distance attenuation model the sound will follow.
  36969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36970. */
  36971. distanceModel: string;
  36972. /**
  36973. * @hidden
  36974. * Back Compat
  36975. **/
  36976. onended: () => any;
  36977. /**
  36978. * Observable event when the current playing sound finishes.
  36979. */
  36980. onEndedObservable: Observable<Sound>;
  36981. private _panningModel;
  36982. private _playbackRate;
  36983. private _streaming;
  36984. private _startTime;
  36985. private _startOffset;
  36986. private _position;
  36987. /** @hidden */
  36988. _positionInEmitterSpace: boolean;
  36989. private _localDirection;
  36990. private _volume;
  36991. private _isReadyToPlay;
  36992. private _isDirectional;
  36993. private _readyToPlayCallback;
  36994. private _audioBuffer;
  36995. private _soundSource;
  36996. private _streamingSource;
  36997. private _soundPanner;
  36998. private _soundGain;
  36999. private _inputAudioNode;
  37000. private _outputAudioNode;
  37001. private _coneInnerAngle;
  37002. private _coneOuterAngle;
  37003. private _coneOuterGain;
  37004. private _scene;
  37005. private _connectedTransformNode;
  37006. private _customAttenuationFunction;
  37007. private _registerFunc;
  37008. private _isOutputConnected;
  37009. private _htmlAudioElement;
  37010. private _urlType;
  37011. private _length?;
  37012. private _offset?;
  37013. /** @hidden */
  37014. static _SceneComponentInitialization: (scene: Scene) => void;
  37015. /**
  37016. * Create a sound and attach it to a scene
  37017. * @param name Name of your sound
  37018. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37019. * @param scene defines the scene the sound belongs to
  37020. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37021. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37022. */
  37023. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37024. /**
  37025. * Release the sound and its associated resources
  37026. */
  37027. dispose(): void;
  37028. /**
  37029. * Gets if the sounds is ready to be played or not.
  37030. * @returns true if ready, otherwise false
  37031. */
  37032. isReady(): boolean;
  37033. private _soundLoaded;
  37034. /**
  37035. * Sets the data of the sound from an audiobuffer
  37036. * @param audioBuffer The audioBuffer containing the data
  37037. */
  37038. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37039. /**
  37040. * Updates the current sounds options such as maxdistance, loop...
  37041. * @param options A JSON object containing values named as the object properties
  37042. */
  37043. updateOptions(options: ISoundOptions): void;
  37044. private _createSpatialParameters;
  37045. private _updateSpatialParameters;
  37046. /**
  37047. * Switch the panning model to HRTF:
  37048. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37050. */
  37051. switchPanningModelToHRTF(): void;
  37052. /**
  37053. * Switch the panning model to Equal Power:
  37054. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37056. */
  37057. switchPanningModelToEqualPower(): void;
  37058. private _switchPanningModel;
  37059. /**
  37060. * Connect this sound to a sound track audio node like gain...
  37061. * @param soundTrackAudioNode the sound track audio node to connect to
  37062. */
  37063. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37064. /**
  37065. * Transform this sound into a directional source
  37066. * @param coneInnerAngle Size of the inner cone in degree
  37067. * @param coneOuterAngle Size of the outer cone in degree
  37068. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37069. */
  37070. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37071. /**
  37072. * Gets or sets the inner angle for the directional cone.
  37073. */
  37074. get directionalConeInnerAngle(): number;
  37075. /**
  37076. * Gets or sets the inner angle for the directional cone.
  37077. */
  37078. set directionalConeInnerAngle(value: number);
  37079. /**
  37080. * Gets or sets the outer angle for the directional cone.
  37081. */
  37082. get directionalConeOuterAngle(): number;
  37083. /**
  37084. * Gets or sets the outer angle for the directional cone.
  37085. */
  37086. set directionalConeOuterAngle(value: number);
  37087. /**
  37088. * Sets the position of the emitter if spatial sound is enabled
  37089. * @param newPosition Defines the new posisiton
  37090. */
  37091. setPosition(newPosition: Vector3): void;
  37092. /**
  37093. * Sets the local direction of the emitter if spatial sound is enabled
  37094. * @param newLocalDirection Defines the new local direction
  37095. */
  37096. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37097. private _updateDirection;
  37098. /** @hidden */
  37099. updateDistanceFromListener(): void;
  37100. /**
  37101. * Sets a new custom attenuation function for the sound.
  37102. * @param callback Defines the function used for the attenuation
  37103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37104. */
  37105. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37106. /**
  37107. * Play the sound
  37108. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37109. * @param offset (optional) Start the sound at a specific time in seconds
  37110. * @param length (optional) Sound duration (in seconds)
  37111. */
  37112. play(time?: number, offset?: number, length?: number): void;
  37113. private _onended;
  37114. /**
  37115. * Stop the sound
  37116. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37117. */
  37118. stop(time?: number): void;
  37119. /**
  37120. * Put the sound in pause
  37121. */
  37122. pause(): void;
  37123. /**
  37124. * Sets a dedicated volume for this sounds
  37125. * @param newVolume Define the new volume of the sound
  37126. * @param time Define time for gradual change to new volume
  37127. */
  37128. setVolume(newVolume: number, time?: number): void;
  37129. /**
  37130. * Set the sound play back rate
  37131. * @param newPlaybackRate Define the playback rate the sound should be played at
  37132. */
  37133. setPlaybackRate(newPlaybackRate: number): void;
  37134. /**
  37135. * Gets the volume of the sound.
  37136. * @returns the volume of the sound
  37137. */
  37138. getVolume(): number;
  37139. /**
  37140. * Attach the sound to a dedicated mesh
  37141. * @param transformNode The transform node to connect the sound with
  37142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37143. */
  37144. attachToMesh(transformNode: TransformNode): void;
  37145. /**
  37146. * Detach the sound from the previously attached mesh
  37147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37148. */
  37149. detachFromMesh(): void;
  37150. private _onRegisterAfterWorldMatrixUpdate;
  37151. /**
  37152. * Clone the current sound in the scene.
  37153. * @returns the new sound clone
  37154. */
  37155. clone(): Nullable<Sound>;
  37156. /**
  37157. * Gets the current underlying audio buffer containing the data
  37158. * @returns the audio buffer
  37159. */
  37160. getAudioBuffer(): Nullable<AudioBuffer>;
  37161. /**
  37162. * Serializes the Sound in a JSON representation
  37163. * @returns the JSON representation of the sound
  37164. */
  37165. serialize(): any;
  37166. /**
  37167. * Parse a JSON representation of a sound to innstantiate in a given scene
  37168. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37169. * @param scene Define the scene the new parsed sound should be created in
  37170. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37171. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37172. * @returns the newly parsed sound
  37173. */
  37174. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37175. }
  37176. }
  37177. declare module BABYLON {
  37178. /**
  37179. * This defines an action helpful to play a defined sound on a triggered action.
  37180. */
  37181. export class PlaySoundAction extends Action {
  37182. private _sound;
  37183. /**
  37184. * Instantiate the action
  37185. * @param triggerOptions defines the trigger options
  37186. * @param sound defines the sound to play
  37187. * @param condition defines the trigger related conditions
  37188. */
  37189. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37190. /** @hidden */
  37191. _prepare(): void;
  37192. /**
  37193. * Execute the action and play the sound.
  37194. */
  37195. execute(): void;
  37196. /**
  37197. * Serializes the actions and its related information.
  37198. * @param parent defines the object to serialize in
  37199. * @returns the serialized object
  37200. */
  37201. serialize(parent: any): any;
  37202. }
  37203. /**
  37204. * This defines an action helpful to stop a defined sound on a triggered action.
  37205. */
  37206. export class StopSoundAction extends Action {
  37207. private _sound;
  37208. /**
  37209. * Instantiate the action
  37210. * @param triggerOptions defines the trigger options
  37211. * @param sound defines the sound to stop
  37212. * @param condition defines the trigger related conditions
  37213. */
  37214. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37215. /** @hidden */
  37216. _prepare(): void;
  37217. /**
  37218. * Execute the action and stop the sound.
  37219. */
  37220. execute(): void;
  37221. /**
  37222. * Serializes the actions and its related information.
  37223. * @param parent defines the object to serialize in
  37224. * @returns the serialized object
  37225. */
  37226. serialize(parent: any): any;
  37227. }
  37228. }
  37229. declare module BABYLON {
  37230. /**
  37231. * This defines an action responsible to change the value of a property
  37232. * by interpolating between its current value and the newly set one once triggered.
  37233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37234. */
  37235. export class InterpolateValueAction extends Action {
  37236. /**
  37237. * Defines the path of the property where the value should be interpolated
  37238. */
  37239. propertyPath: string;
  37240. /**
  37241. * Defines the target value at the end of the interpolation.
  37242. */
  37243. value: any;
  37244. /**
  37245. * Defines the time it will take for the property to interpolate to the value.
  37246. */
  37247. duration: number;
  37248. /**
  37249. * Defines if the other scene animations should be stopped when the action has been triggered
  37250. */
  37251. stopOtherAnimations?: boolean;
  37252. /**
  37253. * Defines a callback raised once the interpolation animation has been done.
  37254. */
  37255. onInterpolationDone?: () => void;
  37256. /**
  37257. * Observable triggered once the interpolation animation has been done.
  37258. */
  37259. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37260. private _target;
  37261. private _effectiveTarget;
  37262. private _property;
  37263. /**
  37264. * Instantiate the action
  37265. * @param triggerOptions defines the trigger options
  37266. * @param target defines the object containing the value to interpolate
  37267. * @param propertyPath defines the path to the property in the target object
  37268. * @param value defines the target value at the end of the interpolation
  37269. * @param duration deines the time it will take for the property to interpolate to the value.
  37270. * @param condition defines the trigger related conditions
  37271. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37272. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37273. */
  37274. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37275. /** @hidden */
  37276. _prepare(): void;
  37277. /**
  37278. * Execute the action starts the value interpolation.
  37279. */
  37280. execute(): void;
  37281. /**
  37282. * Serializes the actions and its related information.
  37283. * @param parent defines the object to serialize in
  37284. * @returns the serialized object
  37285. */
  37286. serialize(parent: any): any;
  37287. }
  37288. }
  37289. declare module BABYLON {
  37290. /**
  37291. * Options allowed during the creation of a sound track.
  37292. */
  37293. export interface ISoundTrackOptions {
  37294. /**
  37295. * The volume the sound track should take during creation
  37296. */
  37297. volume?: number;
  37298. /**
  37299. * Define if the sound track is the main sound track of the scene
  37300. */
  37301. mainTrack?: boolean;
  37302. }
  37303. /**
  37304. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37305. * It will be also used in a future release to apply effects on a specific track.
  37306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37307. */
  37308. export class SoundTrack {
  37309. /**
  37310. * The unique identifier of the sound track in the scene.
  37311. */
  37312. id: number;
  37313. /**
  37314. * The list of sounds included in the sound track.
  37315. */
  37316. soundCollection: Array<Sound>;
  37317. private _outputAudioNode;
  37318. private _scene;
  37319. private _connectedAnalyser;
  37320. private _options;
  37321. private _isInitialized;
  37322. /**
  37323. * Creates a new sound track.
  37324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37325. * @param scene Define the scene the sound track belongs to
  37326. * @param options
  37327. */
  37328. constructor(scene: Scene, options?: ISoundTrackOptions);
  37329. private _initializeSoundTrackAudioGraph;
  37330. /**
  37331. * Release the sound track and its associated resources
  37332. */
  37333. dispose(): void;
  37334. /**
  37335. * Adds a sound to this sound track
  37336. * @param sound define the cound to add
  37337. * @ignoreNaming
  37338. */
  37339. AddSound(sound: Sound): void;
  37340. /**
  37341. * Removes a sound to this sound track
  37342. * @param sound define the cound to remove
  37343. * @ignoreNaming
  37344. */
  37345. RemoveSound(sound: Sound): void;
  37346. /**
  37347. * Set a global volume for the full sound track.
  37348. * @param newVolume Define the new volume of the sound track
  37349. */
  37350. setVolume(newVolume: number): void;
  37351. /**
  37352. * Switch the panning model to HRTF:
  37353. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37355. */
  37356. switchPanningModelToHRTF(): void;
  37357. /**
  37358. * Switch the panning model to Equal Power:
  37359. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37361. */
  37362. switchPanningModelToEqualPower(): void;
  37363. /**
  37364. * Connect the sound track to an audio analyser allowing some amazing
  37365. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37367. * @param analyser The analyser to connect to the engine
  37368. */
  37369. connectToAnalyser(analyser: Analyser): void;
  37370. }
  37371. }
  37372. declare module BABYLON {
  37373. interface AbstractScene {
  37374. /**
  37375. * The list of sounds used in the scene.
  37376. */
  37377. sounds: Nullable<Array<Sound>>;
  37378. }
  37379. interface Scene {
  37380. /**
  37381. * @hidden
  37382. * Backing field
  37383. */
  37384. _mainSoundTrack: SoundTrack;
  37385. /**
  37386. * The main sound track played by the scene.
  37387. * It cotains your primary collection of sounds.
  37388. */
  37389. mainSoundTrack: SoundTrack;
  37390. /**
  37391. * The list of sound tracks added to the scene
  37392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37393. */
  37394. soundTracks: Nullable<Array<SoundTrack>>;
  37395. /**
  37396. * Gets a sound using a given name
  37397. * @param name defines the name to search for
  37398. * @return the found sound or null if not found at all.
  37399. */
  37400. getSoundByName(name: string): Nullable<Sound>;
  37401. /**
  37402. * Gets or sets if audio support is enabled
  37403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37404. */
  37405. audioEnabled: boolean;
  37406. /**
  37407. * Gets or sets if audio will be output to headphones
  37408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37409. */
  37410. headphone: boolean;
  37411. /**
  37412. * Gets or sets custom audio listener position provider
  37413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37414. */
  37415. audioListenerPositionProvider: Nullable<() => Vector3>;
  37416. /**
  37417. * Gets or sets a refresh rate when using 3D audio positioning
  37418. */
  37419. audioPositioningRefreshRate: number;
  37420. }
  37421. /**
  37422. * Defines the sound scene component responsible to manage any sounds
  37423. * in a given scene.
  37424. */
  37425. export class AudioSceneComponent implements ISceneSerializableComponent {
  37426. /**
  37427. * The component name helpfull to identify the component in the list of scene components.
  37428. */
  37429. readonly name: string;
  37430. /**
  37431. * The scene the component belongs to.
  37432. */
  37433. scene: Scene;
  37434. private _audioEnabled;
  37435. /**
  37436. * Gets whether audio is enabled or not.
  37437. * Please use related enable/disable method to switch state.
  37438. */
  37439. get audioEnabled(): boolean;
  37440. private _headphone;
  37441. /**
  37442. * Gets whether audio is outputing to headphone or not.
  37443. * Please use the according Switch methods to change output.
  37444. */
  37445. get headphone(): boolean;
  37446. /**
  37447. * Gets or sets a refresh rate when using 3D audio positioning
  37448. */
  37449. audioPositioningRefreshRate: number;
  37450. private _audioListenerPositionProvider;
  37451. /**
  37452. * Gets the current audio listener position provider
  37453. */
  37454. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37455. /**
  37456. * Sets a custom listener position for all sounds in the scene
  37457. * By default, this is the position of the first active camera
  37458. */
  37459. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37460. /**
  37461. * Creates a new instance of the component for the given scene
  37462. * @param scene Defines the scene to register the component in
  37463. */
  37464. constructor(scene: Scene);
  37465. /**
  37466. * Registers the component in a given scene
  37467. */
  37468. register(): void;
  37469. /**
  37470. * Rebuilds the elements related to this component in case of
  37471. * context lost for instance.
  37472. */
  37473. rebuild(): void;
  37474. /**
  37475. * Serializes the component data to the specified json object
  37476. * @param serializationObject The object to serialize to
  37477. */
  37478. serialize(serializationObject: any): void;
  37479. /**
  37480. * Adds all the elements from the container to the scene
  37481. * @param container the container holding the elements
  37482. */
  37483. addFromContainer(container: AbstractScene): void;
  37484. /**
  37485. * Removes all the elements in the container from the scene
  37486. * @param container contains the elements to remove
  37487. * @param dispose if the removed element should be disposed (default: false)
  37488. */
  37489. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37490. /**
  37491. * Disposes the component and the associated ressources.
  37492. */
  37493. dispose(): void;
  37494. /**
  37495. * Disables audio in the associated scene.
  37496. */
  37497. disableAudio(): void;
  37498. /**
  37499. * Enables audio in the associated scene.
  37500. */
  37501. enableAudio(): void;
  37502. /**
  37503. * Switch audio to headphone output.
  37504. */
  37505. switchAudioModeForHeadphones(): void;
  37506. /**
  37507. * Switch audio to normal speakers.
  37508. */
  37509. switchAudioModeForNormalSpeakers(): void;
  37510. private _cachedCameraDirection;
  37511. private _cachedCameraPosition;
  37512. private _lastCheck;
  37513. private _afterRender;
  37514. }
  37515. }
  37516. declare module BABYLON {
  37517. /**
  37518. * Wraps one or more Sound objects and selects one with random weight for playback.
  37519. */
  37520. export class WeightedSound {
  37521. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37522. loop: boolean;
  37523. private _coneInnerAngle;
  37524. private _coneOuterAngle;
  37525. private _volume;
  37526. /** A Sound is currently playing. */
  37527. isPlaying: boolean;
  37528. /** A Sound is currently paused. */
  37529. isPaused: boolean;
  37530. private _sounds;
  37531. private _weights;
  37532. private _currentIndex?;
  37533. /**
  37534. * Creates a new WeightedSound from the list of sounds given.
  37535. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37536. * @param sounds Array of Sounds that will be selected from.
  37537. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37538. */
  37539. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37540. /**
  37541. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37542. */
  37543. get directionalConeInnerAngle(): number;
  37544. /**
  37545. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37546. */
  37547. set directionalConeInnerAngle(value: number);
  37548. /**
  37549. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37550. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37551. */
  37552. get directionalConeOuterAngle(): number;
  37553. /**
  37554. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37555. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37556. */
  37557. set directionalConeOuterAngle(value: number);
  37558. /**
  37559. * Playback volume.
  37560. */
  37561. get volume(): number;
  37562. /**
  37563. * Playback volume.
  37564. */
  37565. set volume(value: number);
  37566. private _onended;
  37567. /**
  37568. * Suspend playback
  37569. */
  37570. pause(): void;
  37571. /**
  37572. * Stop playback
  37573. */
  37574. stop(): void;
  37575. /**
  37576. * Start playback.
  37577. * @param startOffset Position the clip head at a specific time in seconds.
  37578. */
  37579. play(startOffset?: number): void;
  37580. }
  37581. }
  37582. declare module BABYLON {
  37583. /**
  37584. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37585. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37586. */
  37587. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37588. /**
  37589. * Gets the name of the behavior.
  37590. */
  37591. get name(): string;
  37592. /**
  37593. * The easing function used by animations
  37594. */
  37595. static EasingFunction: BackEase;
  37596. /**
  37597. * The easing mode used by animations
  37598. */
  37599. static EasingMode: number;
  37600. /**
  37601. * The duration of the animation, in milliseconds
  37602. */
  37603. transitionDuration: number;
  37604. /**
  37605. * Length of the distance animated by the transition when lower radius is reached
  37606. */
  37607. lowerRadiusTransitionRange: number;
  37608. /**
  37609. * Length of the distance animated by the transition when upper radius is reached
  37610. */
  37611. upperRadiusTransitionRange: number;
  37612. private _autoTransitionRange;
  37613. /**
  37614. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37615. */
  37616. get autoTransitionRange(): boolean;
  37617. /**
  37618. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37619. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37620. */
  37621. set autoTransitionRange(value: boolean);
  37622. private _attachedCamera;
  37623. private _onAfterCheckInputsObserver;
  37624. private _onMeshTargetChangedObserver;
  37625. /**
  37626. * Initializes the behavior.
  37627. */
  37628. init(): void;
  37629. /**
  37630. * Attaches the behavior to its arc rotate camera.
  37631. * @param camera Defines the camera to attach the behavior to
  37632. */
  37633. attach(camera: ArcRotateCamera): void;
  37634. /**
  37635. * Detaches the behavior from its current arc rotate camera.
  37636. */
  37637. detach(): void;
  37638. private _radiusIsAnimating;
  37639. private _radiusBounceTransition;
  37640. private _animatables;
  37641. private _cachedWheelPrecision;
  37642. /**
  37643. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37644. * @param radiusLimit The limit to check against.
  37645. * @return Bool to indicate if at limit.
  37646. */
  37647. private _isRadiusAtLimit;
  37648. /**
  37649. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37650. * @param radiusDelta The delta by which to animate to. Can be negative.
  37651. */
  37652. private _applyBoundRadiusAnimation;
  37653. /**
  37654. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37655. */
  37656. protected _clearAnimationLocks(): void;
  37657. /**
  37658. * Stops and removes all animations that have been applied to the camera
  37659. */
  37660. stopAllAnimations(): void;
  37661. }
  37662. }
  37663. declare module BABYLON {
  37664. /**
  37665. * 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.
  37666. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37667. */
  37668. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37669. /**
  37670. * Gets the name of the behavior.
  37671. */
  37672. get name(): string;
  37673. private _mode;
  37674. private _radiusScale;
  37675. private _positionScale;
  37676. private _defaultElevation;
  37677. private _elevationReturnTime;
  37678. private _elevationReturnWaitTime;
  37679. private _zoomStopsAnimation;
  37680. private _framingTime;
  37681. /**
  37682. * The easing function used by animations
  37683. */
  37684. static EasingFunction: ExponentialEase;
  37685. /**
  37686. * The easing mode used by animations
  37687. */
  37688. static EasingMode: number;
  37689. /**
  37690. * Sets the current mode used by the behavior
  37691. */
  37692. set mode(mode: number);
  37693. /**
  37694. * Gets current mode used by the behavior.
  37695. */
  37696. get mode(): number;
  37697. /**
  37698. * Sets the scale applied to the radius (1 by default)
  37699. */
  37700. set radiusScale(radius: number);
  37701. /**
  37702. * Gets the scale applied to the radius
  37703. */
  37704. get radiusScale(): number;
  37705. /**
  37706. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37707. */
  37708. set positionScale(scale: number);
  37709. /**
  37710. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37711. */
  37712. get positionScale(): number;
  37713. /**
  37714. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37715. * behaviour is triggered, in radians.
  37716. */
  37717. set defaultElevation(elevation: number);
  37718. /**
  37719. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37720. * behaviour is triggered, in radians.
  37721. */
  37722. get defaultElevation(): number;
  37723. /**
  37724. * Sets the time (in milliseconds) taken to return to the default beta position.
  37725. * Negative value indicates camera should not return to default.
  37726. */
  37727. set elevationReturnTime(speed: number);
  37728. /**
  37729. * Gets the time (in milliseconds) taken to return to the default beta position.
  37730. * Negative value indicates camera should not return to default.
  37731. */
  37732. get elevationReturnTime(): number;
  37733. /**
  37734. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37735. */
  37736. set elevationReturnWaitTime(time: number);
  37737. /**
  37738. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37739. */
  37740. get elevationReturnWaitTime(): number;
  37741. /**
  37742. * Sets the flag that indicates if user zooming should stop animation.
  37743. */
  37744. set zoomStopsAnimation(flag: boolean);
  37745. /**
  37746. * Gets the flag that indicates if user zooming should stop animation.
  37747. */
  37748. get zoomStopsAnimation(): boolean;
  37749. /**
  37750. * Sets the transition time when framing the mesh, in milliseconds
  37751. */
  37752. set framingTime(time: number);
  37753. /**
  37754. * Gets the transition time when framing the mesh, in milliseconds
  37755. */
  37756. get framingTime(): number;
  37757. /**
  37758. * Define if the behavior should automatically change the configured
  37759. * camera limits and sensibilities.
  37760. */
  37761. autoCorrectCameraLimitsAndSensibility: boolean;
  37762. private _onPrePointerObservableObserver;
  37763. private _onAfterCheckInputsObserver;
  37764. private _onMeshTargetChangedObserver;
  37765. private _attachedCamera;
  37766. private _isPointerDown;
  37767. private _lastInteractionTime;
  37768. /**
  37769. * Initializes the behavior.
  37770. */
  37771. init(): void;
  37772. /**
  37773. * Attaches the behavior to its arc rotate camera.
  37774. * @param camera Defines the camera to attach the behavior to
  37775. */
  37776. attach(camera: ArcRotateCamera): void;
  37777. /**
  37778. * Detaches the behavior from its current arc rotate camera.
  37779. */
  37780. detach(): void;
  37781. private _animatables;
  37782. private _betaIsAnimating;
  37783. private _betaTransition;
  37784. private _radiusTransition;
  37785. private _vectorTransition;
  37786. /**
  37787. * Targets the given mesh and updates zoom level accordingly.
  37788. * @param mesh The mesh to target.
  37789. * @param radius Optional. If a cached radius position already exists, overrides default.
  37790. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37791. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37792. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37793. */
  37794. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37795. /**
  37796. * Targets the given mesh with its children and updates zoom level accordingly.
  37797. * @param mesh The mesh to target.
  37798. * @param radius Optional. If a cached radius position already exists, overrides default.
  37799. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37800. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37801. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37802. */
  37803. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37804. /**
  37805. * Targets the given meshes with their children and updates zoom level accordingly.
  37806. * @param meshes The mesh to target.
  37807. * @param radius Optional. If a cached radius position already exists, overrides default.
  37808. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37809. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37810. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37811. */
  37812. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37813. /**
  37814. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37815. * @param minimumWorld Determines the smaller position of the bounding box extend
  37816. * @param maximumWorld Determines the bigger position of the bounding box extend
  37817. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37818. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37819. */
  37820. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37821. /**
  37822. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37823. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37824. * frustum width.
  37825. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37826. * to fully enclose the mesh in the viewing frustum.
  37827. */
  37828. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37829. /**
  37830. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37831. * is automatically returned to its default position (expected to be above ground plane).
  37832. */
  37833. private _maintainCameraAboveGround;
  37834. /**
  37835. * Returns the frustum slope based on the canvas ratio and camera FOV
  37836. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37837. */
  37838. private _getFrustumSlope;
  37839. /**
  37840. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37841. */
  37842. private _clearAnimationLocks;
  37843. /**
  37844. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37845. */
  37846. private _applyUserInteraction;
  37847. /**
  37848. * Stops and removes all animations that have been applied to the camera
  37849. */
  37850. stopAllAnimations(): void;
  37851. /**
  37852. * Gets a value indicating if the user is moving the camera
  37853. */
  37854. get isUserIsMoving(): boolean;
  37855. /**
  37856. * The camera can move all the way towards the mesh.
  37857. */
  37858. static IgnoreBoundsSizeMode: number;
  37859. /**
  37860. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37861. */
  37862. static FitFrustumSidesMode: number;
  37863. }
  37864. }
  37865. declare module BABYLON {
  37866. /**
  37867. * Base class for Camera Pointer Inputs.
  37868. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37869. * for example usage.
  37870. */
  37871. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37872. /**
  37873. * Defines the camera the input is attached to.
  37874. */
  37875. abstract camera: Camera;
  37876. /**
  37877. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37878. */
  37879. protected _altKey: boolean;
  37880. protected _ctrlKey: boolean;
  37881. protected _metaKey: boolean;
  37882. protected _shiftKey: boolean;
  37883. /**
  37884. * Which mouse buttons were pressed at time of last mouse event.
  37885. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37886. */
  37887. protected _buttonsPressed: number;
  37888. /**
  37889. * Defines the buttons associated with the input to handle camera move.
  37890. */
  37891. buttons: number[];
  37892. /**
  37893. * Attach the input controls to a specific dom element to get the input from.
  37894. * @param element Defines the element the controls should be listened from
  37895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37896. */
  37897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37898. /**
  37899. * Detach the current controls from the specified dom element.
  37900. * @param element Defines the element to stop listening the inputs from
  37901. */
  37902. detachControl(element: Nullable<HTMLElement>): void;
  37903. /**
  37904. * Gets the class name of the current input.
  37905. * @returns the class name
  37906. */
  37907. getClassName(): string;
  37908. /**
  37909. * Get the friendly name associated with the input class.
  37910. * @returns the input friendly name
  37911. */
  37912. getSimpleName(): string;
  37913. /**
  37914. * Called on pointer POINTERDOUBLETAP event.
  37915. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37916. */
  37917. protected onDoubleTap(type: string): void;
  37918. /**
  37919. * Called on pointer POINTERMOVE event if only a single touch is active.
  37920. * Override this method to provide functionality.
  37921. */
  37922. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37923. /**
  37924. * Called on pointer POINTERMOVE event if multiple touches are active.
  37925. * Override this method to provide functionality.
  37926. */
  37927. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37928. /**
  37929. * Called on JS contextmenu event.
  37930. * Override this method to provide functionality.
  37931. */
  37932. protected onContextMenu(evt: PointerEvent): void;
  37933. /**
  37934. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37935. * press.
  37936. * Override this method to provide functionality.
  37937. */
  37938. protected onButtonDown(evt: PointerEvent): void;
  37939. /**
  37940. * Called each time a new POINTERUP event occurs. Ie, for each button
  37941. * release.
  37942. * Override this method to provide functionality.
  37943. */
  37944. protected onButtonUp(evt: PointerEvent): void;
  37945. /**
  37946. * Called when window becomes inactive.
  37947. * Override this method to provide functionality.
  37948. */
  37949. protected onLostFocus(): void;
  37950. private _pointerInput;
  37951. private _observer;
  37952. private _onLostFocus;
  37953. private pointA;
  37954. private pointB;
  37955. }
  37956. }
  37957. declare module BABYLON {
  37958. /**
  37959. * Manage the pointers inputs to control an arc rotate camera.
  37960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37961. */
  37962. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37963. /**
  37964. * Defines the camera the input is attached to.
  37965. */
  37966. camera: ArcRotateCamera;
  37967. /**
  37968. * Gets the class name of the current input.
  37969. * @returns the class name
  37970. */
  37971. getClassName(): string;
  37972. /**
  37973. * Defines the buttons associated with the input to handle camera move.
  37974. */
  37975. buttons: number[];
  37976. /**
  37977. * Defines the pointer angular sensibility along the X axis or how fast is
  37978. * the camera rotating.
  37979. */
  37980. angularSensibilityX: number;
  37981. /**
  37982. * Defines the pointer angular sensibility along the Y axis or how fast is
  37983. * the camera rotating.
  37984. */
  37985. angularSensibilityY: number;
  37986. /**
  37987. * Defines the pointer pinch precision or how fast is the camera zooming.
  37988. */
  37989. pinchPrecision: number;
  37990. /**
  37991. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37992. * from 0.
  37993. * It defines the percentage of current camera.radius to use as delta when
  37994. * pinch zoom is used.
  37995. */
  37996. pinchDeltaPercentage: number;
  37997. /**
  37998. * Defines the pointer panning sensibility or how fast is the camera moving.
  37999. */
  38000. panningSensibility: number;
  38001. /**
  38002. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38003. */
  38004. multiTouchPanning: boolean;
  38005. /**
  38006. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38007. * zoom (pinch) through multitouch.
  38008. */
  38009. multiTouchPanAndZoom: boolean;
  38010. /**
  38011. * Revers pinch action direction.
  38012. */
  38013. pinchInwards: boolean;
  38014. private _isPanClick;
  38015. private _twoFingerActivityCount;
  38016. private _isPinching;
  38017. /**
  38018. * Called on pointer POINTERMOVE event if only a single touch is active.
  38019. */
  38020. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38021. /**
  38022. * Called on pointer POINTERDOUBLETAP event.
  38023. */
  38024. protected onDoubleTap(type: string): void;
  38025. /**
  38026. * Called on pointer POINTERMOVE event if multiple touches are active.
  38027. */
  38028. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38029. /**
  38030. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38031. * press.
  38032. */
  38033. protected onButtonDown(evt: PointerEvent): void;
  38034. /**
  38035. * Called each time a new POINTERUP event occurs. Ie, for each button
  38036. * release.
  38037. */
  38038. protected onButtonUp(evt: PointerEvent): void;
  38039. /**
  38040. * Called when window becomes inactive.
  38041. */
  38042. protected onLostFocus(): void;
  38043. }
  38044. }
  38045. declare module BABYLON {
  38046. /**
  38047. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38049. */
  38050. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38051. /**
  38052. * Defines the camera the input is attached to.
  38053. */
  38054. camera: ArcRotateCamera;
  38055. /**
  38056. * Defines the list of key codes associated with the up action (increase alpha)
  38057. */
  38058. keysUp: number[];
  38059. /**
  38060. * Defines the list of key codes associated with the down action (decrease alpha)
  38061. */
  38062. keysDown: number[];
  38063. /**
  38064. * Defines the list of key codes associated with the left action (increase beta)
  38065. */
  38066. keysLeft: number[];
  38067. /**
  38068. * Defines the list of key codes associated with the right action (decrease beta)
  38069. */
  38070. keysRight: number[];
  38071. /**
  38072. * Defines the list of key codes associated with the reset action.
  38073. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38074. */
  38075. keysReset: number[];
  38076. /**
  38077. * Defines the panning sensibility of the inputs.
  38078. * (How fast is the camera paning)
  38079. */
  38080. panningSensibility: number;
  38081. /**
  38082. * Defines the zooming sensibility of the inputs.
  38083. * (How fast is the camera zooming)
  38084. */
  38085. zoomingSensibility: number;
  38086. /**
  38087. * Defines wether maintaining the alt key down switch the movement mode from
  38088. * orientation to zoom.
  38089. */
  38090. useAltToZoom: boolean;
  38091. /**
  38092. * Rotation speed of the camera
  38093. */
  38094. angularSpeed: number;
  38095. private _keys;
  38096. private _ctrlPressed;
  38097. private _altPressed;
  38098. private _onCanvasBlurObserver;
  38099. private _onKeyboardObserver;
  38100. private _engine;
  38101. private _scene;
  38102. /**
  38103. * Attach the input controls to a specific dom element to get the input from.
  38104. * @param element Defines the element the controls should be listened from
  38105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38106. */
  38107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38108. /**
  38109. * Detach the current controls from the specified dom element.
  38110. * @param element Defines the element to stop listening the inputs from
  38111. */
  38112. detachControl(element: Nullable<HTMLElement>): void;
  38113. /**
  38114. * Update the current camera state depending on the inputs that have been used this frame.
  38115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38116. */
  38117. checkInputs(): void;
  38118. /**
  38119. * Gets the class name of the current intput.
  38120. * @returns the class name
  38121. */
  38122. getClassName(): string;
  38123. /**
  38124. * Get the friendly name associated with the input class.
  38125. * @returns the input friendly name
  38126. */
  38127. getSimpleName(): string;
  38128. }
  38129. }
  38130. declare module BABYLON {
  38131. /**
  38132. * Manage the mouse wheel inputs to control an arc rotate camera.
  38133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38134. */
  38135. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38136. /**
  38137. * Defines the camera the input is attached to.
  38138. */
  38139. camera: ArcRotateCamera;
  38140. /**
  38141. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38142. */
  38143. wheelPrecision: number;
  38144. /**
  38145. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38146. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38147. */
  38148. wheelDeltaPercentage: number;
  38149. private _wheel;
  38150. private _observer;
  38151. private computeDeltaFromMouseWheelLegacyEvent;
  38152. /**
  38153. * Attach the input controls to a specific dom element to get the input from.
  38154. * @param element Defines the element the controls should be listened from
  38155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38156. */
  38157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38158. /**
  38159. * Detach the current controls from the specified dom element.
  38160. * @param element Defines the element to stop listening the inputs from
  38161. */
  38162. detachControl(element: Nullable<HTMLElement>): void;
  38163. /**
  38164. * Gets the class name of the current intput.
  38165. * @returns the class name
  38166. */
  38167. getClassName(): string;
  38168. /**
  38169. * Get the friendly name associated with the input class.
  38170. * @returns the input friendly name
  38171. */
  38172. getSimpleName(): string;
  38173. }
  38174. }
  38175. declare module BABYLON {
  38176. /**
  38177. * Default Inputs manager for the ArcRotateCamera.
  38178. * It groups all the default supported inputs for ease of use.
  38179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38180. */
  38181. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38182. /**
  38183. * Instantiates a new ArcRotateCameraInputsManager.
  38184. * @param camera Defines the camera the inputs belong to
  38185. */
  38186. constructor(camera: ArcRotateCamera);
  38187. /**
  38188. * Add mouse wheel input support to the input manager.
  38189. * @returns the current input manager
  38190. */
  38191. addMouseWheel(): ArcRotateCameraInputsManager;
  38192. /**
  38193. * Add pointers input support to the input manager.
  38194. * @returns the current input manager
  38195. */
  38196. addPointers(): ArcRotateCameraInputsManager;
  38197. /**
  38198. * Add keyboard input support to the input manager.
  38199. * @returns the current input manager
  38200. */
  38201. addKeyboard(): ArcRotateCameraInputsManager;
  38202. }
  38203. }
  38204. declare module BABYLON {
  38205. /**
  38206. * This represents an orbital type of camera.
  38207. *
  38208. * 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.
  38209. * 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.
  38210. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38211. */
  38212. export class ArcRotateCamera extends TargetCamera {
  38213. /**
  38214. * Defines the rotation angle of the camera along the longitudinal axis.
  38215. */
  38216. alpha: number;
  38217. /**
  38218. * Defines the rotation angle of the camera along the latitudinal axis.
  38219. */
  38220. beta: number;
  38221. /**
  38222. * Defines the radius of the camera from it s target point.
  38223. */
  38224. radius: number;
  38225. protected _target: Vector3;
  38226. protected _targetHost: Nullable<AbstractMesh>;
  38227. /**
  38228. * Defines the target point of the camera.
  38229. * The camera looks towards it form the radius distance.
  38230. */
  38231. get target(): Vector3;
  38232. set target(value: Vector3);
  38233. /**
  38234. * Define the current local position of the camera in the scene
  38235. */
  38236. get position(): Vector3;
  38237. set position(newPosition: Vector3);
  38238. protected _upVector: Vector3;
  38239. protected _upToYMatrix: Matrix;
  38240. protected _YToUpMatrix: Matrix;
  38241. /**
  38242. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38243. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38244. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38245. */
  38246. set upVector(vec: Vector3);
  38247. get upVector(): Vector3;
  38248. /**
  38249. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38250. */
  38251. setMatUp(): void;
  38252. /**
  38253. * Current inertia value on the longitudinal axis.
  38254. * The bigger this number the longer it will take for the camera to stop.
  38255. */
  38256. inertialAlphaOffset: number;
  38257. /**
  38258. * Current inertia value on the latitudinal axis.
  38259. * The bigger this number the longer it will take for the camera to stop.
  38260. */
  38261. inertialBetaOffset: number;
  38262. /**
  38263. * Current inertia value on the radius axis.
  38264. * The bigger this number the longer it will take for the camera to stop.
  38265. */
  38266. inertialRadiusOffset: number;
  38267. /**
  38268. * Minimum allowed angle on the longitudinal axis.
  38269. * This can help limiting how the Camera is able to move in the scene.
  38270. */
  38271. lowerAlphaLimit: Nullable<number>;
  38272. /**
  38273. * Maximum allowed angle on the longitudinal axis.
  38274. * This can help limiting how the Camera is able to move in the scene.
  38275. */
  38276. upperAlphaLimit: Nullable<number>;
  38277. /**
  38278. * Minimum allowed angle on the latitudinal axis.
  38279. * This can help limiting how the Camera is able to move in the scene.
  38280. */
  38281. lowerBetaLimit: number;
  38282. /**
  38283. * Maximum allowed angle on the latitudinal axis.
  38284. * This can help limiting how the Camera is able to move in the scene.
  38285. */
  38286. upperBetaLimit: number;
  38287. /**
  38288. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38289. * This can help limiting how the Camera is able to move in the scene.
  38290. */
  38291. lowerRadiusLimit: Nullable<number>;
  38292. /**
  38293. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38294. * This can help limiting how the Camera is able to move in the scene.
  38295. */
  38296. upperRadiusLimit: Nullable<number>;
  38297. /**
  38298. * Defines the current inertia value used during panning of the camera along the X axis.
  38299. */
  38300. inertialPanningX: number;
  38301. /**
  38302. * Defines the current inertia value used during panning of the camera along the Y axis.
  38303. */
  38304. inertialPanningY: number;
  38305. /**
  38306. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38307. * Basically if your fingers moves away from more than this distance you will be considered
  38308. * in pinch mode.
  38309. */
  38310. pinchToPanMaxDistance: number;
  38311. /**
  38312. * Defines the maximum distance the camera can pan.
  38313. * This could help keeping the cammera always in your scene.
  38314. */
  38315. panningDistanceLimit: Nullable<number>;
  38316. /**
  38317. * Defines the target of the camera before paning.
  38318. */
  38319. panningOriginTarget: Vector3;
  38320. /**
  38321. * Defines the value of the inertia used during panning.
  38322. * 0 would mean stop inertia and one would mean no decelleration at all.
  38323. */
  38324. panningInertia: number;
  38325. /**
  38326. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38327. */
  38328. get angularSensibilityX(): number;
  38329. set angularSensibilityX(value: number);
  38330. /**
  38331. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38332. */
  38333. get angularSensibilityY(): number;
  38334. set angularSensibilityY(value: number);
  38335. /**
  38336. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38337. */
  38338. get pinchPrecision(): number;
  38339. set pinchPrecision(value: number);
  38340. /**
  38341. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38342. * It will be used instead of pinchDeltaPrecision if different from 0.
  38343. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38344. */
  38345. get pinchDeltaPercentage(): number;
  38346. set pinchDeltaPercentage(value: number);
  38347. /**
  38348. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38349. */
  38350. get panningSensibility(): number;
  38351. set panningSensibility(value: number);
  38352. /**
  38353. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38354. */
  38355. get keysUp(): number[];
  38356. set keysUp(value: number[]);
  38357. /**
  38358. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38359. */
  38360. get keysDown(): number[];
  38361. set keysDown(value: number[]);
  38362. /**
  38363. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38364. */
  38365. get keysLeft(): number[];
  38366. set keysLeft(value: number[]);
  38367. /**
  38368. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38369. */
  38370. get keysRight(): number[];
  38371. set keysRight(value: number[]);
  38372. /**
  38373. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38374. */
  38375. get wheelPrecision(): number;
  38376. set wheelPrecision(value: number);
  38377. /**
  38378. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38379. * It will be used instead of pinchDeltaPrecision if different from 0.
  38380. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38381. */
  38382. get wheelDeltaPercentage(): number;
  38383. set wheelDeltaPercentage(value: number);
  38384. /**
  38385. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38386. */
  38387. zoomOnFactor: number;
  38388. /**
  38389. * Defines a screen offset for the camera position.
  38390. */
  38391. targetScreenOffset: Vector2;
  38392. /**
  38393. * Allows the camera to be completely reversed.
  38394. * If false the camera can not arrive upside down.
  38395. */
  38396. allowUpsideDown: boolean;
  38397. /**
  38398. * Define if double tap/click is used to restore the previously saved state of the camera.
  38399. */
  38400. useInputToRestoreState: boolean;
  38401. /** @hidden */
  38402. _viewMatrix: Matrix;
  38403. /** @hidden */
  38404. _useCtrlForPanning: boolean;
  38405. /** @hidden */
  38406. _panningMouseButton: number;
  38407. /**
  38408. * Defines the input associated to the camera.
  38409. */
  38410. inputs: ArcRotateCameraInputsManager;
  38411. /** @hidden */
  38412. _reset: () => void;
  38413. /**
  38414. * Defines the allowed panning axis.
  38415. */
  38416. panningAxis: Vector3;
  38417. protected _localDirection: Vector3;
  38418. protected _transformedDirection: Vector3;
  38419. private _bouncingBehavior;
  38420. /**
  38421. * Gets the bouncing behavior of the camera if it has been enabled.
  38422. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38423. */
  38424. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38425. /**
  38426. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38427. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38428. */
  38429. get useBouncingBehavior(): boolean;
  38430. set useBouncingBehavior(value: boolean);
  38431. private _framingBehavior;
  38432. /**
  38433. * Gets the framing behavior of the camera if it has been enabled.
  38434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38435. */
  38436. get framingBehavior(): Nullable<FramingBehavior>;
  38437. /**
  38438. * Defines if the framing behavior of the camera is enabled on the camera.
  38439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38440. */
  38441. get useFramingBehavior(): boolean;
  38442. set useFramingBehavior(value: boolean);
  38443. private _autoRotationBehavior;
  38444. /**
  38445. * Gets the auto rotation behavior of the camera if it has been enabled.
  38446. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38447. */
  38448. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38449. /**
  38450. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38451. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38452. */
  38453. get useAutoRotationBehavior(): boolean;
  38454. set useAutoRotationBehavior(value: boolean);
  38455. /**
  38456. * Observable triggered when the mesh target has been changed on the camera.
  38457. */
  38458. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38459. /**
  38460. * Event raised when the camera is colliding with a mesh.
  38461. */
  38462. onCollide: (collidedMesh: AbstractMesh) => void;
  38463. /**
  38464. * Defines whether the camera should check collision with the objects oh the scene.
  38465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38466. */
  38467. checkCollisions: boolean;
  38468. /**
  38469. * Defines the collision radius of the camera.
  38470. * This simulates a sphere around the camera.
  38471. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38472. */
  38473. collisionRadius: Vector3;
  38474. protected _collider: Collider;
  38475. protected _previousPosition: Vector3;
  38476. protected _collisionVelocity: Vector3;
  38477. protected _newPosition: Vector3;
  38478. protected _previousAlpha: number;
  38479. protected _previousBeta: number;
  38480. protected _previousRadius: number;
  38481. protected _collisionTriggered: boolean;
  38482. protected _targetBoundingCenter: Nullable<Vector3>;
  38483. private _computationVector;
  38484. /**
  38485. * Instantiates a new ArcRotateCamera in a given scene
  38486. * @param name Defines the name of the camera
  38487. * @param alpha Defines the camera rotation along the logitudinal axis
  38488. * @param beta Defines the camera rotation along the latitudinal axis
  38489. * @param radius Defines the camera distance from its target
  38490. * @param target Defines the camera target
  38491. * @param scene Defines the scene the camera belongs to
  38492. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38493. */
  38494. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38495. /** @hidden */
  38496. _initCache(): void;
  38497. /** @hidden */
  38498. _updateCache(ignoreParentClass?: boolean): void;
  38499. protected _getTargetPosition(): Vector3;
  38500. private _storedAlpha;
  38501. private _storedBeta;
  38502. private _storedRadius;
  38503. private _storedTarget;
  38504. private _storedTargetScreenOffset;
  38505. /**
  38506. * Stores the current state of the camera (alpha, beta, radius and target)
  38507. * @returns the camera itself
  38508. */
  38509. storeState(): Camera;
  38510. /**
  38511. * @hidden
  38512. * Restored camera state. You must call storeState() first
  38513. */
  38514. _restoreStateValues(): boolean;
  38515. /** @hidden */
  38516. _isSynchronizedViewMatrix(): boolean;
  38517. /**
  38518. * Attached controls to the current camera.
  38519. * @param element Defines the element the controls should be listened from
  38520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38521. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38522. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38523. */
  38524. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38525. /**
  38526. * Detach the current controls from the camera.
  38527. * The camera will stop reacting to inputs.
  38528. * @param element Defines the element to stop listening the inputs from
  38529. */
  38530. detachControl(element: HTMLElement): void;
  38531. /** @hidden */
  38532. _checkInputs(): void;
  38533. protected _checkLimits(): void;
  38534. /**
  38535. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38536. */
  38537. rebuildAnglesAndRadius(): void;
  38538. /**
  38539. * Use a position to define the current camera related information like alpha, beta and radius
  38540. * @param position Defines the position to set the camera at
  38541. */
  38542. setPosition(position: Vector3): void;
  38543. /**
  38544. * Defines the target the camera should look at.
  38545. * This will automatically adapt alpha beta and radius to fit within the new target.
  38546. * @param target Defines the new target as a Vector or a mesh
  38547. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38548. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38549. */
  38550. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38551. /** @hidden */
  38552. _getViewMatrix(): Matrix;
  38553. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38554. /**
  38555. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38556. * @param meshes Defines the mesh to zoom on
  38557. * @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)
  38558. */
  38559. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38560. /**
  38561. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38562. * The target will be changed but the radius
  38563. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38564. * @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)
  38565. */
  38566. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38567. min: Vector3;
  38568. max: Vector3;
  38569. distance: number;
  38570. }, doNotUpdateMaxZ?: boolean): void;
  38571. /**
  38572. * @override
  38573. * Override Camera.createRigCamera
  38574. */
  38575. createRigCamera(name: string, cameraIndex: number): Camera;
  38576. /**
  38577. * @hidden
  38578. * @override
  38579. * Override Camera._updateRigCameras
  38580. */
  38581. _updateRigCameras(): void;
  38582. /**
  38583. * Destroy the camera and release the current resources hold by it.
  38584. */
  38585. dispose(): void;
  38586. /**
  38587. * Gets the current object class name.
  38588. * @return the class name
  38589. */
  38590. getClassName(): string;
  38591. }
  38592. }
  38593. declare module BABYLON {
  38594. /**
  38595. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38596. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38597. */
  38598. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38599. /**
  38600. * Gets the name of the behavior.
  38601. */
  38602. get name(): string;
  38603. private _zoomStopsAnimation;
  38604. private _idleRotationSpeed;
  38605. private _idleRotationWaitTime;
  38606. private _idleRotationSpinupTime;
  38607. /**
  38608. * Sets the flag that indicates if user zooming should stop animation.
  38609. */
  38610. set zoomStopsAnimation(flag: boolean);
  38611. /**
  38612. * Gets the flag that indicates if user zooming should stop animation.
  38613. */
  38614. get zoomStopsAnimation(): boolean;
  38615. /**
  38616. * Sets the default speed at which the camera rotates around the model.
  38617. */
  38618. set idleRotationSpeed(speed: number);
  38619. /**
  38620. * Gets the default speed at which the camera rotates around the model.
  38621. */
  38622. get idleRotationSpeed(): number;
  38623. /**
  38624. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38625. */
  38626. set idleRotationWaitTime(time: number);
  38627. /**
  38628. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38629. */
  38630. get idleRotationWaitTime(): number;
  38631. /**
  38632. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38633. */
  38634. set idleRotationSpinupTime(time: number);
  38635. /**
  38636. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38637. */
  38638. get idleRotationSpinupTime(): number;
  38639. /**
  38640. * Gets a value indicating if the camera is currently rotating because of this behavior
  38641. */
  38642. get rotationInProgress(): boolean;
  38643. private _onPrePointerObservableObserver;
  38644. private _onAfterCheckInputsObserver;
  38645. private _attachedCamera;
  38646. private _isPointerDown;
  38647. private _lastFrameTime;
  38648. private _lastInteractionTime;
  38649. private _cameraRotationSpeed;
  38650. /**
  38651. * Initializes the behavior.
  38652. */
  38653. init(): void;
  38654. /**
  38655. * Attaches the behavior to its arc rotate camera.
  38656. * @param camera Defines the camera to attach the behavior to
  38657. */
  38658. attach(camera: ArcRotateCamera): void;
  38659. /**
  38660. * Detaches the behavior from its current arc rotate camera.
  38661. */
  38662. detach(): void;
  38663. /**
  38664. * Returns true if user is scrolling.
  38665. * @return true if user is scrolling.
  38666. */
  38667. private _userIsZooming;
  38668. private _lastFrameRadius;
  38669. private _shouldAnimationStopForInteraction;
  38670. /**
  38671. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38672. */
  38673. private _applyUserInteraction;
  38674. private _userIsMoving;
  38675. }
  38676. }
  38677. declare module BABYLON {
  38678. /**
  38679. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38680. */
  38681. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38682. private ui;
  38683. /**
  38684. * The name of the behavior
  38685. */
  38686. name: string;
  38687. /**
  38688. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38689. */
  38690. distanceAwayFromFace: number;
  38691. /**
  38692. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38693. */
  38694. distanceAwayFromBottomOfFace: number;
  38695. private _faceVectors;
  38696. private _target;
  38697. private _scene;
  38698. private _onRenderObserver;
  38699. private _tmpMatrix;
  38700. private _tmpVector;
  38701. /**
  38702. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38703. * @param ui The transform node that should be attched to the mesh
  38704. */
  38705. constructor(ui: TransformNode);
  38706. /**
  38707. * Initializes the behavior
  38708. */
  38709. init(): void;
  38710. private _closestFace;
  38711. private _zeroVector;
  38712. private _lookAtTmpMatrix;
  38713. private _lookAtToRef;
  38714. /**
  38715. * Attaches the AttachToBoxBehavior to the passed in mesh
  38716. * @param target The mesh that the specified node will be attached to
  38717. */
  38718. attach(target: Mesh): void;
  38719. /**
  38720. * Detaches the behavior from the mesh
  38721. */
  38722. detach(): void;
  38723. }
  38724. }
  38725. declare module BABYLON {
  38726. /**
  38727. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38728. */
  38729. export class FadeInOutBehavior implements Behavior<Mesh> {
  38730. /**
  38731. * Time in milliseconds to delay before fading in (Default: 0)
  38732. */
  38733. delay: number;
  38734. /**
  38735. * Time in milliseconds for the mesh to fade in (Default: 300)
  38736. */
  38737. fadeInTime: number;
  38738. private _millisecondsPerFrame;
  38739. private _hovered;
  38740. private _hoverValue;
  38741. private _ownerNode;
  38742. /**
  38743. * Instatiates the FadeInOutBehavior
  38744. */
  38745. constructor();
  38746. /**
  38747. * The name of the behavior
  38748. */
  38749. get name(): string;
  38750. /**
  38751. * Initializes the behavior
  38752. */
  38753. init(): void;
  38754. /**
  38755. * Attaches the fade behavior on the passed in mesh
  38756. * @param ownerNode The mesh that will be faded in/out once attached
  38757. */
  38758. attach(ownerNode: Mesh): void;
  38759. /**
  38760. * Detaches the behavior from the mesh
  38761. */
  38762. detach(): void;
  38763. /**
  38764. * Triggers the mesh to begin fading in or out
  38765. * @param value if the object should fade in or out (true to fade in)
  38766. */
  38767. fadeIn(value: boolean): void;
  38768. private _update;
  38769. private _setAllVisibility;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /**
  38774. * Class containing a set of static utilities functions for managing Pivots
  38775. * @hidden
  38776. */
  38777. export class PivotTools {
  38778. private static _PivotCached;
  38779. private static _OldPivotPoint;
  38780. private static _PivotTranslation;
  38781. private static _PivotTmpVector;
  38782. /** @hidden */
  38783. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38784. /** @hidden */
  38785. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38786. }
  38787. }
  38788. declare module BABYLON {
  38789. /**
  38790. * Class containing static functions to help procedurally build meshes
  38791. */
  38792. export class PlaneBuilder {
  38793. /**
  38794. * Creates a plane mesh
  38795. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38796. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38797. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38799. * * 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
  38800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38801. * @param name defines the name of the mesh
  38802. * @param options defines the options used to create the mesh
  38803. * @param scene defines the hosting scene
  38804. * @returns the plane mesh
  38805. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38806. */
  38807. static CreatePlane(name: string, options: {
  38808. size?: number;
  38809. width?: number;
  38810. height?: number;
  38811. sideOrientation?: number;
  38812. frontUVs?: Vector4;
  38813. backUVs?: Vector4;
  38814. updatable?: boolean;
  38815. sourcePlane?: Plane;
  38816. }, scene?: Nullable<Scene>): Mesh;
  38817. }
  38818. }
  38819. declare module BABYLON {
  38820. /**
  38821. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38822. */
  38823. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38824. private static _AnyMouseID;
  38825. /**
  38826. * Abstract mesh the behavior is set on
  38827. */
  38828. attachedNode: AbstractMesh;
  38829. private _dragPlane;
  38830. private _scene;
  38831. private _pointerObserver;
  38832. private _beforeRenderObserver;
  38833. private static _planeScene;
  38834. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38835. /**
  38836. * 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)
  38837. */
  38838. maxDragAngle: number;
  38839. /**
  38840. * @hidden
  38841. */
  38842. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38843. /**
  38844. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38845. */
  38846. currentDraggingPointerID: number;
  38847. /**
  38848. * The last position where the pointer hit the drag plane in world space
  38849. */
  38850. lastDragPosition: Vector3;
  38851. /**
  38852. * If the behavior is currently in a dragging state
  38853. */
  38854. dragging: boolean;
  38855. /**
  38856. * 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)
  38857. */
  38858. dragDeltaRatio: number;
  38859. /**
  38860. * If the drag plane orientation should be updated during the dragging (Default: true)
  38861. */
  38862. updateDragPlane: boolean;
  38863. private _debugMode;
  38864. private _moving;
  38865. /**
  38866. * Fires each time the attached mesh is dragged with the pointer
  38867. * * delta between last drag position and current drag position in world space
  38868. * * dragDistance along the drag axis
  38869. * * dragPlaneNormal normal of the current drag plane used during the drag
  38870. * * dragPlanePoint in world space where the drag intersects the drag plane
  38871. */
  38872. onDragObservable: Observable<{
  38873. delta: Vector3;
  38874. dragPlanePoint: Vector3;
  38875. dragPlaneNormal: Vector3;
  38876. dragDistance: number;
  38877. pointerId: number;
  38878. }>;
  38879. /**
  38880. * Fires each time a drag begins (eg. mouse down on mesh)
  38881. */
  38882. onDragStartObservable: Observable<{
  38883. dragPlanePoint: Vector3;
  38884. pointerId: number;
  38885. }>;
  38886. /**
  38887. * Fires each time a drag ends (eg. mouse release after drag)
  38888. */
  38889. onDragEndObservable: Observable<{
  38890. dragPlanePoint: Vector3;
  38891. pointerId: number;
  38892. }>;
  38893. /**
  38894. * If the attached mesh should be moved when dragged
  38895. */
  38896. moveAttached: boolean;
  38897. /**
  38898. * If the drag behavior will react to drag events (Default: true)
  38899. */
  38900. enabled: boolean;
  38901. /**
  38902. * If pointer events should start and release the drag (Default: true)
  38903. */
  38904. startAndReleaseDragOnPointerEvents: boolean;
  38905. /**
  38906. * If camera controls should be detached during the drag
  38907. */
  38908. detachCameraControls: boolean;
  38909. /**
  38910. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38911. */
  38912. useObjectOrienationForDragging: boolean;
  38913. private _options;
  38914. /**
  38915. * Gets the options used by the behavior
  38916. */
  38917. get options(): {
  38918. dragAxis?: Vector3;
  38919. dragPlaneNormal?: Vector3;
  38920. };
  38921. /**
  38922. * Sets the options used by the behavior
  38923. */
  38924. set options(options: {
  38925. dragAxis?: Vector3;
  38926. dragPlaneNormal?: Vector3;
  38927. });
  38928. /**
  38929. * Creates a pointer drag behavior that can be attached to a mesh
  38930. * @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)
  38931. */
  38932. constructor(options?: {
  38933. dragAxis?: Vector3;
  38934. dragPlaneNormal?: Vector3;
  38935. });
  38936. /**
  38937. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38938. */
  38939. validateDrag: (targetPosition: Vector3) => boolean;
  38940. /**
  38941. * The name of the behavior
  38942. */
  38943. get name(): string;
  38944. /**
  38945. * Initializes the behavior
  38946. */
  38947. init(): void;
  38948. private _tmpVector;
  38949. private _alternatePickedPoint;
  38950. private _worldDragAxis;
  38951. private _targetPosition;
  38952. private _attachedElement;
  38953. /**
  38954. * Attaches the drag behavior the passed in mesh
  38955. * @param ownerNode The mesh that will be dragged around once attached
  38956. * @param predicate Predicate to use for pick filtering
  38957. */
  38958. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38959. /**
  38960. * Force relase the drag action by code.
  38961. */
  38962. releaseDrag(): void;
  38963. private _startDragRay;
  38964. private _lastPointerRay;
  38965. /**
  38966. * Simulates the start of a pointer drag event on the behavior
  38967. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38968. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38969. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38970. */
  38971. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38972. private _startDrag;
  38973. private _dragDelta;
  38974. private _moveDrag;
  38975. private _pickWithRayOnDragPlane;
  38976. private _pointA;
  38977. private _pointB;
  38978. private _pointC;
  38979. private _lineA;
  38980. private _lineB;
  38981. private _localAxis;
  38982. private _lookAt;
  38983. private _updateDragPlanePosition;
  38984. /**
  38985. * Detaches the behavior from the mesh
  38986. */
  38987. detach(): void;
  38988. }
  38989. }
  38990. declare module BABYLON {
  38991. /**
  38992. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38993. */
  38994. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38995. private _dragBehaviorA;
  38996. private _dragBehaviorB;
  38997. private _startDistance;
  38998. private _initialScale;
  38999. private _targetScale;
  39000. private _ownerNode;
  39001. private _sceneRenderObserver;
  39002. /**
  39003. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39004. */
  39005. constructor();
  39006. /**
  39007. * The name of the behavior
  39008. */
  39009. get name(): string;
  39010. /**
  39011. * Initializes the behavior
  39012. */
  39013. init(): void;
  39014. private _getCurrentDistance;
  39015. /**
  39016. * Attaches the scale behavior the passed in mesh
  39017. * @param ownerNode The mesh that will be scaled around once attached
  39018. */
  39019. attach(ownerNode: Mesh): void;
  39020. /**
  39021. * Detaches the behavior from the mesh
  39022. */
  39023. detach(): void;
  39024. }
  39025. }
  39026. declare module BABYLON {
  39027. /**
  39028. * 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
  39029. */
  39030. export class SixDofDragBehavior implements Behavior<Mesh> {
  39031. private static _virtualScene;
  39032. private _ownerNode;
  39033. private _sceneRenderObserver;
  39034. private _scene;
  39035. private _targetPosition;
  39036. private _virtualOriginMesh;
  39037. private _virtualDragMesh;
  39038. private _pointerObserver;
  39039. private _moving;
  39040. private _startingOrientation;
  39041. /**
  39042. * 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)
  39043. */
  39044. private zDragFactor;
  39045. /**
  39046. * If the object should rotate to face the drag origin
  39047. */
  39048. rotateDraggedObject: boolean;
  39049. /**
  39050. * If the behavior is currently in a dragging state
  39051. */
  39052. dragging: boolean;
  39053. /**
  39054. * 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)
  39055. */
  39056. dragDeltaRatio: number;
  39057. /**
  39058. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39059. */
  39060. currentDraggingPointerID: number;
  39061. /**
  39062. * If camera controls should be detached during the drag
  39063. */
  39064. detachCameraControls: boolean;
  39065. /**
  39066. * Fires each time a drag starts
  39067. */
  39068. onDragStartObservable: Observable<{}>;
  39069. /**
  39070. * Fires each time a drag ends (eg. mouse release after drag)
  39071. */
  39072. onDragEndObservable: Observable<{}>;
  39073. /**
  39074. * 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
  39075. */
  39076. constructor();
  39077. /**
  39078. * The name of the behavior
  39079. */
  39080. get name(): string;
  39081. /**
  39082. * Initializes the behavior
  39083. */
  39084. init(): void;
  39085. /**
  39086. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39087. */
  39088. private get _pointerCamera();
  39089. /**
  39090. * Attaches the scale behavior the passed in mesh
  39091. * @param ownerNode The mesh that will be scaled around once attached
  39092. */
  39093. attach(ownerNode: Mesh): void;
  39094. /**
  39095. * Detaches the behavior from the mesh
  39096. */
  39097. detach(): void;
  39098. }
  39099. }
  39100. declare module BABYLON {
  39101. /**
  39102. * Class used to apply inverse kinematics to bones
  39103. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39104. */
  39105. export class BoneIKController {
  39106. private static _tmpVecs;
  39107. private static _tmpQuat;
  39108. private static _tmpMats;
  39109. /**
  39110. * Gets or sets the target mesh
  39111. */
  39112. targetMesh: AbstractMesh;
  39113. /** Gets or sets the mesh used as pole */
  39114. poleTargetMesh: AbstractMesh;
  39115. /**
  39116. * Gets or sets the bone used as pole
  39117. */
  39118. poleTargetBone: Nullable<Bone>;
  39119. /**
  39120. * Gets or sets the target position
  39121. */
  39122. targetPosition: Vector3;
  39123. /**
  39124. * Gets or sets the pole target position
  39125. */
  39126. poleTargetPosition: Vector3;
  39127. /**
  39128. * Gets or sets the pole target local offset
  39129. */
  39130. poleTargetLocalOffset: Vector3;
  39131. /**
  39132. * Gets or sets the pole angle
  39133. */
  39134. poleAngle: number;
  39135. /**
  39136. * Gets or sets the mesh associated with the controller
  39137. */
  39138. mesh: AbstractMesh;
  39139. /**
  39140. * 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)
  39141. */
  39142. slerpAmount: number;
  39143. private _bone1Quat;
  39144. private _bone1Mat;
  39145. private _bone2Ang;
  39146. private _bone1;
  39147. private _bone2;
  39148. private _bone1Length;
  39149. private _bone2Length;
  39150. private _maxAngle;
  39151. private _maxReach;
  39152. private _rightHandedSystem;
  39153. private _bendAxis;
  39154. private _slerping;
  39155. private _adjustRoll;
  39156. /**
  39157. * Gets or sets maximum allowed angle
  39158. */
  39159. get maxAngle(): number;
  39160. set maxAngle(value: number);
  39161. /**
  39162. * Creates a new BoneIKController
  39163. * @param mesh defines the mesh to control
  39164. * @param bone defines the bone to control
  39165. * @param options defines options to set up the controller
  39166. */
  39167. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39168. targetMesh?: AbstractMesh;
  39169. poleTargetMesh?: AbstractMesh;
  39170. poleTargetBone?: Bone;
  39171. poleTargetLocalOffset?: Vector3;
  39172. poleAngle?: number;
  39173. bendAxis?: Vector3;
  39174. maxAngle?: number;
  39175. slerpAmount?: number;
  39176. });
  39177. private _setMaxAngle;
  39178. /**
  39179. * Force the controller to update the bones
  39180. */
  39181. update(): void;
  39182. }
  39183. }
  39184. declare module BABYLON {
  39185. /**
  39186. * Class used to make a bone look toward a point in space
  39187. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39188. */
  39189. export class BoneLookController {
  39190. private static _tmpVecs;
  39191. private static _tmpQuat;
  39192. private static _tmpMats;
  39193. /**
  39194. * The target Vector3 that the bone will look at
  39195. */
  39196. target: Vector3;
  39197. /**
  39198. * The mesh that the bone is attached to
  39199. */
  39200. mesh: AbstractMesh;
  39201. /**
  39202. * The bone that will be looking to the target
  39203. */
  39204. bone: Bone;
  39205. /**
  39206. * The up axis of the coordinate system that is used when the bone is rotated
  39207. */
  39208. upAxis: Vector3;
  39209. /**
  39210. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39211. */
  39212. upAxisSpace: Space;
  39213. /**
  39214. * Used to make an adjustment to the yaw of the bone
  39215. */
  39216. adjustYaw: number;
  39217. /**
  39218. * Used to make an adjustment to the pitch of the bone
  39219. */
  39220. adjustPitch: number;
  39221. /**
  39222. * Used to make an adjustment to the roll of the bone
  39223. */
  39224. adjustRoll: number;
  39225. /**
  39226. * 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)
  39227. */
  39228. slerpAmount: number;
  39229. private _minYaw;
  39230. private _maxYaw;
  39231. private _minPitch;
  39232. private _maxPitch;
  39233. private _minYawSin;
  39234. private _minYawCos;
  39235. private _maxYawSin;
  39236. private _maxYawCos;
  39237. private _midYawConstraint;
  39238. private _minPitchTan;
  39239. private _maxPitchTan;
  39240. private _boneQuat;
  39241. private _slerping;
  39242. private _transformYawPitch;
  39243. private _transformYawPitchInv;
  39244. private _firstFrameSkipped;
  39245. private _yawRange;
  39246. private _fowardAxis;
  39247. /**
  39248. * Gets or sets the minimum yaw angle that the bone can look to
  39249. */
  39250. get minYaw(): number;
  39251. set minYaw(value: number);
  39252. /**
  39253. * Gets or sets the maximum yaw angle that the bone can look to
  39254. */
  39255. get maxYaw(): number;
  39256. set maxYaw(value: number);
  39257. /**
  39258. * Gets or sets the minimum pitch angle that the bone can look to
  39259. */
  39260. get minPitch(): number;
  39261. set minPitch(value: number);
  39262. /**
  39263. * Gets or sets the maximum pitch angle that the bone can look to
  39264. */
  39265. get maxPitch(): number;
  39266. set maxPitch(value: number);
  39267. /**
  39268. * Create a BoneLookController
  39269. * @param mesh the mesh that the bone belongs to
  39270. * @param bone the bone that will be looking to the target
  39271. * @param target the target Vector3 to look at
  39272. * @param options optional settings:
  39273. * * maxYaw: the maximum angle the bone will yaw to
  39274. * * minYaw: the minimum angle the bone will yaw to
  39275. * * maxPitch: the maximum angle the bone will pitch to
  39276. * * minPitch: the minimum angle the bone will yaw to
  39277. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39278. * * upAxis: the up axis of the coordinate system
  39279. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39280. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39281. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39282. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39283. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39284. * * adjustRoll: used to make an adjustment to the roll of the bone
  39285. **/
  39286. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39287. maxYaw?: number;
  39288. minYaw?: number;
  39289. maxPitch?: number;
  39290. minPitch?: number;
  39291. slerpAmount?: number;
  39292. upAxis?: Vector3;
  39293. upAxisSpace?: Space;
  39294. yawAxis?: Vector3;
  39295. pitchAxis?: Vector3;
  39296. adjustYaw?: number;
  39297. adjustPitch?: number;
  39298. adjustRoll?: number;
  39299. });
  39300. /**
  39301. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39302. */
  39303. update(): void;
  39304. private _getAngleDiff;
  39305. private _getAngleBetween;
  39306. private _isAngleBetween;
  39307. }
  39308. }
  39309. declare module BABYLON {
  39310. /**
  39311. * Manage the gamepad inputs to control an arc rotate camera.
  39312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39313. */
  39314. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39315. /**
  39316. * Defines the camera the input is attached to.
  39317. */
  39318. camera: ArcRotateCamera;
  39319. /**
  39320. * Defines the gamepad the input is gathering event from.
  39321. */
  39322. gamepad: Nullable<Gamepad>;
  39323. /**
  39324. * Defines the gamepad rotation sensiblity.
  39325. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39326. */
  39327. gamepadRotationSensibility: number;
  39328. /**
  39329. * Defines the gamepad move sensiblity.
  39330. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39331. */
  39332. gamepadMoveSensibility: number;
  39333. private _yAxisScale;
  39334. /**
  39335. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39336. */
  39337. get invertYAxis(): boolean;
  39338. set invertYAxis(value: boolean);
  39339. private _onGamepadConnectedObserver;
  39340. private _onGamepadDisconnectedObserver;
  39341. /**
  39342. * Attach the input controls to a specific dom element to get the input from.
  39343. * @param element Defines the element the controls should be listened from
  39344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39345. */
  39346. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39347. /**
  39348. * Detach the current controls from the specified dom element.
  39349. * @param element Defines the element to stop listening the inputs from
  39350. */
  39351. detachControl(element: Nullable<HTMLElement>): void;
  39352. /**
  39353. * Update the current camera state depending on the inputs that have been used this frame.
  39354. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39355. */
  39356. checkInputs(): void;
  39357. /**
  39358. * Gets the class name of the current intput.
  39359. * @returns the class name
  39360. */
  39361. getClassName(): string;
  39362. /**
  39363. * Get the friendly name associated with the input class.
  39364. * @returns the input friendly name
  39365. */
  39366. getSimpleName(): string;
  39367. }
  39368. }
  39369. declare module BABYLON {
  39370. interface ArcRotateCameraInputsManager {
  39371. /**
  39372. * Add orientation input support to the input manager.
  39373. * @returns the current input manager
  39374. */
  39375. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39376. }
  39377. /**
  39378. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39379. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39380. */
  39381. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39382. /**
  39383. * Defines the camera the input is attached to.
  39384. */
  39385. camera: ArcRotateCamera;
  39386. /**
  39387. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39388. */
  39389. alphaCorrection: number;
  39390. /**
  39391. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39392. */
  39393. gammaCorrection: number;
  39394. private _alpha;
  39395. private _gamma;
  39396. private _dirty;
  39397. private _deviceOrientationHandler;
  39398. /**
  39399. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39400. */
  39401. constructor();
  39402. /**
  39403. * Attach the input controls to a specific dom element to get the input from.
  39404. * @param element Defines the element the controls should be listened from
  39405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39406. */
  39407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39408. /** @hidden */
  39409. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39410. /**
  39411. * Update the current camera state depending on the inputs that have been used this frame.
  39412. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39413. */
  39414. checkInputs(): void;
  39415. /**
  39416. * Detach the current controls from the specified dom element.
  39417. * @param element Defines the element to stop listening the inputs from
  39418. */
  39419. detachControl(element: Nullable<HTMLElement>): void;
  39420. /**
  39421. * Gets the class name of the current intput.
  39422. * @returns the class name
  39423. */
  39424. getClassName(): string;
  39425. /**
  39426. * Get the friendly name associated with the input class.
  39427. * @returns the input friendly name
  39428. */
  39429. getSimpleName(): string;
  39430. }
  39431. }
  39432. declare module BABYLON {
  39433. /**
  39434. * Listen to mouse events to control the camera.
  39435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39436. */
  39437. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39438. /**
  39439. * Defines the camera the input is attached to.
  39440. */
  39441. camera: FlyCamera;
  39442. /**
  39443. * Defines if touch is enabled. (Default is true.)
  39444. */
  39445. touchEnabled: boolean;
  39446. /**
  39447. * Defines the buttons associated with the input to handle camera rotation.
  39448. */
  39449. buttons: number[];
  39450. /**
  39451. * Assign buttons for Yaw control.
  39452. */
  39453. buttonsYaw: number[];
  39454. /**
  39455. * Assign buttons for Pitch control.
  39456. */
  39457. buttonsPitch: number[];
  39458. /**
  39459. * Assign buttons for Roll control.
  39460. */
  39461. buttonsRoll: number[];
  39462. /**
  39463. * Detect if any button is being pressed while mouse is moved.
  39464. * -1 = Mouse locked.
  39465. * 0 = Left button.
  39466. * 1 = Middle Button.
  39467. * 2 = Right Button.
  39468. */
  39469. activeButton: number;
  39470. /**
  39471. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39472. * Higher values reduce its sensitivity.
  39473. */
  39474. angularSensibility: number;
  39475. private _mousemoveCallback;
  39476. private _observer;
  39477. private _rollObserver;
  39478. private previousPosition;
  39479. private noPreventDefault;
  39480. private element;
  39481. /**
  39482. * Listen to mouse events to control the camera.
  39483. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39485. */
  39486. constructor(touchEnabled?: boolean);
  39487. /**
  39488. * Attach the mouse control to the HTML DOM element.
  39489. * @param element Defines the element that listens to the input events.
  39490. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39491. */
  39492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39493. /**
  39494. * Detach the current controls from the specified dom element.
  39495. * @param element Defines the element to stop listening the inputs from
  39496. */
  39497. detachControl(element: Nullable<HTMLElement>): void;
  39498. /**
  39499. * Gets the class name of the current input.
  39500. * @returns the class name.
  39501. */
  39502. getClassName(): string;
  39503. /**
  39504. * Get the friendly name associated with the input class.
  39505. * @returns the input's friendly name.
  39506. */
  39507. getSimpleName(): string;
  39508. private _pointerInput;
  39509. private _onMouseMove;
  39510. /**
  39511. * Rotate camera by mouse offset.
  39512. */
  39513. private rotateCamera;
  39514. }
  39515. }
  39516. declare module BABYLON {
  39517. /**
  39518. * Default Inputs manager for the FlyCamera.
  39519. * It groups all the default supported inputs for ease of use.
  39520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39521. */
  39522. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39523. /**
  39524. * Instantiates a new FlyCameraInputsManager.
  39525. * @param camera Defines the camera the inputs belong to.
  39526. */
  39527. constructor(camera: FlyCamera);
  39528. /**
  39529. * Add keyboard input support to the input manager.
  39530. * @returns the new FlyCameraKeyboardMoveInput().
  39531. */
  39532. addKeyboard(): FlyCameraInputsManager;
  39533. /**
  39534. * Add mouse input support to the input manager.
  39535. * @param touchEnabled Enable touch screen support.
  39536. * @returns the new FlyCameraMouseInput().
  39537. */
  39538. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39539. }
  39540. }
  39541. declare module BABYLON {
  39542. /**
  39543. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39544. * such as in a 3D Space Shooter or a Flight Simulator.
  39545. */
  39546. export class FlyCamera extends TargetCamera {
  39547. /**
  39548. * Define the collision ellipsoid of the camera.
  39549. * This is helpful for simulating a camera body, like a player's body.
  39550. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39551. */
  39552. ellipsoid: Vector3;
  39553. /**
  39554. * Define an offset for the position of the ellipsoid around the camera.
  39555. * This can be helpful if the camera is attached away from the player's body center,
  39556. * such as at its head.
  39557. */
  39558. ellipsoidOffset: Vector3;
  39559. /**
  39560. * Enable or disable collisions of the camera with the rest of the scene objects.
  39561. */
  39562. checkCollisions: boolean;
  39563. /**
  39564. * Enable or disable gravity on the camera.
  39565. */
  39566. applyGravity: boolean;
  39567. /**
  39568. * Define the current direction the camera is moving to.
  39569. */
  39570. cameraDirection: Vector3;
  39571. /**
  39572. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39573. * This overrides and empties cameraRotation.
  39574. */
  39575. rotationQuaternion: Quaternion;
  39576. /**
  39577. * Track Roll to maintain the wanted Rolling when looking around.
  39578. */
  39579. _trackRoll: number;
  39580. /**
  39581. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39582. */
  39583. rollCorrect: number;
  39584. /**
  39585. * Mimic a banked turn, Rolling the camera when Yawing.
  39586. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39587. */
  39588. bankedTurn: boolean;
  39589. /**
  39590. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39591. */
  39592. bankedTurnLimit: number;
  39593. /**
  39594. * Value of 0 disables the banked Roll.
  39595. * Value of 1 is equal to the Yaw angle in radians.
  39596. */
  39597. bankedTurnMultiplier: number;
  39598. /**
  39599. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39600. */
  39601. inputs: FlyCameraInputsManager;
  39602. /**
  39603. * Gets the input sensibility for mouse input.
  39604. * Higher values reduce sensitivity.
  39605. */
  39606. get angularSensibility(): number;
  39607. /**
  39608. * Sets the input sensibility for a mouse input.
  39609. * Higher values reduce sensitivity.
  39610. */
  39611. set angularSensibility(value: number);
  39612. /**
  39613. * Get the keys for camera movement forward.
  39614. */
  39615. get keysForward(): number[];
  39616. /**
  39617. * Set the keys for camera movement forward.
  39618. */
  39619. set keysForward(value: number[]);
  39620. /**
  39621. * Get the keys for camera movement backward.
  39622. */
  39623. get keysBackward(): number[];
  39624. set keysBackward(value: number[]);
  39625. /**
  39626. * Get the keys for camera movement up.
  39627. */
  39628. get keysUp(): number[];
  39629. /**
  39630. * Set the keys for camera movement up.
  39631. */
  39632. set keysUp(value: number[]);
  39633. /**
  39634. * Get the keys for camera movement down.
  39635. */
  39636. get keysDown(): number[];
  39637. /**
  39638. * Set the keys for camera movement down.
  39639. */
  39640. set keysDown(value: number[]);
  39641. /**
  39642. * Get the keys for camera movement left.
  39643. */
  39644. get keysLeft(): number[];
  39645. /**
  39646. * Set the keys for camera movement left.
  39647. */
  39648. set keysLeft(value: number[]);
  39649. /**
  39650. * Set the keys for camera movement right.
  39651. */
  39652. get keysRight(): number[];
  39653. /**
  39654. * Set the keys for camera movement right.
  39655. */
  39656. set keysRight(value: number[]);
  39657. /**
  39658. * Event raised when the camera collides with a mesh in the scene.
  39659. */
  39660. onCollide: (collidedMesh: AbstractMesh) => void;
  39661. private _collider;
  39662. private _needMoveForGravity;
  39663. private _oldPosition;
  39664. private _diffPosition;
  39665. private _newPosition;
  39666. /** @hidden */
  39667. _localDirection: Vector3;
  39668. /** @hidden */
  39669. _transformedDirection: Vector3;
  39670. /**
  39671. * Instantiates a FlyCamera.
  39672. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39673. * such as in a 3D Space Shooter or a Flight Simulator.
  39674. * @param name Define the name of the camera in the scene.
  39675. * @param position Define the starting position of the camera in the scene.
  39676. * @param scene Define the scene the camera belongs to.
  39677. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39678. */
  39679. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39680. /**
  39681. * Attach a control to the HTML DOM element.
  39682. * @param element Defines the element that listens to the input events.
  39683. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39684. */
  39685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39686. /**
  39687. * Detach a control from the HTML DOM element.
  39688. * The camera will stop reacting to that input.
  39689. * @param element Defines the element that listens to the input events.
  39690. */
  39691. detachControl(element: HTMLElement): void;
  39692. private _collisionMask;
  39693. /**
  39694. * Get the mask that the camera ignores in collision events.
  39695. */
  39696. get collisionMask(): number;
  39697. /**
  39698. * Set the mask that the camera ignores in collision events.
  39699. */
  39700. set collisionMask(mask: number);
  39701. /** @hidden */
  39702. _collideWithWorld(displacement: Vector3): void;
  39703. /** @hidden */
  39704. private _onCollisionPositionChange;
  39705. /** @hidden */
  39706. _checkInputs(): void;
  39707. /** @hidden */
  39708. _decideIfNeedsToMove(): boolean;
  39709. /** @hidden */
  39710. _updatePosition(): void;
  39711. /**
  39712. * Restore the Roll to its target value at the rate specified.
  39713. * @param rate - Higher means slower restoring.
  39714. * @hidden
  39715. */
  39716. restoreRoll(rate: number): void;
  39717. /**
  39718. * Destroy the camera and release the current resources held by it.
  39719. */
  39720. dispose(): void;
  39721. /**
  39722. * Get the current object class name.
  39723. * @returns the class name.
  39724. */
  39725. getClassName(): string;
  39726. }
  39727. }
  39728. declare module BABYLON {
  39729. /**
  39730. * Listen to keyboard events to control the camera.
  39731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39732. */
  39733. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39734. /**
  39735. * Defines the camera the input is attached to.
  39736. */
  39737. camera: FlyCamera;
  39738. /**
  39739. * The list of keyboard keys used to control the forward move of the camera.
  39740. */
  39741. keysForward: number[];
  39742. /**
  39743. * The list of keyboard keys used to control the backward move of the camera.
  39744. */
  39745. keysBackward: number[];
  39746. /**
  39747. * The list of keyboard keys used to control the forward move of the camera.
  39748. */
  39749. keysUp: number[];
  39750. /**
  39751. * The list of keyboard keys used to control the backward move of the camera.
  39752. */
  39753. keysDown: number[];
  39754. /**
  39755. * The list of keyboard keys used to control the right strafe move of the camera.
  39756. */
  39757. keysRight: number[];
  39758. /**
  39759. * The list of keyboard keys used to control the left strafe move of the camera.
  39760. */
  39761. keysLeft: number[];
  39762. private _keys;
  39763. private _onCanvasBlurObserver;
  39764. private _onKeyboardObserver;
  39765. private _engine;
  39766. private _scene;
  39767. /**
  39768. * Attach the input controls to a specific dom element to get the input from.
  39769. * @param element Defines the element the controls should be listened from
  39770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39771. */
  39772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39773. /**
  39774. * Detach the current controls from the specified dom element.
  39775. * @param element Defines the element to stop listening the inputs from
  39776. */
  39777. detachControl(element: Nullable<HTMLElement>): void;
  39778. /**
  39779. * Gets the class name of the current intput.
  39780. * @returns the class name
  39781. */
  39782. getClassName(): string;
  39783. /** @hidden */
  39784. _onLostFocus(e: FocusEvent): void;
  39785. /**
  39786. * Get the friendly name associated with the input class.
  39787. * @returns the input friendly name
  39788. */
  39789. getSimpleName(): string;
  39790. /**
  39791. * Update the current camera state depending on the inputs that have been used this frame.
  39792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39793. */
  39794. checkInputs(): void;
  39795. }
  39796. }
  39797. declare module BABYLON {
  39798. /**
  39799. * Manage the mouse wheel inputs to control a follow camera.
  39800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39801. */
  39802. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39803. /**
  39804. * Defines the camera the input is attached to.
  39805. */
  39806. camera: FollowCamera;
  39807. /**
  39808. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39809. */
  39810. axisControlRadius: boolean;
  39811. /**
  39812. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39813. */
  39814. axisControlHeight: boolean;
  39815. /**
  39816. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39817. */
  39818. axisControlRotation: boolean;
  39819. /**
  39820. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39821. * relation to mouseWheel events.
  39822. */
  39823. wheelPrecision: number;
  39824. /**
  39825. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39826. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39827. */
  39828. wheelDeltaPercentage: number;
  39829. private _wheel;
  39830. private _observer;
  39831. /**
  39832. * Attach the input controls to a specific dom element to get the input from.
  39833. * @param element Defines the element the controls should be listened from
  39834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39835. */
  39836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39837. /**
  39838. * Detach the current controls from the specified dom element.
  39839. * @param element Defines the element to stop listening the inputs from
  39840. */
  39841. detachControl(element: Nullable<HTMLElement>): void;
  39842. /**
  39843. * Gets the class name of the current intput.
  39844. * @returns the class name
  39845. */
  39846. getClassName(): string;
  39847. /**
  39848. * Get the friendly name associated with the input class.
  39849. * @returns the input friendly name
  39850. */
  39851. getSimpleName(): string;
  39852. }
  39853. }
  39854. declare module BABYLON {
  39855. /**
  39856. * Manage the pointers inputs to control an follow camera.
  39857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39858. */
  39859. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39860. /**
  39861. * Defines the camera the input is attached to.
  39862. */
  39863. camera: FollowCamera;
  39864. /**
  39865. * Gets the class name of the current input.
  39866. * @returns the class name
  39867. */
  39868. getClassName(): string;
  39869. /**
  39870. * Defines the pointer angular sensibility along the X axis or how fast is
  39871. * the camera rotating.
  39872. * A negative number will reverse the axis direction.
  39873. */
  39874. angularSensibilityX: number;
  39875. /**
  39876. * Defines the pointer angular sensibility along the Y axis or how fast is
  39877. * the camera rotating.
  39878. * A negative number will reverse the axis direction.
  39879. */
  39880. angularSensibilityY: number;
  39881. /**
  39882. * Defines the pointer pinch precision or how fast is the camera zooming.
  39883. * A negative number will reverse the axis direction.
  39884. */
  39885. pinchPrecision: number;
  39886. /**
  39887. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39888. * from 0.
  39889. * It defines the percentage of current camera.radius to use as delta when
  39890. * pinch zoom is used.
  39891. */
  39892. pinchDeltaPercentage: number;
  39893. /**
  39894. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39895. */
  39896. axisXControlRadius: boolean;
  39897. /**
  39898. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39899. */
  39900. axisXControlHeight: boolean;
  39901. /**
  39902. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39903. */
  39904. axisXControlRotation: boolean;
  39905. /**
  39906. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39907. */
  39908. axisYControlRadius: boolean;
  39909. /**
  39910. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39911. */
  39912. axisYControlHeight: boolean;
  39913. /**
  39914. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39915. */
  39916. axisYControlRotation: boolean;
  39917. /**
  39918. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39919. */
  39920. axisPinchControlRadius: boolean;
  39921. /**
  39922. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39923. */
  39924. axisPinchControlHeight: boolean;
  39925. /**
  39926. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39927. */
  39928. axisPinchControlRotation: boolean;
  39929. /**
  39930. * Log error messages if basic misconfiguration has occurred.
  39931. */
  39932. warningEnable: boolean;
  39933. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39934. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39935. private _warningCounter;
  39936. private _warning;
  39937. }
  39938. }
  39939. declare module BABYLON {
  39940. /**
  39941. * Default Inputs manager for the FollowCamera.
  39942. * It groups all the default supported inputs for ease of use.
  39943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39944. */
  39945. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39946. /**
  39947. * Instantiates a new FollowCameraInputsManager.
  39948. * @param camera Defines the camera the inputs belong to
  39949. */
  39950. constructor(camera: FollowCamera);
  39951. /**
  39952. * Add keyboard input support to the input manager.
  39953. * @returns the current input manager
  39954. */
  39955. addKeyboard(): FollowCameraInputsManager;
  39956. /**
  39957. * Add mouse wheel input support to the input manager.
  39958. * @returns the current input manager
  39959. */
  39960. addMouseWheel(): FollowCameraInputsManager;
  39961. /**
  39962. * Add pointers input support to the input manager.
  39963. * @returns the current input manager
  39964. */
  39965. addPointers(): FollowCameraInputsManager;
  39966. /**
  39967. * Add orientation input support to the input manager.
  39968. * @returns the current input manager
  39969. */
  39970. addVRDeviceOrientation(): FollowCameraInputsManager;
  39971. }
  39972. }
  39973. declare module BABYLON {
  39974. /**
  39975. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39976. * an arc rotate version arcFollowCamera are available.
  39977. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39978. */
  39979. export class FollowCamera extends TargetCamera {
  39980. /**
  39981. * Distance the follow camera should follow an object at
  39982. */
  39983. radius: number;
  39984. /**
  39985. * Minimum allowed distance of the camera to the axis of rotation
  39986. * (The camera can not get closer).
  39987. * This can help limiting how the Camera is able to move in the scene.
  39988. */
  39989. lowerRadiusLimit: Nullable<number>;
  39990. /**
  39991. * Maximum allowed distance of the camera to the axis of rotation
  39992. * (The camera can not get further).
  39993. * This can help limiting how the Camera is able to move in the scene.
  39994. */
  39995. upperRadiusLimit: Nullable<number>;
  39996. /**
  39997. * Define a rotation offset between the camera and the object it follows
  39998. */
  39999. rotationOffset: number;
  40000. /**
  40001. * Minimum allowed angle to camera position relative to target object.
  40002. * This can help limiting how the Camera is able to move in the scene.
  40003. */
  40004. lowerRotationOffsetLimit: Nullable<number>;
  40005. /**
  40006. * Maximum allowed angle to camera position relative to target object.
  40007. * This can help limiting how the Camera is able to move in the scene.
  40008. */
  40009. upperRotationOffsetLimit: Nullable<number>;
  40010. /**
  40011. * Define a height offset between the camera and the object it follows.
  40012. * It can help following an object from the top (like a car chaing a plane)
  40013. */
  40014. heightOffset: number;
  40015. /**
  40016. * Minimum allowed height of camera position relative to target object.
  40017. * This can help limiting how the Camera is able to move in the scene.
  40018. */
  40019. lowerHeightOffsetLimit: Nullable<number>;
  40020. /**
  40021. * Maximum allowed height of camera position relative to target object.
  40022. * This can help limiting how the Camera is able to move in the scene.
  40023. */
  40024. upperHeightOffsetLimit: Nullable<number>;
  40025. /**
  40026. * Define how fast the camera can accelerate to follow it s target.
  40027. */
  40028. cameraAcceleration: number;
  40029. /**
  40030. * Define the speed limit of the camera following an object.
  40031. */
  40032. maxCameraSpeed: number;
  40033. /**
  40034. * Define the target of the camera.
  40035. */
  40036. lockedTarget: Nullable<AbstractMesh>;
  40037. /**
  40038. * Defines the input associated with the camera.
  40039. */
  40040. inputs: FollowCameraInputsManager;
  40041. /**
  40042. * Instantiates the follow camera.
  40043. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40044. * @param name Define the name of the camera in the scene
  40045. * @param position Define the position of the camera
  40046. * @param scene Define the scene the camera belong to
  40047. * @param lockedTarget Define the target of the camera
  40048. */
  40049. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40050. private _follow;
  40051. /**
  40052. * Attached controls to the current camera.
  40053. * @param element Defines the element the controls should be listened from
  40054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40055. */
  40056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40057. /**
  40058. * Detach the current controls from the camera.
  40059. * The camera will stop reacting to inputs.
  40060. * @param element Defines the element to stop listening the inputs from
  40061. */
  40062. detachControl(element: HTMLElement): void;
  40063. /** @hidden */
  40064. _checkInputs(): void;
  40065. private _checkLimits;
  40066. /**
  40067. * Gets the camera class name.
  40068. * @returns the class name
  40069. */
  40070. getClassName(): string;
  40071. }
  40072. /**
  40073. * Arc Rotate version of the follow camera.
  40074. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40075. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40076. */
  40077. export class ArcFollowCamera extends TargetCamera {
  40078. /** The longitudinal angle of the camera */
  40079. alpha: number;
  40080. /** The latitudinal angle of the camera */
  40081. beta: number;
  40082. /** The radius of the camera from its target */
  40083. radius: number;
  40084. /** Define the camera target (the messh it should follow) */
  40085. target: Nullable<AbstractMesh>;
  40086. private _cartesianCoordinates;
  40087. /**
  40088. * Instantiates a new ArcFollowCamera
  40089. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40090. * @param name Define the name of the camera
  40091. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40092. * @param beta Define the rotation angle of the camera around the elevation axis
  40093. * @param radius Define the radius of the camera from its target point
  40094. * @param target Define the target of the camera
  40095. * @param scene Define the scene the camera belongs to
  40096. */
  40097. constructor(name: string,
  40098. /** The longitudinal angle of the camera */
  40099. alpha: number,
  40100. /** The latitudinal angle of the camera */
  40101. beta: number,
  40102. /** The radius of the camera from its target */
  40103. radius: number,
  40104. /** Define the camera target (the messh it should follow) */
  40105. target: Nullable<AbstractMesh>, scene: Scene);
  40106. private _follow;
  40107. /** @hidden */
  40108. _checkInputs(): void;
  40109. /**
  40110. * Returns the class name of the object.
  40111. * It is mostly used internally for serialization purposes.
  40112. */
  40113. getClassName(): string;
  40114. }
  40115. }
  40116. declare module BABYLON {
  40117. /**
  40118. * Manage the keyboard inputs to control the movement of a follow camera.
  40119. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40120. */
  40121. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40122. /**
  40123. * Defines the camera the input is attached to.
  40124. */
  40125. camera: FollowCamera;
  40126. /**
  40127. * Defines the list of key codes associated with the up action (increase heightOffset)
  40128. */
  40129. keysHeightOffsetIncr: number[];
  40130. /**
  40131. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40132. */
  40133. keysHeightOffsetDecr: number[];
  40134. /**
  40135. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40136. */
  40137. keysHeightOffsetModifierAlt: boolean;
  40138. /**
  40139. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40140. */
  40141. keysHeightOffsetModifierCtrl: boolean;
  40142. /**
  40143. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40144. */
  40145. keysHeightOffsetModifierShift: boolean;
  40146. /**
  40147. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40148. */
  40149. keysRotationOffsetIncr: number[];
  40150. /**
  40151. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40152. */
  40153. keysRotationOffsetDecr: number[];
  40154. /**
  40155. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40156. */
  40157. keysRotationOffsetModifierAlt: boolean;
  40158. /**
  40159. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40160. */
  40161. keysRotationOffsetModifierCtrl: boolean;
  40162. /**
  40163. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40164. */
  40165. keysRotationOffsetModifierShift: boolean;
  40166. /**
  40167. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40168. */
  40169. keysRadiusIncr: number[];
  40170. /**
  40171. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40172. */
  40173. keysRadiusDecr: number[];
  40174. /**
  40175. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40176. */
  40177. keysRadiusModifierAlt: boolean;
  40178. /**
  40179. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40180. */
  40181. keysRadiusModifierCtrl: boolean;
  40182. /**
  40183. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40184. */
  40185. keysRadiusModifierShift: boolean;
  40186. /**
  40187. * Defines the rate of change of heightOffset.
  40188. */
  40189. heightSensibility: number;
  40190. /**
  40191. * Defines the rate of change of rotationOffset.
  40192. */
  40193. rotationSensibility: number;
  40194. /**
  40195. * Defines the rate of change of radius.
  40196. */
  40197. radiusSensibility: number;
  40198. private _keys;
  40199. private _ctrlPressed;
  40200. private _altPressed;
  40201. private _shiftPressed;
  40202. private _onCanvasBlurObserver;
  40203. private _onKeyboardObserver;
  40204. private _engine;
  40205. private _scene;
  40206. /**
  40207. * Attach the input controls to a specific dom element to get the input from.
  40208. * @param element Defines the element the controls should be listened from
  40209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40210. */
  40211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40212. /**
  40213. * Detach the current controls from the specified dom element.
  40214. * @param element Defines the element to stop listening the inputs from
  40215. */
  40216. detachControl(element: Nullable<HTMLElement>): void;
  40217. /**
  40218. * Update the current camera state depending on the inputs that have been used this frame.
  40219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40220. */
  40221. checkInputs(): void;
  40222. /**
  40223. * Gets the class name of the current input.
  40224. * @returns the class name
  40225. */
  40226. getClassName(): string;
  40227. /**
  40228. * Get the friendly name associated with the input class.
  40229. * @returns the input friendly name
  40230. */
  40231. getSimpleName(): string;
  40232. /**
  40233. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40234. * allow modification of the heightOffset value.
  40235. */
  40236. private _modifierHeightOffset;
  40237. /**
  40238. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40239. * allow modification of the rotationOffset value.
  40240. */
  40241. private _modifierRotationOffset;
  40242. /**
  40243. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40244. * allow modification of the radius value.
  40245. */
  40246. private _modifierRadius;
  40247. }
  40248. }
  40249. declare module BABYLON {
  40250. interface FreeCameraInputsManager {
  40251. /**
  40252. * @hidden
  40253. */
  40254. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40255. /**
  40256. * Add orientation input support to the input manager.
  40257. * @returns the current input manager
  40258. */
  40259. addDeviceOrientation(): FreeCameraInputsManager;
  40260. }
  40261. /**
  40262. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40263. * Screen rotation is taken into account.
  40264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40265. */
  40266. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40267. private _camera;
  40268. private _screenOrientationAngle;
  40269. private _constantTranform;
  40270. private _screenQuaternion;
  40271. private _alpha;
  40272. private _beta;
  40273. private _gamma;
  40274. /**
  40275. * Can be used to detect if a device orientation sensor is available on a device
  40276. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40277. * @returns a promise that will resolve on orientation change
  40278. */
  40279. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40280. /**
  40281. * @hidden
  40282. */
  40283. _onDeviceOrientationChangedObservable: Observable<void>;
  40284. /**
  40285. * Instantiates a new input
  40286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40287. */
  40288. constructor();
  40289. /**
  40290. * Define the camera controlled by the input.
  40291. */
  40292. get camera(): FreeCamera;
  40293. set camera(camera: FreeCamera);
  40294. /**
  40295. * Attach the input controls to a specific dom element to get the input from.
  40296. * @param element Defines the element the controls should be listened from
  40297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40298. */
  40299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40300. private _orientationChanged;
  40301. private _deviceOrientation;
  40302. /**
  40303. * Detach the current controls from the specified dom element.
  40304. * @param element Defines the element to stop listening the inputs from
  40305. */
  40306. detachControl(element: Nullable<HTMLElement>): void;
  40307. /**
  40308. * Update the current camera state depending on the inputs that have been used this frame.
  40309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40310. */
  40311. checkInputs(): void;
  40312. /**
  40313. * Gets the class name of the current intput.
  40314. * @returns the class name
  40315. */
  40316. getClassName(): string;
  40317. /**
  40318. * Get the friendly name associated with the input class.
  40319. * @returns the input friendly name
  40320. */
  40321. getSimpleName(): string;
  40322. }
  40323. }
  40324. declare module BABYLON {
  40325. /**
  40326. * Manage the gamepad inputs to control a free camera.
  40327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40328. */
  40329. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40330. /**
  40331. * Define the camera the input is attached to.
  40332. */
  40333. camera: FreeCamera;
  40334. /**
  40335. * Define the Gamepad controlling the input
  40336. */
  40337. gamepad: Nullable<Gamepad>;
  40338. /**
  40339. * Defines the gamepad rotation sensiblity.
  40340. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40341. */
  40342. gamepadAngularSensibility: number;
  40343. /**
  40344. * Defines the gamepad move sensiblity.
  40345. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40346. */
  40347. gamepadMoveSensibility: number;
  40348. private _yAxisScale;
  40349. /**
  40350. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40351. */
  40352. get invertYAxis(): boolean;
  40353. set invertYAxis(value: boolean);
  40354. private _onGamepadConnectedObserver;
  40355. private _onGamepadDisconnectedObserver;
  40356. private _cameraTransform;
  40357. private _deltaTransform;
  40358. private _vector3;
  40359. private _vector2;
  40360. /**
  40361. * Attach the input controls to a specific dom element to get the input from.
  40362. * @param element Defines the element the controls should be listened from
  40363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40364. */
  40365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40366. /**
  40367. * Detach the current controls from the specified dom element.
  40368. * @param element Defines the element to stop listening the inputs from
  40369. */
  40370. detachControl(element: Nullable<HTMLElement>): void;
  40371. /**
  40372. * Update the current camera state depending on the inputs that have been used this frame.
  40373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40374. */
  40375. checkInputs(): void;
  40376. /**
  40377. * Gets the class name of the current intput.
  40378. * @returns the class name
  40379. */
  40380. getClassName(): string;
  40381. /**
  40382. * Get the friendly name associated with the input class.
  40383. * @returns the input friendly name
  40384. */
  40385. getSimpleName(): string;
  40386. }
  40387. }
  40388. declare module BABYLON {
  40389. /**
  40390. * Defines the potential axis of a Joystick
  40391. */
  40392. export enum JoystickAxis {
  40393. /** X axis */
  40394. X = 0,
  40395. /** Y axis */
  40396. Y = 1,
  40397. /** Z axis */
  40398. Z = 2
  40399. }
  40400. /**
  40401. * Class used to define virtual joystick (used in touch mode)
  40402. */
  40403. export class VirtualJoystick {
  40404. /**
  40405. * Gets or sets a boolean indicating that left and right values must be inverted
  40406. */
  40407. reverseLeftRight: boolean;
  40408. /**
  40409. * Gets or sets a boolean indicating that up and down values must be inverted
  40410. */
  40411. reverseUpDown: boolean;
  40412. /**
  40413. * Gets the offset value for the position (ie. the change of the position value)
  40414. */
  40415. deltaPosition: Vector3;
  40416. /**
  40417. * Gets a boolean indicating if the virtual joystick was pressed
  40418. */
  40419. pressed: boolean;
  40420. /**
  40421. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40422. */
  40423. static Canvas: Nullable<HTMLCanvasElement>;
  40424. private static _globalJoystickIndex;
  40425. private static vjCanvasContext;
  40426. private static vjCanvasWidth;
  40427. private static vjCanvasHeight;
  40428. private static halfWidth;
  40429. private _action;
  40430. private _axisTargetedByLeftAndRight;
  40431. private _axisTargetedByUpAndDown;
  40432. private _joystickSensibility;
  40433. private _inversedSensibility;
  40434. private _joystickPointerID;
  40435. private _joystickColor;
  40436. private _joystickPointerPos;
  40437. private _joystickPreviousPointerPos;
  40438. private _joystickPointerStartPos;
  40439. private _deltaJoystickVector;
  40440. private _leftJoystick;
  40441. private _touches;
  40442. private _onPointerDownHandlerRef;
  40443. private _onPointerMoveHandlerRef;
  40444. private _onPointerUpHandlerRef;
  40445. private _onResize;
  40446. /**
  40447. * Creates a new virtual joystick
  40448. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40449. */
  40450. constructor(leftJoystick?: boolean);
  40451. /**
  40452. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40453. * @param newJoystickSensibility defines the new sensibility
  40454. */
  40455. setJoystickSensibility(newJoystickSensibility: number): void;
  40456. private _onPointerDown;
  40457. private _onPointerMove;
  40458. private _onPointerUp;
  40459. /**
  40460. * Change the color of the virtual joystick
  40461. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40462. */
  40463. setJoystickColor(newColor: string): void;
  40464. /**
  40465. * Defines a callback to call when the joystick is touched
  40466. * @param action defines the callback
  40467. */
  40468. setActionOnTouch(action: () => any): void;
  40469. /**
  40470. * Defines which axis you'd like to control for left & right
  40471. * @param axis defines the axis to use
  40472. */
  40473. setAxisForLeftRight(axis: JoystickAxis): void;
  40474. /**
  40475. * Defines which axis you'd like to control for up & down
  40476. * @param axis defines the axis to use
  40477. */
  40478. setAxisForUpDown(axis: JoystickAxis): void;
  40479. private _drawVirtualJoystick;
  40480. /**
  40481. * Release internal HTML canvas
  40482. */
  40483. releaseCanvas(): void;
  40484. }
  40485. }
  40486. declare module BABYLON {
  40487. interface FreeCameraInputsManager {
  40488. /**
  40489. * Add virtual joystick input support to the input manager.
  40490. * @returns the current input manager
  40491. */
  40492. addVirtualJoystick(): FreeCameraInputsManager;
  40493. }
  40494. /**
  40495. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40497. */
  40498. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40499. /**
  40500. * Defines the camera the input is attached to.
  40501. */
  40502. camera: FreeCamera;
  40503. private _leftjoystick;
  40504. private _rightjoystick;
  40505. /**
  40506. * Gets the left stick of the virtual joystick.
  40507. * @returns The virtual Joystick
  40508. */
  40509. getLeftJoystick(): VirtualJoystick;
  40510. /**
  40511. * Gets the right stick of the virtual joystick.
  40512. * @returns The virtual Joystick
  40513. */
  40514. getRightJoystick(): VirtualJoystick;
  40515. /**
  40516. * Update the current camera state depending on the inputs that have been used this frame.
  40517. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40518. */
  40519. checkInputs(): void;
  40520. /**
  40521. * Attach the input controls to a specific dom element to get the input from.
  40522. * @param element Defines the element the controls should be listened from
  40523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40524. */
  40525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40526. /**
  40527. * Detach the current controls from the specified dom element.
  40528. * @param element Defines the element to stop listening the inputs from
  40529. */
  40530. detachControl(element: Nullable<HTMLElement>): void;
  40531. /**
  40532. * Gets the class name of the current intput.
  40533. * @returns the class name
  40534. */
  40535. getClassName(): string;
  40536. /**
  40537. * Get the friendly name associated with the input class.
  40538. * @returns the input friendly name
  40539. */
  40540. getSimpleName(): string;
  40541. }
  40542. }
  40543. declare module BABYLON {
  40544. /**
  40545. * This represents a FPS type of camera controlled by touch.
  40546. * This is like a universal camera minus the Gamepad controls.
  40547. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40548. */
  40549. export class TouchCamera extends FreeCamera {
  40550. /**
  40551. * Defines the touch sensibility for rotation.
  40552. * The higher the faster.
  40553. */
  40554. get touchAngularSensibility(): number;
  40555. set touchAngularSensibility(value: number);
  40556. /**
  40557. * Defines the touch sensibility for move.
  40558. * The higher the faster.
  40559. */
  40560. get touchMoveSensibility(): number;
  40561. set touchMoveSensibility(value: number);
  40562. /**
  40563. * Instantiates a new touch camera.
  40564. * This represents a FPS type of camera controlled by touch.
  40565. * This is like a universal camera minus the Gamepad controls.
  40566. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40567. * @param name Define the name of the camera in the scene
  40568. * @param position Define the start position of the camera in the scene
  40569. * @param scene Define the scene the camera belongs to
  40570. */
  40571. constructor(name: string, position: Vector3, scene: Scene);
  40572. /**
  40573. * Gets the current object class name.
  40574. * @return the class name
  40575. */
  40576. getClassName(): string;
  40577. /** @hidden */
  40578. _setupInputs(): void;
  40579. }
  40580. }
  40581. declare module BABYLON {
  40582. /**
  40583. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40584. * being tilted forward or back and left or right.
  40585. */
  40586. export class DeviceOrientationCamera extends FreeCamera {
  40587. private _initialQuaternion;
  40588. private _quaternionCache;
  40589. private _tmpDragQuaternion;
  40590. private _disablePointerInputWhenUsingDeviceOrientation;
  40591. /**
  40592. * Creates a new device orientation camera
  40593. * @param name The name of the camera
  40594. * @param position The start position camera
  40595. * @param scene The scene the camera belongs to
  40596. */
  40597. constructor(name: string, position: Vector3, scene: Scene);
  40598. /**
  40599. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40600. */
  40601. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40602. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40603. private _dragFactor;
  40604. /**
  40605. * Enabled turning on the y axis when the orientation sensor is active
  40606. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40607. */
  40608. enableHorizontalDragging(dragFactor?: number): void;
  40609. /**
  40610. * Gets the current instance class name ("DeviceOrientationCamera").
  40611. * This helps avoiding instanceof at run time.
  40612. * @returns the class name
  40613. */
  40614. getClassName(): string;
  40615. /**
  40616. * @hidden
  40617. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40618. */
  40619. _checkInputs(): void;
  40620. /**
  40621. * Reset the camera to its default orientation on the specified axis only.
  40622. * @param axis The axis to reset
  40623. */
  40624. resetToCurrentRotation(axis?: Axis): void;
  40625. }
  40626. }
  40627. declare module BABYLON {
  40628. /**
  40629. * Defines supported buttons for XBox360 compatible gamepads
  40630. */
  40631. export enum Xbox360Button {
  40632. /** A */
  40633. A = 0,
  40634. /** B */
  40635. B = 1,
  40636. /** X */
  40637. X = 2,
  40638. /** Y */
  40639. Y = 3,
  40640. /** Start */
  40641. Start = 4,
  40642. /** Back */
  40643. Back = 5,
  40644. /** Left button */
  40645. LB = 6,
  40646. /** Right button */
  40647. RB = 7,
  40648. /** Left stick */
  40649. LeftStick = 8,
  40650. /** Right stick */
  40651. RightStick = 9
  40652. }
  40653. /** Defines values for XBox360 DPad */
  40654. export enum Xbox360Dpad {
  40655. /** Up */
  40656. Up = 0,
  40657. /** Down */
  40658. Down = 1,
  40659. /** Left */
  40660. Left = 2,
  40661. /** Right */
  40662. Right = 3
  40663. }
  40664. /**
  40665. * Defines a XBox360 gamepad
  40666. */
  40667. export class Xbox360Pad extends Gamepad {
  40668. private _leftTrigger;
  40669. private _rightTrigger;
  40670. private _onlefttriggerchanged;
  40671. private _onrighttriggerchanged;
  40672. private _onbuttondown;
  40673. private _onbuttonup;
  40674. private _ondpaddown;
  40675. private _ondpadup;
  40676. /** Observable raised when a button is pressed */
  40677. onButtonDownObservable: Observable<Xbox360Button>;
  40678. /** Observable raised when a button is released */
  40679. onButtonUpObservable: Observable<Xbox360Button>;
  40680. /** Observable raised when a pad is pressed */
  40681. onPadDownObservable: Observable<Xbox360Dpad>;
  40682. /** Observable raised when a pad is released */
  40683. onPadUpObservable: Observable<Xbox360Dpad>;
  40684. private _buttonA;
  40685. private _buttonB;
  40686. private _buttonX;
  40687. private _buttonY;
  40688. private _buttonBack;
  40689. private _buttonStart;
  40690. private _buttonLB;
  40691. private _buttonRB;
  40692. private _buttonLeftStick;
  40693. private _buttonRightStick;
  40694. private _dPadUp;
  40695. private _dPadDown;
  40696. private _dPadLeft;
  40697. private _dPadRight;
  40698. private _isXboxOnePad;
  40699. /**
  40700. * Creates a new XBox360 gamepad object
  40701. * @param id defines the id of this gamepad
  40702. * @param index defines its index
  40703. * @param gamepad defines the internal HTML gamepad object
  40704. * @param xboxOne defines if it is a XBox One gamepad
  40705. */
  40706. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40707. /**
  40708. * Defines the callback to call when left trigger is pressed
  40709. * @param callback defines the callback to use
  40710. */
  40711. onlefttriggerchanged(callback: (value: number) => void): void;
  40712. /**
  40713. * Defines the callback to call when right trigger is pressed
  40714. * @param callback defines the callback to use
  40715. */
  40716. onrighttriggerchanged(callback: (value: number) => void): void;
  40717. /**
  40718. * Gets the left trigger value
  40719. */
  40720. get leftTrigger(): number;
  40721. /**
  40722. * Sets the left trigger value
  40723. */
  40724. set leftTrigger(newValue: number);
  40725. /**
  40726. * Gets the right trigger value
  40727. */
  40728. get rightTrigger(): number;
  40729. /**
  40730. * Sets the right trigger value
  40731. */
  40732. set rightTrigger(newValue: number);
  40733. /**
  40734. * Defines the callback to call when a button is pressed
  40735. * @param callback defines the callback to use
  40736. */
  40737. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40738. /**
  40739. * Defines the callback to call when a button is released
  40740. * @param callback defines the callback to use
  40741. */
  40742. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40743. /**
  40744. * Defines the callback to call when a pad is pressed
  40745. * @param callback defines the callback to use
  40746. */
  40747. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40748. /**
  40749. * Defines the callback to call when a pad is released
  40750. * @param callback defines the callback to use
  40751. */
  40752. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40753. private _setButtonValue;
  40754. private _setDPadValue;
  40755. /**
  40756. * Gets the value of the `A` button
  40757. */
  40758. get buttonA(): number;
  40759. /**
  40760. * Sets the value of the `A` button
  40761. */
  40762. set buttonA(value: number);
  40763. /**
  40764. * Gets the value of the `B` button
  40765. */
  40766. get buttonB(): number;
  40767. /**
  40768. * Sets the value of the `B` button
  40769. */
  40770. set buttonB(value: number);
  40771. /**
  40772. * Gets the value of the `X` button
  40773. */
  40774. get buttonX(): number;
  40775. /**
  40776. * Sets the value of the `X` button
  40777. */
  40778. set buttonX(value: number);
  40779. /**
  40780. * Gets the value of the `Y` button
  40781. */
  40782. get buttonY(): number;
  40783. /**
  40784. * Sets the value of the `Y` button
  40785. */
  40786. set buttonY(value: number);
  40787. /**
  40788. * Gets the value of the `Start` button
  40789. */
  40790. get buttonStart(): number;
  40791. /**
  40792. * Sets the value of the `Start` button
  40793. */
  40794. set buttonStart(value: number);
  40795. /**
  40796. * Gets the value of the `Back` button
  40797. */
  40798. get buttonBack(): number;
  40799. /**
  40800. * Sets the value of the `Back` button
  40801. */
  40802. set buttonBack(value: number);
  40803. /**
  40804. * Gets the value of the `Left` button
  40805. */
  40806. get buttonLB(): number;
  40807. /**
  40808. * Sets the value of the `Left` button
  40809. */
  40810. set buttonLB(value: number);
  40811. /**
  40812. * Gets the value of the `Right` button
  40813. */
  40814. get buttonRB(): number;
  40815. /**
  40816. * Sets the value of the `Right` button
  40817. */
  40818. set buttonRB(value: number);
  40819. /**
  40820. * Gets the value of the Left joystick
  40821. */
  40822. get buttonLeftStick(): number;
  40823. /**
  40824. * Sets the value of the Left joystick
  40825. */
  40826. set buttonLeftStick(value: number);
  40827. /**
  40828. * Gets the value of the Right joystick
  40829. */
  40830. get buttonRightStick(): number;
  40831. /**
  40832. * Sets the value of the Right joystick
  40833. */
  40834. set buttonRightStick(value: number);
  40835. /**
  40836. * Gets the value of D-pad up
  40837. */
  40838. get dPadUp(): number;
  40839. /**
  40840. * Sets the value of D-pad up
  40841. */
  40842. set dPadUp(value: number);
  40843. /**
  40844. * Gets the value of D-pad down
  40845. */
  40846. get dPadDown(): number;
  40847. /**
  40848. * Sets the value of D-pad down
  40849. */
  40850. set dPadDown(value: number);
  40851. /**
  40852. * Gets the value of D-pad left
  40853. */
  40854. get dPadLeft(): number;
  40855. /**
  40856. * Sets the value of D-pad left
  40857. */
  40858. set dPadLeft(value: number);
  40859. /**
  40860. * Gets the value of D-pad right
  40861. */
  40862. get dPadRight(): number;
  40863. /**
  40864. * Sets the value of D-pad right
  40865. */
  40866. set dPadRight(value: number);
  40867. /**
  40868. * Force the gamepad to synchronize with device values
  40869. */
  40870. update(): void;
  40871. /**
  40872. * Disposes the gamepad
  40873. */
  40874. dispose(): void;
  40875. }
  40876. }
  40877. declare module BABYLON {
  40878. /**
  40879. * Defines supported buttons for DualShock compatible gamepads
  40880. */
  40881. export enum DualShockButton {
  40882. /** Cross */
  40883. Cross = 0,
  40884. /** Circle */
  40885. Circle = 1,
  40886. /** Square */
  40887. Square = 2,
  40888. /** Triangle */
  40889. Triangle = 3,
  40890. /** Options */
  40891. Options = 4,
  40892. /** Share */
  40893. Share = 5,
  40894. /** L1 */
  40895. L1 = 6,
  40896. /** R1 */
  40897. R1 = 7,
  40898. /** Left stick */
  40899. LeftStick = 8,
  40900. /** Right stick */
  40901. RightStick = 9
  40902. }
  40903. /** Defines values for DualShock DPad */
  40904. export enum DualShockDpad {
  40905. /** Up */
  40906. Up = 0,
  40907. /** Down */
  40908. Down = 1,
  40909. /** Left */
  40910. Left = 2,
  40911. /** Right */
  40912. Right = 3
  40913. }
  40914. /**
  40915. * Defines a DualShock gamepad
  40916. */
  40917. export class DualShockPad extends Gamepad {
  40918. private _leftTrigger;
  40919. private _rightTrigger;
  40920. private _onlefttriggerchanged;
  40921. private _onrighttriggerchanged;
  40922. private _onbuttondown;
  40923. private _onbuttonup;
  40924. private _ondpaddown;
  40925. private _ondpadup;
  40926. /** Observable raised when a button is pressed */
  40927. onButtonDownObservable: Observable<DualShockButton>;
  40928. /** Observable raised when a button is released */
  40929. onButtonUpObservable: Observable<DualShockButton>;
  40930. /** Observable raised when a pad is pressed */
  40931. onPadDownObservable: Observable<DualShockDpad>;
  40932. /** Observable raised when a pad is released */
  40933. onPadUpObservable: Observable<DualShockDpad>;
  40934. private _buttonCross;
  40935. private _buttonCircle;
  40936. private _buttonSquare;
  40937. private _buttonTriangle;
  40938. private _buttonShare;
  40939. private _buttonOptions;
  40940. private _buttonL1;
  40941. private _buttonR1;
  40942. private _buttonLeftStick;
  40943. private _buttonRightStick;
  40944. private _dPadUp;
  40945. private _dPadDown;
  40946. private _dPadLeft;
  40947. private _dPadRight;
  40948. /**
  40949. * Creates a new DualShock gamepad object
  40950. * @param id defines the id of this gamepad
  40951. * @param index defines its index
  40952. * @param gamepad defines the internal HTML gamepad object
  40953. */
  40954. constructor(id: string, index: number, gamepad: any);
  40955. /**
  40956. * Defines the callback to call when left trigger is pressed
  40957. * @param callback defines the callback to use
  40958. */
  40959. onlefttriggerchanged(callback: (value: number) => void): void;
  40960. /**
  40961. * Defines the callback to call when right trigger is pressed
  40962. * @param callback defines the callback to use
  40963. */
  40964. onrighttriggerchanged(callback: (value: number) => void): void;
  40965. /**
  40966. * Gets the left trigger value
  40967. */
  40968. get leftTrigger(): number;
  40969. /**
  40970. * Sets the left trigger value
  40971. */
  40972. set leftTrigger(newValue: number);
  40973. /**
  40974. * Gets the right trigger value
  40975. */
  40976. get rightTrigger(): number;
  40977. /**
  40978. * Sets the right trigger value
  40979. */
  40980. set rightTrigger(newValue: number);
  40981. /**
  40982. * Defines the callback to call when a button is pressed
  40983. * @param callback defines the callback to use
  40984. */
  40985. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40986. /**
  40987. * Defines the callback to call when a button is released
  40988. * @param callback defines the callback to use
  40989. */
  40990. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40991. /**
  40992. * Defines the callback to call when a pad is pressed
  40993. * @param callback defines the callback to use
  40994. */
  40995. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40996. /**
  40997. * Defines the callback to call when a pad is released
  40998. * @param callback defines the callback to use
  40999. */
  41000. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41001. private _setButtonValue;
  41002. private _setDPadValue;
  41003. /**
  41004. * Gets the value of the `Cross` button
  41005. */
  41006. get buttonCross(): number;
  41007. /**
  41008. * Sets the value of the `Cross` button
  41009. */
  41010. set buttonCross(value: number);
  41011. /**
  41012. * Gets the value of the `Circle` button
  41013. */
  41014. get buttonCircle(): number;
  41015. /**
  41016. * Sets the value of the `Circle` button
  41017. */
  41018. set buttonCircle(value: number);
  41019. /**
  41020. * Gets the value of the `Square` button
  41021. */
  41022. get buttonSquare(): number;
  41023. /**
  41024. * Sets the value of the `Square` button
  41025. */
  41026. set buttonSquare(value: number);
  41027. /**
  41028. * Gets the value of the `Triangle` button
  41029. */
  41030. get buttonTriangle(): number;
  41031. /**
  41032. * Sets the value of the `Triangle` button
  41033. */
  41034. set buttonTriangle(value: number);
  41035. /**
  41036. * Gets the value of the `Options` button
  41037. */
  41038. get buttonOptions(): number;
  41039. /**
  41040. * Sets the value of the `Options` button
  41041. */
  41042. set buttonOptions(value: number);
  41043. /**
  41044. * Gets the value of the `Share` button
  41045. */
  41046. get buttonShare(): number;
  41047. /**
  41048. * Sets the value of the `Share` button
  41049. */
  41050. set buttonShare(value: number);
  41051. /**
  41052. * Gets the value of the `L1` button
  41053. */
  41054. get buttonL1(): number;
  41055. /**
  41056. * Sets the value of the `L1` button
  41057. */
  41058. set buttonL1(value: number);
  41059. /**
  41060. * Gets the value of the `R1` button
  41061. */
  41062. get buttonR1(): number;
  41063. /**
  41064. * Sets the value of the `R1` button
  41065. */
  41066. set buttonR1(value: number);
  41067. /**
  41068. * Gets the value of the Left joystick
  41069. */
  41070. get buttonLeftStick(): number;
  41071. /**
  41072. * Sets the value of the Left joystick
  41073. */
  41074. set buttonLeftStick(value: number);
  41075. /**
  41076. * Gets the value of the Right joystick
  41077. */
  41078. get buttonRightStick(): number;
  41079. /**
  41080. * Sets the value of the Right joystick
  41081. */
  41082. set buttonRightStick(value: number);
  41083. /**
  41084. * Gets the value of D-pad up
  41085. */
  41086. get dPadUp(): number;
  41087. /**
  41088. * Sets the value of D-pad up
  41089. */
  41090. set dPadUp(value: number);
  41091. /**
  41092. * Gets the value of D-pad down
  41093. */
  41094. get dPadDown(): number;
  41095. /**
  41096. * Sets the value of D-pad down
  41097. */
  41098. set dPadDown(value: number);
  41099. /**
  41100. * Gets the value of D-pad left
  41101. */
  41102. get dPadLeft(): number;
  41103. /**
  41104. * Sets the value of D-pad left
  41105. */
  41106. set dPadLeft(value: number);
  41107. /**
  41108. * Gets the value of D-pad right
  41109. */
  41110. get dPadRight(): number;
  41111. /**
  41112. * Sets the value of D-pad right
  41113. */
  41114. set dPadRight(value: number);
  41115. /**
  41116. * Force the gamepad to synchronize with device values
  41117. */
  41118. update(): void;
  41119. /**
  41120. * Disposes the gamepad
  41121. */
  41122. dispose(): void;
  41123. }
  41124. }
  41125. declare module BABYLON {
  41126. /**
  41127. * Manager for handling gamepads
  41128. */
  41129. export class GamepadManager {
  41130. private _scene?;
  41131. private _babylonGamepads;
  41132. private _oneGamepadConnected;
  41133. /** @hidden */
  41134. _isMonitoring: boolean;
  41135. private _gamepadEventSupported;
  41136. private _gamepadSupport?;
  41137. /**
  41138. * observable to be triggered when the gamepad controller has been connected
  41139. */
  41140. onGamepadConnectedObservable: Observable<Gamepad>;
  41141. /**
  41142. * observable to be triggered when the gamepad controller has been disconnected
  41143. */
  41144. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41145. private _onGamepadConnectedEvent;
  41146. private _onGamepadDisconnectedEvent;
  41147. /**
  41148. * Initializes the gamepad manager
  41149. * @param _scene BabylonJS scene
  41150. */
  41151. constructor(_scene?: Scene | undefined);
  41152. /**
  41153. * The gamepads in the game pad manager
  41154. */
  41155. get gamepads(): Gamepad[];
  41156. /**
  41157. * Get the gamepad controllers based on type
  41158. * @param type The type of gamepad controller
  41159. * @returns Nullable gamepad
  41160. */
  41161. getGamepadByType(type?: number): Nullable<Gamepad>;
  41162. /**
  41163. * Disposes the gamepad manager
  41164. */
  41165. dispose(): void;
  41166. private _addNewGamepad;
  41167. private _startMonitoringGamepads;
  41168. private _stopMonitoringGamepads;
  41169. /** @hidden */
  41170. _checkGamepadsStatus(): void;
  41171. private _updateGamepadObjects;
  41172. }
  41173. }
  41174. declare module BABYLON {
  41175. interface Scene {
  41176. /** @hidden */
  41177. _gamepadManager: Nullable<GamepadManager>;
  41178. /**
  41179. * Gets the gamepad manager associated with the scene
  41180. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41181. */
  41182. gamepadManager: GamepadManager;
  41183. }
  41184. /**
  41185. * Interface representing a free camera inputs manager
  41186. */
  41187. interface FreeCameraInputsManager {
  41188. /**
  41189. * Adds gamepad input support to the FreeCameraInputsManager.
  41190. * @returns the FreeCameraInputsManager
  41191. */
  41192. addGamepad(): FreeCameraInputsManager;
  41193. }
  41194. /**
  41195. * Interface representing an arc rotate camera inputs manager
  41196. */
  41197. interface ArcRotateCameraInputsManager {
  41198. /**
  41199. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41200. * @returns the camera inputs manager
  41201. */
  41202. addGamepad(): ArcRotateCameraInputsManager;
  41203. }
  41204. /**
  41205. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41206. */
  41207. export class GamepadSystemSceneComponent implements ISceneComponent {
  41208. /**
  41209. * The component name helpfull to identify the component in the list of scene components.
  41210. */
  41211. readonly name: string;
  41212. /**
  41213. * The scene the component belongs to.
  41214. */
  41215. scene: Scene;
  41216. /**
  41217. * Creates a new instance of the component for the given scene
  41218. * @param scene Defines the scene to register the component in
  41219. */
  41220. constructor(scene: Scene);
  41221. /**
  41222. * Registers the component in a given scene
  41223. */
  41224. register(): void;
  41225. /**
  41226. * Rebuilds the elements related to this component in case of
  41227. * context lost for instance.
  41228. */
  41229. rebuild(): void;
  41230. /**
  41231. * Disposes the component and the associated ressources
  41232. */
  41233. dispose(): void;
  41234. private _beforeCameraUpdate;
  41235. }
  41236. }
  41237. declare module BABYLON {
  41238. /**
  41239. * 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,
  41240. * which still works and will still be found in many Playgrounds.
  41241. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41242. */
  41243. export class UniversalCamera extends TouchCamera {
  41244. /**
  41245. * Defines the gamepad rotation sensiblity.
  41246. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41247. */
  41248. get gamepadAngularSensibility(): number;
  41249. set gamepadAngularSensibility(value: number);
  41250. /**
  41251. * Defines the gamepad move sensiblity.
  41252. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41253. */
  41254. get gamepadMoveSensibility(): number;
  41255. set gamepadMoveSensibility(value: number);
  41256. /**
  41257. * 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,
  41258. * which still works and will still be found in many Playgrounds.
  41259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41260. * @param name Define the name of the camera in the scene
  41261. * @param position Define the start position of the camera in the scene
  41262. * @param scene Define the scene the camera belongs to
  41263. */
  41264. constructor(name: string, position: Vector3, scene: Scene);
  41265. /**
  41266. * Gets the current object class name.
  41267. * @return the class name
  41268. */
  41269. getClassName(): string;
  41270. }
  41271. }
  41272. declare module BABYLON {
  41273. /**
  41274. * This represents a FPS type of camera. This is only here for back compat purpose.
  41275. * Please use the UniversalCamera instead as both are identical.
  41276. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41277. */
  41278. export class GamepadCamera extends UniversalCamera {
  41279. /**
  41280. * Instantiates a new Gamepad Camera
  41281. * This represents a FPS type of camera. This is only here for back compat purpose.
  41282. * Please use the UniversalCamera instead as both are identical.
  41283. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41284. * @param name Define the name of the camera in the scene
  41285. * @param position Define the start position of the camera in the scene
  41286. * @param scene Define the scene the camera belongs to
  41287. */
  41288. constructor(name: string, position: Vector3, scene: Scene);
  41289. /**
  41290. * Gets the current object class name.
  41291. * @return the class name
  41292. */
  41293. getClassName(): string;
  41294. }
  41295. }
  41296. declare module BABYLON {
  41297. /** @hidden */
  41298. export var passPixelShader: {
  41299. name: string;
  41300. shader: string;
  41301. };
  41302. }
  41303. declare module BABYLON {
  41304. /** @hidden */
  41305. export var passCubePixelShader: {
  41306. name: string;
  41307. shader: string;
  41308. };
  41309. }
  41310. declare module BABYLON {
  41311. /**
  41312. * PassPostProcess which produces an output the same as it's input
  41313. */
  41314. export class PassPostProcess extends PostProcess {
  41315. /**
  41316. * Creates the PassPostProcess
  41317. * @param name The name of the effect.
  41318. * @param options The required width/height ratio to downsize to before computing the render pass.
  41319. * @param camera The camera to apply the render pass to.
  41320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41321. * @param engine The engine which the post process will be applied. (default: current engine)
  41322. * @param reusable If the post process can be reused on the same frame. (default: false)
  41323. * @param textureType The type of texture to be used when performing the post processing.
  41324. * @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)
  41325. */
  41326. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41327. }
  41328. /**
  41329. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41330. */
  41331. export class PassCubePostProcess extends PostProcess {
  41332. private _face;
  41333. /**
  41334. * Gets or sets the cube face to display.
  41335. * * 0 is +X
  41336. * * 1 is -X
  41337. * * 2 is +Y
  41338. * * 3 is -Y
  41339. * * 4 is +Z
  41340. * * 5 is -Z
  41341. */
  41342. get face(): number;
  41343. set face(value: number);
  41344. /**
  41345. * Creates the PassCubePostProcess
  41346. * @param name The name of the effect.
  41347. * @param options The required width/height ratio to downsize to before computing the render pass.
  41348. * @param camera The camera to apply the render pass to.
  41349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41350. * @param engine The engine which the post process will be applied. (default: current engine)
  41351. * @param reusable If the post process can be reused on the same frame. (default: false)
  41352. * @param textureType The type of texture to be used when performing the post processing.
  41353. * @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)
  41354. */
  41355. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41356. }
  41357. }
  41358. declare module BABYLON {
  41359. /** @hidden */
  41360. export var anaglyphPixelShader: {
  41361. name: string;
  41362. shader: string;
  41363. };
  41364. }
  41365. declare module BABYLON {
  41366. /**
  41367. * Postprocess used to generate anaglyphic rendering
  41368. */
  41369. export class AnaglyphPostProcess extends PostProcess {
  41370. private _passedProcess;
  41371. /**
  41372. * Creates a new AnaglyphPostProcess
  41373. * @param name defines postprocess name
  41374. * @param options defines creation options or target ratio scale
  41375. * @param rigCameras defines cameras using this postprocess
  41376. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41377. * @param engine defines hosting engine
  41378. * @param reusable defines if the postprocess will be reused multiple times per frame
  41379. */
  41380. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41381. }
  41382. }
  41383. declare module BABYLON {
  41384. /**
  41385. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41386. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41387. */
  41388. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41389. /**
  41390. * Creates a new AnaglyphArcRotateCamera
  41391. * @param name defines camera name
  41392. * @param alpha defines alpha angle (in radians)
  41393. * @param beta defines beta angle (in radians)
  41394. * @param radius defines radius
  41395. * @param target defines camera target
  41396. * @param interaxialDistance defines distance between each color axis
  41397. * @param scene defines the hosting scene
  41398. */
  41399. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41400. /**
  41401. * Gets camera class name
  41402. * @returns AnaglyphArcRotateCamera
  41403. */
  41404. getClassName(): string;
  41405. }
  41406. }
  41407. declare module BABYLON {
  41408. /**
  41409. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41410. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41411. */
  41412. export class AnaglyphFreeCamera extends FreeCamera {
  41413. /**
  41414. * Creates a new AnaglyphFreeCamera
  41415. * @param name defines camera name
  41416. * @param position defines initial position
  41417. * @param interaxialDistance defines distance between each color axis
  41418. * @param scene defines the hosting scene
  41419. */
  41420. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41421. /**
  41422. * Gets camera class name
  41423. * @returns AnaglyphFreeCamera
  41424. */
  41425. getClassName(): string;
  41426. }
  41427. }
  41428. declare module BABYLON {
  41429. /**
  41430. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41431. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41432. */
  41433. export class AnaglyphGamepadCamera extends GamepadCamera {
  41434. /**
  41435. * Creates a new AnaglyphGamepadCamera
  41436. * @param name defines camera name
  41437. * @param position defines initial position
  41438. * @param interaxialDistance defines distance between each color axis
  41439. * @param scene defines the hosting scene
  41440. */
  41441. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41442. /**
  41443. * Gets camera class name
  41444. * @returns AnaglyphGamepadCamera
  41445. */
  41446. getClassName(): string;
  41447. }
  41448. }
  41449. declare module BABYLON {
  41450. /**
  41451. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41452. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41453. */
  41454. export class AnaglyphUniversalCamera extends UniversalCamera {
  41455. /**
  41456. * Creates a new AnaglyphUniversalCamera
  41457. * @param name defines camera name
  41458. * @param position defines initial position
  41459. * @param interaxialDistance defines distance between each color axis
  41460. * @param scene defines the hosting scene
  41461. */
  41462. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41463. /**
  41464. * Gets camera class name
  41465. * @returns AnaglyphUniversalCamera
  41466. */
  41467. getClassName(): string;
  41468. }
  41469. }
  41470. declare module BABYLON {
  41471. /** @hidden */
  41472. export var stereoscopicInterlacePixelShader: {
  41473. name: string;
  41474. shader: string;
  41475. };
  41476. }
  41477. declare module BABYLON {
  41478. /**
  41479. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41480. */
  41481. export class StereoscopicInterlacePostProcess extends PostProcess {
  41482. private _stepSize;
  41483. private _passedProcess;
  41484. /**
  41485. * Initializes a StereoscopicInterlacePostProcess
  41486. * @param name The name of the effect.
  41487. * @param rigCameras The rig cameras to be appled to the post process
  41488. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41490. * @param engine The engine which the post process will be applied. (default: current engine)
  41491. * @param reusable If the post process can be reused on the same frame. (default: false)
  41492. */
  41493. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41494. }
  41495. }
  41496. declare module BABYLON {
  41497. /**
  41498. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41499. * @see http://doc.babylonjs.com/features/cameras
  41500. */
  41501. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41502. /**
  41503. * Creates a new StereoscopicArcRotateCamera
  41504. * @param name defines camera name
  41505. * @param alpha defines alpha angle (in radians)
  41506. * @param beta defines beta angle (in radians)
  41507. * @param radius defines radius
  41508. * @param target defines camera target
  41509. * @param interaxialDistance defines distance between each color axis
  41510. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41511. * @param scene defines the hosting scene
  41512. */
  41513. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41514. /**
  41515. * Gets camera class name
  41516. * @returns StereoscopicArcRotateCamera
  41517. */
  41518. getClassName(): string;
  41519. }
  41520. }
  41521. declare module BABYLON {
  41522. /**
  41523. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41524. * @see http://doc.babylonjs.com/features/cameras
  41525. */
  41526. export class StereoscopicFreeCamera extends FreeCamera {
  41527. /**
  41528. * Creates a new StereoscopicFreeCamera
  41529. * @param name defines camera name
  41530. * @param position defines initial position
  41531. * @param interaxialDistance defines distance between each color axis
  41532. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41533. * @param scene defines the hosting scene
  41534. */
  41535. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41536. /**
  41537. * Gets camera class name
  41538. * @returns StereoscopicFreeCamera
  41539. */
  41540. getClassName(): string;
  41541. }
  41542. }
  41543. declare module BABYLON {
  41544. /**
  41545. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41546. * @see http://doc.babylonjs.com/features/cameras
  41547. */
  41548. export class StereoscopicGamepadCamera extends GamepadCamera {
  41549. /**
  41550. * Creates a new StereoscopicGamepadCamera
  41551. * @param name defines camera name
  41552. * @param position defines initial position
  41553. * @param interaxialDistance defines distance between each color axis
  41554. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41555. * @param scene defines the hosting scene
  41556. */
  41557. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41558. /**
  41559. * Gets camera class name
  41560. * @returns StereoscopicGamepadCamera
  41561. */
  41562. getClassName(): string;
  41563. }
  41564. }
  41565. declare module BABYLON {
  41566. /**
  41567. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41568. * @see http://doc.babylonjs.com/features/cameras
  41569. */
  41570. export class StereoscopicUniversalCamera extends UniversalCamera {
  41571. /**
  41572. * Creates a new StereoscopicUniversalCamera
  41573. * @param name defines camera name
  41574. * @param position defines initial position
  41575. * @param interaxialDistance defines distance between each color axis
  41576. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41577. * @param scene defines the hosting scene
  41578. */
  41579. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41580. /**
  41581. * Gets camera class name
  41582. * @returns StereoscopicUniversalCamera
  41583. */
  41584. getClassName(): string;
  41585. }
  41586. }
  41587. declare module BABYLON {
  41588. /**
  41589. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41590. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41591. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41592. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41593. */
  41594. export class VirtualJoysticksCamera extends FreeCamera {
  41595. /**
  41596. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41597. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41598. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41599. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41600. * @param name Define the name of the camera in the scene
  41601. * @param position Define the start position of the camera in the scene
  41602. * @param scene Define the scene the camera belongs to
  41603. */
  41604. constructor(name: string, position: Vector3, scene: Scene);
  41605. /**
  41606. * Gets the current object class name.
  41607. * @return the class name
  41608. */
  41609. getClassName(): string;
  41610. }
  41611. }
  41612. declare module BABYLON {
  41613. /**
  41614. * This represents all the required metrics to create a VR camera.
  41615. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41616. */
  41617. export class VRCameraMetrics {
  41618. /**
  41619. * Define the horizontal resolution off the screen.
  41620. */
  41621. hResolution: number;
  41622. /**
  41623. * Define the vertical resolution off the screen.
  41624. */
  41625. vResolution: number;
  41626. /**
  41627. * Define the horizontal screen size.
  41628. */
  41629. hScreenSize: number;
  41630. /**
  41631. * Define the vertical screen size.
  41632. */
  41633. vScreenSize: number;
  41634. /**
  41635. * Define the vertical screen center position.
  41636. */
  41637. vScreenCenter: number;
  41638. /**
  41639. * Define the distance of the eyes to the screen.
  41640. */
  41641. eyeToScreenDistance: number;
  41642. /**
  41643. * Define the distance between both lenses
  41644. */
  41645. lensSeparationDistance: number;
  41646. /**
  41647. * Define the distance between both viewer's eyes.
  41648. */
  41649. interpupillaryDistance: number;
  41650. /**
  41651. * Define the distortion factor of the VR postprocess.
  41652. * Please, touch with care.
  41653. */
  41654. distortionK: number[];
  41655. /**
  41656. * Define the chromatic aberration correction factors for the VR post process.
  41657. */
  41658. chromaAbCorrection: number[];
  41659. /**
  41660. * Define the scale factor of the post process.
  41661. * The smaller the better but the slower.
  41662. */
  41663. postProcessScaleFactor: number;
  41664. /**
  41665. * Define an offset for the lens center.
  41666. */
  41667. lensCenterOffset: number;
  41668. /**
  41669. * Define if the current vr camera should compensate the distortion of the lense or not.
  41670. */
  41671. compensateDistortion: boolean;
  41672. /**
  41673. * Defines if multiview should be enabled when rendering (Default: false)
  41674. */
  41675. multiviewEnabled: boolean;
  41676. /**
  41677. * Gets the rendering aspect ratio based on the provided resolutions.
  41678. */
  41679. get aspectRatio(): number;
  41680. /**
  41681. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41682. */
  41683. get aspectRatioFov(): number;
  41684. /**
  41685. * @hidden
  41686. */
  41687. get leftHMatrix(): Matrix;
  41688. /**
  41689. * @hidden
  41690. */
  41691. get rightHMatrix(): Matrix;
  41692. /**
  41693. * @hidden
  41694. */
  41695. get leftPreViewMatrix(): Matrix;
  41696. /**
  41697. * @hidden
  41698. */
  41699. get rightPreViewMatrix(): Matrix;
  41700. /**
  41701. * Get the default VRMetrics based on the most generic setup.
  41702. * @returns the default vr metrics
  41703. */
  41704. static GetDefault(): VRCameraMetrics;
  41705. }
  41706. }
  41707. declare module BABYLON {
  41708. /** @hidden */
  41709. export var vrDistortionCorrectionPixelShader: {
  41710. name: string;
  41711. shader: string;
  41712. };
  41713. }
  41714. declare module BABYLON {
  41715. /**
  41716. * VRDistortionCorrectionPostProcess used for mobile VR
  41717. */
  41718. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41719. private _isRightEye;
  41720. private _distortionFactors;
  41721. private _postProcessScaleFactor;
  41722. private _lensCenterOffset;
  41723. private _scaleIn;
  41724. private _scaleFactor;
  41725. private _lensCenter;
  41726. /**
  41727. * Initializes the VRDistortionCorrectionPostProcess
  41728. * @param name The name of the effect.
  41729. * @param camera The camera to apply the render pass to.
  41730. * @param isRightEye If this is for the right eye distortion
  41731. * @param vrMetrics All the required metrics for the VR camera
  41732. */
  41733. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41734. }
  41735. }
  41736. declare module BABYLON {
  41737. /**
  41738. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41739. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41740. */
  41741. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41742. /**
  41743. * Creates a new VRDeviceOrientationArcRotateCamera
  41744. * @param name defines camera name
  41745. * @param alpha defines the camera rotation along the logitudinal axis
  41746. * @param beta defines the camera rotation along the latitudinal axis
  41747. * @param radius defines the camera distance from its target
  41748. * @param target defines the camera target
  41749. * @param scene defines the scene the camera belongs to
  41750. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41751. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41752. */
  41753. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41754. /**
  41755. * Gets camera class name
  41756. * @returns VRDeviceOrientationArcRotateCamera
  41757. */
  41758. getClassName(): string;
  41759. }
  41760. }
  41761. declare module BABYLON {
  41762. /**
  41763. * Camera used to simulate VR rendering (based on FreeCamera)
  41764. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41765. */
  41766. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41767. /**
  41768. * Creates a new VRDeviceOrientationFreeCamera
  41769. * @param name defines camera name
  41770. * @param position defines the start position of the camera
  41771. * @param scene defines the scene the camera belongs to
  41772. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41773. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41774. */
  41775. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41776. /**
  41777. * Gets camera class name
  41778. * @returns VRDeviceOrientationFreeCamera
  41779. */
  41780. getClassName(): string;
  41781. }
  41782. }
  41783. declare module BABYLON {
  41784. /**
  41785. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41786. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41787. */
  41788. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41789. /**
  41790. * Creates a new VRDeviceOrientationGamepadCamera
  41791. * @param name defines camera name
  41792. * @param position defines the start position of the camera
  41793. * @param scene defines the scene the camera belongs to
  41794. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41795. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41796. */
  41797. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41798. /**
  41799. * Gets camera class name
  41800. * @returns VRDeviceOrientationGamepadCamera
  41801. */
  41802. getClassName(): string;
  41803. }
  41804. }
  41805. declare module BABYLON {
  41806. /** @hidden */
  41807. export var imageProcessingPixelShader: {
  41808. name: string;
  41809. shader: string;
  41810. };
  41811. }
  41812. declare module BABYLON {
  41813. /**
  41814. * ImageProcessingPostProcess
  41815. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41816. */
  41817. export class ImageProcessingPostProcess extends PostProcess {
  41818. /**
  41819. * Default configuration related to image processing available in the PBR Material.
  41820. */
  41821. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41822. /**
  41823. * Gets the image processing configuration used either in this material.
  41824. */
  41825. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41826. /**
  41827. * Sets the Default image processing configuration used either in the this material.
  41828. *
  41829. * If sets to null, the scene one is in use.
  41830. */
  41831. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  41832. /**
  41833. * Keep track of the image processing observer to allow dispose and replace.
  41834. */
  41835. private _imageProcessingObserver;
  41836. /**
  41837. * Attaches a new image processing configuration to the PBR Material.
  41838. * @param configuration
  41839. */
  41840. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41841. /**
  41842. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41843. */
  41844. get colorCurves(): Nullable<ColorCurves>;
  41845. /**
  41846. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41847. */
  41848. set colorCurves(value: Nullable<ColorCurves>);
  41849. /**
  41850. * Gets wether the color curves effect is enabled.
  41851. */
  41852. get colorCurvesEnabled(): boolean;
  41853. /**
  41854. * Sets wether the color curves effect is enabled.
  41855. */
  41856. set colorCurvesEnabled(value: boolean);
  41857. /**
  41858. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41859. */
  41860. get colorGradingTexture(): Nullable<BaseTexture>;
  41861. /**
  41862. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41863. */
  41864. set colorGradingTexture(value: Nullable<BaseTexture>);
  41865. /**
  41866. * Gets wether the color grading effect is enabled.
  41867. */
  41868. get colorGradingEnabled(): boolean;
  41869. /**
  41870. * Gets wether the color grading effect is enabled.
  41871. */
  41872. set colorGradingEnabled(value: boolean);
  41873. /**
  41874. * Gets exposure used in the effect.
  41875. */
  41876. get exposure(): number;
  41877. /**
  41878. * Sets exposure used in the effect.
  41879. */
  41880. set exposure(value: number);
  41881. /**
  41882. * Gets wether tonemapping is enabled or not.
  41883. */
  41884. get toneMappingEnabled(): boolean;
  41885. /**
  41886. * Sets wether tonemapping is enabled or not
  41887. */
  41888. set toneMappingEnabled(value: boolean);
  41889. /**
  41890. * Gets the type of tone mapping effect.
  41891. */
  41892. get toneMappingType(): number;
  41893. /**
  41894. * Sets the type of tone mapping effect.
  41895. */
  41896. set toneMappingType(value: number);
  41897. /**
  41898. * Gets contrast used in the effect.
  41899. */
  41900. get contrast(): number;
  41901. /**
  41902. * Sets contrast used in the effect.
  41903. */
  41904. set contrast(value: number);
  41905. /**
  41906. * Gets Vignette stretch size.
  41907. */
  41908. get vignetteStretch(): number;
  41909. /**
  41910. * Sets Vignette stretch size.
  41911. */
  41912. set vignetteStretch(value: number);
  41913. /**
  41914. * Gets Vignette centre X Offset.
  41915. */
  41916. get vignetteCentreX(): number;
  41917. /**
  41918. * Sets Vignette centre X Offset.
  41919. */
  41920. set vignetteCentreX(value: number);
  41921. /**
  41922. * Gets Vignette centre Y Offset.
  41923. */
  41924. get vignetteCentreY(): number;
  41925. /**
  41926. * Sets Vignette centre Y Offset.
  41927. */
  41928. set vignetteCentreY(value: number);
  41929. /**
  41930. * Gets Vignette weight or intensity of the vignette effect.
  41931. */
  41932. get vignetteWeight(): number;
  41933. /**
  41934. * Sets Vignette weight or intensity of the vignette effect.
  41935. */
  41936. set vignetteWeight(value: number);
  41937. /**
  41938. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41939. * if vignetteEnabled is set to true.
  41940. */
  41941. get vignetteColor(): Color4;
  41942. /**
  41943. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41944. * if vignetteEnabled is set to true.
  41945. */
  41946. set vignetteColor(value: Color4);
  41947. /**
  41948. * Gets Camera field of view used by the Vignette effect.
  41949. */
  41950. get vignetteCameraFov(): number;
  41951. /**
  41952. * Sets Camera field of view used by the Vignette effect.
  41953. */
  41954. set vignetteCameraFov(value: number);
  41955. /**
  41956. * Gets the vignette blend mode allowing different kind of effect.
  41957. */
  41958. get vignetteBlendMode(): number;
  41959. /**
  41960. * Sets the vignette blend mode allowing different kind of effect.
  41961. */
  41962. set vignetteBlendMode(value: number);
  41963. /**
  41964. * Gets wether the vignette effect is enabled.
  41965. */
  41966. get vignetteEnabled(): boolean;
  41967. /**
  41968. * Sets wether the vignette effect is enabled.
  41969. */
  41970. set vignetteEnabled(value: boolean);
  41971. private _fromLinearSpace;
  41972. /**
  41973. * Gets wether the input of the processing is in Gamma or Linear Space.
  41974. */
  41975. get fromLinearSpace(): boolean;
  41976. /**
  41977. * Sets wether the input of the processing is in Gamma or Linear Space.
  41978. */
  41979. set fromLinearSpace(value: boolean);
  41980. /**
  41981. * Defines cache preventing GC.
  41982. */
  41983. private _defines;
  41984. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41985. /**
  41986. * "ImageProcessingPostProcess"
  41987. * @returns "ImageProcessingPostProcess"
  41988. */
  41989. getClassName(): string;
  41990. protected _updateParameters(): void;
  41991. dispose(camera?: Camera): void;
  41992. }
  41993. }
  41994. declare module BABYLON {
  41995. /**
  41996. * Class containing static functions to help procedurally build meshes
  41997. */
  41998. export class GroundBuilder {
  41999. /**
  42000. * Creates a ground mesh
  42001. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42002. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42004. * @param name defines the name of the mesh
  42005. * @param options defines the options used to create the mesh
  42006. * @param scene defines the hosting scene
  42007. * @returns the ground mesh
  42008. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42009. */
  42010. static CreateGround(name: string, options: {
  42011. width?: number;
  42012. height?: number;
  42013. subdivisions?: number;
  42014. subdivisionsX?: number;
  42015. subdivisionsY?: number;
  42016. updatable?: boolean;
  42017. }, scene: any): Mesh;
  42018. /**
  42019. * Creates a tiled ground mesh
  42020. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42021. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42022. * * 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
  42023. * * 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
  42024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42025. * @param name defines the name of the mesh
  42026. * @param options defines the options used to create the mesh
  42027. * @param scene defines the hosting scene
  42028. * @returns the tiled ground mesh
  42029. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42030. */
  42031. static CreateTiledGround(name: string, options: {
  42032. xmin: number;
  42033. zmin: number;
  42034. xmax: number;
  42035. zmax: number;
  42036. subdivisions?: {
  42037. w: number;
  42038. h: number;
  42039. };
  42040. precision?: {
  42041. w: number;
  42042. h: number;
  42043. };
  42044. updatable?: boolean;
  42045. }, scene?: Nullable<Scene>): Mesh;
  42046. /**
  42047. * Creates a ground mesh from a height map
  42048. * * The parameter `url` sets the URL of the height map image resource.
  42049. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42050. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42051. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42052. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42053. * * 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.
  42054. * * 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).
  42055. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42057. * @param name defines the name of the mesh
  42058. * @param url defines the url to the height map
  42059. * @param options defines the options used to create the mesh
  42060. * @param scene defines the hosting scene
  42061. * @returns the ground mesh
  42062. * @see https://doc.babylonjs.com/babylon101/height_map
  42063. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42064. */
  42065. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42066. width?: number;
  42067. height?: number;
  42068. subdivisions?: number;
  42069. minHeight?: number;
  42070. maxHeight?: number;
  42071. colorFilter?: Color3;
  42072. alphaFilter?: number;
  42073. updatable?: boolean;
  42074. onReady?: (mesh: GroundMesh) => void;
  42075. }, scene?: Nullable<Scene>): GroundMesh;
  42076. }
  42077. }
  42078. declare module BABYLON {
  42079. /**
  42080. * Class containing static functions to help procedurally build meshes
  42081. */
  42082. export class TorusBuilder {
  42083. /**
  42084. * Creates a torus mesh
  42085. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42086. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42087. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42089. * * 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
  42090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42091. * @param name defines the name of the mesh
  42092. * @param options defines the options used to create the mesh
  42093. * @param scene defines the hosting scene
  42094. * @returns the torus mesh
  42095. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42096. */
  42097. static CreateTorus(name: string, options: {
  42098. diameter?: number;
  42099. thickness?: number;
  42100. tessellation?: number;
  42101. updatable?: boolean;
  42102. sideOrientation?: number;
  42103. frontUVs?: Vector4;
  42104. backUVs?: Vector4;
  42105. }, scene: any): Mesh;
  42106. }
  42107. }
  42108. declare module BABYLON {
  42109. /**
  42110. * Class containing static functions to help procedurally build meshes
  42111. */
  42112. export class CylinderBuilder {
  42113. /**
  42114. * Creates a cylinder or a cone mesh
  42115. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42116. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42117. * * 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.
  42118. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42119. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42120. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42121. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42122. * * 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).
  42123. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42124. * * 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).
  42125. * * 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
  42126. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42127. * * 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
  42128. * * 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.
  42129. * * If `enclose` is false, a ring surface is one element.
  42130. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42131. * * 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
  42132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42133. * * 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
  42134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42135. * @param name defines the name of the mesh
  42136. * @param options defines the options used to create the mesh
  42137. * @param scene defines the hosting scene
  42138. * @returns the cylinder mesh
  42139. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42140. */
  42141. static CreateCylinder(name: string, options: {
  42142. height?: number;
  42143. diameterTop?: number;
  42144. diameterBottom?: number;
  42145. diameter?: number;
  42146. tessellation?: number;
  42147. subdivisions?: number;
  42148. arc?: number;
  42149. faceColors?: Color4[];
  42150. faceUV?: Vector4[];
  42151. updatable?: boolean;
  42152. hasRings?: boolean;
  42153. enclose?: boolean;
  42154. cap?: number;
  42155. sideOrientation?: number;
  42156. frontUVs?: Vector4;
  42157. backUVs?: Vector4;
  42158. }, scene: any): Mesh;
  42159. }
  42160. }
  42161. declare module BABYLON {
  42162. /**
  42163. * States of the webXR experience
  42164. */
  42165. export enum WebXRState {
  42166. /**
  42167. * Transitioning to being in XR mode
  42168. */
  42169. ENTERING_XR = 0,
  42170. /**
  42171. * Transitioning to non XR mode
  42172. */
  42173. EXITING_XR = 1,
  42174. /**
  42175. * In XR mode and presenting
  42176. */
  42177. IN_XR = 2,
  42178. /**
  42179. * Not entered XR mode
  42180. */
  42181. NOT_IN_XR = 3
  42182. }
  42183. /**
  42184. * Abstraction of the XR render target
  42185. */
  42186. export interface WebXRRenderTarget extends IDisposable {
  42187. /**
  42188. * xrpresent context of the canvas which can be used to display/mirror xr content
  42189. */
  42190. canvasContext: WebGLRenderingContext;
  42191. /**
  42192. * xr layer for the canvas
  42193. */
  42194. xrLayer: Nullable<XRWebGLLayer>;
  42195. /**
  42196. * Initializes the xr layer for the session
  42197. * @param xrSession xr session
  42198. * @returns a promise that will resolve once the XR Layer has been created
  42199. */
  42200. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  42201. }
  42202. }
  42203. declare module BABYLON {
  42204. /**
  42205. * COnfiguration object for WebXR output canvas
  42206. */
  42207. export class WebXRManagedOutputCanvasOptions {
  42208. /**
  42209. * Options for this XR Layer output
  42210. */
  42211. canvasOptions: XRWebGLLayerOptions;
  42212. /**
  42213. * CSS styling for a newly created canvas (if not provided)
  42214. */
  42215. newCanvasCssStyle?: string;
  42216. /**
  42217. * Get the default values of the configuration object
  42218. * @returns default values of this configuration object
  42219. */
  42220. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42221. }
  42222. /**
  42223. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42224. */
  42225. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42226. private configuration;
  42227. private _engine;
  42228. private _canvas;
  42229. /**
  42230. * xrpresent context of the canvas which can be used to display/mirror xr content
  42231. */
  42232. canvasContext: WebGLRenderingContext;
  42233. /**
  42234. * xr layer for the canvas
  42235. */
  42236. xrLayer: Nullable<XRWebGLLayer>;
  42237. /**
  42238. * Initializes the xr layer for the session
  42239. * @param xrSession xr session
  42240. * @returns a promise that will resolve once the XR Layer has been created
  42241. */
  42242. initializeXRLayerAsync(xrSession: any): any;
  42243. /**
  42244. * Initializes the canvas to be added/removed upon entering/exiting xr
  42245. * @param engine the Babylon engine
  42246. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42247. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  42248. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  42249. */
  42250. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  42251. /**
  42252. * Disposes of the object
  42253. */
  42254. dispose(): void;
  42255. private _setManagedOutputCanvas;
  42256. private _addCanvas;
  42257. private _removeCanvas;
  42258. }
  42259. }
  42260. declare module BABYLON {
  42261. /**
  42262. * Manages an XRSession to work with Babylon's engine
  42263. * @see https://doc.babylonjs.com/how_to/webxr
  42264. */
  42265. export class WebXRSessionManager implements IDisposable {
  42266. /** The scene which the session should be created for */
  42267. scene: Scene;
  42268. /**
  42269. * Fires every time a new xrFrame arrives which can be used to update the camera
  42270. */
  42271. onXRFrameObservable: Observable<XRFrame>;
  42272. /**
  42273. * Fires when the xr session is ended either by the device or manually done
  42274. */
  42275. onXRSessionEnded: Observable<any>;
  42276. /**
  42277. * Fires when the xr session is ended either by the device or manually done
  42278. */
  42279. onXRSessionInit: Observable<XRSession>;
  42280. /**
  42281. * Underlying xr session
  42282. */
  42283. session: XRSession;
  42284. /**
  42285. * Type of reference space used when creating the session
  42286. */
  42287. referenceSpace: XRReferenceSpace;
  42288. /**
  42289. * Current XR frame
  42290. */
  42291. currentFrame: Nullable<XRFrame>;
  42292. /** WebXR timestamp updated every frame */
  42293. currentTimestamp: number;
  42294. private _xrNavigator;
  42295. private baseLayer;
  42296. private _rttProvider;
  42297. private _sessionEnded;
  42298. /**
  42299. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42300. * @param scene The scene which the session should be created for
  42301. */
  42302. constructor(
  42303. /** The scene which the session should be created for */
  42304. scene: Scene);
  42305. /**
  42306. * Initializes the manager
  42307. * After initialization enterXR can be called to start an XR session
  42308. * @returns Promise which resolves after it is initialized
  42309. */
  42310. initializeAsync(): Promise<void>;
  42311. /**
  42312. * Initializes an xr session
  42313. * @param xrSessionMode mode to initialize
  42314. * @param optionalFeatures defines optional values to pass to the session builder
  42315. * @returns a promise which will resolve once the session has been initialized
  42316. */
  42317. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  42318. /**
  42319. * Sets the reference space on the xr session
  42320. * @param referenceSpace space to set
  42321. * @returns a promise that will resolve once the reference space has been set
  42322. */
  42323. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42324. /**
  42325. * Updates the render state of the session
  42326. * @param state state to set
  42327. * @returns a promise that resolves once the render state has been updated
  42328. */
  42329. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42330. /**
  42331. * Starts rendering to the xr layer
  42332. * @returns a promise that will resolve once rendering has started
  42333. */
  42334. startRenderingToXRAsync(): Promise<void>;
  42335. /**
  42336. * Gets the correct render target texture to be rendered this frame for this eye
  42337. * @param eye the eye for which to get the render target
  42338. * @returns the render target for the specified eye
  42339. */
  42340. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42341. /**
  42342. * Stops the xrSession and restores the renderloop
  42343. * @returns Promise which resolves after it exits XR
  42344. */
  42345. exitXRAsync(): Promise<void>;
  42346. /**
  42347. * Checks if a session would be supported for the creation options specified
  42348. * @param sessionMode session mode to check if supported eg. immersive-vr
  42349. * @returns true if supported
  42350. */
  42351. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42352. /**
  42353. * Creates a WebXRRenderTarget object for the XR session
  42354. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42355. * @param options optional options to provide when creating a new render target
  42356. * @returns a WebXR render target to which the session can render
  42357. */
  42358. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42359. /**
  42360. * @hidden
  42361. * Converts the render layer of xrSession to a render target
  42362. * @param session session to create render target for
  42363. * @param scene scene the new render target should be created for
  42364. * @param baseLayer the webgl layer to create the render target for
  42365. */
  42366. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42367. /**
  42368. * Disposes of the session manager
  42369. */
  42370. dispose(): void;
  42371. /**
  42372. * Gets a promise returning true when fullfiled if the given session mode is supported
  42373. * @param sessionMode defines the session to test
  42374. * @returns a promise
  42375. */
  42376. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42377. }
  42378. }
  42379. declare module BABYLON {
  42380. /**
  42381. * WebXR Camera which holds the views for the xrSession
  42382. * @see https://doc.babylonjs.com/how_to/webxr
  42383. */
  42384. export class WebXRCamera extends FreeCamera {
  42385. /**
  42386. * Is the camera in debug mode. Used when using an emulator
  42387. */
  42388. debugMode: boolean;
  42389. /**
  42390. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42391. * @param name the name of the camera
  42392. * @param scene the scene to add the camera to
  42393. */
  42394. constructor(name: string, scene: Scene);
  42395. private _updateNumberOfRigCameras;
  42396. /** @hidden */
  42397. _updateForDualEyeDebugging(): void;
  42398. /**
  42399. * Updates the cameras position from the current pose information of the XR session
  42400. * @param xrSessionManager the session containing pose information
  42401. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42402. */
  42403. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42404. }
  42405. }
  42406. declare module BABYLON {
  42407. /**
  42408. * Defining the interface required for a (webxr) feature
  42409. */
  42410. export interface IWebXRFeature extends IDisposable {
  42411. /**
  42412. * Attach the feature to the session
  42413. * Will usually be called by the features manager
  42414. *
  42415. * @returns true if successful.
  42416. */
  42417. attach(): boolean;
  42418. /**
  42419. * Detach the feature from the session
  42420. * Will usually be called by the features manager
  42421. *
  42422. * @returns true if successful.
  42423. */
  42424. detach(): boolean;
  42425. }
  42426. /**
  42427. * Defining the constructor of a feature. Used to register the modules.
  42428. */
  42429. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42430. /**
  42431. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42432. * It is mainly used in AR sessions.
  42433. *
  42434. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42435. */
  42436. export class WebXRFeaturesManager implements IDisposable {
  42437. private _xrSessionManager;
  42438. private static readonly _AvailableFeatures;
  42439. /**
  42440. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42441. * Mainly used internally.
  42442. *
  42443. * @param featureName the name of the feature to register
  42444. * @param constructorFunction the function used to construct the module
  42445. * @param version the (babylon) version of the module
  42446. * @param stable is that a stable version of this module
  42447. */
  42448. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42449. /**
  42450. * Returns a constructor of a specific feature.
  42451. *
  42452. * @param featureName the name of the feature to construct
  42453. * @param version the version of the feature to load
  42454. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42455. * @param options optional options provided to the module.
  42456. * @returns a function that, when called, will return a new instance of this feature
  42457. */
  42458. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42459. /**
  42460. * Return the latest unstable version of this feature
  42461. * @param featureName the name of the feature to search
  42462. * @returns the version number. if not found will return -1
  42463. */
  42464. static GetLatestVersionOfFeature(featureName: string): number;
  42465. /**
  42466. * Return the latest stable version of this feature
  42467. * @param featureName the name of the feature to search
  42468. * @returns the version number. if not found will return -1
  42469. */
  42470. static GetStableVersionOfFeature(featureName: string): number;
  42471. /**
  42472. * Can be used to return the list of features currently registered
  42473. *
  42474. * @returns an Array of available features
  42475. */
  42476. static GetAvailableFeatures(): string[];
  42477. /**
  42478. * Gets the versions available for a specific feature
  42479. * @param featureName the name of the feature
  42480. * @returns an array with the available versions
  42481. */
  42482. static GetAvailableVersions(featureName: string): string[];
  42483. private _features;
  42484. /**
  42485. * constructs a new features manages.
  42486. *
  42487. * @param _xrSessionManager an instance of WebXRSessionManager
  42488. */
  42489. constructor(_xrSessionManager: WebXRSessionManager);
  42490. /**
  42491. * 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.
  42492. *
  42493. * @param featureName the name of the feature to load or the class of the feature
  42494. * @param version optional version to load. if not provided the latest version will be enabled
  42495. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42496. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42497. * @returns a new constructed feature or throws an error if feature not found.
  42498. */
  42499. enableFeature(featureName: string | {
  42500. Name: string;
  42501. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42502. /**
  42503. * Used to disable an already-enabled feature
  42504. * @param featureName the feature to disable
  42505. * @returns true if disable was successful
  42506. */
  42507. disableFeature(featureName: string | {
  42508. Name: string;
  42509. }): boolean;
  42510. /**
  42511. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42512. * Can be used during a session to start a feature
  42513. * @param featureName the name of feature to attach
  42514. */
  42515. attachFeature(featureName: string): void;
  42516. /**
  42517. * Can be used inside a session or when the session ends to detach a specific feature
  42518. * @param featureName the name of the feature to detach
  42519. */
  42520. detachFeature(featureName: string): void;
  42521. /**
  42522. * Get the list of enabled features
  42523. * @returns an array of enabled features
  42524. */
  42525. getEnabledFeatures(): string[];
  42526. /**
  42527. * get the implementation of an enabled feature.
  42528. * @param featureName the name of the feature to load
  42529. * @returns the feature class, if found
  42530. */
  42531. getEnabledFeature(featureName: string): IWebXRFeature;
  42532. /**
  42533. * dispose this features manager
  42534. */
  42535. dispose(): void;
  42536. }
  42537. }
  42538. declare module BABYLON {
  42539. /**
  42540. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42541. * @see https://doc.babylonjs.com/how_to/webxr
  42542. */
  42543. export class WebXRExperienceHelper implements IDisposable {
  42544. private scene;
  42545. /**
  42546. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42547. */
  42548. container: AbstractMesh;
  42549. /**
  42550. * Camera used to render xr content
  42551. */
  42552. camera: WebXRCamera;
  42553. /**
  42554. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42555. */
  42556. state: WebXRState;
  42557. private _setState;
  42558. private static _TmpVector;
  42559. /**
  42560. * Fires when the state of the experience helper has changed
  42561. */
  42562. onStateChangedObservable: Observable<WebXRState>;
  42563. /** Session manager used to keep track of xr session */
  42564. sessionManager: WebXRSessionManager;
  42565. /** A features manager for this xr session */
  42566. featuresManager: WebXRFeaturesManager;
  42567. private _nonVRCamera;
  42568. private _originalSceneAutoClear;
  42569. private _supported;
  42570. /**
  42571. * Creates the experience helper
  42572. * @param scene the scene to attach the experience helper to
  42573. * @returns a promise for the experience helper
  42574. */
  42575. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42576. /**
  42577. * Creates a WebXRExperienceHelper
  42578. * @param scene The scene the helper should be created in
  42579. */
  42580. private constructor();
  42581. /**
  42582. * Exits XR mode and returns the scene to its original state
  42583. * @returns promise that resolves after xr mode has exited
  42584. */
  42585. exitXRAsync(): Promise<void>;
  42586. /**
  42587. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42588. * @param sessionMode options for the XR session
  42589. * @param referenceSpaceType frame of reference of the XR session
  42590. * @param renderTarget the output canvas that will be used to enter XR mode
  42591. * @returns promise that resolves after xr mode has entered
  42592. */
  42593. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42594. /**
  42595. * Updates the global position of the camera by moving the camera's container
  42596. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42597. * @param position The desired global position of the camera
  42598. */
  42599. setPositionOfCameraUsingContainer(position: Vector3): void;
  42600. /**
  42601. * Rotates the xr camera by rotating the camera's container around the camera's position
  42602. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42603. * @param rotation the desired quaternion rotation to apply to the camera
  42604. */
  42605. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42606. /**
  42607. * Disposes of the experience helper
  42608. */
  42609. dispose(): void;
  42610. }
  42611. }
  42612. declare module BABYLON {
  42613. /**
  42614. * Represents an XR input
  42615. */
  42616. export class WebXRController {
  42617. private scene;
  42618. /** The underlying input source for the controller */
  42619. inputSource: XRInputSource;
  42620. private parentContainer;
  42621. /**
  42622. * 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
  42623. */
  42624. grip?: AbstractMesh;
  42625. /**
  42626. * Pointer which can be used to select objects or attach a visible laser to
  42627. */
  42628. pointer: AbstractMesh;
  42629. private _gamepadMode;
  42630. /**
  42631. * If available, this is the gamepad object related to this controller.
  42632. * Using this object it is possible to get click events and trackpad changes of the
  42633. * webxr controller that is currently being used.
  42634. */
  42635. gamepadController?: WebVRController;
  42636. /**
  42637. * Event that fires when the controller is removed/disposed
  42638. */
  42639. onDisposeObservable: Observable<{}>;
  42640. private _tmpQuaternion;
  42641. private _tmpVector;
  42642. /**
  42643. * Creates the controller
  42644. * @see https://doc.babylonjs.com/how_to/webxr
  42645. * @param scene the scene which the controller should be associated to
  42646. * @param inputSource the underlying input source for the controller
  42647. * @param parentContainer parent that the controller meshes should be children of
  42648. */
  42649. constructor(scene: Scene,
  42650. /** The underlying input source for the controller */
  42651. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42652. /**
  42653. * Updates the controller pose based on the given XRFrame
  42654. * @param xrFrame xr frame to update the pose with
  42655. * @param referenceSpace reference space to use
  42656. */
  42657. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42658. /**
  42659. * Gets a world space ray coming from the controller
  42660. * @param result the resulting ray
  42661. */
  42662. getWorldPointerRayToRef(result: Ray): void;
  42663. /**
  42664. * Get the scene associated with this controller
  42665. * @returns the scene object
  42666. */
  42667. getScene(): Scene;
  42668. /**
  42669. * Disposes of the object
  42670. */
  42671. dispose(): void;
  42672. }
  42673. }
  42674. declare module BABYLON {
  42675. /**
  42676. * XR input used to track XR inputs such as controllers/rays
  42677. */
  42678. export class WebXRInput implements IDisposable {
  42679. /**
  42680. * Base experience the input listens to
  42681. */
  42682. baseExperience: WebXRExperienceHelper;
  42683. /**
  42684. * XR controllers being tracked
  42685. */
  42686. controllers: Array<WebXRController>;
  42687. private _frameObserver;
  42688. private _stateObserver;
  42689. /**
  42690. * Event when a controller has been connected/added
  42691. */
  42692. onControllerAddedObservable: Observable<WebXRController>;
  42693. /**
  42694. * Event when a controller has been removed/disconnected
  42695. */
  42696. onControllerRemovedObservable: Observable<WebXRController>;
  42697. /**
  42698. * Initializes the WebXRInput
  42699. * @param baseExperience experience helper which the input should be created for
  42700. */
  42701. constructor(
  42702. /**
  42703. * Base experience the input listens to
  42704. */
  42705. baseExperience: WebXRExperienceHelper);
  42706. private _onInputSourcesChange;
  42707. private _addAndRemoveControllers;
  42708. /**
  42709. * Disposes of the object
  42710. */
  42711. dispose(): void;
  42712. }
  42713. }
  42714. declare module BABYLON {
  42715. /**
  42716. * Class used to represent data loading progression
  42717. */
  42718. export class SceneLoaderProgressEvent {
  42719. /** defines if data length to load can be evaluated */
  42720. readonly lengthComputable: boolean;
  42721. /** defines the loaded data length */
  42722. readonly loaded: number;
  42723. /** defines the data length to load */
  42724. readonly total: number;
  42725. /**
  42726. * Create a new progress event
  42727. * @param lengthComputable defines if data length to load can be evaluated
  42728. * @param loaded defines the loaded data length
  42729. * @param total defines the data length to load
  42730. */
  42731. constructor(
  42732. /** defines if data length to load can be evaluated */
  42733. lengthComputable: boolean,
  42734. /** defines the loaded data length */
  42735. loaded: number,
  42736. /** defines the data length to load */
  42737. total: number);
  42738. /**
  42739. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42740. * @param event defines the source event
  42741. * @returns a new SceneLoaderProgressEvent
  42742. */
  42743. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42744. }
  42745. /**
  42746. * Interface used by SceneLoader plugins to define supported file extensions
  42747. */
  42748. export interface ISceneLoaderPluginExtensions {
  42749. /**
  42750. * Defines the list of supported extensions
  42751. */
  42752. [extension: string]: {
  42753. isBinary: boolean;
  42754. };
  42755. }
  42756. /**
  42757. * Interface used by SceneLoader plugin factory
  42758. */
  42759. export interface ISceneLoaderPluginFactory {
  42760. /**
  42761. * Defines the name of the factory
  42762. */
  42763. name: string;
  42764. /**
  42765. * Function called to create a new plugin
  42766. * @return the new plugin
  42767. */
  42768. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42769. /**
  42770. * The callback that returns true if the data can be directly loaded.
  42771. * @param data string containing the file data
  42772. * @returns if the data can be loaded directly
  42773. */
  42774. canDirectLoad?(data: string): boolean;
  42775. }
  42776. /**
  42777. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42778. */
  42779. export interface ISceneLoaderPluginBase {
  42780. /**
  42781. * The friendly name of this plugin.
  42782. */
  42783. name: string;
  42784. /**
  42785. * The file extensions supported by this plugin.
  42786. */
  42787. extensions: string | ISceneLoaderPluginExtensions;
  42788. /**
  42789. * The callback called when loading from a url.
  42790. * @param scene scene loading this url
  42791. * @param url url to load
  42792. * @param onSuccess callback called when the file successfully loads
  42793. * @param onProgress callback called while file is loading (if the server supports this mode)
  42794. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42795. * @param onError callback called when the file fails to load
  42796. * @returns a file request object
  42797. */
  42798. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42799. /**
  42800. * The callback called when loading from a file object.
  42801. * @param scene scene loading this file
  42802. * @param file defines the file to load
  42803. * @param onSuccess defines the callback to call when data is loaded
  42804. * @param onProgress defines the callback to call during loading process
  42805. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42806. * @param onError defines the callback to call when an error occurs
  42807. * @returns a file request object
  42808. */
  42809. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42810. /**
  42811. * The callback that returns true if the data can be directly loaded.
  42812. * @param data string containing the file data
  42813. * @returns if the data can be loaded directly
  42814. */
  42815. canDirectLoad?(data: string): boolean;
  42816. /**
  42817. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42818. * @param scene scene loading this data
  42819. * @param data string containing the data
  42820. * @returns data to pass to the plugin
  42821. */
  42822. directLoad?(scene: Scene, data: string): any;
  42823. /**
  42824. * The callback that allows custom handling of the root url based on the response url.
  42825. * @param rootUrl the original root url
  42826. * @param responseURL the response url if available
  42827. * @returns the new root url
  42828. */
  42829. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42830. }
  42831. /**
  42832. * Interface used to define a SceneLoader plugin
  42833. */
  42834. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42835. /**
  42836. * Import meshes into a scene.
  42837. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42838. * @param scene The scene to import into
  42839. * @param data The data to import
  42840. * @param rootUrl The root url for scene and resources
  42841. * @param meshes The meshes array to import into
  42842. * @param particleSystems The particle systems array to import into
  42843. * @param skeletons The skeletons array to import into
  42844. * @param onError The callback when import fails
  42845. * @returns True if successful or false otherwise
  42846. */
  42847. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42848. /**
  42849. * Load into a scene.
  42850. * @param scene The scene to load into
  42851. * @param data The data to import
  42852. * @param rootUrl The root url for scene and resources
  42853. * @param onError The callback when import fails
  42854. * @returns True if successful or false otherwise
  42855. */
  42856. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42857. /**
  42858. * Load into an asset container.
  42859. * @param scene The scene to load into
  42860. * @param data The data to import
  42861. * @param rootUrl The root url for scene and resources
  42862. * @param onError The callback when import fails
  42863. * @returns The loaded asset container
  42864. */
  42865. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42866. }
  42867. /**
  42868. * Interface used to define an async SceneLoader plugin
  42869. */
  42870. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42871. /**
  42872. * Import meshes into a scene.
  42873. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42874. * @param scene The scene to import into
  42875. * @param data The data to import
  42876. * @param rootUrl The root url for scene and resources
  42877. * @param onProgress The callback when the load progresses
  42878. * @param fileName Defines the name of the file to load
  42879. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42880. */
  42881. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42882. meshes: AbstractMesh[];
  42883. particleSystems: IParticleSystem[];
  42884. skeletons: Skeleton[];
  42885. animationGroups: AnimationGroup[];
  42886. }>;
  42887. /**
  42888. * Load into a scene.
  42889. * @param scene The scene to load into
  42890. * @param data The data to import
  42891. * @param rootUrl The root url for scene and resources
  42892. * @param onProgress The callback when the load progresses
  42893. * @param fileName Defines the name of the file to load
  42894. * @returns Nothing
  42895. */
  42896. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42897. /**
  42898. * Load into an asset container.
  42899. * @param scene The scene to load into
  42900. * @param data The data to import
  42901. * @param rootUrl The root url for scene and resources
  42902. * @param onProgress The callback when the load progresses
  42903. * @param fileName Defines the name of the file to load
  42904. * @returns The loaded asset container
  42905. */
  42906. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42907. }
  42908. /**
  42909. * Mode that determines how to handle old animation groups before loading new ones.
  42910. */
  42911. export enum SceneLoaderAnimationGroupLoadingMode {
  42912. /**
  42913. * Reset all old animations to initial state then dispose them.
  42914. */
  42915. Clean = 0,
  42916. /**
  42917. * Stop all old animations.
  42918. */
  42919. Stop = 1,
  42920. /**
  42921. * Restart old animations from first frame.
  42922. */
  42923. Sync = 2,
  42924. /**
  42925. * Old animations remains untouched.
  42926. */
  42927. NoSync = 3
  42928. }
  42929. /**
  42930. * Class used to load scene from various file formats using registered plugins
  42931. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42932. */
  42933. export class SceneLoader {
  42934. /**
  42935. * No logging while loading
  42936. */
  42937. static readonly NO_LOGGING: number;
  42938. /**
  42939. * Minimal logging while loading
  42940. */
  42941. static readonly MINIMAL_LOGGING: number;
  42942. /**
  42943. * Summary logging while loading
  42944. */
  42945. static readonly SUMMARY_LOGGING: number;
  42946. /**
  42947. * Detailled logging while loading
  42948. */
  42949. static readonly DETAILED_LOGGING: number;
  42950. /**
  42951. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42952. */
  42953. static get ForceFullSceneLoadingForIncremental(): boolean;
  42954. static set ForceFullSceneLoadingForIncremental(value: boolean);
  42955. /**
  42956. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42957. */
  42958. static get ShowLoadingScreen(): boolean;
  42959. static set ShowLoadingScreen(value: boolean);
  42960. /**
  42961. * Defines the current logging level (while loading the scene)
  42962. * @ignorenaming
  42963. */
  42964. static get loggingLevel(): number;
  42965. static set loggingLevel(value: number);
  42966. /**
  42967. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42968. */
  42969. static get CleanBoneMatrixWeights(): boolean;
  42970. static set CleanBoneMatrixWeights(value: boolean);
  42971. /**
  42972. * Event raised when a plugin is used to load a scene
  42973. */
  42974. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42975. private static _registeredPlugins;
  42976. private static _getDefaultPlugin;
  42977. private static _getPluginForExtension;
  42978. private static _getPluginForDirectLoad;
  42979. private static _getPluginForFilename;
  42980. private static _getDirectLoad;
  42981. private static _loadData;
  42982. private static _getFileInfo;
  42983. /**
  42984. * Gets a plugin that can load the given extension
  42985. * @param extension defines the extension to load
  42986. * @returns a plugin or null if none works
  42987. */
  42988. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42989. /**
  42990. * Gets a boolean indicating that the given extension can be loaded
  42991. * @param extension defines the extension to load
  42992. * @returns true if the extension is supported
  42993. */
  42994. static IsPluginForExtensionAvailable(extension: string): boolean;
  42995. /**
  42996. * Adds a new plugin to the list of registered plugins
  42997. * @param plugin defines the plugin to add
  42998. */
  42999. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43000. /**
  43001. * Import meshes into a scene
  43002. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43003. * @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)
  43004. * @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)
  43005. * @param scene the instance of BABYLON.Scene to append to
  43006. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43007. * @param onProgress a callback with a progress event for each file being loaded
  43008. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43009. * @param pluginExtension the extension used to determine the plugin
  43010. * @returns The loaded plugin
  43011. */
  43012. 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>;
  43013. /**
  43014. * Import meshes into a scene
  43015. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43016. * @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)
  43017. * @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)
  43018. * @param scene the instance of BABYLON.Scene to append to
  43019. * @param onProgress a callback with a progress event for each file being loaded
  43020. * @param pluginExtension the extension used to determine the plugin
  43021. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43022. */
  43023. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43024. meshes: AbstractMesh[];
  43025. particleSystems: IParticleSystem[];
  43026. skeletons: Skeleton[];
  43027. animationGroups: AnimationGroup[];
  43028. }>;
  43029. /**
  43030. * Load a scene
  43031. * @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)
  43032. * @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)
  43033. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43034. * @param onSuccess a callback with the scene when import succeeds
  43035. * @param onProgress a callback with a progress event for each file being loaded
  43036. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43037. * @param pluginExtension the extension used to determine the plugin
  43038. * @returns The loaded plugin
  43039. */
  43040. 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>;
  43041. /**
  43042. * Load a scene
  43043. * @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)
  43044. * @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)
  43045. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43046. * @param onProgress a callback with a progress event for each file being loaded
  43047. * @param pluginExtension the extension used to determine the plugin
  43048. * @returns The loaded scene
  43049. */
  43050. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43051. /**
  43052. * Append a scene
  43053. * @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)
  43054. * @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)
  43055. * @param scene is the instance of BABYLON.Scene to append to
  43056. * @param onSuccess a callback with the scene when import succeeds
  43057. * @param onProgress a callback with a progress event for each file being loaded
  43058. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43059. * @param pluginExtension the extension used to determine the plugin
  43060. * @returns The loaded plugin
  43061. */
  43062. 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>;
  43063. /**
  43064. * Append a scene
  43065. * @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)
  43066. * @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)
  43067. * @param scene is the instance of BABYLON.Scene to append to
  43068. * @param onProgress a callback with a progress event for each file being loaded
  43069. * @param pluginExtension the extension used to determine the plugin
  43070. * @returns The given scene
  43071. */
  43072. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43073. /**
  43074. * Load a scene into an asset container
  43075. * @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)
  43076. * @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)
  43077. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43078. * @param onSuccess a callback with the scene when import succeeds
  43079. * @param onProgress a callback with a progress event for each file being loaded
  43080. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43081. * @param pluginExtension the extension used to determine the plugin
  43082. * @returns The loaded plugin
  43083. */
  43084. 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>;
  43085. /**
  43086. * Load a scene into an asset container
  43087. * @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)
  43088. * @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)
  43089. * @param scene is the instance of Scene to append to
  43090. * @param onProgress a callback with a progress event for each file being loaded
  43091. * @param pluginExtension the extension used to determine the plugin
  43092. * @returns The loaded asset container
  43093. */
  43094. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43095. /**
  43096. * Import animations from a file into a scene
  43097. * @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)
  43098. * @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)
  43099. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43100. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43101. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43102. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43103. * @param onSuccess a callback with the scene when import succeeds
  43104. * @param onProgress a callback with a progress event for each file being loaded
  43105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43106. */
  43107. 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;
  43108. /**
  43109. * Import animations from a file into a scene
  43110. * @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)
  43111. * @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)
  43112. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43113. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43114. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43115. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43116. * @param onSuccess a callback with the scene when import succeeds
  43117. * @param onProgress a callback with a progress event for each file being loaded
  43118. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43119. * @returns the updated scene with imported animations
  43120. */
  43121. 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>;
  43122. }
  43123. }
  43124. declare module BABYLON {
  43125. /**
  43126. * Generic Controller
  43127. */
  43128. export class GenericController extends WebVRController {
  43129. /**
  43130. * Base Url for the controller model.
  43131. */
  43132. static readonly MODEL_BASE_URL: string;
  43133. /**
  43134. * File name for the controller model.
  43135. */
  43136. static readonly MODEL_FILENAME: string;
  43137. /**
  43138. * Creates a new GenericController from a gamepad
  43139. * @param vrGamepad the gamepad that the controller should be created from
  43140. */
  43141. constructor(vrGamepad: any);
  43142. /**
  43143. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43144. * @param scene scene in which to add meshes
  43145. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43146. */
  43147. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43148. /**
  43149. * Called once for each button that changed state since the last frame
  43150. * @param buttonIdx Which button index changed
  43151. * @param state New state of the button
  43152. * @param changes Which properties on the state changed since last frame
  43153. */
  43154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43155. }
  43156. }
  43157. declare module BABYLON {
  43158. /**
  43159. * Defines the WindowsMotionController object that the state of the windows motion controller
  43160. */
  43161. export class WindowsMotionController extends WebVRController {
  43162. /**
  43163. * The base url used to load the left and right controller models
  43164. */
  43165. static MODEL_BASE_URL: string;
  43166. /**
  43167. * The name of the left controller model file
  43168. */
  43169. static MODEL_LEFT_FILENAME: string;
  43170. /**
  43171. * The name of the right controller model file
  43172. */
  43173. static MODEL_RIGHT_FILENAME: string;
  43174. /**
  43175. * The controller name prefix for this controller type
  43176. */
  43177. static readonly GAMEPAD_ID_PREFIX: string;
  43178. /**
  43179. * The controller id pattern for this controller type
  43180. */
  43181. private static readonly GAMEPAD_ID_PATTERN;
  43182. private _loadedMeshInfo;
  43183. protected readonly _mapping: {
  43184. buttons: string[];
  43185. buttonMeshNames: {
  43186. 'trigger': string;
  43187. 'menu': string;
  43188. 'grip': string;
  43189. 'thumbstick': string;
  43190. 'trackpad': string;
  43191. };
  43192. buttonObservableNames: {
  43193. 'trigger': string;
  43194. 'menu': string;
  43195. 'grip': string;
  43196. 'thumbstick': string;
  43197. 'trackpad': string;
  43198. };
  43199. axisMeshNames: string[];
  43200. pointingPoseMeshName: string;
  43201. };
  43202. /**
  43203. * Fired when the trackpad on this controller is clicked
  43204. */
  43205. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43206. /**
  43207. * Fired when the trackpad on this controller is modified
  43208. */
  43209. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43210. /**
  43211. * The current x and y values of this controller's trackpad
  43212. */
  43213. trackpad: StickValues;
  43214. /**
  43215. * Creates a new WindowsMotionController from a gamepad
  43216. * @param vrGamepad the gamepad that the controller should be created from
  43217. */
  43218. constructor(vrGamepad: any);
  43219. /**
  43220. * Fired when the trigger on this controller is modified
  43221. */
  43222. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43223. /**
  43224. * Fired when the menu button on this controller is modified
  43225. */
  43226. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43227. /**
  43228. * Fired when the grip button on this controller is modified
  43229. */
  43230. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43231. /**
  43232. * Fired when the thumbstick button on this controller is modified
  43233. */
  43234. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43235. /**
  43236. * Fired when the touchpad button on this controller is modified
  43237. */
  43238. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43239. /**
  43240. * Fired when the touchpad values on this controller are modified
  43241. */
  43242. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  43243. protected _updateTrackpad(): void;
  43244. /**
  43245. * Called once per frame by the engine.
  43246. */
  43247. update(): void;
  43248. /**
  43249. * Called once for each button that changed state since the last frame
  43250. * @param buttonIdx Which button index changed
  43251. * @param state New state of the button
  43252. * @param changes Which properties on the state changed since last frame
  43253. */
  43254. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43255. /**
  43256. * Moves the buttons on the controller mesh based on their current state
  43257. * @param buttonName the name of the button to move
  43258. * @param buttonValue the value of the button which determines the buttons new position
  43259. */
  43260. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43261. /**
  43262. * Moves the axis on the controller mesh based on its current state
  43263. * @param axis the index of the axis
  43264. * @param axisValue the value of the axis which determines the meshes new position
  43265. * @hidden
  43266. */
  43267. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43268. /**
  43269. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43270. * @param scene scene in which to add meshes
  43271. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43272. */
  43273. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43274. /**
  43275. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43276. * can be transformed by button presses and axes values, based on this._mapping.
  43277. *
  43278. * @param scene scene in which the meshes exist
  43279. * @param meshes list of meshes that make up the controller model to process
  43280. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43281. */
  43282. private processModel;
  43283. private createMeshInfo;
  43284. /**
  43285. * Gets the ray of the controller in the direction the controller is pointing
  43286. * @param length the length the resulting ray should be
  43287. * @returns a ray in the direction the controller is pointing
  43288. */
  43289. getForwardRay(length?: number): Ray;
  43290. /**
  43291. * Disposes of the controller
  43292. */
  43293. dispose(): void;
  43294. }
  43295. /**
  43296. * This class represents a new windows motion controller in XR.
  43297. */
  43298. export class XRWindowsMotionController extends WindowsMotionController {
  43299. /**
  43300. * Changing the original WIndowsMotionController mapping to fir the new mapping
  43301. */
  43302. protected readonly _mapping: {
  43303. buttons: string[];
  43304. buttonMeshNames: {
  43305. 'trigger': string;
  43306. 'menu': string;
  43307. 'grip': string;
  43308. 'thumbstick': string;
  43309. 'trackpad': string;
  43310. };
  43311. buttonObservableNames: {
  43312. 'trigger': string;
  43313. 'menu': string;
  43314. 'grip': string;
  43315. 'thumbstick': string;
  43316. 'trackpad': string;
  43317. };
  43318. axisMeshNames: string[];
  43319. pointingPoseMeshName: string;
  43320. };
  43321. /**
  43322. * Construct a new XR-Based windows motion controller
  43323. *
  43324. * @param gamepadInfo the gamepad object from the browser
  43325. */
  43326. constructor(gamepadInfo: any);
  43327. /**
  43328. * holds the thumbstick values (X,Y)
  43329. */
  43330. thumbstickValues: StickValues;
  43331. /**
  43332. * Fired when the thumbstick on this controller is clicked
  43333. */
  43334. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  43335. /**
  43336. * Fired when the thumbstick on this controller is modified
  43337. */
  43338. onThumbstickValuesChangedObservable: Observable<StickValues>;
  43339. /**
  43340. * Fired when the touchpad button on this controller is modified
  43341. */
  43342. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43343. /**
  43344. * Fired when the touchpad values on this controller are modified
  43345. */
  43346. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43347. /**
  43348. * Fired when the thumbstick button on this controller is modified
  43349. * here to prevent breaking changes
  43350. */
  43351. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43352. /**
  43353. * updating the thumbstick(!) and not the trackpad.
  43354. * This is named this way due to the difference between WebVR and XR and to avoid
  43355. * changing the parent class.
  43356. */
  43357. protected _updateTrackpad(): void;
  43358. /**
  43359. * Disposes the class with joy
  43360. */
  43361. dispose(): void;
  43362. }
  43363. }
  43364. declare module BABYLON {
  43365. /**
  43366. * Oculus Touch Controller
  43367. */
  43368. export class OculusTouchController extends WebVRController {
  43369. /**
  43370. * Base Url for the controller model.
  43371. */
  43372. static MODEL_BASE_URL: string;
  43373. /**
  43374. * File name for the left controller model.
  43375. */
  43376. static MODEL_LEFT_FILENAME: string;
  43377. /**
  43378. * File name for the right controller model.
  43379. */
  43380. static MODEL_RIGHT_FILENAME: string;
  43381. /**
  43382. * Base Url for the Quest controller model.
  43383. */
  43384. static QUEST_MODEL_BASE_URL: string;
  43385. /**
  43386. * @hidden
  43387. * If the controllers are running on a device that needs the updated Quest controller models
  43388. */
  43389. static _IsQuest: boolean;
  43390. /**
  43391. * Fired when the secondary trigger on this controller is modified
  43392. */
  43393. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43394. /**
  43395. * Fired when the thumb rest on this controller is modified
  43396. */
  43397. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43398. /**
  43399. * Creates a new OculusTouchController from a gamepad
  43400. * @param vrGamepad the gamepad that the controller should be created from
  43401. */
  43402. constructor(vrGamepad: any);
  43403. /**
  43404. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43405. * @param scene scene in which to add meshes
  43406. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43407. */
  43408. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43409. /**
  43410. * Fired when the A button on this controller is modified
  43411. */
  43412. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43413. /**
  43414. * Fired when the B button on this controller is modified
  43415. */
  43416. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43417. /**
  43418. * Fired when the X button on this controller is modified
  43419. */
  43420. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43421. /**
  43422. * Fired when the Y button on this controller is modified
  43423. */
  43424. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43425. /**
  43426. * Called once for each button that changed state since the last frame
  43427. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43428. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43429. * 2) secondary trigger (same)
  43430. * 3) A (right) X (left), touch, pressed = value
  43431. * 4) B / Y
  43432. * 5) thumb rest
  43433. * @param buttonIdx Which button index changed
  43434. * @param state New state of the button
  43435. * @param changes Which properties on the state changed since last frame
  43436. */
  43437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43438. }
  43439. }
  43440. declare module BABYLON {
  43441. /**
  43442. * Vive Controller
  43443. */
  43444. export class ViveController extends WebVRController {
  43445. /**
  43446. * Base Url for the controller model.
  43447. */
  43448. static MODEL_BASE_URL: string;
  43449. /**
  43450. * File name for the controller model.
  43451. */
  43452. static MODEL_FILENAME: string;
  43453. /**
  43454. * Creates a new ViveController from a gamepad
  43455. * @param vrGamepad the gamepad that the controller should be created from
  43456. */
  43457. constructor(vrGamepad: any);
  43458. /**
  43459. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43460. * @param scene scene in which to add meshes
  43461. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43462. */
  43463. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43464. /**
  43465. * Fired when the left button on this controller is modified
  43466. */
  43467. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43468. /**
  43469. * Fired when the right button on this controller is modified
  43470. */
  43471. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43472. /**
  43473. * Fired when the menu button on this controller is modified
  43474. */
  43475. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  43476. /**
  43477. * Called once for each button that changed state since the last frame
  43478. * Vive mapping:
  43479. * 0: touchpad
  43480. * 1: trigger
  43481. * 2: left AND right buttons
  43482. * 3: menu button
  43483. * @param buttonIdx Which button index changed
  43484. * @param state New state of the button
  43485. * @param changes Which properties on the state changed since last frame
  43486. */
  43487. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43488. }
  43489. }
  43490. declare module BABYLON {
  43491. /**
  43492. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43493. */
  43494. export class WebXRControllerModelLoader {
  43495. /**
  43496. * an observable that triggers when a new model (the mesh itself) was initialized.
  43497. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43498. */
  43499. onControllerModelLoaded: Observable<WebXRController>;
  43500. /**
  43501. * Creates the WebXRControllerModelLoader
  43502. * @param input xr input that creates the controllers
  43503. */
  43504. constructor(input: WebXRInput);
  43505. }
  43506. }
  43507. declare module BABYLON {
  43508. /**
  43509. * Handles pointer input automatically for the pointer of XR controllers
  43510. */
  43511. export class WebXRControllerPointerSelection {
  43512. private static _idCounter;
  43513. private _tmpRay;
  43514. /**
  43515. * Creates a WebXRControllerPointerSelection
  43516. * @param input input manager to setup pointer selection
  43517. */
  43518. constructor(input: WebXRInput);
  43519. private _convertNormalToDirectionOfRay;
  43520. private _updatePointerDistance;
  43521. }
  43522. }
  43523. declare module BABYLON {
  43524. /**
  43525. * Enables teleportation
  43526. */
  43527. export class WebXRControllerTeleportation {
  43528. private _teleportationFillColor;
  43529. private _teleportationBorderColor;
  43530. private _tmpRay;
  43531. private _tmpVector;
  43532. /**
  43533. * when set to true (default) teleportation will wait for thumbstick changes.
  43534. * When set to false teleportation will be disabled.
  43535. *
  43536. * If set to false while teleporting results can be unexpected.
  43537. */
  43538. enabled: boolean;
  43539. /**
  43540. * Creates a WebXRControllerTeleportation
  43541. * @param input input manager to add teleportation to
  43542. * @param floorMeshes floormeshes which can be teleported to
  43543. */
  43544. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43545. }
  43546. }
  43547. declare module BABYLON {
  43548. /**
  43549. * Button which can be used to enter a different mode of XR
  43550. */
  43551. export class WebXREnterExitUIButton {
  43552. /** button element */
  43553. element: HTMLElement;
  43554. /** XR initialization options for the button */
  43555. sessionMode: XRSessionMode;
  43556. /** Reference space type */
  43557. referenceSpaceType: XRReferenceSpaceType;
  43558. /**
  43559. * Creates a WebXREnterExitUIButton
  43560. * @param element button element
  43561. * @param sessionMode XR initialization session mode
  43562. * @param referenceSpaceType the type of reference space to be used
  43563. */
  43564. constructor(
  43565. /** button element */
  43566. element: HTMLElement,
  43567. /** XR initialization options for the button */
  43568. sessionMode: XRSessionMode,
  43569. /** Reference space type */
  43570. referenceSpaceType: XRReferenceSpaceType);
  43571. /**
  43572. * Overwritable function which can be used to update the button's visuals when the state changes
  43573. * @param activeButton the current active button in the UI
  43574. */
  43575. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43576. }
  43577. /**
  43578. * Options to create the webXR UI
  43579. */
  43580. export class WebXREnterExitUIOptions {
  43581. /**
  43582. * Context to enter xr with
  43583. */
  43584. renderTarget?: Nullable<WebXRRenderTarget>;
  43585. /**
  43586. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43587. */
  43588. customButtons?: Array<WebXREnterExitUIButton>;
  43589. /**
  43590. * A session mode to use when creating the default button.
  43591. * Default is immersive-vr
  43592. */
  43593. sessionMode?: XRSessionMode;
  43594. /**
  43595. * A reference space type to use when creating the default button.
  43596. * Default is local-floor
  43597. */
  43598. referenceSpaceType?: XRReferenceSpaceType;
  43599. }
  43600. /**
  43601. * UI to allow the user to enter/exit XR mode
  43602. */
  43603. export class WebXREnterExitUI implements IDisposable {
  43604. private scene;
  43605. /** version of the options passed to this UI */
  43606. options: WebXREnterExitUIOptions;
  43607. private _overlay;
  43608. private _buttons;
  43609. private _activeButton;
  43610. /**
  43611. * Fired every time the active button is changed.
  43612. *
  43613. * When xr is entered via a button that launches xr that button will be the callback parameter
  43614. *
  43615. * When exiting xr the callback parameter will be null)
  43616. */
  43617. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43618. /**
  43619. * Creates UI to allow the user to enter/exit XR mode
  43620. * @param scene the scene to add the ui to
  43621. * @param helper the xr experience helper to enter/exit xr with
  43622. * @param options options to configure the UI
  43623. * @returns the created ui
  43624. */
  43625. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43626. /**
  43627. *
  43628. * @param scene babylon scene object to use
  43629. * @param options (read-only) version of the options passed to this UI
  43630. */
  43631. private constructor();
  43632. private _updateButtons;
  43633. /**
  43634. * Disposes of the object
  43635. */
  43636. dispose(): void;
  43637. }
  43638. }
  43639. declare module BABYLON {
  43640. /**
  43641. * Options for the default xr helper
  43642. */
  43643. export class WebXRDefaultExperienceOptions {
  43644. /**
  43645. * Floor meshes that should be used for teleporting
  43646. */
  43647. floorMeshes: Array<AbstractMesh>;
  43648. /**
  43649. * Enable or disable default UI to enter XR
  43650. */
  43651. disableDefaultUI?: boolean;
  43652. /**
  43653. * optional configuration for the output canvas
  43654. */
  43655. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43656. /**
  43657. * optional UI options. This can be used among other to change session mode and reference space type
  43658. */
  43659. uiOptions?: WebXREnterExitUIOptions;
  43660. }
  43661. /**
  43662. * Default experience which provides a similar setup to the previous webVRExperience
  43663. */
  43664. export class WebXRDefaultExperience {
  43665. /**
  43666. * Base experience
  43667. */
  43668. baseExperience: WebXRExperienceHelper;
  43669. /**
  43670. * Input experience extension
  43671. */
  43672. input: WebXRInput;
  43673. /**
  43674. * Loads the controller models
  43675. */
  43676. controllerModelLoader: WebXRControllerModelLoader;
  43677. /**
  43678. * Enables laser pointer and selection
  43679. */
  43680. pointerSelection: WebXRControllerPointerSelection;
  43681. /**
  43682. * Enables teleportation
  43683. */
  43684. teleportation: WebXRControllerTeleportation;
  43685. /**
  43686. * Enables ui for entering/exiting xr
  43687. */
  43688. enterExitUI: WebXREnterExitUI;
  43689. /**
  43690. * Default target xr should render to
  43691. */
  43692. renderTarget: WebXRRenderTarget;
  43693. /**
  43694. * Creates the default xr experience
  43695. * @param scene scene
  43696. * @param options options for basic configuration
  43697. * @returns resulting WebXRDefaultExperience
  43698. */
  43699. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43700. private constructor();
  43701. /**
  43702. * DIsposes of the experience helper
  43703. */
  43704. dispose(): void;
  43705. }
  43706. }
  43707. declare module BABYLON {
  43708. /**
  43709. * Options to modify the vr teleportation behavior.
  43710. */
  43711. export interface VRTeleportationOptions {
  43712. /**
  43713. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43714. */
  43715. floorMeshName?: string;
  43716. /**
  43717. * A list of meshes to be used as the teleportation floor. (default: empty)
  43718. */
  43719. floorMeshes?: Mesh[];
  43720. /**
  43721. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43722. */
  43723. teleportationMode?: number;
  43724. /**
  43725. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43726. */
  43727. teleportationTime?: number;
  43728. /**
  43729. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43730. */
  43731. teleportationSpeed?: number;
  43732. /**
  43733. * The easing function used in the animation or null for Linear. (default CircleEase)
  43734. */
  43735. easingFunction?: EasingFunction;
  43736. }
  43737. /**
  43738. * Options to modify the vr experience helper's behavior.
  43739. */
  43740. export interface VRExperienceHelperOptions extends WebVROptions {
  43741. /**
  43742. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43743. */
  43744. createDeviceOrientationCamera?: boolean;
  43745. /**
  43746. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43747. */
  43748. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43749. /**
  43750. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43751. */
  43752. laserToggle?: boolean;
  43753. /**
  43754. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43755. */
  43756. floorMeshes?: Mesh[];
  43757. /**
  43758. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43759. */
  43760. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43761. /**
  43762. * Defines if WebXR should be used instead of WebVR (if available)
  43763. */
  43764. useXR?: boolean;
  43765. }
  43766. /**
  43767. * Event containing information after VR has been entered
  43768. */
  43769. export class OnAfterEnteringVRObservableEvent {
  43770. /**
  43771. * If entering vr was successful
  43772. */
  43773. success: boolean;
  43774. }
  43775. /**
  43776. * Helps to quickly add VR support to an existing scene.
  43777. * See http://doc.babylonjs.com/how_to/webvr_helper
  43778. */
  43779. export class VRExperienceHelper {
  43780. /** Options to modify the vr experience helper's behavior. */
  43781. webVROptions: VRExperienceHelperOptions;
  43782. private _scene;
  43783. private _position;
  43784. private _btnVR;
  43785. private _btnVRDisplayed;
  43786. private _webVRsupported;
  43787. private _webVRready;
  43788. private _webVRrequesting;
  43789. private _webVRpresenting;
  43790. private _hasEnteredVR;
  43791. private _fullscreenVRpresenting;
  43792. private _inputElement;
  43793. private _webVRCamera;
  43794. private _vrDeviceOrientationCamera;
  43795. private _deviceOrientationCamera;
  43796. private _existingCamera;
  43797. private _onKeyDown;
  43798. private _onVrDisplayPresentChange;
  43799. private _onVRDisplayChanged;
  43800. private _onVRRequestPresentStart;
  43801. private _onVRRequestPresentComplete;
  43802. /**
  43803. * 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)
  43804. */
  43805. enableGazeEvenWhenNoPointerLock: boolean;
  43806. /**
  43807. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43808. */
  43809. exitVROnDoubleTap: boolean;
  43810. /**
  43811. * Observable raised right before entering VR.
  43812. */
  43813. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43814. /**
  43815. * Observable raised when entering VR has completed.
  43816. */
  43817. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43818. /**
  43819. * Observable raised when exiting VR.
  43820. */
  43821. onExitingVRObservable: Observable<VRExperienceHelper>;
  43822. /**
  43823. * Observable raised when controller mesh is loaded.
  43824. */
  43825. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43826. /** Return this.onEnteringVRObservable
  43827. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43828. */
  43829. get onEnteringVR(): Observable<VRExperienceHelper>;
  43830. /** Return this.onExitingVRObservable
  43831. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43832. */
  43833. get onExitingVR(): Observable<VRExperienceHelper>;
  43834. /** Return this.onControllerMeshLoadedObservable
  43835. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43836. */
  43837. get onControllerMeshLoaded(): Observable<WebVRController>;
  43838. private _rayLength;
  43839. private _useCustomVRButton;
  43840. private _teleportationRequested;
  43841. private _teleportActive;
  43842. private _floorMeshName;
  43843. private _floorMeshesCollection;
  43844. private _teleportationMode;
  43845. private _teleportationTime;
  43846. private _teleportationSpeed;
  43847. private _teleportationEasing;
  43848. private _rotationAllowed;
  43849. private _teleportBackwardsVector;
  43850. private _teleportationTarget;
  43851. private _isDefaultTeleportationTarget;
  43852. private _postProcessMove;
  43853. private _teleportationFillColor;
  43854. private _teleportationBorderColor;
  43855. private _rotationAngle;
  43856. private _haloCenter;
  43857. private _cameraGazer;
  43858. private _padSensibilityUp;
  43859. private _padSensibilityDown;
  43860. private _leftController;
  43861. private _rightController;
  43862. /**
  43863. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43864. */
  43865. onNewMeshSelected: Observable<AbstractMesh>;
  43866. /**
  43867. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43868. * This observable will provide the mesh and the controller used to select the mesh
  43869. */
  43870. onMeshSelectedWithController: Observable<{
  43871. mesh: AbstractMesh;
  43872. controller: WebVRController;
  43873. }>;
  43874. /**
  43875. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43876. */
  43877. onNewMeshPicked: Observable<PickingInfo>;
  43878. private _circleEase;
  43879. /**
  43880. * Observable raised before camera teleportation
  43881. */
  43882. onBeforeCameraTeleport: Observable<Vector3>;
  43883. /**
  43884. * Observable raised after camera teleportation
  43885. */
  43886. onAfterCameraTeleport: Observable<Vector3>;
  43887. /**
  43888. * Observable raised when current selected mesh gets unselected
  43889. */
  43890. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43891. private _raySelectionPredicate;
  43892. /**
  43893. * To be optionaly changed by user to define custom ray selection
  43894. */
  43895. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43896. /**
  43897. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43898. */
  43899. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43900. /**
  43901. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43902. */
  43903. teleportationEnabled: boolean;
  43904. private _defaultHeight;
  43905. private _teleportationInitialized;
  43906. private _interactionsEnabled;
  43907. private _interactionsRequested;
  43908. private _displayGaze;
  43909. private _displayLaserPointer;
  43910. /**
  43911. * The mesh used to display where the user is going to teleport.
  43912. */
  43913. get teleportationTarget(): Mesh;
  43914. /**
  43915. * Sets the mesh to be used to display where the user is going to teleport.
  43916. */
  43917. set teleportationTarget(value: Mesh);
  43918. /**
  43919. * 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
  43920. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43921. * See http://doc.babylonjs.com/resources/baking_transformations
  43922. */
  43923. get gazeTrackerMesh(): Mesh;
  43924. set gazeTrackerMesh(value: Mesh);
  43925. /**
  43926. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43927. */
  43928. updateGazeTrackerScale: boolean;
  43929. /**
  43930. * If the gaze trackers color should be updated when selecting meshes
  43931. */
  43932. updateGazeTrackerColor: boolean;
  43933. /**
  43934. * If the controller laser color should be updated when selecting meshes
  43935. */
  43936. updateControllerLaserColor: boolean;
  43937. /**
  43938. * The gaze tracking mesh corresponding to the left controller
  43939. */
  43940. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  43941. /**
  43942. * The gaze tracking mesh corresponding to the right controller
  43943. */
  43944. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  43945. /**
  43946. * If the ray of the gaze should be displayed.
  43947. */
  43948. get displayGaze(): boolean;
  43949. /**
  43950. * Sets if the ray of the gaze should be displayed.
  43951. */
  43952. set displayGaze(value: boolean);
  43953. /**
  43954. * If the ray of the LaserPointer should be displayed.
  43955. */
  43956. get displayLaserPointer(): boolean;
  43957. /**
  43958. * Sets if the ray of the LaserPointer should be displayed.
  43959. */
  43960. set displayLaserPointer(value: boolean);
  43961. /**
  43962. * The deviceOrientationCamera used as the camera when not in VR.
  43963. */
  43964. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  43965. /**
  43966. * Based on the current WebVR support, returns the current VR camera used.
  43967. */
  43968. get currentVRCamera(): Nullable<Camera>;
  43969. /**
  43970. * The webVRCamera which is used when in VR.
  43971. */
  43972. get webVRCamera(): WebVRFreeCamera;
  43973. /**
  43974. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43975. */
  43976. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  43977. /**
  43978. * The html button that is used to trigger entering into VR.
  43979. */
  43980. get vrButton(): Nullable<HTMLButtonElement>;
  43981. private get _teleportationRequestInitiated();
  43982. /**
  43983. * Defines wether or not Pointer lock should be requested when switching to
  43984. * full screen.
  43985. */
  43986. requestPointerLockOnFullScreen: boolean;
  43987. /**
  43988. * If asking to force XR, this will be populated with the default xr experience
  43989. */
  43990. xr: WebXRDefaultExperience;
  43991. /**
  43992. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  43993. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  43994. */
  43995. xrTestDone: boolean;
  43996. /**
  43997. * Instantiates a VRExperienceHelper.
  43998. * Helps to quickly add VR support to an existing scene.
  43999. * @param scene The scene the VRExperienceHelper belongs to.
  44000. * @param webVROptions Options to modify the vr experience helper's behavior.
  44001. */
  44002. constructor(scene: Scene,
  44003. /** Options to modify the vr experience helper's behavior. */
  44004. webVROptions?: VRExperienceHelperOptions);
  44005. private completeVRInit;
  44006. private _onDefaultMeshLoaded;
  44007. private _onResize;
  44008. private _onFullscreenChange;
  44009. /**
  44010. * Gets a value indicating if we are currently in VR mode.
  44011. */
  44012. get isInVRMode(): boolean;
  44013. private onVrDisplayPresentChange;
  44014. private onVRDisplayChanged;
  44015. private moveButtonToBottomRight;
  44016. private displayVRButton;
  44017. private updateButtonVisibility;
  44018. private _cachedAngularSensibility;
  44019. /**
  44020. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44021. * Otherwise, will use the fullscreen API.
  44022. */
  44023. enterVR(): void;
  44024. /**
  44025. * Attempt to exit VR, or fullscreen.
  44026. */
  44027. exitVR(): void;
  44028. /**
  44029. * The position of the vr experience helper.
  44030. */
  44031. get position(): Vector3;
  44032. /**
  44033. * Sets the position of the vr experience helper.
  44034. */
  44035. set position(value: Vector3);
  44036. /**
  44037. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44038. */
  44039. enableInteractions(): void;
  44040. private get _noControllerIsActive();
  44041. private beforeRender;
  44042. private _isTeleportationFloor;
  44043. /**
  44044. * Adds a floor mesh to be used for teleportation.
  44045. * @param floorMesh the mesh to be used for teleportation.
  44046. */
  44047. addFloorMesh(floorMesh: Mesh): void;
  44048. /**
  44049. * Removes a floor mesh from being used for teleportation.
  44050. * @param floorMesh the mesh to be removed.
  44051. */
  44052. removeFloorMesh(floorMesh: Mesh): void;
  44053. /**
  44054. * Enables interactions and teleportation using the VR controllers and gaze.
  44055. * @param vrTeleportationOptions options to modify teleportation behavior.
  44056. */
  44057. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44058. private _onNewGamepadConnected;
  44059. private _tryEnableInteractionOnController;
  44060. private _onNewGamepadDisconnected;
  44061. private _enableInteractionOnController;
  44062. private _checkTeleportWithRay;
  44063. private _checkRotate;
  44064. private _checkTeleportBackwards;
  44065. private _enableTeleportationOnController;
  44066. private _createTeleportationCircles;
  44067. private _displayTeleportationTarget;
  44068. private _hideTeleportationTarget;
  44069. private _rotateCamera;
  44070. private _moveTeleportationSelectorTo;
  44071. private _workingVector;
  44072. private _workingQuaternion;
  44073. private _workingMatrix;
  44074. /**
  44075. * Time Constant Teleportation Mode
  44076. */
  44077. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44078. /**
  44079. * Speed Constant Teleportation Mode
  44080. */
  44081. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44082. /**
  44083. * Teleports the users feet to the desired location
  44084. * @param location The location where the user's feet should be placed
  44085. */
  44086. teleportCamera(location: Vector3): void;
  44087. private _convertNormalToDirectionOfRay;
  44088. private _castRayAndSelectObject;
  44089. private _notifySelectedMeshUnselected;
  44090. /**
  44091. * Sets the color of the laser ray from the vr controllers.
  44092. * @param color new color for the ray.
  44093. */
  44094. changeLaserColor(color: Color3): void;
  44095. /**
  44096. * Sets the color of the ray from the vr headsets gaze.
  44097. * @param color new color for the ray.
  44098. */
  44099. changeGazeColor(color: Color3): void;
  44100. /**
  44101. * Exits VR and disposes of the vr experience helper
  44102. */
  44103. dispose(): void;
  44104. /**
  44105. * Gets the name of the VRExperienceHelper class
  44106. * @returns "VRExperienceHelper"
  44107. */
  44108. getClassName(): string;
  44109. }
  44110. }
  44111. declare module BABYLON {
  44112. /**
  44113. * Options used for hit testing
  44114. */
  44115. export interface IWebXRHitTestOptions {
  44116. /**
  44117. * Only test when user interacted with the scene. Default - hit test every frame
  44118. */
  44119. testOnPointerDownOnly?: boolean;
  44120. /**
  44121. * The node to use to transform the local results to world coordinates
  44122. */
  44123. worldParentNode?: TransformNode;
  44124. }
  44125. /**
  44126. * Interface defining the babylon result of raycasting/hit-test
  44127. */
  44128. export interface IWebXRHitResult {
  44129. /**
  44130. * The native hit test result
  44131. */
  44132. xrHitResult: XRHitResult;
  44133. /**
  44134. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44135. */
  44136. transformationMatrix: Matrix;
  44137. }
  44138. /**
  44139. * The currently-working hit-test module.
  44140. * Hit test (or raycasting) is used to interact with the real world.
  44141. * For further information read here - https://github.com/immersive-web/hit-test
  44142. */
  44143. export class WebXRHitTestLegacy implements IWebXRFeature {
  44144. private _xrSessionManager;
  44145. /**
  44146. * options to use when constructing this feature
  44147. */
  44148. readonly options: IWebXRHitTestOptions;
  44149. /**
  44150. * The module's name
  44151. */
  44152. static readonly Name: string;
  44153. /**
  44154. * The (Babylon) version of this module.
  44155. * This is an integer representing the implementation version.
  44156. * This number does not correspond to the webxr specs version
  44157. */
  44158. static readonly Version: number;
  44159. /**
  44160. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44161. * @param event the (select) event to use to select with
  44162. * @param referenceSpace the reference space to use for this hit test
  44163. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44164. */
  44165. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44166. /**
  44167. * execute a hit test with an XR Ray
  44168. *
  44169. * @param xrSession a native xrSession that will execute this hit test
  44170. * @param xrRay the ray (position and direction) to use for raycasting
  44171. * @param referenceSpace native XR reference space to use for the hit-test
  44172. * @param filter filter function that will filter the results
  44173. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44174. */
  44175. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44176. /**
  44177. * Triggered when new babylon (transformed) hit test results are available
  44178. */
  44179. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44180. /**
  44181. * Creates a new instance of the (legacy version) hit test feature
  44182. * @param _xrSessionManager an instance of WebXRSessionManager
  44183. * @param options options to use when constructing this feature
  44184. */
  44185. constructor(_xrSessionManager: WebXRSessionManager,
  44186. /**
  44187. * options to use when constructing this feature
  44188. */
  44189. options?: IWebXRHitTestOptions);
  44190. private _onSelectEnabled;
  44191. private _xrFrameObserver;
  44192. private _attached;
  44193. /**
  44194. * Populated with the last native XR Hit Results
  44195. */
  44196. lastNativeXRHitResults: XRHitResult[];
  44197. /**
  44198. * attach this feature
  44199. * Will usually be called by the features manager
  44200. *
  44201. * @returns true if successful.
  44202. */
  44203. attach(): boolean;
  44204. /**
  44205. * detach this feature.
  44206. * Will usually be called by the features manager
  44207. *
  44208. * @returns true if successful.
  44209. */
  44210. detach(): boolean;
  44211. private _onHitTestResults;
  44212. private _onSelect;
  44213. /**
  44214. * Dispose this feature and all of the resources attached
  44215. */
  44216. dispose(): void;
  44217. }
  44218. }
  44219. declare module BABYLON {
  44220. /**
  44221. * Options used in the plane detector module
  44222. */
  44223. export interface IWebXRPlaneDetectorOptions {
  44224. /**
  44225. * The node to use to transform the local results to world coordinates
  44226. */
  44227. worldParentNode?: TransformNode;
  44228. }
  44229. /**
  44230. * A babylon interface for a webxr plane.
  44231. * A Plane is actually a polygon, built from N points in space
  44232. */
  44233. export interface IWebXRPlane {
  44234. /**
  44235. * a babylon-assigned ID for this polygon
  44236. */
  44237. id: number;
  44238. /**
  44239. * the native xr-plane object
  44240. */
  44241. xrPlane: XRPlane;
  44242. /**
  44243. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  44244. */
  44245. polygonDefinition: Array<Vector3>;
  44246. /**
  44247. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  44248. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  44249. */
  44250. transformationMatrix: Matrix;
  44251. }
  44252. /**
  44253. * The plane detector is used to detect planes in the real world when in AR
  44254. * For more information see https://github.com/immersive-web/real-world-geometry/
  44255. */
  44256. export class WebXRPlaneDetector implements IWebXRFeature {
  44257. private _xrSessionManager;
  44258. private _options;
  44259. /**
  44260. * The module's name
  44261. */
  44262. static readonly Name: string;
  44263. /**
  44264. * The (Babylon) version of this module.
  44265. * This is an integer representing the implementation version.
  44266. * This number does not correspond to the webxr specs version
  44267. */
  44268. static readonly Version: number;
  44269. /**
  44270. * Observers registered here will be executed when a new plane was added to the session
  44271. */
  44272. onPlaneAddedObservable: Observable<IWebXRPlane>;
  44273. /**
  44274. * Observers registered here will be executed when a plane is no longer detected in the session
  44275. */
  44276. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  44277. /**
  44278. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  44279. * This can execute N times every frame
  44280. */
  44281. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  44282. private _enabled;
  44283. private _attached;
  44284. private _detectedPlanes;
  44285. private _lastFrameDetected;
  44286. private _observerTracked;
  44287. /**
  44288. * construct a new Plane Detector
  44289. * @param _xrSessionManager an instance of xr Session manager
  44290. * @param _options configuration to use when constructing this feature
  44291. */
  44292. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  44293. /**
  44294. * attach this feature
  44295. * Will usually be called by the features manager
  44296. *
  44297. * @returns true if successful.
  44298. */
  44299. attach(): boolean;
  44300. /**
  44301. * detach this feature.
  44302. * Will usually be called by the features manager
  44303. *
  44304. * @returns true if successful.
  44305. */
  44306. detach(): boolean;
  44307. /**
  44308. * Dispose this feature and all of the resources attached
  44309. */
  44310. dispose(): void;
  44311. private _updatePlaneWithXRPlane;
  44312. /**
  44313. * avoiding using Array.find for global support.
  44314. * @param xrPlane the plane to find in the array
  44315. */
  44316. private findIndexInPlaneArray;
  44317. }
  44318. }
  44319. declare module BABYLON {
  44320. /**
  44321. * Configuration options of the anchor system
  44322. */
  44323. export interface IWebXRAnchorSystemOptions {
  44324. /**
  44325. * a node that will be used to convert local to world coordinates
  44326. */
  44327. worldParentNode?: TransformNode;
  44328. /**
  44329. * should the anchor system use plane detection.
  44330. * If set to true, the plane-detection feature should be set using setPlaneDetector
  44331. */
  44332. usePlaneDetection?: boolean;
  44333. /**
  44334. * Should a new anchor be added every time a select event is triggered
  44335. */
  44336. addAnchorOnSelect?: boolean;
  44337. }
  44338. /**
  44339. * A babylon container for an XR Anchor
  44340. */
  44341. export interface IWebXRAnchor {
  44342. /**
  44343. * A babylon-assigned ID for this anchor
  44344. */
  44345. id: number;
  44346. /**
  44347. * The native anchor object
  44348. */
  44349. xrAnchor: XRAnchor;
  44350. /**
  44351. * Transformation matrix to apply to an object attached to this anchor
  44352. */
  44353. transformationMatrix: Matrix;
  44354. }
  44355. /**
  44356. * An implementation of the anchor system of WebXR.
  44357. * Note that the current documented implementation is not available in any browser. Future implementations
  44358. * will use the frame to create an anchor and not the session or a detected plane
  44359. * For further information see https://github.com/immersive-web/anchors/
  44360. */
  44361. export class WebXRAnchorSystem implements IWebXRFeature {
  44362. private _xrSessionManager;
  44363. private _options;
  44364. /**
  44365. * The module's name
  44366. */
  44367. static readonly Name: string;
  44368. /**
  44369. * The (Babylon) version of this module.
  44370. * This is an integer representing the implementation version.
  44371. * This number does not correspond to the webxr specs version
  44372. */
  44373. static readonly Version: number;
  44374. /**
  44375. * Observers registered here will be executed when a new anchor was added to the session
  44376. */
  44377. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  44378. /**
  44379. * Observers registered here will be executed when an existing anchor updates
  44380. * This can execute N times every frame
  44381. */
  44382. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  44383. /**
  44384. * Observers registered here will be executed when an anchor was removed from the session
  44385. */
  44386. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  44387. private _planeDetector;
  44388. private _hitTestModule;
  44389. private _enabled;
  44390. private _attached;
  44391. private _trackedAnchors;
  44392. private _lastFrameDetected;
  44393. private _observerTracked;
  44394. /**
  44395. * constructs a new anchor system
  44396. * @param _xrSessionManager an instance of WebXRSessionManager
  44397. * @param _options configuration object for this feature
  44398. */
  44399. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  44400. /**
  44401. * set the plane detector to use in order to create anchors from frames
  44402. * @param planeDetector the plane-detector module to use
  44403. * @param enable enable plane-anchors. default is true
  44404. */
  44405. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  44406. /**
  44407. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  44408. * @param hitTestModule the hit-test module to use.
  44409. */
  44410. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44411. /**
  44412. * attach this feature
  44413. * Will usually be called by the features manager
  44414. *
  44415. * @returns true if successful.
  44416. */
  44417. attach(): boolean;
  44418. /**
  44419. * detach this feature.
  44420. * Will usually be called by the features manager
  44421. *
  44422. * @returns true if successful.
  44423. */
  44424. detach(): boolean;
  44425. /**
  44426. * Dispose this feature and all of the resources attached
  44427. */
  44428. dispose(): void;
  44429. private _onSelect;
  44430. /**
  44431. * Add anchor at a specific XR point.
  44432. *
  44433. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44434. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44435. * @returns a promise the fulfills when the anchor was created
  44436. */
  44437. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44438. private _updateAnchorWithXRFrame;
  44439. /**
  44440. * avoiding using Array.find for global support.
  44441. * @param xrAnchor the plane to find in the array
  44442. */
  44443. private _findIndexInAnchorArray;
  44444. }
  44445. }
  44446. declare module BABYLON {
  44447. /**
  44448. * Options interface for the background remover plugin
  44449. */
  44450. export interface IWebXRBackgroundRemoverOptions {
  44451. /**
  44452. * don't disable the environment helper
  44453. */
  44454. ignoreEnvironmentHelper?: boolean;
  44455. /**
  44456. * flags to configure the removal of the environment helper.
  44457. * If not set, the entire background will be removed. If set, flags should be set as well.
  44458. */
  44459. environmentHelperRemovalFlags?: {
  44460. /**
  44461. * Should the skybox be removed (default false)
  44462. */
  44463. skyBox?: boolean;
  44464. /**
  44465. * Should the ground be removed (default false)
  44466. */
  44467. ground?: boolean;
  44468. };
  44469. /**
  44470. * Further background meshes to disable when entering AR
  44471. */
  44472. backgroundMeshes?: AbstractMesh[];
  44473. }
  44474. /**
  44475. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44476. */
  44477. export class WebXRBackgroundRemover implements IWebXRFeature {
  44478. private _xrSessionManager;
  44479. /**
  44480. * read-only options to be used in this module
  44481. */
  44482. readonly options: IWebXRBackgroundRemoverOptions;
  44483. /**
  44484. * The module's name
  44485. */
  44486. static readonly Name: string;
  44487. /**
  44488. * The (Babylon) version of this module.
  44489. * This is an integer representing the implementation version.
  44490. * This number does not correspond to the webxr specs version
  44491. */
  44492. static readonly Version: number;
  44493. /**
  44494. * registered observers will be triggered when the background state changes
  44495. */
  44496. onBackgroundStateChangedObservable: Observable<boolean>;
  44497. /**
  44498. * constructs a new background remover module
  44499. * @param _xrSessionManager the session manager for this module
  44500. * @param options read-only options to be used in this module
  44501. */
  44502. constructor(_xrSessionManager: WebXRSessionManager,
  44503. /**
  44504. * read-only options to be used in this module
  44505. */
  44506. options?: IWebXRBackgroundRemoverOptions);
  44507. /**
  44508. * attach this feature
  44509. * Will usually be called by the features manager
  44510. *
  44511. * @returns true if successful.
  44512. */
  44513. attach(): boolean;
  44514. /**
  44515. * detach this feature.
  44516. * Will usually be called by the features manager
  44517. *
  44518. * @returns true if successful.
  44519. */
  44520. detach(): boolean;
  44521. private _setBackgroundState;
  44522. /**
  44523. * Dispose this feature and all of the resources attached
  44524. */
  44525. dispose(): void;
  44526. }
  44527. }
  44528. declare module BABYLON {
  44529. /**
  44530. * Contains an array of blocks representing the octree
  44531. */
  44532. export interface IOctreeContainer<T> {
  44533. /**
  44534. * Blocks within the octree
  44535. */
  44536. blocks: Array<OctreeBlock<T>>;
  44537. }
  44538. /**
  44539. * Class used to store a cell in an octree
  44540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44541. */
  44542. export class OctreeBlock<T> {
  44543. /**
  44544. * Gets the content of the current block
  44545. */
  44546. entries: T[];
  44547. /**
  44548. * Gets the list of block children
  44549. */
  44550. blocks: Array<OctreeBlock<T>>;
  44551. private _depth;
  44552. private _maxDepth;
  44553. private _capacity;
  44554. private _minPoint;
  44555. private _maxPoint;
  44556. private _boundingVectors;
  44557. private _creationFunc;
  44558. /**
  44559. * Creates a new block
  44560. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44561. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44562. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44563. * @param depth defines the current depth of this block in the octree
  44564. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44565. * @param creationFunc defines a callback to call when an element is added to the block
  44566. */
  44567. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44568. /**
  44569. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44570. */
  44571. get capacity(): number;
  44572. /**
  44573. * Gets the minimum vector (in world space) of the block's bounding box
  44574. */
  44575. get minPoint(): Vector3;
  44576. /**
  44577. * Gets the maximum vector (in world space) of the block's bounding box
  44578. */
  44579. get maxPoint(): Vector3;
  44580. /**
  44581. * Add a new element to this block
  44582. * @param entry defines the element to add
  44583. */
  44584. addEntry(entry: T): void;
  44585. /**
  44586. * Remove an element from this block
  44587. * @param entry defines the element to remove
  44588. */
  44589. removeEntry(entry: T): void;
  44590. /**
  44591. * Add an array of elements to this block
  44592. * @param entries defines the array of elements to add
  44593. */
  44594. addEntries(entries: T[]): void;
  44595. /**
  44596. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44597. * @param frustumPlanes defines the frustum planes to test
  44598. * @param selection defines the array to store current content if selection is positive
  44599. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44600. */
  44601. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44602. /**
  44603. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44604. * @param sphereCenter defines the bounding sphere center
  44605. * @param sphereRadius defines the bounding sphere radius
  44606. * @param selection defines the array to store current content if selection is positive
  44607. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44608. */
  44609. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44610. /**
  44611. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44612. * @param ray defines the ray to test with
  44613. * @param selection defines the array to store current content if selection is positive
  44614. */
  44615. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44616. /**
  44617. * Subdivide the content into child blocks (this block will then be empty)
  44618. */
  44619. createInnerBlocks(): void;
  44620. /**
  44621. * @hidden
  44622. */
  44623. 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;
  44624. }
  44625. }
  44626. declare module BABYLON {
  44627. /**
  44628. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44629. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44630. */
  44631. export class Octree<T> {
  44632. /** 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.) */
  44633. maxDepth: number;
  44634. /**
  44635. * Blocks within the octree containing objects
  44636. */
  44637. blocks: Array<OctreeBlock<T>>;
  44638. /**
  44639. * Content stored in the octree
  44640. */
  44641. dynamicContent: T[];
  44642. private _maxBlockCapacity;
  44643. private _selectionContent;
  44644. private _creationFunc;
  44645. /**
  44646. * Creates a octree
  44647. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44648. * @param creationFunc function to be used to instatiate the octree
  44649. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44650. * @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.)
  44651. */
  44652. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44653. /** 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.) */
  44654. maxDepth?: number);
  44655. /**
  44656. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44657. * @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);
  44658. * @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);
  44659. * @param entries meshes to be added to the octree blocks
  44660. */
  44661. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44662. /**
  44663. * Adds a mesh to the octree
  44664. * @param entry Mesh to add to the octree
  44665. */
  44666. addMesh(entry: T): void;
  44667. /**
  44668. * Remove an element from the octree
  44669. * @param entry defines the element to remove
  44670. */
  44671. removeMesh(entry: T): void;
  44672. /**
  44673. * Selects an array of meshes within the frustum
  44674. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44675. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44676. * @returns array of meshes within the frustum
  44677. */
  44678. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44679. /**
  44680. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44681. * @param sphereCenter defines the bounding sphere center
  44682. * @param sphereRadius defines the bounding sphere radius
  44683. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44684. * @returns an array of objects that intersect the sphere
  44685. */
  44686. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44687. /**
  44688. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44689. * @param ray defines the ray to test with
  44690. * @returns array of intersected objects
  44691. */
  44692. intersectsRay(ray: Ray): SmartArray<T>;
  44693. /**
  44694. * Adds a mesh into the octree block if it intersects the block
  44695. */
  44696. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44697. /**
  44698. * Adds a submesh into the octree block if it intersects the block
  44699. */
  44700. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44701. }
  44702. }
  44703. declare module BABYLON {
  44704. interface Scene {
  44705. /**
  44706. * @hidden
  44707. * Backing Filed
  44708. */
  44709. _selectionOctree: Octree<AbstractMesh>;
  44710. /**
  44711. * Gets the octree used to boost mesh selection (picking)
  44712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44713. */
  44714. selectionOctree: Octree<AbstractMesh>;
  44715. /**
  44716. * Creates or updates the octree used to boost selection (picking)
  44717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44718. * @param maxCapacity defines the maximum capacity per leaf
  44719. * @param maxDepth defines the maximum depth of the octree
  44720. * @returns an octree of AbstractMesh
  44721. */
  44722. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44723. }
  44724. interface AbstractMesh {
  44725. /**
  44726. * @hidden
  44727. * Backing Field
  44728. */
  44729. _submeshesOctree: Octree<SubMesh>;
  44730. /**
  44731. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44732. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44733. * @param maxCapacity defines the maximum size of each block (64 by default)
  44734. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44735. * @returns the new octree
  44736. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44737. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44738. */
  44739. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44740. }
  44741. /**
  44742. * Defines the octree scene component responsible to manage any octrees
  44743. * in a given scene.
  44744. */
  44745. export class OctreeSceneComponent {
  44746. /**
  44747. * The component name help to identify the component in the list of scene components.
  44748. */
  44749. readonly name: string;
  44750. /**
  44751. * The scene the component belongs to.
  44752. */
  44753. scene: Scene;
  44754. /**
  44755. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44756. */
  44757. readonly checksIsEnabled: boolean;
  44758. /**
  44759. * Creates a new instance of the component for the given scene
  44760. * @param scene Defines the scene to register the component in
  44761. */
  44762. constructor(scene: Scene);
  44763. /**
  44764. * Registers the component in a given scene
  44765. */
  44766. register(): void;
  44767. /**
  44768. * Return the list of active meshes
  44769. * @returns the list of active meshes
  44770. */
  44771. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44772. /**
  44773. * Return the list of active sub meshes
  44774. * @param mesh The mesh to get the candidates sub meshes from
  44775. * @returns the list of active sub meshes
  44776. */
  44777. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44778. private _tempRay;
  44779. /**
  44780. * Return the list of sub meshes intersecting with a given local ray
  44781. * @param mesh defines the mesh to find the submesh for
  44782. * @param localRay defines the ray in local space
  44783. * @returns the list of intersecting sub meshes
  44784. */
  44785. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44786. /**
  44787. * Return the list of sub meshes colliding with a collider
  44788. * @param mesh defines the mesh to find the submesh for
  44789. * @param collider defines the collider to evaluate the collision against
  44790. * @returns the list of colliding sub meshes
  44791. */
  44792. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44793. /**
  44794. * Rebuilds the elements related to this component in case of
  44795. * context lost for instance.
  44796. */
  44797. rebuild(): void;
  44798. /**
  44799. * Disposes the component and the associated ressources.
  44800. */
  44801. dispose(): void;
  44802. }
  44803. }
  44804. declare module BABYLON {
  44805. /**
  44806. * Renders a layer on top of an existing scene
  44807. */
  44808. export class UtilityLayerRenderer implements IDisposable {
  44809. /** the original scene that will be rendered on top of */
  44810. originalScene: Scene;
  44811. private _pointerCaptures;
  44812. private _lastPointerEvents;
  44813. private static _DefaultUtilityLayer;
  44814. private static _DefaultKeepDepthUtilityLayer;
  44815. private _sharedGizmoLight;
  44816. private _renderCamera;
  44817. /**
  44818. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44819. * @returns the camera that is used when rendering the utility layer
  44820. */
  44821. getRenderCamera(): Nullable<Camera>;
  44822. /**
  44823. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44824. * @param cam the camera that should be used when rendering the utility layer
  44825. */
  44826. setRenderCamera(cam: Nullable<Camera>): void;
  44827. /**
  44828. * @hidden
  44829. * Light which used by gizmos to get light shading
  44830. */
  44831. _getSharedGizmoLight(): HemisphericLight;
  44832. /**
  44833. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44834. */
  44835. pickUtilitySceneFirst: boolean;
  44836. /**
  44837. * 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)
  44838. */
  44839. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44840. /**
  44841. * 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)
  44842. */
  44843. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44844. /**
  44845. * The scene that is rendered on top of the original scene
  44846. */
  44847. utilityLayerScene: Scene;
  44848. /**
  44849. * If the utility layer should automatically be rendered on top of existing scene
  44850. */
  44851. shouldRender: boolean;
  44852. /**
  44853. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44854. */
  44855. onlyCheckPointerDownEvents: boolean;
  44856. /**
  44857. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44858. */
  44859. processAllEvents: boolean;
  44860. /**
  44861. * Observable raised when the pointer move from the utility layer scene to the main scene
  44862. */
  44863. onPointerOutObservable: Observable<number>;
  44864. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44865. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44866. private _afterRenderObserver;
  44867. private _sceneDisposeObserver;
  44868. private _originalPointerObserver;
  44869. /**
  44870. * Instantiates a UtilityLayerRenderer
  44871. * @param originalScene the original scene that will be rendered on top of
  44872. * @param handleEvents boolean indicating if the utility layer should handle events
  44873. */
  44874. constructor(
  44875. /** the original scene that will be rendered on top of */
  44876. originalScene: Scene, handleEvents?: boolean);
  44877. private _notifyObservers;
  44878. /**
  44879. * Renders the utility layers scene on top of the original scene
  44880. */
  44881. render(): void;
  44882. /**
  44883. * Disposes of the renderer
  44884. */
  44885. dispose(): void;
  44886. private _updateCamera;
  44887. }
  44888. }
  44889. declare module BABYLON {
  44890. /**
  44891. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44892. */
  44893. export class Gizmo implements IDisposable {
  44894. /** The utility layer the gizmo will be added to */
  44895. gizmoLayer: UtilityLayerRenderer;
  44896. /**
  44897. * The root mesh of the gizmo
  44898. */
  44899. _rootMesh: Mesh;
  44900. private _attachedMesh;
  44901. /**
  44902. * Ratio for the scale of the gizmo (Default: 1)
  44903. */
  44904. scaleRatio: number;
  44905. /**
  44906. * If a custom mesh has been set (Default: false)
  44907. */
  44908. protected _customMeshSet: boolean;
  44909. /**
  44910. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44911. * * When set, interactions will be enabled
  44912. */
  44913. get attachedMesh(): Nullable<AbstractMesh>;
  44914. set attachedMesh(value: Nullable<AbstractMesh>);
  44915. /**
  44916. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44917. * @param mesh The mesh to replace the default mesh of the gizmo
  44918. */
  44919. setCustomMesh(mesh: Mesh): void;
  44920. /**
  44921. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44922. */
  44923. updateGizmoRotationToMatchAttachedMesh: boolean;
  44924. /**
  44925. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44926. */
  44927. updateGizmoPositionToMatchAttachedMesh: boolean;
  44928. /**
  44929. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44930. */
  44931. updateScale: boolean;
  44932. protected _interactionsEnabled: boolean;
  44933. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44934. private _beforeRenderObserver;
  44935. private _tempVector;
  44936. /**
  44937. * Creates a gizmo
  44938. * @param gizmoLayer The utility layer the gizmo will be added to
  44939. */
  44940. constructor(
  44941. /** The utility layer the gizmo will be added to */
  44942. gizmoLayer?: UtilityLayerRenderer);
  44943. /**
  44944. * Updates the gizmo to match the attached mesh's position/rotation
  44945. */
  44946. protected _update(): void;
  44947. /**
  44948. * Disposes of the gizmo
  44949. */
  44950. dispose(): void;
  44951. }
  44952. }
  44953. declare module BABYLON {
  44954. /**
  44955. * Single plane drag gizmo
  44956. */
  44957. export class PlaneDragGizmo extends Gizmo {
  44958. /**
  44959. * Drag behavior responsible for the gizmos dragging interactions
  44960. */
  44961. dragBehavior: PointerDragBehavior;
  44962. private _pointerObserver;
  44963. /**
  44964. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44965. */
  44966. snapDistance: number;
  44967. /**
  44968. * Event that fires each time the gizmo snaps to a new location.
  44969. * * snapDistance is the the change in distance
  44970. */
  44971. onSnapObservable: Observable<{
  44972. snapDistance: number;
  44973. }>;
  44974. private _plane;
  44975. private _coloredMaterial;
  44976. private _hoverMaterial;
  44977. private _isEnabled;
  44978. private _parent;
  44979. /** @hidden */
  44980. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44981. /** @hidden */
  44982. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44983. /**
  44984. * Creates a PlaneDragGizmo
  44985. * @param gizmoLayer The utility layer the gizmo will be added to
  44986. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44987. * @param color The color of the gizmo
  44988. */
  44989. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44990. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44991. /**
  44992. * If the gizmo is enabled
  44993. */
  44994. set isEnabled(value: boolean);
  44995. get isEnabled(): boolean;
  44996. /**
  44997. * Disposes of the gizmo
  44998. */
  44999. dispose(): void;
  45000. }
  45001. }
  45002. declare module BABYLON {
  45003. /**
  45004. * Gizmo that enables dragging a mesh along 3 axis
  45005. */
  45006. export class PositionGizmo extends Gizmo {
  45007. /**
  45008. * Internal gizmo used for interactions on the x axis
  45009. */
  45010. xGizmo: AxisDragGizmo;
  45011. /**
  45012. * Internal gizmo used for interactions on the y axis
  45013. */
  45014. yGizmo: AxisDragGizmo;
  45015. /**
  45016. * Internal gizmo used for interactions on the z axis
  45017. */
  45018. zGizmo: AxisDragGizmo;
  45019. /**
  45020. * Internal gizmo used for interactions on the yz plane
  45021. */
  45022. xPlaneGizmo: PlaneDragGizmo;
  45023. /**
  45024. * Internal gizmo used for interactions on the xz plane
  45025. */
  45026. yPlaneGizmo: PlaneDragGizmo;
  45027. /**
  45028. * Internal gizmo used for interactions on the xy plane
  45029. */
  45030. zPlaneGizmo: PlaneDragGizmo;
  45031. /**
  45032. * private variables
  45033. */
  45034. private _meshAttached;
  45035. private _updateGizmoRotationToMatchAttachedMesh;
  45036. private _snapDistance;
  45037. private _scaleRatio;
  45038. /** Fires an event when any of it's sub gizmos are dragged */
  45039. onDragStartObservable: Observable<unknown>;
  45040. /** Fires an event when any of it's sub gizmos are released from dragging */
  45041. onDragEndObservable: Observable<unknown>;
  45042. /**
  45043. * If set to true, planar drag is enabled
  45044. */
  45045. private _planarGizmoEnabled;
  45046. get attachedMesh(): Nullable<AbstractMesh>;
  45047. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45048. /**
  45049. * Creates a PositionGizmo
  45050. * @param gizmoLayer The utility layer the gizmo will be added to
  45051. */
  45052. constructor(gizmoLayer?: UtilityLayerRenderer);
  45053. /**
  45054. * If the planar drag gizmo is enabled
  45055. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45056. */
  45057. set planarGizmoEnabled(value: boolean);
  45058. get planarGizmoEnabled(): boolean;
  45059. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45060. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45061. /**
  45062. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45063. */
  45064. set snapDistance(value: number);
  45065. get snapDistance(): number;
  45066. /**
  45067. * Ratio for the scale of the gizmo (Default: 1)
  45068. */
  45069. set scaleRatio(value: number);
  45070. get scaleRatio(): number;
  45071. /**
  45072. * Disposes of the gizmo
  45073. */
  45074. dispose(): void;
  45075. /**
  45076. * CustomMeshes are not supported by this gizmo
  45077. * @param mesh The mesh to replace the default mesh of the gizmo
  45078. */
  45079. setCustomMesh(mesh: Mesh): void;
  45080. }
  45081. }
  45082. declare module BABYLON {
  45083. /**
  45084. * Single axis drag gizmo
  45085. */
  45086. export class AxisDragGizmo extends Gizmo {
  45087. /**
  45088. * Drag behavior responsible for the gizmos dragging interactions
  45089. */
  45090. dragBehavior: PointerDragBehavior;
  45091. private _pointerObserver;
  45092. /**
  45093. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45094. */
  45095. snapDistance: number;
  45096. /**
  45097. * Event that fires each time the gizmo snaps to a new location.
  45098. * * snapDistance is the the change in distance
  45099. */
  45100. onSnapObservable: Observable<{
  45101. snapDistance: number;
  45102. }>;
  45103. private _isEnabled;
  45104. private _parent;
  45105. private _arrow;
  45106. private _coloredMaterial;
  45107. private _hoverMaterial;
  45108. /** @hidden */
  45109. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45110. /** @hidden */
  45111. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45112. /**
  45113. * Creates an AxisDragGizmo
  45114. * @param gizmoLayer The utility layer the gizmo will be added to
  45115. * @param dragAxis The axis which the gizmo will be able to drag on
  45116. * @param color The color of the gizmo
  45117. */
  45118. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45119. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45120. /**
  45121. * If the gizmo is enabled
  45122. */
  45123. set isEnabled(value: boolean);
  45124. get isEnabled(): boolean;
  45125. /**
  45126. * Disposes of the gizmo
  45127. */
  45128. dispose(): void;
  45129. }
  45130. }
  45131. declare module BABYLON.Debug {
  45132. /**
  45133. * The Axes viewer will show 3 axes in a specific point in space
  45134. */
  45135. export class AxesViewer {
  45136. private _xAxis;
  45137. private _yAxis;
  45138. private _zAxis;
  45139. private _scaleLinesFactor;
  45140. private _instanced;
  45141. /**
  45142. * Gets the hosting scene
  45143. */
  45144. scene: Scene;
  45145. /**
  45146. * Gets or sets a number used to scale line length
  45147. */
  45148. scaleLines: number;
  45149. /** Gets the node hierarchy used to render x-axis */
  45150. get xAxis(): TransformNode;
  45151. /** Gets the node hierarchy used to render y-axis */
  45152. get yAxis(): TransformNode;
  45153. /** Gets the node hierarchy used to render z-axis */
  45154. get zAxis(): TransformNode;
  45155. /**
  45156. * Creates a new AxesViewer
  45157. * @param scene defines the hosting scene
  45158. * @param scaleLines defines a number used to scale line length (1 by default)
  45159. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45160. * @param xAxis defines the node hierarchy used to render the x-axis
  45161. * @param yAxis defines the node hierarchy used to render the y-axis
  45162. * @param zAxis defines the node hierarchy used to render the z-axis
  45163. */
  45164. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45165. /**
  45166. * Force the viewer to update
  45167. * @param position defines the position of the viewer
  45168. * @param xaxis defines the x axis of the viewer
  45169. * @param yaxis defines the y axis of the viewer
  45170. * @param zaxis defines the z axis of the viewer
  45171. */
  45172. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45173. /**
  45174. * Creates an instance of this axes viewer.
  45175. * @returns a new axes viewer with instanced meshes
  45176. */
  45177. createInstance(): AxesViewer;
  45178. /** Releases resources */
  45179. dispose(): void;
  45180. private static _SetRenderingGroupId;
  45181. }
  45182. }
  45183. declare module BABYLON.Debug {
  45184. /**
  45185. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45186. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45187. */
  45188. export class BoneAxesViewer extends AxesViewer {
  45189. /**
  45190. * Gets or sets the target mesh where to display the axes viewer
  45191. */
  45192. mesh: Nullable<Mesh>;
  45193. /**
  45194. * Gets or sets the target bone where to display the axes viewer
  45195. */
  45196. bone: Nullable<Bone>;
  45197. /** Gets current position */
  45198. pos: Vector3;
  45199. /** Gets direction of X axis */
  45200. xaxis: Vector3;
  45201. /** Gets direction of Y axis */
  45202. yaxis: Vector3;
  45203. /** Gets direction of Z axis */
  45204. zaxis: Vector3;
  45205. /**
  45206. * Creates a new BoneAxesViewer
  45207. * @param scene defines the hosting scene
  45208. * @param bone defines the target bone
  45209. * @param mesh defines the target mesh
  45210. * @param scaleLines defines a scaling factor for line length (1 by default)
  45211. */
  45212. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45213. /**
  45214. * Force the viewer to update
  45215. */
  45216. update(): void;
  45217. /** Releases resources */
  45218. dispose(): void;
  45219. }
  45220. }
  45221. declare module BABYLON {
  45222. /**
  45223. * Interface used to define scene explorer extensibility option
  45224. */
  45225. export interface IExplorerExtensibilityOption {
  45226. /**
  45227. * Define the option label
  45228. */
  45229. label: string;
  45230. /**
  45231. * Defines the action to execute on click
  45232. */
  45233. action: (entity: any) => void;
  45234. }
  45235. /**
  45236. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45237. */
  45238. export interface IExplorerExtensibilityGroup {
  45239. /**
  45240. * Defines a predicate to test if a given type mut be extended
  45241. */
  45242. predicate: (entity: any) => boolean;
  45243. /**
  45244. * Gets the list of options added to a type
  45245. */
  45246. entries: IExplorerExtensibilityOption[];
  45247. }
  45248. /**
  45249. * Interface used to define the options to use to create the Inspector
  45250. */
  45251. export interface IInspectorOptions {
  45252. /**
  45253. * Display in overlay mode (default: false)
  45254. */
  45255. overlay?: boolean;
  45256. /**
  45257. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45258. */
  45259. globalRoot?: HTMLElement;
  45260. /**
  45261. * Display the Scene explorer
  45262. */
  45263. showExplorer?: boolean;
  45264. /**
  45265. * Display the property inspector
  45266. */
  45267. showInspector?: boolean;
  45268. /**
  45269. * Display in embed mode (both panes on the right)
  45270. */
  45271. embedMode?: boolean;
  45272. /**
  45273. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45274. */
  45275. handleResize?: boolean;
  45276. /**
  45277. * Allow the panes to popup (default: true)
  45278. */
  45279. enablePopup?: boolean;
  45280. /**
  45281. * Allow the panes to be closed by users (default: true)
  45282. */
  45283. enableClose?: boolean;
  45284. /**
  45285. * Optional list of extensibility entries
  45286. */
  45287. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45288. /**
  45289. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45290. */
  45291. inspectorURL?: string;
  45292. /**
  45293. * Optional initial tab (default to DebugLayerTab.Properties)
  45294. */
  45295. initialTab?: DebugLayerTab;
  45296. }
  45297. interface Scene {
  45298. /**
  45299. * @hidden
  45300. * Backing field
  45301. */
  45302. _debugLayer: DebugLayer;
  45303. /**
  45304. * Gets the debug layer (aka Inspector) associated with the scene
  45305. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45306. */
  45307. debugLayer: DebugLayer;
  45308. }
  45309. /**
  45310. * Enum of inspector action tab
  45311. */
  45312. export enum DebugLayerTab {
  45313. /**
  45314. * Properties tag (default)
  45315. */
  45316. Properties = 0,
  45317. /**
  45318. * Debug tab
  45319. */
  45320. Debug = 1,
  45321. /**
  45322. * Statistics tab
  45323. */
  45324. Statistics = 2,
  45325. /**
  45326. * Tools tab
  45327. */
  45328. Tools = 3,
  45329. /**
  45330. * Settings tab
  45331. */
  45332. Settings = 4
  45333. }
  45334. /**
  45335. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45336. * what is happening in your scene
  45337. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45338. */
  45339. export class DebugLayer {
  45340. /**
  45341. * Define the url to get the inspector script from.
  45342. * By default it uses the babylonjs CDN.
  45343. * @ignoreNaming
  45344. */
  45345. static InspectorURL: string;
  45346. private _scene;
  45347. private BJSINSPECTOR;
  45348. private _onPropertyChangedObservable?;
  45349. /**
  45350. * Observable triggered when a property is changed through the inspector.
  45351. */
  45352. get onPropertyChangedObservable(): any;
  45353. /**
  45354. * Instantiates a new debug layer.
  45355. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45356. * what is happening in your scene
  45357. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45358. * @param scene Defines the scene to inspect
  45359. */
  45360. constructor(scene: Scene);
  45361. /** Creates the inspector window. */
  45362. private _createInspector;
  45363. /**
  45364. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45365. * @param entity defines the entity to select
  45366. * @param lineContainerTitle defines the specific block to highlight
  45367. */
  45368. select(entity: any, lineContainerTitle?: string): void;
  45369. /** Get the inspector from bundle or global */
  45370. private _getGlobalInspector;
  45371. /**
  45372. * Get if the inspector is visible or not.
  45373. * @returns true if visible otherwise, false
  45374. */
  45375. isVisible(): boolean;
  45376. /**
  45377. * Hide the inspector and close its window.
  45378. */
  45379. hide(): void;
  45380. /**
  45381. * Launch the debugLayer.
  45382. * @param config Define the configuration of the inspector
  45383. * @return a promise fulfilled when the debug layer is visible
  45384. */
  45385. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45386. }
  45387. }
  45388. declare module BABYLON {
  45389. /**
  45390. * Class containing static functions to help procedurally build meshes
  45391. */
  45392. export class BoxBuilder {
  45393. /**
  45394. * Creates a box mesh
  45395. * * The parameter `size` sets the size (float) of each box side (default 1)
  45396. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45397. * * 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)
  45398. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45400. * * 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
  45401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45402. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45403. * @param name defines the name of the mesh
  45404. * @param options defines the options used to create the mesh
  45405. * @param scene defines the hosting scene
  45406. * @returns the box mesh
  45407. */
  45408. static CreateBox(name: string, options: {
  45409. size?: number;
  45410. width?: number;
  45411. height?: number;
  45412. depth?: number;
  45413. faceUV?: Vector4[];
  45414. faceColors?: Color4[];
  45415. sideOrientation?: number;
  45416. frontUVs?: Vector4;
  45417. backUVs?: Vector4;
  45418. wrap?: boolean;
  45419. topBaseAt?: number;
  45420. bottomBaseAt?: number;
  45421. updatable?: boolean;
  45422. }, scene?: Nullable<Scene>): Mesh;
  45423. }
  45424. }
  45425. declare module BABYLON {
  45426. /**
  45427. * Class containing static functions to help procedurally build meshes
  45428. */
  45429. export class SphereBuilder {
  45430. /**
  45431. * Creates a sphere mesh
  45432. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45433. * * 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`)
  45434. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45435. * * 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
  45436. * * 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)
  45437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45438. * * 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
  45439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45440. * @param name defines the name of the mesh
  45441. * @param options defines the options used to create the mesh
  45442. * @param scene defines the hosting scene
  45443. * @returns the sphere mesh
  45444. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45445. */
  45446. static CreateSphere(name: string, options: {
  45447. segments?: number;
  45448. diameter?: number;
  45449. diameterX?: number;
  45450. diameterY?: number;
  45451. diameterZ?: number;
  45452. arc?: number;
  45453. slice?: number;
  45454. sideOrientation?: number;
  45455. frontUVs?: Vector4;
  45456. backUVs?: Vector4;
  45457. updatable?: boolean;
  45458. }, scene?: Nullable<Scene>): Mesh;
  45459. }
  45460. }
  45461. declare module BABYLON.Debug {
  45462. /**
  45463. * Used to show the physics impostor around the specific mesh
  45464. */
  45465. export class PhysicsViewer {
  45466. /** @hidden */
  45467. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45468. /** @hidden */
  45469. protected _meshes: Array<Nullable<AbstractMesh>>;
  45470. /** @hidden */
  45471. protected _scene: Nullable<Scene>;
  45472. /** @hidden */
  45473. protected _numMeshes: number;
  45474. /** @hidden */
  45475. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45476. private _renderFunction;
  45477. private _utilityLayer;
  45478. private _debugBoxMesh;
  45479. private _debugSphereMesh;
  45480. private _debugCylinderMesh;
  45481. private _debugMaterial;
  45482. private _debugMeshMeshes;
  45483. /**
  45484. * Creates a new PhysicsViewer
  45485. * @param scene defines the hosting scene
  45486. */
  45487. constructor(scene: Scene);
  45488. /** @hidden */
  45489. protected _updateDebugMeshes(): void;
  45490. /**
  45491. * Renders a specified physic impostor
  45492. * @param impostor defines the impostor to render
  45493. * @param targetMesh defines the mesh represented by the impostor
  45494. * @returns the new debug mesh used to render the impostor
  45495. */
  45496. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45497. /**
  45498. * Hides a specified physic impostor
  45499. * @param impostor defines the impostor to hide
  45500. */
  45501. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45502. private _getDebugMaterial;
  45503. private _getDebugBoxMesh;
  45504. private _getDebugSphereMesh;
  45505. private _getDebugCylinderMesh;
  45506. private _getDebugMeshMesh;
  45507. private _getDebugMesh;
  45508. /** Releases all resources */
  45509. dispose(): void;
  45510. }
  45511. }
  45512. declare module BABYLON {
  45513. /**
  45514. * Class containing static functions to help procedurally build meshes
  45515. */
  45516. export class LinesBuilder {
  45517. /**
  45518. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45519. * * 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
  45520. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45521. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45522. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45523. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45524. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45525. * * 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
  45526. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45529. * @param name defines the name of the new line system
  45530. * @param options defines the options used to create the line system
  45531. * @param scene defines the hosting scene
  45532. * @returns a new line system mesh
  45533. */
  45534. static CreateLineSystem(name: string, options: {
  45535. lines: Vector3[][];
  45536. updatable?: boolean;
  45537. instance?: Nullable<LinesMesh>;
  45538. colors?: Nullable<Color4[][]>;
  45539. useVertexAlpha?: boolean;
  45540. }, scene: Nullable<Scene>): LinesMesh;
  45541. /**
  45542. * Creates a line mesh
  45543. * 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
  45544. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45545. * * The parameter `points` is an array successive Vector3
  45546. * * 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
  45547. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45548. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45549. * * When updating an instance, remember that only point positions can change, not the number of points
  45550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45552. * @param name defines the name of the new line system
  45553. * @param options defines the options used to create the line system
  45554. * @param scene defines the hosting scene
  45555. * @returns a new line mesh
  45556. */
  45557. static CreateLines(name: string, options: {
  45558. points: Vector3[];
  45559. updatable?: boolean;
  45560. instance?: Nullable<LinesMesh>;
  45561. colors?: Color4[];
  45562. useVertexAlpha?: boolean;
  45563. }, scene?: Nullable<Scene>): LinesMesh;
  45564. /**
  45565. * Creates a dashed line mesh
  45566. * * 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
  45567. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45568. * * The parameter `points` is an array successive Vector3
  45569. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45570. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45571. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45572. * * 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
  45573. * * When updating an instance, remember that only point positions can change, not the number of points
  45574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45575. * @param name defines the name of the mesh
  45576. * @param options defines the options used to create the mesh
  45577. * @param scene defines the hosting scene
  45578. * @returns the dashed line mesh
  45579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45580. */
  45581. static CreateDashedLines(name: string, options: {
  45582. points: Vector3[];
  45583. dashSize?: number;
  45584. gapSize?: number;
  45585. dashNb?: number;
  45586. updatable?: boolean;
  45587. instance?: LinesMesh;
  45588. }, scene?: Nullable<Scene>): LinesMesh;
  45589. }
  45590. }
  45591. declare module BABYLON {
  45592. /**
  45593. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45594. * in order to better appreciate the issue one might have.
  45595. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45596. */
  45597. export class RayHelper {
  45598. /**
  45599. * Defines the ray we are currently tryin to visualize.
  45600. */
  45601. ray: Nullable<Ray>;
  45602. private _renderPoints;
  45603. private _renderLine;
  45604. private _renderFunction;
  45605. private _scene;
  45606. private _updateToMeshFunction;
  45607. private _attachedToMesh;
  45608. private _meshSpaceDirection;
  45609. private _meshSpaceOrigin;
  45610. /**
  45611. * Helper function to create a colored helper in a scene in one line.
  45612. * @param ray Defines the ray we are currently tryin to visualize
  45613. * @param scene Defines the scene the ray is used in
  45614. * @param color Defines the color we want to see the ray in
  45615. * @returns The newly created ray helper.
  45616. */
  45617. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45618. /**
  45619. * Instantiate a new ray helper.
  45620. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45621. * in order to better appreciate the issue one might have.
  45622. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45623. * @param ray Defines the ray we are currently tryin to visualize
  45624. */
  45625. constructor(ray: Ray);
  45626. /**
  45627. * Shows the ray we are willing to debug.
  45628. * @param scene Defines the scene the ray needs to be rendered in
  45629. * @param color Defines the color the ray needs to be rendered in
  45630. */
  45631. show(scene: Scene, color?: Color3): void;
  45632. /**
  45633. * Hides the ray we are debugging.
  45634. */
  45635. hide(): void;
  45636. private _render;
  45637. /**
  45638. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45639. * @param mesh Defines the mesh we want the helper attached to
  45640. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45641. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45642. * @param length Defines the length of the ray
  45643. */
  45644. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45645. /**
  45646. * Detach the ray helper from the mesh it has previously been attached to.
  45647. */
  45648. detachFromMesh(): void;
  45649. private _updateToMesh;
  45650. /**
  45651. * Dispose the helper and release its associated resources.
  45652. */
  45653. dispose(): void;
  45654. }
  45655. }
  45656. declare module BABYLON.Debug {
  45657. /**
  45658. * Class used to render a debug view of a given skeleton
  45659. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45660. */
  45661. export class SkeletonViewer {
  45662. /** defines the skeleton to render */
  45663. skeleton: Skeleton;
  45664. /** defines the mesh attached to the skeleton */
  45665. mesh: AbstractMesh;
  45666. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45667. autoUpdateBonesMatrices: boolean;
  45668. /** defines the rendering group id to use with the viewer */
  45669. renderingGroupId: number;
  45670. /** Gets or sets the color used to render the skeleton */
  45671. color: Color3;
  45672. private _scene;
  45673. private _debugLines;
  45674. private _debugMesh;
  45675. private _isEnabled;
  45676. private _renderFunction;
  45677. private _utilityLayer;
  45678. /**
  45679. * Returns the mesh used to render the bones
  45680. */
  45681. get debugMesh(): Nullable<LinesMesh>;
  45682. /**
  45683. * Creates a new SkeletonViewer
  45684. * @param skeleton defines the skeleton to render
  45685. * @param mesh defines the mesh attached to the skeleton
  45686. * @param scene defines the hosting scene
  45687. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45688. * @param renderingGroupId defines the rendering group id to use with the viewer
  45689. */
  45690. constructor(
  45691. /** defines the skeleton to render */
  45692. skeleton: Skeleton,
  45693. /** defines the mesh attached to the skeleton */
  45694. mesh: AbstractMesh, scene: Scene,
  45695. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45696. autoUpdateBonesMatrices?: boolean,
  45697. /** defines the rendering group id to use with the viewer */
  45698. renderingGroupId?: number);
  45699. /** Gets or sets a boolean indicating if the viewer is enabled */
  45700. set isEnabled(value: boolean);
  45701. get isEnabled(): boolean;
  45702. private _getBonePosition;
  45703. private _getLinesForBonesWithLength;
  45704. private _getLinesForBonesNoLength;
  45705. /** Update the viewer to sync with current skeleton state */
  45706. update(): void;
  45707. /** Release associated resources */
  45708. dispose(): void;
  45709. }
  45710. }
  45711. declare module BABYLON {
  45712. /**
  45713. * Options to create the null engine
  45714. */
  45715. export class NullEngineOptions {
  45716. /**
  45717. * Render width (Default: 512)
  45718. */
  45719. renderWidth: number;
  45720. /**
  45721. * Render height (Default: 256)
  45722. */
  45723. renderHeight: number;
  45724. /**
  45725. * Texture size (Default: 512)
  45726. */
  45727. textureSize: number;
  45728. /**
  45729. * If delta time between frames should be constant
  45730. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45731. */
  45732. deterministicLockstep: boolean;
  45733. /**
  45734. * Maximum about of steps between frames (Default: 4)
  45735. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45736. */
  45737. lockstepMaxSteps: number;
  45738. }
  45739. /**
  45740. * The null engine class provides support for headless version of babylon.js.
  45741. * This can be used in server side scenario or for testing purposes
  45742. */
  45743. export class NullEngine extends Engine {
  45744. private _options;
  45745. /**
  45746. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45748. * @returns true if engine is in deterministic lock step mode
  45749. */
  45750. isDeterministicLockStep(): boolean;
  45751. /**
  45752. * Gets the max steps when engine is running in deterministic lock step
  45753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45754. * @returns the max steps
  45755. */
  45756. getLockstepMaxSteps(): number;
  45757. /**
  45758. * Gets the current hardware scaling level.
  45759. * By default the hardware scaling level is computed from the window device ratio.
  45760. * 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.
  45761. * @returns a number indicating the current hardware scaling level
  45762. */
  45763. getHardwareScalingLevel(): number;
  45764. constructor(options?: NullEngineOptions);
  45765. /**
  45766. * Creates a vertex buffer
  45767. * @param vertices the data for the vertex buffer
  45768. * @returns the new WebGL static buffer
  45769. */
  45770. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45771. /**
  45772. * Creates a new index buffer
  45773. * @param indices defines the content of the index buffer
  45774. * @param updatable defines if the index buffer must be updatable
  45775. * @returns a new webGL buffer
  45776. */
  45777. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45778. /**
  45779. * Clear the current render buffer or the current render target (if any is set up)
  45780. * @param color defines the color to use
  45781. * @param backBuffer defines if the back buffer must be cleared
  45782. * @param depth defines if the depth buffer must be cleared
  45783. * @param stencil defines if the stencil buffer must be cleared
  45784. */
  45785. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45786. /**
  45787. * Gets the current render width
  45788. * @param useScreen defines if screen size must be used (or the current render target if any)
  45789. * @returns a number defining the current render width
  45790. */
  45791. getRenderWidth(useScreen?: boolean): number;
  45792. /**
  45793. * Gets the current render height
  45794. * @param useScreen defines if screen size must be used (or the current render target if any)
  45795. * @returns a number defining the current render height
  45796. */
  45797. getRenderHeight(useScreen?: boolean): number;
  45798. /**
  45799. * Set the WebGL's viewport
  45800. * @param viewport defines the viewport element to be used
  45801. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45802. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45803. */
  45804. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45805. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45806. /**
  45807. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45808. * @param pipelineContext defines the pipeline context to use
  45809. * @param uniformsNames defines the list of uniform names
  45810. * @returns an array of webGL uniform locations
  45811. */
  45812. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45813. /**
  45814. * Gets the lsit of active attributes for a given webGL program
  45815. * @param pipelineContext defines the pipeline context to use
  45816. * @param attributesNames defines the list of attribute names to get
  45817. * @returns an array of indices indicating the offset of each attribute
  45818. */
  45819. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45820. /**
  45821. * Binds an effect to the webGL context
  45822. * @param effect defines the effect to bind
  45823. */
  45824. bindSamplers(effect: Effect): void;
  45825. /**
  45826. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45827. * @param effect defines the effect to activate
  45828. */
  45829. enableEffect(effect: Effect): void;
  45830. /**
  45831. * Set various states to the webGL context
  45832. * @param culling defines backface culling state
  45833. * @param zOffset defines the value to apply to zOffset (0 by default)
  45834. * @param force defines if states must be applied even if cache is up to date
  45835. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45836. */
  45837. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45838. /**
  45839. * Set the value of an uniform to an array of int32
  45840. * @param uniform defines the webGL uniform location where to store the value
  45841. * @param array defines the array of int32 to store
  45842. */
  45843. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45844. /**
  45845. * Set the value of an uniform to an array of int32 (stored as vec2)
  45846. * @param uniform defines the webGL uniform location where to store the value
  45847. * @param array defines the array of int32 to store
  45848. */
  45849. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45850. /**
  45851. * Set the value of an uniform to an array of int32 (stored as vec3)
  45852. * @param uniform defines the webGL uniform location where to store the value
  45853. * @param array defines the array of int32 to store
  45854. */
  45855. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45856. /**
  45857. * Set the value of an uniform to an array of int32 (stored as vec4)
  45858. * @param uniform defines the webGL uniform location where to store the value
  45859. * @param array defines the array of int32 to store
  45860. */
  45861. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45862. /**
  45863. * Set the value of an uniform to an array of float32
  45864. * @param uniform defines the webGL uniform location where to store the value
  45865. * @param array defines the array of float32 to store
  45866. */
  45867. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45868. /**
  45869. * Set the value of an uniform to an array of float32 (stored as vec2)
  45870. * @param uniform defines the webGL uniform location where to store the value
  45871. * @param array defines the array of float32 to store
  45872. */
  45873. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45874. /**
  45875. * Set the value of an uniform to an array of float32 (stored as vec3)
  45876. * @param uniform defines the webGL uniform location where to store the value
  45877. * @param array defines the array of float32 to store
  45878. */
  45879. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45880. /**
  45881. * Set the value of an uniform to an array of float32 (stored as vec4)
  45882. * @param uniform defines the webGL uniform location where to store the value
  45883. * @param array defines the array of float32 to store
  45884. */
  45885. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45886. /**
  45887. * Set the value of an uniform to an array of number
  45888. * @param uniform defines the webGL uniform location where to store the value
  45889. * @param array defines the array of number to store
  45890. */
  45891. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45892. /**
  45893. * Set the value of an uniform to an array of number (stored as vec2)
  45894. * @param uniform defines the webGL uniform location where to store the value
  45895. * @param array defines the array of number to store
  45896. */
  45897. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45898. /**
  45899. * Set the value of an uniform to an array of number (stored as vec3)
  45900. * @param uniform defines the webGL uniform location where to store the value
  45901. * @param array defines the array of number to store
  45902. */
  45903. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45904. /**
  45905. * Set the value of an uniform to an array of number (stored as vec4)
  45906. * @param uniform defines the webGL uniform location where to store the value
  45907. * @param array defines the array of number to store
  45908. */
  45909. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45910. /**
  45911. * Set the value of an uniform to an array of float32 (stored as matrices)
  45912. * @param uniform defines the webGL uniform location where to store the value
  45913. * @param matrices defines the array of float32 to store
  45914. */
  45915. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45916. /**
  45917. * Set the value of an uniform to a matrix (3x3)
  45918. * @param uniform defines the webGL uniform location where to store the value
  45919. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45920. */
  45921. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45922. /**
  45923. * Set the value of an uniform to a matrix (2x2)
  45924. * @param uniform defines the webGL uniform location where to store the value
  45925. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45926. */
  45927. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45928. /**
  45929. * Set the value of an uniform to a number (float)
  45930. * @param uniform defines the webGL uniform location where to store the value
  45931. * @param value defines the float number to store
  45932. */
  45933. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45934. /**
  45935. * Set the value of an uniform to a vec2
  45936. * @param uniform defines the webGL uniform location where to store the value
  45937. * @param x defines the 1st component of the value
  45938. * @param y defines the 2nd component of the value
  45939. */
  45940. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45941. /**
  45942. * Set the value of an uniform to a vec3
  45943. * @param uniform defines the webGL uniform location where to store the value
  45944. * @param x defines the 1st component of the value
  45945. * @param y defines the 2nd component of the value
  45946. * @param z defines the 3rd component of the value
  45947. */
  45948. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45949. /**
  45950. * Set the value of an uniform to a boolean
  45951. * @param uniform defines the webGL uniform location where to store the value
  45952. * @param bool defines the boolean to store
  45953. */
  45954. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45955. /**
  45956. * Set the value of an uniform to a vec4
  45957. * @param uniform defines the webGL uniform location where to store the value
  45958. * @param x defines the 1st component of the value
  45959. * @param y defines the 2nd component of the value
  45960. * @param z defines the 3rd component of the value
  45961. * @param w defines the 4th component of the value
  45962. */
  45963. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45964. /**
  45965. * Sets the current alpha mode
  45966. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45967. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45969. */
  45970. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45971. /**
  45972. * Bind webGl buffers directly to the webGL context
  45973. * @param vertexBuffers defines the vertex buffer to bind
  45974. * @param indexBuffer defines the index buffer to bind
  45975. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45976. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45977. * @param effect defines the effect associated with the vertex buffer
  45978. */
  45979. bindBuffers(vertexBuffers: {
  45980. [key: string]: VertexBuffer;
  45981. }, indexBuffer: DataBuffer, effect: Effect): void;
  45982. /**
  45983. * Force the entire cache to be cleared
  45984. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45985. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45986. */
  45987. wipeCaches(bruteForce?: boolean): void;
  45988. /**
  45989. * Send a draw order
  45990. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45991. * @param indexStart defines the starting index
  45992. * @param indexCount defines the number of index to draw
  45993. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45994. */
  45995. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45996. /**
  45997. * Draw a list of indexed primitives
  45998. * @param fillMode defines the primitive to use
  45999. * @param indexStart defines the starting index
  46000. * @param indexCount defines the number of index to draw
  46001. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46002. */
  46003. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46004. /**
  46005. * Draw a list of unindexed primitives
  46006. * @param fillMode defines the primitive to use
  46007. * @param verticesStart defines the index of first vertex to draw
  46008. * @param verticesCount defines the count of vertices to draw
  46009. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46010. */
  46011. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46012. /** @hidden */
  46013. _createTexture(): WebGLTexture;
  46014. /** @hidden */
  46015. _releaseTexture(texture: InternalTexture): void;
  46016. /**
  46017. * Usually called from Texture.ts.
  46018. * Passed information to create a WebGLTexture
  46019. * @param urlArg defines a value which contains one of the following:
  46020. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46021. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46022. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46023. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46024. * @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)
  46025. * @param scene needed for loading to the correct scene
  46026. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46027. * @param onLoad optional callback to be called upon successful completion
  46028. * @param onError optional callback to be called upon failure
  46029. * @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
  46030. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46031. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46032. * @param forcedExtension defines the extension to use to pick the right loader
  46033. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46034. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46035. */
  46036. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  46037. /**
  46038. * Creates a new render target texture
  46039. * @param size defines the size of the texture
  46040. * @param options defines the options used to create the texture
  46041. * @returns a new render target texture stored in an InternalTexture
  46042. */
  46043. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46044. /**
  46045. * Update the sampling mode of a given texture
  46046. * @param samplingMode defines the required sampling mode
  46047. * @param texture defines the texture to update
  46048. */
  46049. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46050. /**
  46051. * Binds the frame buffer to the specified texture.
  46052. * @param texture The texture to render to or null for the default canvas
  46053. * @param faceIndex The face of the texture to render to in case of cube texture
  46054. * @param requiredWidth The width of the target to render to
  46055. * @param requiredHeight The height of the target to render to
  46056. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46057. * @param depthStencilTexture The depth stencil texture to use to render
  46058. * @param lodLevel defines le lod level to bind to the frame buffer
  46059. */
  46060. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46061. /**
  46062. * Unbind the current render target texture from the webGL context
  46063. * @param texture defines the render target texture to unbind
  46064. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46065. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46066. */
  46067. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46068. /**
  46069. * Creates a dynamic vertex buffer
  46070. * @param vertices the data for the dynamic vertex buffer
  46071. * @returns the new WebGL dynamic buffer
  46072. */
  46073. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46074. /**
  46075. * Update the content of a dynamic texture
  46076. * @param texture defines the texture to update
  46077. * @param canvas defines the canvas containing the source
  46078. * @param invertY defines if data must be stored with Y axis inverted
  46079. * @param premulAlpha defines if alpha is stored as premultiplied
  46080. * @param format defines the format of the data
  46081. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46082. */
  46083. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46084. /**
  46085. * Gets a boolean indicating if all created effects are ready
  46086. * @returns true if all effects are ready
  46087. */
  46088. areAllEffectsReady(): boolean;
  46089. /**
  46090. * @hidden
  46091. * Get the current error code of the webGL context
  46092. * @returns the error code
  46093. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46094. */
  46095. getError(): number;
  46096. /** @hidden */
  46097. _getUnpackAlignement(): number;
  46098. /** @hidden */
  46099. _unpackFlipY(value: boolean): void;
  46100. /**
  46101. * Update a dynamic index buffer
  46102. * @param indexBuffer defines the target index buffer
  46103. * @param indices defines the data to update
  46104. * @param offset defines the offset in the target index buffer where update should start
  46105. */
  46106. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46107. /**
  46108. * Updates a dynamic vertex buffer.
  46109. * @param vertexBuffer the vertex buffer to update
  46110. * @param vertices the data used to update the vertex buffer
  46111. * @param byteOffset the byte offset of the data (optional)
  46112. * @param byteLength the byte length of the data (optional)
  46113. */
  46114. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46115. /** @hidden */
  46116. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46117. /** @hidden */
  46118. _bindTexture(channel: number, texture: InternalTexture): void;
  46119. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46120. /**
  46121. * 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
  46122. */
  46123. releaseEffects(): void;
  46124. displayLoadingUI(): void;
  46125. hideLoadingUI(): void;
  46126. /** @hidden */
  46127. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46128. /** @hidden */
  46129. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46130. /** @hidden */
  46131. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46132. /** @hidden */
  46133. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46134. }
  46135. }
  46136. declare module BABYLON {
  46137. /** @hidden */
  46138. export class _OcclusionDataStorage {
  46139. /** @hidden */
  46140. occlusionInternalRetryCounter: number;
  46141. /** @hidden */
  46142. isOcclusionQueryInProgress: boolean;
  46143. /** @hidden */
  46144. isOccluded: boolean;
  46145. /** @hidden */
  46146. occlusionRetryCount: number;
  46147. /** @hidden */
  46148. occlusionType: number;
  46149. /** @hidden */
  46150. occlusionQueryAlgorithmType: number;
  46151. }
  46152. interface Engine {
  46153. /**
  46154. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46155. * @return the new query
  46156. */
  46157. createQuery(): WebGLQuery;
  46158. /**
  46159. * Delete and release a webGL query
  46160. * @param query defines the query to delete
  46161. * @return the current engine
  46162. */
  46163. deleteQuery(query: WebGLQuery): Engine;
  46164. /**
  46165. * Check if a given query has resolved and got its value
  46166. * @param query defines the query to check
  46167. * @returns true if the query got its value
  46168. */
  46169. isQueryResultAvailable(query: WebGLQuery): boolean;
  46170. /**
  46171. * Gets the value of a given query
  46172. * @param query defines the query to check
  46173. * @returns the value of the query
  46174. */
  46175. getQueryResult(query: WebGLQuery): number;
  46176. /**
  46177. * Initiates an occlusion query
  46178. * @param algorithmType defines the algorithm to use
  46179. * @param query defines the query to use
  46180. * @returns the current engine
  46181. * @see http://doc.babylonjs.com/features/occlusionquery
  46182. */
  46183. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46184. /**
  46185. * Ends an occlusion query
  46186. * @see http://doc.babylonjs.com/features/occlusionquery
  46187. * @param algorithmType defines the algorithm to use
  46188. * @returns the current engine
  46189. */
  46190. endOcclusionQuery(algorithmType: number): Engine;
  46191. /**
  46192. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46193. * Please note that only one query can be issued at a time
  46194. * @returns a time token used to track the time span
  46195. */
  46196. startTimeQuery(): Nullable<_TimeToken>;
  46197. /**
  46198. * Ends a time query
  46199. * @param token defines the token used to measure the time span
  46200. * @returns the time spent (in ns)
  46201. */
  46202. endTimeQuery(token: _TimeToken): int;
  46203. /** @hidden */
  46204. _currentNonTimestampToken: Nullable<_TimeToken>;
  46205. /** @hidden */
  46206. _createTimeQuery(): WebGLQuery;
  46207. /** @hidden */
  46208. _deleteTimeQuery(query: WebGLQuery): void;
  46209. /** @hidden */
  46210. _getGlAlgorithmType(algorithmType: number): number;
  46211. /** @hidden */
  46212. _getTimeQueryResult(query: WebGLQuery): any;
  46213. /** @hidden */
  46214. _getTimeQueryAvailability(query: WebGLQuery): any;
  46215. }
  46216. interface AbstractMesh {
  46217. /**
  46218. * Backing filed
  46219. * @hidden
  46220. */
  46221. __occlusionDataStorage: _OcclusionDataStorage;
  46222. /**
  46223. * Access property
  46224. * @hidden
  46225. */
  46226. _occlusionDataStorage: _OcclusionDataStorage;
  46227. /**
  46228. * 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.
  46229. * The default value is -1 which means don't break the query and wait till the result
  46230. * @see http://doc.babylonjs.com/features/occlusionquery
  46231. */
  46232. occlusionRetryCount: number;
  46233. /**
  46234. * 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:
  46235. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46236. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46237. * * 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.
  46238. * @see http://doc.babylonjs.com/features/occlusionquery
  46239. */
  46240. occlusionType: number;
  46241. /**
  46242. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46243. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46244. * * 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.
  46245. * @see http://doc.babylonjs.com/features/occlusionquery
  46246. */
  46247. occlusionQueryAlgorithmType: number;
  46248. /**
  46249. * 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
  46250. * @see http://doc.babylonjs.com/features/occlusionquery
  46251. */
  46252. isOccluded: boolean;
  46253. /**
  46254. * Flag to check the progress status of the query
  46255. * @see http://doc.babylonjs.com/features/occlusionquery
  46256. */
  46257. isOcclusionQueryInProgress: boolean;
  46258. }
  46259. }
  46260. declare module BABYLON {
  46261. /** @hidden */
  46262. export var _forceTransformFeedbackToBundle: boolean;
  46263. interface Engine {
  46264. /**
  46265. * Creates a webGL transform feedback object
  46266. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46267. * @returns the webGL transform feedback object
  46268. */
  46269. createTransformFeedback(): WebGLTransformFeedback;
  46270. /**
  46271. * Delete a webGL transform feedback object
  46272. * @param value defines the webGL transform feedback object to delete
  46273. */
  46274. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46275. /**
  46276. * Bind a webGL transform feedback object to the webgl context
  46277. * @param value defines the webGL transform feedback object to bind
  46278. */
  46279. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46280. /**
  46281. * Begins a transform feedback operation
  46282. * @param usePoints defines if points or triangles must be used
  46283. */
  46284. beginTransformFeedback(usePoints: boolean): void;
  46285. /**
  46286. * Ends a transform feedback operation
  46287. */
  46288. endTransformFeedback(): void;
  46289. /**
  46290. * Specify the varyings to use with transform feedback
  46291. * @param program defines the associated webGL program
  46292. * @param value defines the list of strings representing the varying names
  46293. */
  46294. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46295. /**
  46296. * Bind a webGL buffer for a transform feedback operation
  46297. * @param value defines the webGL buffer to bind
  46298. */
  46299. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46300. }
  46301. }
  46302. declare module BABYLON {
  46303. /**
  46304. * Creation options of the multi render target texture.
  46305. */
  46306. export interface IMultiRenderTargetOptions {
  46307. /**
  46308. * Define if the texture needs to create mip maps after render.
  46309. */
  46310. generateMipMaps?: boolean;
  46311. /**
  46312. * Define the types of all the draw buffers we want to create
  46313. */
  46314. types?: number[];
  46315. /**
  46316. * Define the sampling modes of all the draw buffers we want to create
  46317. */
  46318. samplingModes?: number[];
  46319. /**
  46320. * Define if a depth buffer is required
  46321. */
  46322. generateDepthBuffer?: boolean;
  46323. /**
  46324. * Define if a stencil buffer is required
  46325. */
  46326. generateStencilBuffer?: boolean;
  46327. /**
  46328. * Define if a depth texture is required instead of a depth buffer
  46329. */
  46330. generateDepthTexture?: boolean;
  46331. /**
  46332. * Define the number of desired draw buffers
  46333. */
  46334. textureCount?: number;
  46335. /**
  46336. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46337. */
  46338. doNotChangeAspectRatio?: boolean;
  46339. /**
  46340. * Define the default type of the buffers we are creating
  46341. */
  46342. defaultType?: number;
  46343. }
  46344. /**
  46345. * A multi render target, like a render target provides the ability to render to a texture.
  46346. * Unlike the render target, it can render to several draw buffers in one draw.
  46347. * This is specially interesting in deferred rendering or for any effects requiring more than
  46348. * just one color from a single pass.
  46349. */
  46350. export class MultiRenderTarget extends RenderTargetTexture {
  46351. private _internalTextures;
  46352. private _textures;
  46353. private _multiRenderTargetOptions;
  46354. /**
  46355. * Get if draw buffers are currently supported by the used hardware and browser.
  46356. */
  46357. get isSupported(): boolean;
  46358. /**
  46359. * Get the list of textures generated by the multi render target.
  46360. */
  46361. get textures(): Texture[];
  46362. /**
  46363. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46364. */
  46365. get depthTexture(): Texture;
  46366. /**
  46367. * Set the wrapping mode on U of all the textures we are rendering to.
  46368. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46369. */
  46370. set wrapU(wrap: number);
  46371. /**
  46372. * Set the wrapping mode on V of all the textures we are rendering to.
  46373. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46374. */
  46375. set wrapV(wrap: number);
  46376. /**
  46377. * Instantiate a new multi render target texture.
  46378. * A multi render target, like a render target provides the ability to render to a texture.
  46379. * Unlike the render target, it can render to several draw buffers in one draw.
  46380. * This is specially interesting in deferred rendering or for any effects requiring more than
  46381. * just one color from a single pass.
  46382. * @param name Define the name of the texture
  46383. * @param size Define the size of the buffers to render to
  46384. * @param count Define the number of target we are rendering into
  46385. * @param scene Define the scene the texture belongs to
  46386. * @param options Define the options used to create the multi render target
  46387. */
  46388. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46389. /** @hidden */
  46390. _rebuild(): void;
  46391. private _createInternalTextures;
  46392. private _createTextures;
  46393. /**
  46394. * Define the number of samples used if MSAA is enabled.
  46395. */
  46396. get samples(): number;
  46397. set samples(value: number);
  46398. /**
  46399. * Resize all the textures in the multi render target.
  46400. * Be carrefull as it will recreate all the data in the new texture.
  46401. * @param size Define the new size
  46402. */
  46403. resize(size: any): void;
  46404. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46405. /**
  46406. * Dispose the render targets and their associated resources
  46407. */
  46408. dispose(): void;
  46409. /**
  46410. * Release all the underlying texture used as draw buffers.
  46411. */
  46412. releaseInternalTextures(): void;
  46413. }
  46414. }
  46415. declare module BABYLON {
  46416. interface ThinEngine {
  46417. /**
  46418. * Unbind a list of render target textures from the webGL context
  46419. * This is used only when drawBuffer extension or webGL2 are active
  46420. * @param textures defines the render target textures to unbind
  46421. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46422. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46423. */
  46424. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46425. /**
  46426. * Create a multi render target texture
  46427. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46428. * @param size defines the size of the texture
  46429. * @param options defines the creation options
  46430. * @returns the cube texture as an InternalTexture
  46431. */
  46432. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46433. /**
  46434. * Update the sample count for a given multiple render target texture
  46435. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46436. * @param textures defines the textures to update
  46437. * @param samples defines the sample count to set
  46438. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46439. */
  46440. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46441. }
  46442. }
  46443. declare module BABYLON {
  46444. /**
  46445. * Class used to define an additional view for the engine
  46446. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46447. */
  46448. export class EngineView {
  46449. /** Defines the canvas where to render the view */
  46450. target: HTMLCanvasElement;
  46451. /** Defines an optional camera used to render the view (will use active camera else) */
  46452. camera?: Camera;
  46453. }
  46454. interface Engine {
  46455. /**
  46456. * Gets or sets the HTML element to use for attaching events
  46457. */
  46458. inputElement: Nullable<HTMLElement>;
  46459. /**
  46460. * Gets the current engine view
  46461. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46462. */
  46463. activeView: Nullable<EngineView>;
  46464. /** Gets or sets the list of views */
  46465. views: EngineView[];
  46466. /**
  46467. * Register a new child canvas
  46468. * @param canvas defines the canvas to register
  46469. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46470. * @returns the associated view
  46471. */
  46472. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46473. /**
  46474. * Remove a registered child canvas
  46475. * @param canvas defines the canvas to remove
  46476. * @returns the current engine
  46477. */
  46478. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46479. }
  46480. }
  46481. declare module BABYLON {
  46482. /**
  46483. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46484. */
  46485. export interface CubeMapInfo {
  46486. /**
  46487. * The pixel array for the front face.
  46488. * This is stored in format, left to right, up to down format.
  46489. */
  46490. front: Nullable<ArrayBufferView>;
  46491. /**
  46492. * The pixel array for the back face.
  46493. * This is stored in format, left to right, up to down format.
  46494. */
  46495. back: Nullable<ArrayBufferView>;
  46496. /**
  46497. * The pixel array for the left face.
  46498. * This is stored in format, left to right, up to down format.
  46499. */
  46500. left: Nullable<ArrayBufferView>;
  46501. /**
  46502. * The pixel array for the right face.
  46503. * This is stored in format, left to right, up to down format.
  46504. */
  46505. right: Nullable<ArrayBufferView>;
  46506. /**
  46507. * The pixel array for the up face.
  46508. * This is stored in format, left to right, up to down format.
  46509. */
  46510. up: Nullable<ArrayBufferView>;
  46511. /**
  46512. * The pixel array for the down face.
  46513. * This is stored in format, left to right, up to down format.
  46514. */
  46515. down: Nullable<ArrayBufferView>;
  46516. /**
  46517. * The size of the cubemap stored.
  46518. *
  46519. * Each faces will be size * size pixels.
  46520. */
  46521. size: number;
  46522. /**
  46523. * The format of the texture.
  46524. *
  46525. * RGBA, RGB.
  46526. */
  46527. format: number;
  46528. /**
  46529. * The type of the texture data.
  46530. *
  46531. * UNSIGNED_INT, FLOAT.
  46532. */
  46533. type: number;
  46534. /**
  46535. * Specifies whether the texture is in gamma space.
  46536. */
  46537. gammaSpace: boolean;
  46538. }
  46539. /**
  46540. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46541. */
  46542. export class PanoramaToCubeMapTools {
  46543. private static FACE_FRONT;
  46544. private static FACE_BACK;
  46545. private static FACE_RIGHT;
  46546. private static FACE_LEFT;
  46547. private static FACE_DOWN;
  46548. private static FACE_UP;
  46549. /**
  46550. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46551. *
  46552. * @param float32Array The source data.
  46553. * @param inputWidth The width of the input panorama.
  46554. * @param inputHeight The height of the input panorama.
  46555. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46556. * @return The cubemap data
  46557. */
  46558. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46559. private static CreateCubemapTexture;
  46560. private static CalcProjectionSpherical;
  46561. }
  46562. }
  46563. declare module BABYLON {
  46564. /**
  46565. * Helper class dealing with the extraction of spherical polynomial dataArray
  46566. * from a cube map.
  46567. */
  46568. export class CubeMapToSphericalPolynomialTools {
  46569. private static FileFaces;
  46570. /**
  46571. * Converts a texture to the according Spherical Polynomial data.
  46572. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46573. *
  46574. * @param texture The texture to extract the information from.
  46575. * @return The Spherical Polynomial data.
  46576. */
  46577. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46578. /**
  46579. * Converts a cubemap to the according Spherical Polynomial data.
  46580. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46581. *
  46582. * @param cubeInfo The Cube map to extract the information from.
  46583. * @return The Spherical Polynomial data.
  46584. */
  46585. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46586. }
  46587. }
  46588. declare module BABYLON {
  46589. interface BaseTexture {
  46590. /**
  46591. * Get the polynomial representation of the texture data.
  46592. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46593. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46594. */
  46595. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46596. }
  46597. }
  46598. declare module BABYLON {
  46599. /** @hidden */
  46600. export var rgbdEncodePixelShader: {
  46601. name: string;
  46602. shader: string;
  46603. };
  46604. }
  46605. declare module BABYLON {
  46606. /** @hidden */
  46607. export var rgbdDecodePixelShader: {
  46608. name: string;
  46609. shader: string;
  46610. };
  46611. }
  46612. declare module BABYLON {
  46613. /**
  46614. * Raw texture data and descriptor sufficient for WebGL texture upload
  46615. */
  46616. export interface EnvironmentTextureInfo {
  46617. /**
  46618. * Version of the environment map
  46619. */
  46620. version: number;
  46621. /**
  46622. * Width of image
  46623. */
  46624. width: number;
  46625. /**
  46626. * Irradiance information stored in the file.
  46627. */
  46628. irradiance: any;
  46629. /**
  46630. * Specular information stored in the file.
  46631. */
  46632. specular: any;
  46633. }
  46634. /**
  46635. * Defines One Image in the file. It requires only the position in the file
  46636. * as well as the length.
  46637. */
  46638. interface BufferImageData {
  46639. /**
  46640. * Length of the image data.
  46641. */
  46642. length: number;
  46643. /**
  46644. * Position of the data from the null terminator delimiting the end of the JSON.
  46645. */
  46646. position: number;
  46647. }
  46648. /**
  46649. * Defines the specular data enclosed in the file.
  46650. * This corresponds to the version 1 of the data.
  46651. */
  46652. export interface EnvironmentTextureSpecularInfoV1 {
  46653. /**
  46654. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46655. */
  46656. specularDataPosition?: number;
  46657. /**
  46658. * This contains all the images data needed to reconstruct the cubemap.
  46659. */
  46660. mipmaps: Array<BufferImageData>;
  46661. /**
  46662. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46663. */
  46664. lodGenerationScale: number;
  46665. }
  46666. /**
  46667. * Sets of helpers addressing the serialization and deserialization of environment texture
  46668. * stored in a BabylonJS env file.
  46669. * Those files are usually stored as .env files.
  46670. */
  46671. export class EnvironmentTextureTools {
  46672. /**
  46673. * Magic number identifying the env file.
  46674. */
  46675. private static _MagicBytes;
  46676. /**
  46677. * Gets the environment info from an env file.
  46678. * @param data The array buffer containing the .env bytes.
  46679. * @returns the environment file info (the json header) if successfully parsed.
  46680. */
  46681. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46682. /**
  46683. * Creates an environment texture from a loaded cube texture.
  46684. * @param texture defines the cube texture to convert in env file
  46685. * @return a promise containing the environment data if succesfull.
  46686. */
  46687. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46688. /**
  46689. * Creates a JSON representation of the spherical data.
  46690. * @param texture defines the texture containing the polynomials
  46691. * @return the JSON representation of the spherical info
  46692. */
  46693. private static _CreateEnvTextureIrradiance;
  46694. /**
  46695. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46696. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46697. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46698. * @return the views described by info providing access to the underlying buffer
  46699. */
  46700. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46701. /**
  46702. * Uploads the texture info contained in the env file to the GPU.
  46703. * @param texture defines the internal texture to upload to
  46704. * @param arrayBuffer defines the buffer cotaining the data to load
  46705. * @param info defines the texture info retrieved through the GetEnvInfo method
  46706. * @returns a promise
  46707. */
  46708. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46709. private static _OnImageReadyAsync;
  46710. /**
  46711. * Uploads the levels of image data to the GPU.
  46712. * @param texture defines the internal texture to upload to
  46713. * @param imageData defines the array buffer views of image data [mipmap][face]
  46714. * @returns a promise
  46715. */
  46716. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46717. /**
  46718. * Uploads spherical polynomials information to the texture.
  46719. * @param texture defines the texture we are trying to upload the information to
  46720. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46721. */
  46722. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46723. /** @hidden */
  46724. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46725. }
  46726. }
  46727. declare module BABYLON {
  46728. /**
  46729. * Contains position and normal vectors for a vertex
  46730. */
  46731. export class PositionNormalVertex {
  46732. /** the position of the vertex (defaut: 0,0,0) */
  46733. position: Vector3;
  46734. /** the normal of the vertex (defaut: 0,1,0) */
  46735. normal: Vector3;
  46736. /**
  46737. * Creates a PositionNormalVertex
  46738. * @param position the position of the vertex (defaut: 0,0,0)
  46739. * @param normal the normal of the vertex (defaut: 0,1,0)
  46740. */
  46741. constructor(
  46742. /** the position of the vertex (defaut: 0,0,0) */
  46743. position?: Vector3,
  46744. /** the normal of the vertex (defaut: 0,1,0) */
  46745. normal?: Vector3);
  46746. /**
  46747. * Clones the PositionNormalVertex
  46748. * @returns the cloned PositionNormalVertex
  46749. */
  46750. clone(): PositionNormalVertex;
  46751. }
  46752. /**
  46753. * Contains position, normal and uv vectors for a vertex
  46754. */
  46755. export class PositionNormalTextureVertex {
  46756. /** the position of the vertex (defaut: 0,0,0) */
  46757. position: Vector3;
  46758. /** the normal of the vertex (defaut: 0,1,0) */
  46759. normal: Vector3;
  46760. /** the uv of the vertex (default: 0,0) */
  46761. uv: Vector2;
  46762. /**
  46763. * Creates a PositionNormalTextureVertex
  46764. * @param position the position of the vertex (defaut: 0,0,0)
  46765. * @param normal the normal of the vertex (defaut: 0,1,0)
  46766. * @param uv the uv of the vertex (default: 0,0)
  46767. */
  46768. constructor(
  46769. /** the position of the vertex (defaut: 0,0,0) */
  46770. position?: Vector3,
  46771. /** the normal of the vertex (defaut: 0,1,0) */
  46772. normal?: Vector3,
  46773. /** the uv of the vertex (default: 0,0) */
  46774. uv?: Vector2);
  46775. /**
  46776. * Clones the PositionNormalTextureVertex
  46777. * @returns the cloned PositionNormalTextureVertex
  46778. */
  46779. clone(): PositionNormalTextureVertex;
  46780. }
  46781. }
  46782. declare module BABYLON {
  46783. /** @hidden */
  46784. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46785. private _genericAttributeLocation;
  46786. private _varyingLocationCount;
  46787. private _varyingLocationMap;
  46788. private _replacements;
  46789. private _textureCount;
  46790. private _uniforms;
  46791. lineProcessor(line: string): string;
  46792. attributeProcessor(attribute: string): string;
  46793. varyingProcessor(varying: string, isFragment: boolean): string;
  46794. uniformProcessor(uniform: string): string;
  46795. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46796. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46797. }
  46798. }
  46799. declare module BABYLON {
  46800. /**
  46801. * Container for accessors for natively-stored mesh data buffers.
  46802. */
  46803. class NativeDataBuffer extends DataBuffer {
  46804. /**
  46805. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46806. */
  46807. nativeIndexBuffer?: any;
  46808. /**
  46809. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46810. */
  46811. nativeVertexBuffer?: any;
  46812. }
  46813. /** @hidden */
  46814. class NativeTexture extends InternalTexture {
  46815. getInternalTexture(): InternalTexture;
  46816. getViewCount(): number;
  46817. }
  46818. /** @hidden */
  46819. export class NativeEngine extends Engine {
  46820. private readonly _native;
  46821. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46822. private readonly INVALID_HANDLE;
  46823. getHardwareScalingLevel(): number;
  46824. constructor();
  46825. /**
  46826. * Can be used to override the current requestAnimationFrame requester.
  46827. * @hidden
  46828. */
  46829. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46830. /**
  46831. * Override default engine behavior.
  46832. * @param color
  46833. * @param backBuffer
  46834. * @param depth
  46835. * @param stencil
  46836. */
  46837. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46838. /**
  46839. * Gets host document
  46840. * @returns the host document object
  46841. */
  46842. getHostDocument(): Nullable<Document>;
  46843. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46844. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46845. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46846. recordVertexArrayObject(vertexBuffers: {
  46847. [key: string]: VertexBuffer;
  46848. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46849. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46850. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46851. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46852. /**
  46853. * Draw a list of indexed primitives
  46854. * @param fillMode defines the primitive to use
  46855. * @param indexStart defines the starting index
  46856. * @param indexCount defines the number of index to draw
  46857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46858. */
  46859. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46860. /**
  46861. * Draw a list of unindexed primitives
  46862. * @param fillMode defines the primitive to use
  46863. * @param verticesStart defines the index of first vertex to draw
  46864. * @param verticesCount defines the count of vertices to draw
  46865. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46866. */
  46867. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46868. createPipelineContext(): IPipelineContext;
  46869. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46870. /** @hidden */
  46871. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46872. /** @hidden */
  46873. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46874. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46875. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46876. protected _setProgram(program: WebGLProgram): void;
  46877. _releaseEffect(effect: Effect): void;
  46878. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46879. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46880. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46881. bindSamplers(effect: Effect): void;
  46882. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46883. getRenderWidth(useScreen?: boolean): number;
  46884. getRenderHeight(useScreen?: boolean): number;
  46885. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46886. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46887. /**
  46888. * Set the z offset to apply to current rendering
  46889. * @param value defines the offset to apply
  46890. */
  46891. setZOffset(value: number): void;
  46892. /**
  46893. * Gets the current value of the zOffset
  46894. * @returns the current zOffset state
  46895. */
  46896. getZOffset(): number;
  46897. /**
  46898. * Enable or disable depth buffering
  46899. * @param enable defines the state to set
  46900. */
  46901. setDepthBuffer(enable: boolean): void;
  46902. /**
  46903. * Gets a boolean indicating if depth writing is enabled
  46904. * @returns the current depth writing state
  46905. */
  46906. getDepthWrite(): boolean;
  46907. /**
  46908. * Enable or disable depth writing
  46909. * @param enable defines the state to set
  46910. */
  46911. setDepthWrite(enable: boolean): void;
  46912. /**
  46913. * Enable or disable color writing
  46914. * @param enable defines the state to set
  46915. */
  46916. setColorWrite(enable: boolean): void;
  46917. /**
  46918. * Gets a boolean indicating if color writing is enabled
  46919. * @returns the current color writing state
  46920. */
  46921. getColorWrite(): boolean;
  46922. /**
  46923. * Sets alpha constants used by some alpha blending modes
  46924. * @param r defines the red component
  46925. * @param g defines the green component
  46926. * @param b defines the blue component
  46927. * @param a defines the alpha component
  46928. */
  46929. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46930. /**
  46931. * Sets the current alpha mode
  46932. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46933. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46934. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46935. */
  46936. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46937. /**
  46938. * Gets the current alpha mode
  46939. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46940. * @returns the current alpha mode
  46941. */
  46942. getAlphaMode(): number;
  46943. setInt(uniform: WebGLUniformLocation, int: number): void;
  46944. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46945. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46946. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46947. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46948. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46949. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46950. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46951. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46952. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46953. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46954. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46955. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46956. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46957. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46958. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46959. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46960. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46961. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46962. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46963. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46964. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46965. wipeCaches(bruteForce?: boolean): void;
  46966. _createTexture(): WebGLTexture;
  46967. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46968. /**
  46969. * Usually called from BABYLON.Texture.ts.
  46970. * Passed information to create a WebGLTexture
  46971. * @param urlArg defines a value which contains one of the following:
  46972. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46973. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46974. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46975. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46976. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46977. * @param scene needed for loading to the correct scene
  46978. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46979. * @param onLoad optional callback to be called upon successful completion
  46980. * @param onError optional callback to be called upon failure
  46981. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46982. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46983. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46984. * @param forcedExtension defines the extension to use to pick the right loader
  46985. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46986. */
  46987. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  46988. /**
  46989. * Creates a cube texture
  46990. * @param rootUrl defines the url where the files to load is located
  46991. * @param scene defines the current scene
  46992. * @param files defines the list of files to load (1 per face)
  46993. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46994. * @param onLoad defines an optional callback raised when the texture is loaded
  46995. * @param onError defines an optional callback raised if there is an issue to load the texture
  46996. * @param format defines the format of the data
  46997. * @param forcedExtension defines the extension to use to pick the right loader
  46998. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46999. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47000. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47001. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47002. * @returns the cube texture as an InternalTexture
  47003. */
  47004. 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;
  47005. private _getSamplingFilter;
  47006. private static _GetNativeTextureFormat;
  47007. createRenderTargetTexture(size: number | {
  47008. width: number;
  47009. height: number;
  47010. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47011. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47012. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47013. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47014. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47015. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47016. /**
  47017. * Updates a dynamic vertex buffer.
  47018. * @param vertexBuffer the vertex buffer to update
  47019. * @param data the data used to update the vertex buffer
  47020. * @param byteOffset the byte offset of the data (optional)
  47021. * @param byteLength the byte length of the data (optional)
  47022. */
  47023. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47024. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47025. private _updateAnisotropicLevel;
  47026. private _getAddressMode;
  47027. /** @hidden */
  47028. _bindTexture(channel: number, texture: InternalTexture): void;
  47029. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47030. releaseEffects(): void;
  47031. /** @hidden */
  47032. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47033. /** @hidden */
  47034. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47035. /** @hidden */
  47036. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47037. /** @hidden */
  47038. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47039. }
  47040. }
  47041. declare module BABYLON {
  47042. /**
  47043. * Gather the list of clipboard event types as constants.
  47044. */
  47045. export class ClipboardEventTypes {
  47046. /**
  47047. * The clipboard event is fired when a copy command is active (pressed).
  47048. */
  47049. static readonly COPY: number;
  47050. /**
  47051. * The clipboard event is fired when a cut command is active (pressed).
  47052. */
  47053. static readonly CUT: number;
  47054. /**
  47055. * The clipboard event is fired when a paste command is active (pressed).
  47056. */
  47057. static readonly PASTE: number;
  47058. }
  47059. /**
  47060. * This class is used to store clipboard related info for the onClipboardObservable event.
  47061. */
  47062. export class ClipboardInfo {
  47063. /**
  47064. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47065. */
  47066. type: number;
  47067. /**
  47068. * Defines the related dom event
  47069. */
  47070. event: ClipboardEvent;
  47071. /**
  47072. *Creates an instance of ClipboardInfo.
  47073. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47074. * @param event Defines the related dom event
  47075. */
  47076. constructor(
  47077. /**
  47078. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47079. */
  47080. type: number,
  47081. /**
  47082. * Defines the related dom event
  47083. */
  47084. event: ClipboardEvent);
  47085. /**
  47086. * Get the clipboard event's type from the keycode.
  47087. * @param keyCode Defines the keyCode for the current keyboard event.
  47088. * @return {number}
  47089. */
  47090. static GetTypeFromCharacter(keyCode: number): number;
  47091. }
  47092. }
  47093. declare module BABYLON {
  47094. /**
  47095. * Google Daydream controller
  47096. */
  47097. export class DaydreamController extends WebVRController {
  47098. /**
  47099. * Base Url for the controller model.
  47100. */
  47101. static MODEL_BASE_URL: string;
  47102. /**
  47103. * File name for the controller model.
  47104. */
  47105. static MODEL_FILENAME: string;
  47106. /**
  47107. * Gamepad Id prefix used to identify Daydream Controller.
  47108. */
  47109. static readonly GAMEPAD_ID_PREFIX: string;
  47110. /**
  47111. * Creates a new DaydreamController from a gamepad
  47112. * @param vrGamepad the gamepad that the controller should be created from
  47113. */
  47114. constructor(vrGamepad: any);
  47115. /**
  47116. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47117. * @param scene scene in which to add meshes
  47118. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47119. */
  47120. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47121. /**
  47122. * Called once for each button that changed state since the last frame
  47123. * @param buttonIdx Which button index changed
  47124. * @param state New state of the button
  47125. * @param changes Which properties on the state changed since last frame
  47126. */
  47127. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47128. }
  47129. }
  47130. declare module BABYLON {
  47131. /**
  47132. * Gear VR Controller
  47133. */
  47134. export class GearVRController extends WebVRController {
  47135. /**
  47136. * Base Url for the controller model.
  47137. */
  47138. static MODEL_BASE_URL: string;
  47139. /**
  47140. * File name for the controller model.
  47141. */
  47142. static MODEL_FILENAME: string;
  47143. /**
  47144. * Gamepad Id prefix used to identify this controller.
  47145. */
  47146. static readonly GAMEPAD_ID_PREFIX: string;
  47147. private readonly _buttonIndexToObservableNameMap;
  47148. /**
  47149. * Creates a new GearVRController from a gamepad
  47150. * @param vrGamepad the gamepad that the controller should be created from
  47151. */
  47152. constructor(vrGamepad: any);
  47153. /**
  47154. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47155. * @param scene scene in which to add meshes
  47156. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47157. */
  47158. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47159. /**
  47160. * Called once for each button that changed state since the last frame
  47161. * @param buttonIdx Which button index changed
  47162. * @param state New state of the button
  47163. * @param changes Which properties on the state changed since last frame
  47164. */
  47165. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47166. }
  47167. }
  47168. declare module BABYLON {
  47169. /**
  47170. * Class containing static functions to help procedurally build meshes
  47171. */
  47172. export class PolyhedronBuilder {
  47173. /**
  47174. * Creates a polyhedron mesh
  47175. * * 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
  47176. * * The parameter `size` (positive float, default 1) sets the polygon size
  47177. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47178. * * 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`
  47179. * * 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
  47180. * * 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)`)
  47181. * * 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
  47182. * * 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
  47183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47184. * * 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
  47185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47186. * @param name defines the name of the mesh
  47187. * @param options defines the options used to create the mesh
  47188. * @param scene defines the hosting scene
  47189. * @returns the polyhedron mesh
  47190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47191. */
  47192. static CreatePolyhedron(name: string, options: {
  47193. type?: number;
  47194. size?: number;
  47195. sizeX?: number;
  47196. sizeY?: number;
  47197. sizeZ?: number;
  47198. custom?: any;
  47199. faceUV?: Vector4[];
  47200. faceColors?: Color4[];
  47201. flat?: boolean;
  47202. updatable?: boolean;
  47203. sideOrientation?: number;
  47204. frontUVs?: Vector4;
  47205. backUVs?: Vector4;
  47206. }, scene?: Nullable<Scene>): Mesh;
  47207. }
  47208. }
  47209. declare module BABYLON {
  47210. /**
  47211. * Gizmo that enables scaling a mesh along 3 axis
  47212. */
  47213. export class ScaleGizmo extends Gizmo {
  47214. /**
  47215. * Internal gizmo used for interactions on the x axis
  47216. */
  47217. xGizmo: AxisScaleGizmo;
  47218. /**
  47219. * Internal gizmo used for interactions on the y axis
  47220. */
  47221. yGizmo: AxisScaleGizmo;
  47222. /**
  47223. * Internal gizmo used for interactions on the z axis
  47224. */
  47225. zGizmo: AxisScaleGizmo;
  47226. /**
  47227. * Internal gizmo used to scale all axis equally
  47228. */
  47229. uniformScaleGizmo: AxisScaleGizmo;
  47230. private _meshAttached;
  47231. private _updateGizmoRotationToMatchAttachedMesh;
  47232. private _snapDistance;
  47233. private _scaleRatio;
  47234. private _uniformScalingMesh;
  47235. private _octahedron;
  47236. private _sensitivity;
  47237. /** Fires an event when any of it's sub gizmos are dragged */
  47238. onDragStartObservable: Observable<unknown>;
  47239. /** Fires an event when any of it's sub gizmos are released from dragging */
  47240. onDragEndObservable: Observable<unknown>;
  47241. get attachedMesh(): Nullable<AbstractMesh>;
  47242. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47243. /**
  47244. * Creates a ScaleGizmo
  47245. * @param gizmoLayer The utility layer the gizmo will be added to
  47246. */
  47247. constructor(gizmoLayer?: UtilityLayerRenderer);
  47248. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47249. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47250. /**
  47251. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47252. */
  47253. set snapDistance(value: number);
  47254. get snapDistance(): number;
  47255. /**
  47256. * Ratio for the scale of the gizmo (Default: 1)
  47257. */
  47258. set scaleRatio(value: number);
  47259. get scaleRatio(): number;
  47260. /**
  47261. * Sensitivity factor for dragging (Default: 1)
  47262. */
  47263. set sensitivity(value: number);
  47264. get sensitivity(): number;
  47265. /**
  47266. * Disposes of the gizmo
  47267. */
  47268. dispose(): void;
  47269. }
  47270. }
  47271. declare module BABYLON {
  47272. /**
  47273. * Single axis scale gizmo
  47274. */
  47275. export class AxisScaleGizmo extends Gizmo {
  47276. /**
  47277. * Drag behavior responsible for the gizmos dragging interactions
  47278. */
  47279. dragBehavior: PointerDragBehavior;
  47280. private _pointerObserver;
  47281. /**
  47282. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47283. */
  47284. snapDistance: number;
  47285. /**
  47286. * Event that fires each time the gizmo snaps to a new location.
  47287. * * snapDistance is the the change in distance
  47288. */
  47289. onSnapObservable: Observable<{
  47290. snapDistance: number;
  47291. }>;
  47292. /**
  47293. * If the scaling operation should be done on all axis (default: false)
  47294. */
  47295. uniformScaling: boolean;
  47296. /**
  47297. * Custom sensitivity value for the drag strength
  47298. */
  47299. sensitivity: number;
  47300. private _isEnabled;
  47301. private _parent;
  47302. private _arrow;
  47303. private _coloredMaterial;
  47304. private _hoverMaterial;
  47305. /**
  47306. * Creates an AxisScaleGizmo
  47307. * @param gizmoLayer The utility layer the gizmo will be added to
  47308. * @param dragAxis The axis which the gizmo will be able to scale on
  47309. * @param color The color of the gizmo
  47310. */
  47311. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47312. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47313. /**
  47314. * If the gizmo is enabled
  47315. */
  47316. set isEnabled(value: boolean);
  47317. get isEnabled(): boolean;
  47318. /**
  47319. * Disposes of the gizmo
  47320. */
  47321. dispose(): void;
  47322. /**
  47323. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47324. * @param mesh The mesh to replace the default mesh of the gizmo
  47325. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47326. */
  47327. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47328. }
  47329. }
  47330. declare module BABYLON {
  47331. /**
  47332. * Bounding box gizmo
  47333. */
  47334. export class BoundingBoxGizmo extends Gizmo {
  47335. private _lineBoundingBox;
  47336. private _rotateSpheresParent;
  47337. private _scaleBoxesParent;
  47338. private _boundingDimensions;
  47339. private _renderObserver;
  47340. private _pointerObserver;
  47341. private _scaleDragSpeed;
  47342. private _tmpQuaternion;
  47343. private _tmpVector;
  47344. private _tmpRotationMatrix;
  47345. /**
  47346. * 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)
  47347. */
  47348. ignoreChildren: boolean;
  47349. /**
  47350. * 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)
  47351. */
  47352. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47353. /**
  47354. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47355. */
  47356. rotationSphereSize: number;
  47357. /**
  47358. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47359. */
  47360. scaleBoxSize: number;
  47361. /**
  47362. * 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)
  47363. */
  47364. fixedDragMeshScreenSize: boolean;
  47365. /**
  47366. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47367. */
  47368. fixedDragMeshScreenSizeDistanceFactor: number;
  47369. /**
  47370. * Fired when a rotation sphere or scale box is dragged
  47371. */
  47372. onDragStartObservable: Observable<{}>;
  47373. /**
  47374. * Fired when a scale box is dragged
  47375. */
  47376. onScaleBoxDragObservable: Observable<{}>;
  47377. /**
  47378. * Fired when a scale box drag is ended
  47379. */
  47380. onScaleBoxDragEndObservable: Observable<{}>;
  47381. /**
  47382. * Fired when a rotation sphere is dragged
  47383. */
  47384. onRotationSphereDragObservable: Observable<{}>;
  47385. /**
  47386. * Fired when a rotation sphere drag is ended
  47387. */
  47388. onRotationSphereDragEndObservable: Observable<{}>;
  47389. /**
  47390. * 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)
  47391. */
  47392. scalePivot: Nullable<Vector3>;
  47393. /**
  47394. * Mesh used as a pivot to rotate the attached mesh
  47395. */
  47396. private _anchorMesh;
  47397. private _existingMeshScale;
  47398. private _dragMesh;
  47399. private pointerDragBehavior;
  47400. private coloredMaterial;
  47401. private hoverColoredMaterial;
  47402. /**
  47403. * Sets the color of the bounding box gizmo
  47404. * @param color the color to set
  47405. */
  47406. setColor(color: Color3): void;
  47407. /**
  47408. * Creates an BoundingBoxGizmo
  47409. * @param gizmoLayer The utility layer the gizmo will be added to
  47410. * @param color The color of the gizmo
  47411. */
  47412. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47413. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47414. private _selectNode;
  47415. /**
  47416. * Updates the bounding box information for the Gizmo
  47417. */
  47418. updateBoundingBox(): void;
  47419. private _updateRotationSpheres;
  47420. private _updateScaleBoxes;
  47421. /**
  47422. * Enables rotation on the specified axis and disables rotation on the others
  47423. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47424. */
  47425. setEnabledRotationAxis(axis: string): void;
  47426. /**
  47427. * Enables/disables scaling
  47428. * @param enable if scaling should be enabled
  47429. */
  47430. setEnabledScaling(enable: boolean): void;
  47431. private _updateDummy;
  47432. /**
  47433. * Enables a pointer drag behavior on the bounding box of the gizmo
  47434. */
  47435. enableDragBehavior(): void;
  47436. /**
  47437. * Disposes of the gizmo
  47438. */
  47439. dispose(): void;
  47440. /**
  47441. * 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)
  47442. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47443. * @returns the bounding box mesh with the passed in mesh as a child
  47444. */
  47445. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47446. /**
  47447. * CustomMeshes are not supported by this gizmo
  47448. * @param mesh The mesh to replace the default mesh of the gizmo
  47449. */
  47450. setCustomMesh(mesh: Mesh): void;
  47451. }
  47452. }
  47453. declare module BABYLON {
  47454. /**
  47455. * Single plane rotation gizmo
  47456. */
  47457. export class PlaneRotationGizmo extends Gizmo {
  47458. /**
  47459. * Drag behavior responsible for the gizmos dragging interactions
  47460. */
  47461. dragBehavior: PointerDragBehavior;
  47462. private _pointerObserver;
  47463. /**
  47464. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47465. */
  47466. snapDistance: number;
  47467. /**
  47468. * Event that fires each time the gizmo snaps to a new location.
  47469. * * snapDistance is the the change in distance
  47470. */
  47471. onSnapObservable: Observable<{
  47472. snapDistance: number;
  47473. }>;
  47474. private _isEnabled;
  47475. private _parent;
  47476. /**
  47477. * Creates a PlaneRotationGizmo
  47478. * @param gizmoLayer The utility layer the gizmo will be added to
  47479. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47480. * @param color The color of the gizmo
  47481. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47482. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47483. */
  47484. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47485. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47486. /**
  47487. * If the gizmo is enabled
  47488. */
  47489. set isEnabled(value: boolean);
  47490. get isEnabled(): boolean;
  47491. /**
  47492. * Disposes of the gizmo
  47493. */
  47494. dispose(): void;
  47495. }
  47496. }
  47497. declare module BABYLON {
  47498. /**
  47499. * Gizmo that enables rotating a mesh along 3 axis
  47500. */
  47501. export class RotationGizmo extends Gizmo {
  47502. /**
  47503. * Internal gizmo used for interactions on the x axis
  47504. */
  47505. xGizmo: PlaneRotationGizmo;
  47506. /**
  47507. * Internal gizmo used for interactions on the y axis
  47508. */
  47509. yGizmo: PlaneRotationGizmo;
  47510. /**
  47511. * Internal gizmo used for interactions on the z axis
  47512. */
  47513. zGizmo: PlaneRotationGizmo;
  47514. /** Fires an event when any of it's sub gizmos are dragged */
  47515. onDragStartObservable: Observable<unknown>;
  47516. /** Fires an event when any of it's sub gizmos are released from dragging */
  47517. onDragEndObservable: Observable<unknown>;
  47518. private _meshAttached;
  47519. get attachedMesh(): Nullable<AbstractMesh>;
  47520. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47521. /**
  47522. * Creates a RotationGizmo
  47523. * @param gizmoLayer The utility layer the gizmo will be added to
  47524. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47525. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47526. */
  47527. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47528. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47529. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47530. /**
  47531. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47532. */
  47533. set snapDistance(value: number);
  47534. get snapDistance(): number;
  47535. /**
  47536. * Ratio for the scale of the gizmo (Default: 1)
  47537. */
  47538. set scaleRatio(value: number);
  47539. get scaleRatio(): number;
  47540. /**
  47541. * Disposes of the gizmo
  47542. */
  47543. dispose(): void;
  47544. /**
  47545. * CustomMeshes are not supported by this gizmo
  47546. * @param mesh The mesh to replace the default mesh of the gizmo
  47547. */
  47548. setCustomMesh(mesh: Mesh): void;
  47549. }
  47550. }
  47551. declare module BABYLON {
  47552. /**
  47553. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47554. */
  47555. export class GizmoManager implements IDisposable {
  47556. private scene;
  47557. /**
  47558. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47559. */
  47560. gizmos: {
  47561. positionGizmo: Nullable<PositionGizmo>;
  47562. rotationGizmo: Nullable<RotationGizmo>;
  47563. scaleGizmo: Nullable<ScaleGizmo>;
  47564. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47565. };
  47566. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47567. clearGizmoOnEmptyPointerEvent: boolean;
  47568. /** Fires an event when the manager is attached to a mesh */
  47569. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47570. private _gizmosEnabled;
  47571. private _pointerObserver;
  47572. private _attachedMesh;
  47573. private _boundingBoxColor;
  47574. private _defaultUtilityLayer;
  47575. private _defaultKeepDepthUtilityLayer;
  47576. /**
  47577. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47578. */
  47579. boundingBoxDragBehavior: SixDofDragBehavior;
  47580. /**
  47581. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47582. */
  47583. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47584. /**
  47585. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47586. */
  47587. usePointerToAttachGizmos: boolean;
  47588. /**
  47589. * Utility layer that the bounding box gizmo belongs to
  47590. */
  47591. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  47592. /**
  47593. * Utility layer that all gizmos besides bounding box belong to
  47594. */
  47595. get utilityLayer(): UtilityLayerRenderer;
  47596. /**
  47597. * Instatiates a gizmo manager
  47598. * @param scene the scene to overlay the gizmos on top of
  47599. */
  47600. constructor(scene: Scene);
  47601. /**
  47602. * Attaches a set of gizmos to the specified mesh
  47603. * @param mesh The mesh the gizmo's should be attached to
  47604. */
  47605. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47606. /**
  47607. * If the position gizmo is enabled
  47608. */
  47609. set positionGizmoEnabled(value: boolean);
  47610. get positionGizmoEnabled(): boolean;
  47611. /**
  47612. * If the rotation gizmo is enabled
  47613. */
  47614. set rotationGizmoEnabled(value: boolean);
  47615. get rotationGizmoEnabled(): boolean;
  47616. /**
  47617. * If the scale gizmo is enabled
  47618. */
  47619. set scaleGizmoEnabled(value: boolean);
  47620. get scaleGizmoEnabled(): boolean;
  47621. /**
  47622. * If the boundingBox gizmo is enabled
  47623. */
  47624. set boundingBoxGizmoEnabled(value: boolean);
  47625. get boundingBoxGizmoEnabled(): boolean;
  47626. /**
  47627. * Disposes of the gizmo manager
  47628. */
  47629. dispose(): void;
  47630. }
  47631. }
  47632. declare module BABYLON {
  47633. /**
  47634. * A directional light is defined by a direction (what a surprise!).
  47635. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47636. * 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.
  47637. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47638. */
  47639. export class DirectionalLight extends ShadowLight {
  47640. private _shadowFrustumSize;
  47641. /**
  47642. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47643. */
  47644. get shadowFrustumSize(): number;
  47645. /**
  47646. * Specifies a fix frustum size for the shadow generation.
  47647. */
  47648. set shadowFrustumSize(value: number);
  47649. private _shadowOrthoScale;
  47650. /**
  47651. * Gets the shadow projection scale against the optimal computed one.
  47652. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47653. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47654. */
  47655. get shadowOrthoScale(): number;
  47656. /**
  47657. * Sets the shadow projection scale against the optimal computed one.
  47658. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47659. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47660. */
  47661. set shadowOrthoScale(value: number);
  47662. /**
  47663. * Automatically compute the projection matrix to best fit (including all the casters)
  47664. * on each frame.
  47665. */
  47666. autoUpdateExtends: boolean;
  47667. private _orthoLeft;
  47668. private _orthoRight;
  47669. private _orthoTop;
  47670. private _orthoBottom;
  47671. /**
  47672. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47673. * The directional light is emitted from everywhere in the given direction.
  47674. * It can cast shadows.
  47675. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47676. * @param name The friendly name of the light
  47677. * @param direction The direction of the light
  47678. * @param scene The scene the light belongs to
  47679. */
  47680. constructor(name: string, direction: Vector3, scene: Scene);
  47681. /**
  47682. * Returns the string "DirectionalLight".
  47683. * @return The class name
  47684. */
  47685. getClassName(): string;
  47686. /**
  47687. * Returns the integer 1.
  47688. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47689. */
  47690. getTypeID(): number;
  47691. /**
  47692. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47693. * Returns the DirectionalLight Shadow projection matrix.
  47694. */
  47695. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47696. /**
  47697. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47698. * Returns the DirectionalLight Shadow projection matrix.
  47699. */
  47700. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47701. /**
  47702. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47703. * Returns the DirectionalLight Shadow projection matrix.
  47704. */
  47705. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47706. protected _buildUniformLayout(): void;
  47707. /**
  47708. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47709. * @param effect The effect to update
  47710. * @param lightIndex The index of the light in the effect to update
  47711. * @returns The directional light
  47712. */
  47713. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47714. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47715. /**
  47716. * Gets the minZ used for shadow according to both the scene and the light.
  47717. *
  47718. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47719. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47720. * @param activeCamera The camera we are returning the min for
  47721. * @returns the depth min z
  47722. */
  47723. getDepthMinZ(activeCamera: Camera): number;
  47724. /**
  47725. * Gets the maxZ used for shadow according to both the scene and the light.
  47726. *
  47727. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47728. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47729. * @param activeCamera The camera we are returning the max for
  47730. * @returns the depth max z
  47731. */
  47732. getDepthMaxZ(activeCamera: Camera): number;
  47733. /**
  47734. * Prepares the list of defines specific to the light type.
  47735. * @param defines the list of defines
  47736. * @param lightIndex defines the index of the light for the effect
  47737. */
  47738. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47739. }
  47740. }
  47741. declare module BABYLON {
  47742. /**
  47743. * Class containing static functions to help procedurally build meshes
  47744. */
  47745. export class HemisphereBuilder {
  47746. /**
  47747. * Creates a hemisphere mesh
  47748. * @param name defines the name of the mesh
  47749. * @param options defines the options used to create the mesh
  47750. * @param scene defines the hosting scene
  47751. * @returns the hemisphere mesh
  47752. */
  47753. static CreateHemisphere(name: string, options: {
  47754. segments?: number;
  47755. diameter?: number;
  47756. sideOrientation?: number;
  47757. }, scene: any): Mesh;
  47758. }
  47759. }
  47760. declare module BABYLON {
  47761. /**
  47762. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47763. * These values define a cone of light starting from the position, emitting toward the direction.
  47764. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47765. * and the exponent defines the speed of the decay of the light with distance (reach).
  47766. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47767. */
  47768. export class SpotLight extends ShadowLight {
  47769. private _angle;
  47770. private _innerAngle;
  47771. private _cosHalfAngle;
  47772. private _lightAngleScale;
  47773. private _lightAngleOffset;
  47774. /**
  47775. * Gets the cone angle of the spot light in Radians.
  47776. */
  47777. get angle(): number;
  47778. /**
  47779. * Sets the cone angle of the spot light in Radians.
  47780. */
  47781. set angle(value: number);
  47782. /**
  47783. * Only used in gltf falloff mode, this defines the angle where
  47784. * the directional falloff will start before cutting at angle which could be seen
  47785. * as outer angle.
  47786. */
  47787. get innerAngle(): number;
  47788. /**
  47789. * Only used in gltf falloff mode, this defines the angle where
  47790. * the directional falloff will start before cutting at angle which could be seen
  47791. * as outer angle.
  47792. */
  47793. set innerAngle(value: number);
  47794. private _shadowAngleScale;
  47795. /**
  47796. * Allows scaling the angle of the light for shadow generation only.
  47797. */
  47798. get shadowAngleScale(): number;
  47799. /**
  47800. * Allows scaling the angle of the light for shadow generation only.
  47801. */
  47802. set shadowAngleScale(value: number);
  47803. /**
  47804. * The light decay speed with the distance from the emission spot.
  47805. */
  47806. exponent: number;
  47807. private _projectionTextureMatrix;
  47808. /**
  47809. * Allows reading the projecton texture
  47810. */
  47811. get projectionTextureMatrix(): Matrix;
  47812. protected _projectionTextureLightNear: number;
  47813. /**
  47814. * Gets the near clip of the Spotlight for texture projection.
  47815. */
  47816. get projectionTextureLightNear(): number;
  47817. /**
  47818. * Sets the near clip of the Spotlight for texture projection.
  47819. */
  47820. set projectionTextureLightNear(value: number);
  47821. protected _projectionTextureLightFar: number;
  47822. /**
  47823. * Gets the far clip of the Spotlight for texture projection.
  47824. */
  47825. get projectionTextureLightFar(): number;
  47826. /**
  47827. * Sets the far clip of the Spotlight for texture projection.
  47828. */
  47829. set projectionTextureLightFar(value: number);
  47830. protected _projectionTextureUpDirection: Vector3;
  47831. /**
  47832. * Gets the Up vector of the Spotlight for texture projection.
  47833. */
  47834. get projectionTextureUpDirection(): Vector3;
  47835. /**
  47836. * Sets the Up vector of the Spotlight for texture projection.
  47837. */
  47838. set projectionTextureUpDirection(value: Vector3);
  47839. private _projectionTexture;
  47840. /**
  47841. * Gets the projection texture of the light.
  47842. */
  47843. get projectionTexture(): Nullable<BaseTexture>;
  47844. /**
  47845. * Sets the projection texture of the light.
  47846. */
  47847. set projectionTexture(value: Nullable<BaseTexture>);
  47848. private _projectionTextureViewLightDirty;
  47849. private _projectionTextureProjectionLightDirty;
  47850. private _projectionTextureDirty;
  47851. private _projectionTextureViewTargetVector;
  47852. private _projectionTextureViewLightMatrix;
  47853. private _projectionTextureProjectionLightMatrix;
  47854. private _projectionTextureScalingMatrix;
  47855. /**
  47856. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47857. * It can cast shadows.
  47858. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47859. * @param name The light friendly name
  47860. * @param position The position of the spot light in the scene
  47861. * @param direction The direction of the light in the scene
  47862. * @param angle The cone angle of the light in Radians
  47863. * @param exponent The light decay speed with the distance from the emission spot
  47864. * @param scene The scene the lights belongs to
  47865. */
  47866. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47867. /**
  47868. * Returns the string "SpotLight".
  47869. * @returns the class name
  47870. */
  47871. getClassName(): string;
  47872. /**
  47873. * Returns the integer 2.
  47874. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47875. */
  47876. getTypeID(): number;
  47877. /**
  47878. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47879. */
  47880. protected _setDirection(value: Vector3): void;
  47881. /**
  47882. * Overrides the position setter to recompute the projection texture view light Matrix.
  47883. */
  47884. protected _setPosition(value: Vector3): void;
  47885. /**
  47886. * 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.
  47887. * Returns the SpotLight.
  47888. */
  47889. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47890. protected _computeProjectionTextureViewLightMatrix(): void;
  47891. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47892. /**
  47893. * Main function for light texture projection matrix computing.
  47894. */
  47895. protected _computeProjectionTextureMatrix(): void;
  47896. protected _buildUniformLayout(): void;
  47897. private _computeAngleValues;
  47898. /**
  47899. * Sets the passed Effect "effect" with the Light textures.
  47900. * @param effect The effect to update
  47901. * @param lightIndex The index of the light in the effect to update
  47902. * @returns The light
  47903. */
  47904. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  47905. /**
  47906. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47907. * @param effect The effect to update
  47908. * @param lightIndex The index of the light in the effect to update
  47909. * @returns The spot light
  47910. */
  47911. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47912. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47913. /**
  47914. * Disposes the light and the associated resources.
  47915. */
  47916. dispose(): void;
  47917. /**
  47918. * Prepares the list of defines specific to the light type.
  47919. * @param defines the list of defines
  47920. * @param lightIndex defines the index of the light for the effect
  47921. */
  47922. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47923. }
  47924. }
  47925. declare module BABYLON {
  47926. /**
  47927. * Gizmo that enables viewing a light
  47928. */
  47929. export class LightGizmo extends Gizmo {
  47930. private _lightMesh;
  47931. private _material;
  47932. private _cachedPosition;
  47933. private _cachedForward;
  47934. private _attachedMeshParent;
  47935. /**
  47936. * Creates a LightGizmo
  47937. * @param gizmoLayer The utility layer the gizmo will be added to
  47938. */
  47939. constructor(gizmoLayer?: UtilityLayerRenderer);
  47940. private _light;
  47941. /**
  47942. * The light that the gizmo is attached to
  47943. */
  47944. set light(light: Nullable<Light>);
  47945. get light(): Nullable<Light>;
  47946. /**
  47947. * Gets the material used to render the light gizmo
  47948. */
  47949. get material(): StandardMaterial;
  47950. /**
  47951. * @hidden
  47952. * Updates the gizmo to match the attached mesh's position/rotation
  47953. */
  47954. protected _update(): void;
  47955. private static _Scale;
  47956. /**
  47957. * Creates the lines for a light mesh
  47958. */
  47959. private static _CreateLightLines;
  47960. /**
  47961. * Disposes of the light gizmo
  47962. */
  47963. dispose(): void;
  47964. private static _CreateHemisphericLightMesh;
  47965. private static _CreatePointLightMesh;
  47966. private static _CreateSpotLightMesh;
  47967. private static _CreateDirectionalLightMesh;
  47968. }
  47969. }
  47970. declare module BABYLON {
  47971. /** @hidden */
  47972. export var backgroundFragmentDeclaration: {
  47973. name: string;
  47974. shader: string;
  47975. };
  47976. }
  47977. declare module BABYLON {
  47978. /** @hidden */
  47979. export var backgroundUboDeclaration: {
  47980. name: string;
  47981. shader: string;
  47982. };
  47983. }
  47984. declare module BABYLON {
  47985. /** @hidden */
  47986. export var backgroundPixelShader: {
  47987. name: string;
  47988. shader: string;
  47989. };
  47990. }
  47991. declare module BABYLON {
  47992. /** @hidden */
  47993. export var backgroundVertexDeclaration: {
  47994. name: string;
  47995. shader: string;
  47996. };
  47997. }
  47998. declare module BABYLON {
  47999. /** @hidden */
  48000. export var backgroundVertexShader: {
  48001. name: string;
  48002. shader: string;
  48003. };
  48004. }
  48005. declare module BABYLON {
  48006. /**
  48007. * Background material used to create an efficient environement around your scene.
  48008. */
  48009. export class BackgroundMaterial extends PushMaterial {
  48010. /**
  48011. * Standard reflectance value at parallel view angle.
  48012. */
  48013. static StandardReflectance0: number;
  48014. /**
  48015. * Standard reflectance value at grazing angle.
  48016. */
  48017. static StandardReflectance90: number;
  48018. protected _primaryColor: Color3;
  48019. /**
  48020. * Key light Color (multiply against the environement texture)
  48021. */
  48022. primaryColor: Color3;
  48023. protected __perceptualColor: Nullable<Color3>;
  48024. /**
  48025. * Experimental Internal Use Only.
  48026. *
  48027. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48028. * This acts as a helper to set the primary color to a more "human friendly" value.
  48029. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48030. * output color as close as possible from the chosen value.
  48031. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48032. * part of lighting setup.)
  48033. */
  48034. get _perceptualColor(): Nullable<Color3>;
  48035. set _perceptualColor(value: Nullable<Color3>);
  48036. protected _primaryColorShadowLevel: float;
  48037. /**
  48038. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48039. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48040. */
  48041. get primaryColorShadowLevel(): float;
  48042. set primaryColorShadowLevel(value: float);
  48043. protected _primaryColorHighlightLevel: float;
  48044. /**
  48045. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48046. * The primary color is used at the level chosen to define what the white area would look.
  48047. */
  48048. get primaryColorHighlightLevel(): float;
  48049. set primaryColorHighlightLevel(value: float);
  48050. protected _reflectionTexture: Nullable<BaseTexture>;
  48051. /**
  48052. * Reflection Texture used in the material.
  48053. * Should be author in a specific way for the best result (refer to the documentation).
  48054. */
  48055. reflectionTexture: Nullable<BaseTexture>;
  48056. protected _reflectionBlur: float;
  48057. /**
  48058. * Reflection Texture level of blur.
  48059. *
  48060. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48061. * texture twice.
  48062. */
  48063. reflectionBlur: float;
  48064. protected _diffuseTexture: Nullable<BaseTexture>;
  48065. /**
  48066. * Diffuse Texture used in the material.
  48067. * Should be author in a specific way for the best result (refer to the documentation).
  48068. */
  48069. diffuseTexture: Nullable<BaseTexture>;
  48070. protected _shadowLights: Nullable<IShadowLight[]>;
  48071. /**
  48072. * Specify the list of lights casting shadow on the material.
  48073. * All scene shadow lights will be included if null.
  48074. */
  48075. shadowLights: Nullable<IShadowLight[]>;
  48076. protected _shadowLevel: float;
  48077. /**
  48078. * Helps adjusting the shadow to a softer level if required.
  48079. * 0 means black shadows and 1 means no shadows.
  48080. */
  48081. shadowLevel: float;
  48082. protected _sceneCenter: Vector3;
  48083. /**
  48084. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48085. * It is usually zero but might be interesting to modify according to your setup.
  48086. */
  48087. sceneCenter: Vector3;
  48088. protected _opacityFresnel: boolean;
  48089. /**
  48090. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48091. * This helps ensuring a nice transition when the camera goes under the ground.
  48092. */
  48093. opacityFresnel: boolean;
  48094. protected _reflectionFresnel: boolean;
  48095. /**
  48096. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48097. * This helps adding a mirror texture on the ground.
  48098. */
  48099. reflectionFresnel: boolean;
  48100. protected _reflectionFalloffDistance: number;
  48101. /**
  48102. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48103. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48104. */
  48105. reflectionFalloffDistance: number;
  48106. protected _reflectionAmount: number;
  48107. /**
  48108. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48109. */
  48110. reflectionAmount: number;
  48111. protected _reflectionReflectance0: number;
  48112. /**
  48113. * This specifies the weight of the reflection at grazing angle.
  48114. */
  48115. reflectionReflectance0: number;
  48116. protected _reflectionReflectance90: number;
  48117. /**
  48118. * This specifies the weight of the reflection at a perpendicular point of view.
  48119. */
  48120. reflectionReflectance90: number;
  48121. /**
  48122. * Sets the reflection reflectance fresnel values according to the default standard
  48123. * empirically know to work well :-)
  48124. */
  48125. set reflectionStandardFresnelWeight(value: number);
  48126. protected _useRGBColor: boolean;
  48127. /**
  48128. * Helps to directly use the maps channels instead of their level.
  48129. */
  48130. useRGBColor: boolean;
  48131. protected _enableNoise: boolean;
  48132. /**
  48133. * This helps reducing the banding effect that could occur on the background.
  48134. */
  48135. enableNoise: boolean;
  48136. /**
  48137. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48138. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48139. * Recommended to be keep at 1.0 except for special cases.
  48140. */
  48141. get fovMultiplier(): number;
  48142. set fovMultiplier(value: number);
  48143. private _fovMultiplier;
  48144. /**
  48145. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48146. */
  48147. useEquirectangularFOV: boolean;
  48148. private _maxSimultaneousLights;
  48149. /**
  48150. * Number of Simultaneous lights allowed on the material.
  48151. */
  48152. maxSimultaneousLights: int;
  48153. /**
  48154. * Default configuration related to image processing available in the Background Material.
  48155. */
  48156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48157. /**
  48158. * Keep track of the image processing observer to allow dispose and replace.
  48159. */
  48160. private _imageProcessingObserver;
  48161. /**
  48162. * Attaches a new image processing configuration to the PBR Material.
  48163. * @param configuration (if null the scene configuration will be use)
  48164. */
  48165. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48166. /**
  48167. * Gets the image processing configuration used either in this material.
  48168. */
  48169. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  48170. /**
  48171. * Sets the Default image processing configuration used either in the this material.
  48172. *
  48173. * If sets to null, the scene one is in use.
  48174. */
  48175. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  48176. /**
  48177. * Gets wether the color curves effect is enabled.
  48178. */
  48179. get cameraColorCurvesEnabled(): boolean;
  48180. /**
  48181. * Sets wether the color curves effect is enabled.
  48182. */
  48183. set cameraColorCurvesEnabled(value: boolean);
  48184. /**
  48185. * Gets wether the color grading effect is enabled.
  48186. */
  48187. get cameraColorGradingEnabled(): boolean;
  48188. /**
  48189. * Gets wether the color grading effect is enabled.
  48190. */
  48191. set cameraColorGradingEnabled(value: boolean);
  48192. /**
  48193. * Gets wether tonemapping is enabled or not.
  48194. */
  48195. get cameraToneMappingEnabled(): boolean;
  48196. /**
  48197. * Sets wether tonemapping is enabled or not
  48198. */
  48199. set cameraToneMappingEnabled(value: boolean);
  48200. /**
  48201. * The camera exposure used on this material.
  48202. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48203. * This corresponds to a photographic exposure.
  48204. */
  48205. get cameraExposure(): float;
  48206. /**
  48207. * The camera exposure used on this material.
  48208. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48209. * This corresponds to a photographic exposure.
  48210. */
  48211. set cameraExposure(value: float);
  48212. /**
  48213. * Gets The camera contrast used on this material.
  48214. */
  48215. get cameraContrast(): float;
  48216. /**
  48217. * Sets The camera contrast used on this material.
  48218. */
  48219. set cameraContrast(value: float);
  48220. /**
  48221. * Gets the Color Grading 2D Lookup Texture.
  48222. */
  48223. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  48224. /**
  48225. * Sets the Color Grading 2D Lookup Texture.
  48226. */
  48227. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  48228. /**
  48229. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48230. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48231. * 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;
  48232. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48233. */
  48234. get cameraColorCurves(): Nullable<ColorCurves>;
  48235. /**
  48236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48238. * 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;
  48239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48240. */
  48241. set cameraColorCurves(value: Nullable<ColorCurves>);
  48242. /**
  48243. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48244. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48245. */
  48246. switchToBGR: boolean;
  48247. private _renderTargets;
  48248. private _reflectionControls;
  48249. private _white;
  48250. private _primaryShadowColor;
  48251. private _primaryHighlightColor;
  48252. /**
  48253. * Instantiates a Background Material in the given scene
  48254. * @param name The friendly name of the material
  48255. * @param scene The scene to add the material to
  48256. */
  48257. constructor(name: string, scene: Scene);
  48258. /**
  48259. * Gets a boolean indicating that current material needs to register RTT
  48260. */
  48261. get hasRenderTargetTextures(): boolean;
  48262. /**
  48263. * The entire material has been created in order to prevent overdraw.
  48264. * @returns false
  48265. */
  48266. needAlphaTesting(): boolean;
  48267. /**
  48268. * The entire material has been created in order to prevent overdraw.
  48269. * @returns true if blending is enable
  48270. */
  48271. needAlphaBlending(): boolean;
  48272. /**
  48273. * Checks wether the material is ready to be rendered for a given mesh.
  48274. * @param mesh The mesh to render
  48275. * @param subMesh The submesh to check against
  48276. * @param useInstances Specify wether or not the material is used with instances
  48277. * @returns true if all the dependencies are ready (Textures, Effects...)
  48278. */
  48279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48280. /**
  48281. * Compute the primary color according to the chosen perceptual color.
  48282. */
  48283. private _computePrimaryColorFromPerceptualColor;
  48284. /**
  48285. * Compute the highlights and shadow colors according to their chosen levels.
  48286. */
  48287. private _computePrimaryColors;
  48288. /**
  48289. * Build the uniform buffer used in the material.
  48290. */
  48291. buildUniformLayout(): void;
  48292. /**
  48293. * Unbind the material.
  48294. */
  48295. unbind(): void;
  48296. /**
  48297. * Bind only the world matrix to the material.
  48298. * @param world The world matrix to bind.
  48299. */
  48300. bindOnlyWorldMatrix(world: Matrix): void;
  48301. /**
  48302. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48303. * @param world The world matrix to bind.
  48304. * @param subMesh The submesh to bind for.
  48305. */
  48306. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48307. /**
  48308. * Checks to see if a texture is used in the material.
  48309. * @param texture - Base texture to use.
  48310. * @returns - Boolean specifying if a texture is used in the material.
  48311. */
  48312. hasTexture(texture: BaseTexture): boolean;
  48313. /**
  48314. * Dispose the material.
  48315. * @param forceDisposeEffect Force disposal of the associated effect.
  48316. * @param forceDisposeTextures Force disposal of the associated textures.
  48317. */
  48318. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48319. /**
  48320. * Clones the material.
  48321. * @param name The cloned name.
  48322. * @returns The cloned material.
  48323. */
  48324. clone(name: string): BackgroundMaterial;
  48325. /**
  48326. * Serializes the current material to its JSON representation.
  48327. * @returns The JSON representation.
  48328. */
  48329. serialize(): any;
  48330. /**
  48331. * Gets the class name of the material
  48332. * @returns "BackgroundMaterial"
  48333. */
  48334. getClassName(): string;
  48335. /**
  48336. * Parse a JSON input to create back a background material.
  48337. * @param source The JSON data to parse
  48338. * @param scene The scene to create the parsed material in
  48339. * @param rootUrl The root url of the assets the material depends upon
  48340. * @returns the instantiated BackgroundMaterial.
  48341. */
  48342. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48343. }
  48344. }
  48345. declare module BABYLON {
  48346. /**
  48347. * Represents the different options available during the creation of
  48348. * a Environment helper.
  48349. *
  48350. * This can control the default ground, skybox and image processing setup of your scene.
  48351. */
  48352. export interface IEnvironmentHelperOptions {
  48353. /**
  48354. * Specifies wether or not to create a ground.
  48355. * True by default.
  48356. */
  48357. createGround: boolean;
  48358. /**
  48359. * Specifies the ground size.
  48360. * 15 by default.
  48361. */
  48362. groundSize: number;
  48363. /**
  48364. * The texture used on the ground for the main color.
  48365. * Comes from the BabylonJS CDN by default.
  48366. *
  48367. * Remarks: Can be either a texture or a url.
  48368. */
  48369. groundTexture: string | BaseTexture;
  48370. /**
  48371. * The color mixed in the ground texture by default.
  48372. * BabylonJS clearColor by default.
  48373. */
  48374. groundColor: Color3;
  48375. /**
  48376. * Specifies the ground opacity.
  48377. * 1 by default.
  48378. */
  48379. groundOpacity: number;
  48380. /**
  48381. * Enables the ground to receive shadows.
  48382. * True by default.
  48383. */
  48384. enableGroundShadow: boolean;
  48385. /**
  48386. * Helps preventing the shadow to be fully black on the ground.
  48387. * 0.5 by default.
  48388. */
  48389. groundShadowLevel: number;
  48390. /**
  48391. * Creates a mirror texture attach to the ground.
  48392. * false by default.
  48393. */
  48394. enableGroundMirror: boolean;
  48395. /**
  48396. * Specifies the ground mirror size ratio.
  48397. * 0.3 by default as the default kernel is 64.
  48398. */
  48399. groundMirrorSizeRatio: number;
  48400. /**
  48401. * Specifies the ground mirror blur kernel size.
  48402. * 64 by default.
  48403. */
  48404. groundMirrorBlurKernel: number;
  48405. /**
  48406. * Specifies the ground mirror visibility amount.
  48407. * 1 by default
  48408. */
  48409. groundMirrorAmount: number;
  48410. /**
  48411. * Specifies the ground mirror reflectance weight.
  48412. * This uses the standard weight of the background material to setup the fresnel effect
  48413. * of the mirror.
  48414. * 1 by default.
  48415. */
  48416. groundMirrorFresnelWeight: number;
  48417. /**
  48418. * Specifies the ground mirror Falloff distance.
  48419. * This can helps reducing the size of the reflection.
  48420. * 0 by Default.
  48421. */
  48422. groundMirrorFallOffDistance: number;
  48423. /**
  48424. * Specifies the ground mirror texture type.
  48425. * Unsigned Int by Default.
  48426. */
  48427. groundMirrorTextureType: number;
  48428. /**
  48429. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48430. * the shown objects.
  48431. */
  48432. groundYBias: number;
  48433. /**
  48434. * Specifies wether or not to create a skybox.
  48435. * True by default.
  48436. */
  48437. createSkybox: boolean;
  48438. /**
  48439. * Specifies the skybox size.
  48440. * 20 by default.
  48441. */
  48442. skyboxSize: number;
  48443. /**
  48444. * The texture used on the skybox for the main color.
  48445. * Comes from the BabylonJS CDN by default.
  48446. *
  48447. * Remarks: Can be either a texture or a url.
  48448. */
  48449. skyboxTexture: string | BaseTexture;
  48450. /**
  48451. * The color mixed in the skybox texture by default.
  48452. * BabylonJS clearColor by default.
  48453. */
  48454. skyboxColor: Color3;
  48455. /**
  48456. * The background rotation around the Y axis of the scene.
  48457. * This helps aligning the key lights of your scene with the background.
  48458. * 0 by default.
  48459. */
  48460. backgroundYRotation: number;
  48461. /**
  48462. * Compute automatically the size of the elements to best fit with the scene.
  48463. */
  48464. sizeAuto: boolean;
  48465. /**
  48466. * Default position of the rootMesh if autoSize is not true.
  48467. */
  48468. rootPosition: Vector3;
  48469. /**
  48470. * Sets up the image processing in the scene.
  48471. * true by default.
  48472. */
  48473. setupImageProcessing: boolean;
  48474. /**
  48475. * The texture used as your environment texture in the scene.
  48476. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48477. *
  48478. * Remarks: Can be either a texture or a url.
  48479. */
  48480. environmentTexture: string | BaseTexture;
  48481. /**
  48482. * The value of the exposure to apply to the scene.
  48483. * 0.6 by default if setupImageProcessing is true.
  48484. */
  48485. cameraExposure: number;
  48486. /**
  48487. * The value of the contrast to apply to the scene.
  48488. * 1.6 by default if setupImageProcessing is true.
  48489. */
  48490. cameraContrast: number;
  48491. /**
  48492. * Specifies wether or not tonemapping should be enabled in the scene.
  48493. * true by default if setupImageProcessing is true.
  48494. */
  48495. toneMappingEnabled: boolean;
  48496. }
  48497. /**
  48498. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48499. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48500. * It also helps with the default setup of your imageProcessing configuration.
  48501. */
  48502. export class EnvironmentHelper {
  48503. /**
  48504. * Default ground texture URL.
  48505. */
  48506. private static _groundTextureCDNUrl;
  48507. /**
  48508. * Default skybox texture URL.
  48509. */
  48510. private static _skyboxTextureCDNUrl;
  48511. /**
  48512. * Default environment texture URL.
  48513. */
  48514. private static _environmentTextureCDNUrl;
  48515. /**
  48516. * Creates the default options for the helper.
  48517. */
  48518. private static _getDefaultOptions;
  48519. private _rootMesh;
  48520. /**
  48521. * Gets the root mesh created by the helper.
  48522. */
  48523. get rootMesh(): Mesh;
  48524. private _skybox;
  48525. /**
  48526. * Gets the skybox created by the helper.
  48527. */
  48528. get skybox(): Nullable<Mesh>;
  48529. private _skyboxTexture;
  48530. /**
  48531. * Gets the skybox texture created by the helper.
  48532. */
  48533. get skyboxTexture(): Nullable<BaseTexture>;
  48534. private _skyboxMaterial;
  48535. /**
  48536. * Gets the skybox material created by the helper.
  48537. */
  48538. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  48539. private _ground;
  48540. /**
  48541. * Gets the ground mesh created by the helper.
  48542. */
  48543. get ground(): Nullable<Mesh>;
  48544. private _groundTexture;
  48545. /**
  48546. * Gets the ground texture created by the helper.
  48547. */
  48548. get groundTexture(): Nullable<BaseTexture>;
  48549. private _groundMirror;
  48550. /**
  48551. * Gets the ground mirror created by the helper.
  48552. */
  48553. get groundMirror(): Nullable<MirrorTexture>;
  48554. /**
  48555. * Gets the ground mirror render list to helps pushing the meshes
  48556. * you wish in the ground reflection.
  48557. */
  48558. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  48559. private _groundMaterial;
  48560. /**
  48561. * Gets the ground material created by the helper.
  48562. */
  48563. get groundMaterial(): Nullable<BackgroundMaterial>;
  48564. /**
  48565. * Stores the creation options.
  48566. */
  48567. private readonly _scene;
  48568. private _options;
  48569. /**
  48570. * This observable will be notified with any error during the creation of the environment,
  48571. * mainly texture creation errors.
  48572. */
  48573. onErrorObservable: Observable<{
  48574. message?: string;
  48575. exception?: any;
  48576. }>;
  48577. /**
  48578. * constructor
  48579. * @param options Defines the options we want to customize the helper
  48580. * @param scene The scene to add the material to
  48581. */
  48582. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48583. /**
  48584. * Updates the background according to the new options
  48585. * @param options
  48586. */
  48587. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48588. /**
  48589. * Sets the primary color of all the available elements.
  48590. * @param color the main color to affect to the ground and the background
  48591. */
  48592. setMainColor(color: Color3): void;
  48593. /**
  48594. * Setup the image processing according to the specified options.
  48595. */
  48596. private _setupImageProcessing;
  48597. /**
  48598. * Setup the environment texture according to the specified options.
  48599. */
  48600. private _setupEnvironmentTexture;
  48601. /**
  48602. * Setup the background according to the specified options.
  48603. */
  48604. private _setupBackground;
  48605. /**
  48606. * Get the scene sizes according to the setup.
  48607. */
  48608. private _getSceneSize;
  48609. /**
  48610. * Setup the ground according to the specified options.
  48611. */
  48612. private _setupGround;
  48613. /**
  48614. * Setup the ground material according to the specified options.
  48615. */
  48616. private _setupGroundMaterial;
  48617. /**
  48618. * Setup the ground diffuse texture according to the specified options.
  48619. */
  48620. private _setupGroundDiffuseTexture;
  48621. /**
  48622. * Setup the ground mirror texture according to the specified options.
  48623. */
  48624. private _setupGroundMirrorTexture;
  48625. /**
  48626. * Setup the ground to receive the mirror texture.
  48627. */
  48628. private _setupMirrorInGroundMaterial;
  48629. /**
  48630. * Setup the skybox according to the specified options.
  48631. */
  48632. private _setupSkybox;
  48633. /**
  48634. * Setup the skybox material according to the specified options.
  48635. */
  48636. private _setupSkyboxMaterial;
  48637. /**
  48638. * Setup the skybox reflection texture according to the specified options.
  48639. */
  48640. private _setupSkyboxReflectionTexture;
  48641. private _errorHandler;
  48642. /**
  48643. * Dispose all the elements created by the Helper.
  48644. */
  48645. dispose(): void;
  48646. }
  48647. }
  48648. declare module BABYLON {
  48649. /**
  48650. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48651. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48652. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48653. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48654. */
  48655. export class PhotoDome extends TransformNode {
  48656. /**
  48657. * Define the image as a Monoscopic panoramic 360 image.
  48658. */
  48659. static readonly MODE_MONOSCOPIC: number;
  48660. /**
  48661. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48662. */
  48663. static readonly MODE_TOPBOTTOM: number;
  48664. /**
  48665. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48666. */
  48667. static readonly MODE_SIDEBYSIDE: number;
  48668. private _useDirectMapping;
  48669. /**
  48670. * The texture being displayed on the sphere
  48671. */
  48672. protected _photoTexture: Texture;
  48673. /**
  48674. * Gets or sets the texture being displayed on the sphere
  48675. */
  48676. get photoTexture(): Texture;
  48677. set photoTexture(value: Texture);
  48678. /**
  48679. * Observable raised when an error occured while loading the 360 image
  48680. */
  48681. onLoadErrorObservable: Observable<string>;
  48682. /**
  48683. * The skybox material
  48684. */
  48685. protected _material: BackgroundMaterial;
  48686. /**
  48687. * The surface used for the skybox
  48688. */
  48689. protected _mesh: Mesh;
  48690. /**
  48691. * Gets the mesh used for the skybox.
  48692. */
  48693. get mesh(): Mesh;
  48694. /**
  48695. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48696. * Also see the options.resolution property.
  48697. */
  48698. get fovMultiplier(): number;
  48699. set fovMultiplier(value: number);
  48700. private _imageMode;
  48701. /**
  48702. * Gets or set the current video mode for the video. It can be:
  48703. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48704. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48705. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48706. */
  48707. get imageMode(): number;
  48708. set imageMode(value: number);
  48709. /**
  48710. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48711. * @param name Element's name, child elements will append suffixes for their own names.
  48712. * @param urlsOfPhoto defines the url of the photo to display
  48713. * @param options defines an object containing optional or exposed sub element properties
  48714. * @param onError defines a callback called when an error occured while loading the texture
  48715. */
  48716. constructor(name: string, urlOfPhoto: string, options: {
  48717. resolution?: number;
  48718. size?: number;
  48719. useDirectMapping?: boolean;
  48720. faceForward?: boolean;
  48721. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48722. private _onBeforeCameraRenderObserver;
  48723. private _changeImageMode;
  48724. /**
  48725. * Releases resources associated with this node.
  48726. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48727. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48728. */
  48729. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48730. }
  48731. }
  48732. declare module BABYLON {
  48733. /**
  48734. * Class used to host RGBD texture specific utilities
  48735. */
  48736. export class RGBDTextureTools {
  48737. /**
  48738. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48739. * @param texture the texture to expand.
  48740. */
  48741. static ExpandRGBDTexture(texture: Texture): void;
  48742. }
  48743. }
  48744. declare module BABYLON {
  48745. /**
  48746. * Class used to host texture specific utilities
  48747. */
  48748. export class BRDFTextureTools {
  48749. /**
  48750. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48751. * @param scene defines the hosting scene
  48752. * @returns the environment BRDF texture
  48753. */
  48754. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48755. private static _environmentBRDFBase64Texture;
  48756. }
  48757. }
  48758. declare module BABYLON {
  48759. /**
  48760. * @hidden
  48761. */
  48762. export interface IMaterialClearCoatDefines {
  48763. CLEARCOAT: boolean;
  48764. CLEARCOAT_DEFAULTIOR: boolean;
  48765. CLEARCOAT_TEXTURE: boolean;
  48766. CLEARCOAT_TEXTUREDIRECTUV: number;
  48767. CLEARCOAT_BUMP: boolean;
  48768. CLEARCOAT_BUMPDIRECTUV: number;
  48769. CLEARCOAT_TINT: boolean;
  48770. CLEARCOAT_TINT_TEXTURE: boolean;
  48771. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48772. /** @hidden */
  48773. _areTexturesDirty: boolean;
  48774. }
  48775. /**
  48776. * Define the code related to the clear coat parameters of the pbr material.
  48777. */
  48778. export class PBRClearCoatConfiguration {
  48779. /**
  48780. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48781. * The default fits with a polyurethane material.
  48782. */
  48783. private static readonly _DefaultIndexOfRefraction;
  48784. private _isEnabled;
  48785. /**
  48786. * Defines if the clear coat is enabled in the material.
  48787. */
  48788. isEnabled: boolean;
  48789. /**
  48790. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48791. */
  48792. intensity: number;
  48793. /**
  48794. * Defines the clear coat layer roughness.
  48795. */
  48796. roughness: number;
  48797. private _indexOfRefraction;
  48798. /**
  48799. * Defines the index of refraction of the clear coat.
  48800. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48801. * The default fits with a polyurethane material.
  48802. * Changing the default value is more performance intensive.
  48803. */
  48804. indexOfRefraction: number;
  48805. private _texture;
  48806. /**
  48807. * Stores the clear coat values in a texture.
  48808. */
  48809. texture: Nullable<BaseTexture>;
  48810. private _bumpTexture;
  48811. /**
  48812. * Define the clear coat specific bump texture.
  48813. */
  48814. bumpTexture: Nullable<BaseTexture>;
  48815. private _isTintEnabled;
  48816. /**
  48817. * Defines if the clear coat tint is enabled in the material.
  48818. */
  48819. isTintEnabled: boolean;
  48820. /**
  48821. * Defines the clear coat tint of the material.
  48822. * This is only use if tint is enabled
  48823. */
  48824. tintColor: Color3;
  48825. /**
  48826. * Defines the distance at which the tint color should be found in the
  48827. * clear coat media.
  48828. * This is only use if tint is enabled
  48829. */
  48830. tintColorAtDistance: number;
  48831. /**
  48832. * Defines the clear coat layer thickness.
  48833. * This is only use if tint is enabled
  48834. */
  48835. tintThickness: number;
  48836. private _tintTexture;
  48837. /**
  48838. * Stores the clear tint values in a texture.
  48839. * rgb is tint
  48840. * a is a thickness factor
  48841. */
  48842. tintTexture: Nullable<BaseTexture>;
  48843. /** @hidden */
  48844. private _internalMarkAllSubMeshesAsTexturesDirty;
  48845. /** @hidden */
  48846. _markAllSubMeshesAsTexturesDirty(): void;
  48847. /**
  48848. * Instantiate a new istance of clear coat configuration.
  48849. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48850. */
  48851. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48852. /**
  48853. * Gets wehter the submesh is ready to be used or not.
  48854. * @param defines the list of "defines" to update.
  48855. * @param scene defines the scene the material belongs to.
  48856. * @param engine defines the engine the material belongs to.
  48857. * @param disableBumpMap defines wether the material disables bump or not.
  48858. * @returns - boolean indicating that the submesh is ready or not.
  48859. */
  48860. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48861. /**
  48862. * Checks to see if a texture is used in the material.
  48863. * @param defines the list of "defines" to update.
  48864. * @param scene defines the scene to the material belongs to.
  48865. */
  48866. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48867. /**
  48868. * Binds the material data.
  48869. * @param uniformBuffer defines the Uniform buffer to fill in.
  48870. * @param scene defines the scene the material belongs to.
  48871. * @param engine defines the engine the material belongs to.
  48872. * @param disableBumpMap defines wether the material disables bump or not.
  48873. * @param isFrozen defines wether the material is frozen or not.
  48874. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48875. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48876. */
  48877. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48878. /**
  48879. * Checks to see if a texture is used in the material.
  48880. * @param texture - Base texture to use.
  48881. * @returns - Boolean specifying if a texture is used in the material.
  48882. */
  48883. hasTexture(texture: BaseTexture): boolean;
  48884. /**
  48885. * Returns an array of the actively used textures.
  48886. * @param activeTextures Array of BaseTextures
  48887. */
  48888. getActiveTextures(activeTextures: BaseTexture[]): void;
  48889. /**
  48890. * Returns the animatable textures.
  48891. * @param animatables Array of animatable textures.
  48892. */
  48893. getAnimatables(animatables: IAnimatable[]): void;
  48894. /**
  48895. * Disposes the resources of the material.
  48896. * @param forceDisposeTextures - Forces the disposal of all textures.
  48897. */
  48898. dispose(forceDisposeTextures?: boolean): void;
  48899. /**
  48900. * Get the current class name of the texture useful for serialization or dynamic coding.
  48901. * @returns "PBRClearCoatConfiguration"
  48902. */
  48903. getClassName(): string;
  48904. /**
  48905. * Add fallbacks to the effect fallbacks list.
  48906. * @param defines defines the Base texture to use.
  48907. * @param fallbacks defines the current fallback list.
  48908. * @param currentRank defines the current fallback rank.
  48909. * @returns the new fallback rank.
  48910. */
  48911. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48912. /**
  48913. * Add the required uniforms to the current list.
  48914. * @param uniforms defines the current uniform list.
  48915. */
  48916. static AddUniforms(uniforms: string[]): void;
  48917. /**
  48918. * Add the required samplers to the current list.
  48919. * @param samplers defines the current sampler list.
  48920. */
  48921. static AddSamplers(samplers: string[]): void;
  48922. /**
  48923. * Add the required uniforms to the current buffer.
  48924. * @param uniformBuffer defines the current uniform buffer.
  48925. */
  48926. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48927. /**
  48928. * Makes a duplicate of the current configuration into another one.
  48929. * @param clearCoatConfiguration define the config where to copy the info
  48930. */
  48931. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48932. /**
  48933. * Serializes this clear coat configuration.
  48934. * @returns - An object with the serialized config.
  48935. */
  48936. serialize(): any;
  48937. /**
  48938. * Parses a anisotropy Configuration from a serialized object.
  48939. * @param source - Serialized object.
  48940. * @param scene Defines the scene we are parsing for
  48941. * @param rootUrl Defines the rootUrl to load from
  48942. */
  48943. parse(source: any, scene: Scene, rootUrl: string): void;
  48944. }
  48945. }
  48946. declare module BABYLON {
  48947. /**
  48948. * @hidden
  48949. */
  48950. export interface IMaterialAnisotropicDefines {
  48951. ANISOTROPIC: boolean;
  48952. ANISOTROPIC_TEXTURE: boolean;
  48953. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48954. MAINUV1: boolean;
  48955. _areTexturesDirty: boolean;
  48956. _needUVs: boolean;
  48957. }
  48958. /**
  48959. * Define the code related to the anisotropic parameters of the pbr material.
  48960. */
  48961. export class PBRAnisotropicConfiguration {
  48962. private _isEnabled;
  48963. /**
  48964. * Defines if the anisotropy is enabled in the material.
  48965. */
  48966. isEnabled: boolean;
  48967. /**
  48968. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48969. */
  48970. intensity: number;
  48971. /**
  48972. * Defines if the effect is along the tangents, bitangents or in between.
  48973. * By default, the effect is "strectching" the highlights along the tangents.
  48974. */
  48975. direction: Vector2;
  48976. private _texture;
  48977. /**
  48978. * Stores the anisotropy values in a texture.
  48979. * rg is direction (like normal from -1 to 1)
  48980. * b is a intensity
  48981. */
  48982. texture: Nullable<BaseTexture>;
  48983. /** @hidden */
  48984. private _internalMarkAllSubMeshesAsTexturesDirty;
  48985. /** @hidden */
  48986. _markAllSubMeshesAsTexturesDirty(): void;
  48987. /**
  48988. * Instantiate a new istance of anisotropy configuration.
  48989. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48990. */
  48991. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48992. /**
  48993. * Specifies that the submesh is ready to be used.
  48994. * @param defines the list of "defines" to update.
  48995. * @param scene defines the scene the material belongs to.
  48996. * @returns - boolean indicating that the submesh is ready or not.
  48997. */
  48998. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48999. /**
  49000. * Checks to see if a texture is used in the material.
  49001. * @param defines the list of "defines" to update.
  49002. * @param mesh the mesh we are preparing the defines for.
  49003. * @param scene defines the scene the material belongs to.
  49004. */
  49005. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49006. /**
  49007. * Binds the material data.
  49008. * @param uniformBuffer defines the Uniform buffer to fill in.
  49009. * @param scene defines the scene the material belongs to.
  49010. * @param isFrozen defines wether the material is frozen or not.
  49011. */
  49012. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49013. /**
  49014. * Checks to see if a texture is used in the material.
  49015. * @param texture - Base texture to use.
  49016. * @returns - Boolean specifying if a texture is used in the material.
  49017. */
  49018. hasTexture(texture: BaseTexture): boolean;
  49019. /**
  49020. * Returns an array of the actively used textures.
  49021. * @param activeTextures Array of BaseTextures
  49022. */
  49023. getActiveTextures(activeTextures: BaseTexture[]): void;
  49024. /**
  49025. * Returns the animatable textures.
  49026. * @param animatables Array of animatable textures.
  49027. */
  49028. getAnimatables(animatables: IAnimatable[]): void;
  49029. /**
  49030. * Disposes the resources of the material.
  49031. * @param forceDisposeTextures - Forces the disposal of all textures.
  49032. */
  49033. dispose(forceDisposeTextures?: boolean): void;
  49034. /**
  49035. * Get the current class name of the texture useful for serialization or dynamic coding.
  49036. * @returns "PBRAnisotropicConfiguration"
  49037. */
  49038. getClassName(): string;
  49039. /**
  49040. * Add fallbacks to the effect fallbacks list.
  49041. * @param defines defines the Base texture to use.
  49042. * @param fallbacks defines the current fallback list.
  49043. * @param currentRank defines the current fallback rank.
  49044. * @returns the new fallback rank.
  49045. */
  49046. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49047. /**
  49048. * Add the required uniforms to the current list.
  49049. * @param uniforms defines the current uniform list.
  49050. */
  49051. static AddUniforms(uniforms: string[]): void;
  49052. /**
  49053. * Add the required uniforms to the current buffer.
  49054. * @param uniformBuffer defines the current uniform buffer.
  49055. */
  49056. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49057. /**
  49058. * Add the required samplers to the current list.
  49059. * @param samplers defines the current sampler list.
  49060. */
  49061. static AddSamplers(samplers: string[]): void;
  49062. /**
  49063. * Makes a duplicate of the current configuration into another one.
  49064. * @param anisotropicConfiguration define the config where to copy the info
  49065. */
  49066. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49067. /**
  49068. * Serializes this anisotropy configuration.
  49069. * @returns - An object with the serialized config.
  49070. */
  49071. serialize(): any;
  49072. /**
  49073. * Parses a anisotropy Configuration from a serialized object.
  49074. * @param source - Serialized object.
  49075. * @param scene Defines the scene we are parsing for
  49076. * @param rootUrl Defines the rootUrl to load from
  49077. */
  49078. parse(source: any, scene: Scene, rootUrl: string): void;
  49079. }
  49080. }
  49081. declare module BABYLON {
  49082. /**
  49083. * @hidden
  49084. */
  49085. export interface IMaterialBRDFDefines {
  49086. BRDF_V_HEIGHT_CORRELATED: boolean;
  49087. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49088. SPHERICAL_HARMONICS: boolean;
  49089. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49090. /** @hidden */
  49091. _areMiscDirty: boolean;
  49092. }
  49093. /**
  49094. * Define the code related to the BRDF parameters of the pbr material.
  49095. */
  49096. export class PBRBRDFConfiguration {
  49097. /**
  49098. * Default value used for the energy conservation.
  49099. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49100. */
  49101. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49102. /**
  49103. * Default value used for the Smith Visibility Height Correlated mode.
  49104. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49105. */
  49106. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49107. /**
  49108. * Default value used for the IBL diffuse part.
  49109. * This can help switching back to the polynomials mode globally which is a tiny bit
  49110. * less GPU intensive at the drawback of a lower quality.
  49111. */
  49112. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49113. /**
  49114. * Default value used for activating energy conservation for the specular workflow.
  49115. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49116. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49117. */
  49118. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49119. private _useEnergyConservation;
  49120. /**
  49121. * Defines if the material uses energy conservation.
  49122. */
  49123. useEnergyConservation: boolean;
  49124. private _useSmithVisibilityHeightCorrelated;
  49125. /**
  49126. * LEGACY Mode set to false
  49127. * Defines if the material uses height smith correlated visibility term.
  49128. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49129. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49130. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49131. * Not relying on height correlated will also disable energy conservation.
  49132. */
  49133. useSmithVisibilityHeightCorrelated: boolean;
  49134. private _useSphericalHarmonics;
  49135. /**
  49136. * LEGACY Mode set to false
  49137. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49138. * diffuse part of the IBL.
  49139. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49140. * to the ground truth.
  49141. */
  49142. useSphericalHarmonics: boolean;
  49143. private _useSpecularGlossinessInputEnergyConservation;
  49144. /**
  49145. * Defines if the material uses energy conservation, when the specular workflow is active.
  49146. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49147. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49148. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49149. */
  49150. useSpecularGlossinessInputEnergyConservation: boolean;
  49151. /** @hidden */
  49152. private _internalMarkAllSubMeshesAsMiscDirty;
  49153. /** @hidden */
  49154. _markAllSubMeshesAsMiscDirty(): void;
  49155. /**
  49156. * Instantiate a new istance of clear coat configuration.
  49157. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49158. */
  49159. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49160. /**
  49161. * Checks to see if a texture is used in the material.
  49162. * @param defines the list of "defines" to update.
  49163. */
  49164. prepareDefines(defines: IMaterialBRDFDefines): void;
  49165. /**
  49166. * Get the current class name of the texture useful for serialization or dynamic coding.
  49167. * @returns "PBRClearCoatConfiguration"
  49168. */
  49169. getClassName(): string;
  49170. /**
  49171. * Makes a duplicate of the current configuration into another one.
  49172. * @param brdfConfiguration define the config where to copy the info
  49173. */
  49174. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49175. /**
  49176. * Serializes this BRDF configuration.
  49177. * @returns - An object with the serialized config.
  49178. */
  49179. serialize(): any;
  49180. /**
  49181. * Parses a anisotropy Configuration from a serialized object.
  49182. * @param source - Serialized object.
  49183. * @param scene Defines the scene we are parsing for
  49184. * @param rootUrl Defines the rootUrl to load from
  49185. */
  49186. parse(source: any, scene: Scene, rootUrl: string): void;
  49187. }
  49188. }
  49189. declare module BABYLON {
  49190. /**
  49191. * @hidden
  49192. */
  49193. export interface IMaterialSheenDefines {
  49194. SHEEN: boolean;
  49195. SHEEN_TEXTURE: boolean;
  49196. SHEEN_TEXTUREDIRECTUV: number;
  49197. SHEEN_LINKWITHALBEDO: boolean;
  49198. /** @hidden */
  49199. _areTexturesDirty: boolean;
  49200. }
  49201. /**
  49202. * Define the code related to the Sheen parameters of the pbr material.
  49203. */
  49204. export class PBRSheenConfiguration {
  49205. private _isEnabled;
  49206. /**
  49207. * Defines if the material uses sheen.
  49208. */
  49209. isEnabled: boolean;
  49210. private _linkSheenWithAlbedo;
  49211. /**
  49212. * Defines if the sheen is linked to the sheen color.
  49213. */
  49214. linkSheenWithAlbedo: boolean;
  49215. /**
  49216. * Defines the sheen intensity.
  49217. */
  49218. intensity: number;
  49219. /**
  49220. * Defines the sheen color.
  49221. */
  49222. color: Color3;
  49223. private _texture;
  49224. /**
  49225. * Stores the sheen tint values in a texture.
  49226. * rgb is tint
  49227. * a is a intensity
  49228. */
  49229. texture: Nullable<BaseTexture>;
  49230. /** @hidden */
  49231. private _internalMarkAllSubMeshesAsTexturesDirty;
  49232. /** @hidden */
  49233. _markAllSubMeshesAsTexturesDirty(): void;
  49234. /**
  49235. * Instantiate a new istance of clear coat configuration.
  49236. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49237. */
  49238. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49239. /**
  49240. * Specifies that the submesh is ready to be used.
  49241. * @param defines the list of "defines" to update.
  49242. * @param scene defines the scene the material belongs to.
  49243. * @returns - boolean indicating that the submesh is ready or not.
  49244. */
  49245. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49246. /**
  49247. * Checks to see if a texture is used in the material.
  49248. * @param defines the list of "defines" to update.
  49249. * @param scene defines the scene the material belongs to.
  49250. */
  49251. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49252. /**
  49253. * Binds the material data.
  49254. * @param uniformBuffer defines the Uniform buffer to fill in.
  49255. * @param scene defines the scene the material belongs to.
  49256. * @param isFrozen defines wether the material is frozen or not.
  49257. */
  49258. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49259. /**
  49260. * Checks to see if a texture is used in the material.
  49261. * @param texture - Base texture to use.
  49262. * @returns - Boolean specifying if a texture is used in the material.
  49263. */
  49264. hasTexture(texture: BaseTexture): boolean;
  49265. /**
  49266. * Returns an array of the actively used textures.
  49267. * @param activeTextures Array of BaseTextures
  49268. */
  49269. getActiveTextures(activeTextures: BaseTexture[]): void;
  49270. /**
  49271. * Returns the animatable textures.
  49272. * @param animatables Array of animatable textures.
  49273. */
  49274. getAnimatables(animatables: IAnimatable[]): void;
  49275. /**
  49276. * Disposes the resources of the material.
  49277. * @param forceDisposeTextures - Forces the disposal of all textures.
  49278. */
  49279. dispose(forceDisposeTextures?: boolean): void;
  49280. /**
  49281. * Get the current class name of the texture useful for serialization or dynamic coding.
  49282. * @returns "PBRSheenConfiguration"
  49283. */
  49284. getClassName(): string;
  49285. /**
  49286. * Add fallbacks to the effect fallbacks list.
  49287. * @param defines defines the Base texture to use.
  49288. * @param fallbacks defines the current fallback list.
  49289. * @param currentRank defines the current fallback rank.
  49290. * @returns the new fallback rank.
  49291. */
  49292. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49293. /**
  49294. * Add the required uniforms to the current list.
  49295. * @param uniforms defines the current uniform list.
  49296. */
  49297. static AddUniforms(uniforms: string[]): void;
  49298. /**
  49299. * Add the required uniforms to the current buffer.
  49300. * @param uniformBuffer defines the current uniform buffer.
  49301. */
  49302. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49303. /**
  49304. * Add the required samplers to the current list.
  49305. * @param samplers defines the current sampler list.
  49306. */
  49307. static AddSamplers(samplers: string[]): void;
  49308. /**
  49309. * Makes a duplicate of the current configuration into another one.
  49310. * @param sheenConfiguration define the config where to copy the info
  49311. */
  49312. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49313. /**
  49314. * Serializes this BRDF configuration.
  49315. * @returns - An object with the serialized config.
  49316. */
  49317. serialize(): any;
  49318. /**
  49319. * Parses a anisotropy Configuration from a serialized object.
  49320. * @param source - Serialized object.
  49321. * @param scene Defines the scene we are parsing for
  49322. * @param rootUrl Defines the rootUrl to load from
  49323. */
  49324. parse(source: any, scene: Scene, rootUrl: string): void;
  49325. }
  49326. }
  49327. declare module BABYLON {
  49328. /**
  49329. * @hidden
  49330. */
  49331. export interface IMaterialSubSurfaceDefines {
  49332. SUBSURFACE: boolean;
  49333. SS_REFRACTION: boolean;
  49334. SS_TRANSLUCENCY: boolean;
  49335. SS_SCATERRING: boolean;
  49336. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49337. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49338. SS_REFRACTIONMAP_3D: boolean;
  49339. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49340. SS_LODINREFRACTIONALPHA: boolean;
  49341. SS_GAMMAREFRACTION: boolean;
  49342. SS_RGBDREFRACTION: boolean;
  49343. SS_LINEARSPECULARREFRACTION: boolean;
  49344. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49345. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49346. /** @hidden */
  49347. _areTexturesDirty: boolean;
  49348. }
  49349. /**
  49350. * Define the code related to the sub surface parameters of the pbr material.
  49351. */
  49352. export class PBRSubSurfaceConfiguration {
  49353. private _isRefractionEnabled;
  49354. /**
  49355. * Defines if the refraction is enabled in the material.
  49356. */
  49357. isRefractionEnabled: boolean;
  49358. private _isTranslucencyEnabled;
  49359. /**
  49360. * Defines if the translucency is enabled in the material.
  49361. */
  49362. isTranslucencyEnabled: boolean;
  49363. private _isScatteringEnabled;
  49364. /**
  49365. * Defines the refraction intensity of the material.
  49366. * The refraction when enabled replaces the Diffuse part of the material.
  49367. * The intensity helps transitionning between diffuse and refraction.
  49368. */
  49369. refractionIntensity: number;
  49370. /**
  49371. * Defines the translucency intensity of the material.
  49372. * When translucency has been enabled, this defines how much of the "translucency"
  49373. * is addded to the diffuse part of the material.
  49374. */
  49375. translucencyIntensity: number;
  49376. /**
  49377. * Defines the scattering intensity of the material.
  49378. * When scattering has been enabled, this defines how much of the "scattered light"
  49379. * is addded to the diffuse part of the material.
  49380. */
  49381. scatteringIntensity: number;
  49382. private _thicknessTexture;
  49383. /**
  49384. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49385. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49386. * 0 would mean minimumThickness
  49387. * 1 would mean maximumThickness
  49388. * The other channels might be use as a mask to vary the different effects intensity.
  49389. */
  49390. thicknessTexture: Nullable<BaseTexture>;
  49391. private _refractionTexture;
  49392. /**
  49393. * Defines the texture to use for refraction.
  49394. */
  49395. refractionTexture: Nullable<BaseTexture>;
  49396. private _indexOfRefraction;
  49397. /**
  49398. * Defines the index of refraction used in the material.
  49399. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49400. */
  49401. indexOfRefraction: number;
  49402. private _invertRefractionY;
  49403. /**
  49404. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49405. */
  49406. invertRefractionY: boolean;
  49407. private _linkRefractionWithTransparency;
  49408. /**
  49409. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49410. * Materials half opaque for instance using refraction could benefit from this control.
  49411. */
  49412. linkRefractionWithTransparency: boolean;
  49413. /**
  49414. * Defines the minimum thickness stored in the thickness map.
  49415. * If no thickness map is defined, this value will be used to simulate thickness.
  49416. */
  49417. minimumThickness: number;
  49418. /**
  49419. * Defines the maximum thickness stored in the thickness map.
  49420. */
  49421. maximumThickness: number;
  49422. /**
  49423. * Defines the volume tint of the material.
  49424. * This is used for both translucency and scattering.
  49425. */
  49426. tintColor: Color3;
  49427. /**
  49428. * Defines the distance at which the tint color should be found in the media.
  49429. * This is used for refraction only.
  49430. */
  49431. tintColorAtDistance: number;
  49432. /**
  49433. * Defines how far each channel transmit through the media.
  49434. * It is defined as a color to simplify it selection.
  49435. */
  49436. diffusionDistance: Color3;
  49437. private _useMaskFromThicknessTexture;
  49438. /**
  49439. * Stores the intensity of the different subsurface effects in the thickness texture.
  49440. * * the green channel is the translucency intensity.
  49441. * * the blue channel is the scattering intensity.
  49442. * * the alpha channel is the refraction intensity.
  49443. */
  49444. useMaskFromThicknessTexture: boolean;
  49445. /** @hidden */
  49446. private _internalMarkAllSubMeshesAsTexturesDirty;
  49447. /** @hidden */
  49448. _markAllSubMeshesAsTexturesDirty(): void;
  49449. /**
  49450. * Instantiate a new istance of sub surface configuration.
  49451. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49452. */
  49453. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49454. /**
  49455. * Gets wehter the submesh is ready to be used or not.
  49456. * @param defines the list of "defines" to update.
  49457. * @param scene defines the scene the material belongs to.
  49458. * @returns - boolean indicating that the submesh is ready or not.
  49459. */
  49460. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49461. /**
  49462. * Checks to see if a texture is used in the material.
  49463. * @param defines the list of "defines" to update.
  49464. * @param scene defines the scene to the material belongs to.
  49465. */
  49466. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49467. /**
  49468. * Binds the material data.
  49469. * @param uniformBuffer defines the Uniform buffer to fill in.
  49470. * @param scene defines the scene the material belongs to.
  49471. * @param engine defines the engine the material belongs to.
  49472. * @param isFrozen defines wether the material is frozen or not.
  49473. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49474. */
  49475. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49476. /**
  49477. * Unbinds the material from the mesh.
  49478. * @param activeEffect defines the effect that should be unbound from.
  49479. * @returns true if unbound, otherwise false
  49480. */
  49481. unbind(activeEffect: Effect): boolean;
  49482. /**
  49483. * Returns the texture used for refraction or null if none is used.
  49484. * @param scene defines the scene the material belongs to.
  49485. * @returns - Refraction texture if present. If no refraction texture and refraction
  49486. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49487. */
  49488. private _getRefractionTexture;
  49489. /**
  49490. * Returns true if alpha blending should be disabled.
  49491. */
  49492. get disableAlphaBlending(): boolean;
  49493. /**
  49494. * Fills the list of render target textures.
  49495. * @param renderTargets the list of render targets to update
  49496. */
  49497. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49498. /**
  49499. * Checks to see if a texture is used in the material.
  49500. * @param texture - Base texture to use.
  49501. * @returns - Boolean specifying if a texture is used in the material.
  49502. */
  49503. hasTexture(texture: BaseTexture): boolean;
  49504. /**
  49505. * Gets a boolean indicating that current material needs to register RTT
  49506. * @returns true if this uses a render target otherwise false.
  49507. */
  49508. hasRenderTargetTextures(): boolean;
  49509. /**
  49510. * Returns an array of the actively used textures.
  49511. * @param activeTextures Array of BaseTextures
  49512. */
  49513. getActiveTextures(activeTextures: BaseTexture[]): void;
  49514. /**
  49515. * Returns the animatable textures.
  49516. * @param animatables Array of animatable textures.
  49517. */
  49518. getAnimatables(animatables: IAnimatable[]): void;
  49519. /**
  49520. * Disposes the resources of the material.
  49521. * @param forceDisposeTextures - Forces the disposal of all textures.
  49522. */
  49523. dispose(forceDisposeTextures?: boolean): void;
  49524. /**
  49525. * Get the current class name of the texture useful for serialization or dynamic coding.
  49526. * @returns "PBRSubSurfaceConfiguration"
  49527. */
  49528. getClassName(): string;
  49529. /**
  49530. * Add fallbacks to the effect fallbacks list.
  49531. * @param defines defines the Base texture to use.
  49532. * @param fallbacks defines the current fallback list.
  49533. * @param currentRank defines the current fallback rank.
  49534. * @returns the new fallback rank.
  49535. */
  49536. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49537. /**
  49538. * Add the required uniforms to the current list.
  49539. * @param uniforms defines the current uniform list.
  49540. */
  49541. static AddUniforms(uniforms: string[]): void;
  49542. /**
  49543. * Add the required samplers to the current list.
  49544. * @param samplers defines the current sampler list.
  49545. */
  49546. static AddSamplers(samplers: string[]): void;
  49547. /**
  49548. * Add the required uniforms to the current buffer.
  49549. * @param uniformBuffer defines the current uniform buffer.
  49550. */
  49551. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49552. /**
  49553. * Makes a duplicate of the current configuration into another one.
  49554. * @param configuration define the config where to copy the info
  49555. */
  49556. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49557. /**
  49558. * Serializes this Sub Surface configuration.
  49559. * @returns - An object with the serialized config.
  49560. */
  49561. serialize(): any;
  49562. /**
  49563. * Parses a anisotropy Configuration from a serialized object.
  49564. * @param source - Serialized object.
  49565. * @param scene Defines the scene we are parsing for
  49566. * @param rootUrl Defines the rootUrl to load from
  49567. */
  49568. parse(source: any, scene: Scene, rootUrl: string): void;
  49569. }
  49570. }
  49571. declare module BABYLON {
  49572. /** @hidden */
  49573. export var pbrFragmentDeclaration: {
  49574. name: string;
  49575. shader: string;
  49576. };
  49577. }
  49578. declare module BABYLON {
  49579. /** @hidden */
  49580. export var pbrUboDeclaration: {
  49581. name: string;
  49582. shader: string;
  49583. };
  49584. }
  49585. declare module BABYLON {
  49586. /** @hidden */
  49587. export var pbrFragmentExtraDeclaration: {
  49588. name: string;
  49589. shader: string;
  49590. };
  49591. }
  49592. declare module BABYLON {
  49593. /** @hidden */
  49594. export var pbrFragmentSamplersDeclaration: {
  49595. name: string;
  49596. shader: string;
  49597. };
  49598. }
  49599. declare module BABYLON {
  49600. /** @hidden */
  49601. export var pbrHelperFunctions: {
  49602. name: string;
  49603. shader: string;
  49604. };
  49605. }
  49606. declare module BABYLON {
  49607. /** @hidden */
  49608. export var harmonicsFunctions: {
  49609. name: string;
  49610. shader: string;
  49611. };
  49612. }
  49613. declare module BABYLON {
  49614. /** @hidden */
  49615. export var pbrDirectLightingSetupFunctions: {
  49616. name: string;
  49617. shader: string;
  49618. };
  49619. }
  49620. declare module BABYLON {
  49621. /** @hidden */
  49622. export var pbrDirectLightingFalloffFunctions: {
  49623. name: string;
  49624. shader: string;
  49625. };
  49626. }
  49627. declare module BABYLON {
  49628. /** @hidden */
  49629. export var pbrBRDFFunctions: {
  49630. name: string;
  49631. shader: string;
  49632. };
  49633. }
  49634. declare module BABYLON {
  49635. /** @hidden */
  49636. export var pbrDirectLightingFunctions: {
  49637. name: string;
  49638. shader: string;
  49639. };
  49640. }
  49641. declare module BABYLON {
  49642. /** @hidden */
  49643. export var pbrIBLFunctions: {
  49644. name: string;
  49645. shader: string;
  49646. };
  49647. }
  49648. declare module BABYLON {
  49649. /** @hidden */
  49650. export var pbrDebug: {
  49651. name: string;
  49652. shader: string;
  49653. };
  49654. }
  49655. declare module BABYLON {
  49656. /** @hidden */
  49657. export var pbrPixelShader: {
  49658. name: string;
  49659. shader: string;
  49660. };
  49661. }
  49662. declare module BABYLON {
  49663. /** @hidden */
  49664. export var pbrVertexDeclaration: {
  49665. name: string;
  49666. shader: string;
  49667. };
  49668. }
  49669. declare module BABYLON {
  49670. /** @hidden */
  49671. export var pbrVertexShader: {
  49672. name: string;
  49673. shader: string;
  49674. };
  49675. }
  49676. declare module BABYLON {
  49677. /**
  49678. * Manages the defines for the PBR Material.
  49679. * @hidden
  49680. */
  49681. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49682. PBR: boolean;
  49683. MAINUV1: boolean;
  49684. MAINUV2: boolean;
  49685. UV1: boolean;
  49686. UV2: boolean;
  49687. ALBEDO: boolean;
  49688. ALBEDODIRECTUV: number;
  49689. VERTEXCOLOR: boolean;
  49690. AMBIENT: boolean;
  49691. AMBIENTDIRECTUV: number;
  49692. AMBIENTINGRAYSCALE: boolean;
  49693. OPACITY: boolean;
  49694. VERTEXALPHA: boolean;
  49695. OPACITYDIRECTUV: number;
  49696. OPACITYRGB: boolean;
  49697. ALPHATEST: boolean;
  49698. DEPTHPREPASS: boolean;
  49699. ALPHABLEND: boolean;
  49700. ALPHAFROMALBEDO: boolean;
  49701. ALPHATESTVALUE: string;
  49702. SPECULAROVERALPHA: boolean;
  49703. RADIANCEOVERALPHA: boolean;
  49704. ALPHAFRESNEL: boolean;
  49705. LINEARALPHAFRESNEL: boolean;
  49706. PREMULTIPLYALPHA: boolean;
  49707. EMISSIVE: boolean;
  49708. EMISSIVEDIRECTUV: number;
  49709. REFLECTIVITY: boolean;
  49710. REFLECTIVITYDIRECTUV: number;
  49711. SPECULARTERM: boolean;
  49712. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49713. MICROSURFACEAUTOMATIC: boolean;
  49714. LODBASEDMICROSFURACE: boolean;
  49715. MICROSURFACEMAP: boolean;
  49716. MICROSURFACEMAPDIRECTUV: number;
  49717. METALLICWORKFLOW: boolean;
  49718. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49719. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49720. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49721. AOSTOREINMETALMAPRED: boolean;
  49722. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49723. ENVIRONMENTBRDF: boolean;
  49724. ENVIRONMENTBRDF_RGBD: boolean;
  49725. NORMAL: boolean;
  49726. TANGENT: boolean;
  49727. BUMP: boolean;
  49728. BUMPDIRECTUV: number;
  49729. OBJECTSPACE_NORMALMAP: boolean;
  49730. PARALLAX: boolean;
  49731. PARALLAXOCCLUSION: boolean;
  49732. NORMALXYSCALE: boolean;
  49733. LIGHTMAP: boolean;
  49734. LIGHTMAPDIRECTUV: number;
  49735. USELIGHTMAPASSHADOWMAP: boolean;
  49736. GAMMALIGHTMAP: boolean;
  49737. RGBDLIGHTMAP: boolean;
  49738. REFLECTION: boolean;
  49739. REFLECTIONMAP_3D: boolean;
  49740. REFLECTIONMAP_SPHERICAL: boolean;
  49741. REFLECTIONMAP_PLANAR: boolean;
  49742. REFLECTIONMAP_CUBIC: boolean;
  49743. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49744. REFLECTIONMAP_PROJECTION: boolean;
  49745. REFLECTIONMAP_SKYBOX: boolean;
  49746. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49747. REFLECTIONMAP_EXPLICIT: boolean;
  49748. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49749. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49750. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49751. INVERTCUBICMAP: boolean;
  49752. USESPHERICALFROMREFLECTIONMAP: boolean;
  49753. USEIRRADIANCEMAP: boolean;
  49754. SPHERICAL_HARMONICS: boolean;
  49755. USESPHERICALINVERTEX: boolean;
  49756. REFLECTIONMAP_OPPOSITEZ: boolean;
  49757. LODINREFLECTIONALPHA: boolean;
  49758. GAMMAREFLECTION: boolean;
  49759. RGBDREFLECTION: boolean;
  49760. LINEARSPECULARREFLECTION: boolean;
  49761. RADIANCEOCCLUSION: boolean;
  49762. HORIZONOCCLUSION: boolean;
  49763. INSTANCES: boolean;
  49764. NUM_BONE_INFLUENCERS: number;
  49765. BonesPerMesh: number;
  49766. BONETEXTURE: boolean;
  49767. NONUNIFORMSCALING: boolean;
  49768. MORPHTARGETS: boolean;
  49769. MORPHTARGETS_NORMAL: boolean;
  49770. MORPHTARGETS_TANGENT: boolean;
  49771. MORPHTARGETS_UV: boolean;
  49772. NUM_MORPH_INFLUENCERS: number;
  49773. IMAGEPROCESSING: boolean;
  49774. VIGNETTE: boolean;
  49775. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49776. VIGNETTEBLENDMODEOPAQUE: boolean;
  49777. TONEMAPPING: boolean;
  49778. TONEMAPPING_ACES: boolean;
  49779. CONTRAST: boolean;
  49780. COLORCURVES: boolean;
  49781. COLORGRADING: boolean;
  49782. COLORGRADING3D: boolean;
  49783. SAMPLER3DGREENDEPTH: boolean;
  49784. SAMPLER3DBGRMAP: boolean;
  49785. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49786. EXPOSURE: boolean;
  49787. MULTIVIEW: boolean;
  49788. USEPHYSICALLIGHTFALLOFF: boolean;
  49789. USEGLTFLIGHTFALLOFF: boolean;
  49790. TWOSIDEDLIGHTING: boolean;
  49791. SHADOWFLOAT: boolean;
  49792. CLIPPLANE: boolean;
  49793. CLIPPLANE2: boolean;
  49794. CLIPPLANE3: boolean;
  49795. CLIPPLANE4: boolean;
  49796. POINTSIZE: boolean;
  49797. FOG: boolean;
  49798. LOGARITHMICDEPTH: boolean;
  49799. FORCENORMALFORWARD: boolean;
  49800. SPECULARAA: boolean;
  49801. CLEARCOAT: boolean;
  49802. CLEARCOAT_DEFAULTIOR: boolean;
  49803. CLEARCOAT_TEXTURE: boolean;
  49804. CLEARCOAT_TEXTUREDIRECTUV: number;
  49805. CLEARCOAT_BUMP: boolean;
  49806. CLEARCOAT_BUMPDIRECTUV: number;
  49807. CLEARCOAT_TINT: boolean;
  49808. CLEARCOAT_TINT_TEXTURE: boolean;
  49809. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49810. ANISOTROPIC: boolean;
  49811. ANISOTROPIC_TEXTURE: boolean;
  49812. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49813. BRDF_V_HEIGHT_CORRELATED: boolean;
  49814. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49815. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49816. SHEEN: boolean;
  49817. SHEEN_TEXTURE: boolean;
  49818. SHEEN_TEXTUREDIRECTUV: number;
  49819. SHEEN_LINKWITHALBEDO: boolean;
  49820. SUBSURFACE: boolean;
  49821. SS_REFRACTION: boolean;
  49822. SS_TRANSLUCENCY: boolean;
  49823. SS_SCATERRING: boolean;
  49824. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49825. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49826. SS_REFRACTIONMAP_3D: boolean;
  49827. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49828. SS_LODINREFRACTIONALPHA: boolean;
  49829. SS_GAMMAREFRACTION: boolean;
  49830. SS_RGBDREFRACTION: boolean;
  49831. SS_LINEARSPECULARREFRACTION: boolean;
  49832. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49833. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49834. UNLIT: boolean;
  49835. DEBUGMODE: number;
  49836. /**
  49837. * Initializes the PBR Material defines.
  49838. */
  49839. constructor();
  49840. /**
  49841. * Resets the PBR Material defines.
  49842. */
  49843. reset(): void;
  49844. }
  49845. /**
  49846. * The Physically based material base class of BJS.
  49847. *
  49848. * This offers the main features of a standard PBR material.
  49849. * For more information, please refer to the documentation :
  49850. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49851. */
  49852. export abstract class PBRBaseMaterial extends PushMaterial {
  49853. /**
  49854. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49855. */
  49856. static readonly PBRMATERIAL_OPAQUE: number;
  49857. /**
  49858. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49859. */
  49860. static readonly PBRMATERIAL_ALPHATEST: number;
  49861. /**
  49862. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49863. */
  49864. static readonly PBRMATERIAL_ALPHABLEND: number;
  49865. /**
  49866. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49867. * They are also discarded below the alpha cutoff threshold to improve performances.
  49868. */
  49869. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49870. /**
  49871. * Defines the default value of how much AO map is occluding the analytical lights
  49872. * (point spot...).
  49873. */
  49874. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49875. /**
  49876. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49877. */
  49878. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49879. /**
  49880. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49881. * to enhance interoperability with other engines.
  49882. */
  49883. static readonly LIGHTFALLOFF_GLTF: number;
  49884. /**
  49885. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49886. * to enhance interoperability with other materials.
  49887. */
  49888. static readonly LIGHTFALLOFF_STANDARD: number;
  49889. /**
  49890. * Intensity of the direct lights e.g. the four lights available in your scene.
  49891. * This impacts both the direct diffuse and specular highlights.
  49892. */
  49893. protected _directIntensity: number;
  49894. /**
  49895. * Intensity of the emissive part of the material.
  49896. * This helps controlling the emissive effect without modifying the emissive color.
  49897. */
  49898. protected _emissiveIntensity: number;
  49899. /**
  49900. * Intensity of the environment e.g. how much the environment will light the object
  49901. * either through harmonics for rough material or through the refelction for shiny ones.
  49902. */
  49903. protected _environmentIntensity: number;
  49904. /**
  49905. * This is a special control allowing the reduction of the specular highlights coming from the
  49906. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49907. */
  49908. protected _specularIntensity: number;
  49909. /**
  49910. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49911. */
  49912. private _lightingInfos;
  49913. /**
  49914. * Debug Control allowing disabling the bump map on this material.
  49915. */
  49916. protected _disableBumpMap: boolean;
  49917. /**
  49918. * AKA Diffuse Texture in standard nomenclature.
  49919. */
  49920. protected _albedoTexture: Nullable<BaseTexture>;
  49921. /**
  49922. * AKA Occlusion Texture in other nomenclature.
  49923. */
  49924. protected _ambientTexture: Nullable<BaseTexture>;
  49925. /**
  49926. * AKA Occlusion Texture Intensity in other nomenclature.
  49927. */
  49928. protected _ambientTextureStrength: number;
  49929. /**
  49930. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49931. * 1 means it completely occludes it
  49932. * 0 mean it has no impact
  49933. */
  49934. protected _ambientTextureImpactOnAnalyticalLights: number;
  49935. /**
  49936. * Stores the alpha values in a texture.
  49937. */
  49938. protected _opacityTexture: Nullable<BaseTexture>;
  49939. /**
  49940. * Stores the reflection values in a texture.
  49941. */
  49942. protected _reflectionTexture: Nullable<BaseTexture>;
  49943. /**
  49944. * Stores the emissive values in a texture.
  49945. */
  49946. protected _emissiveTexture: Nullable<BaseTexture>;
  49947. /**
  49948. * AKA Specular texture in other nomenclature.
  49949. */
  49950. protected _reflectivityTexture: Nullable<BaseTexture>;
  49951. /**
  49952. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49953. */
  49954. protected _metallicTexture: Nullable<BaseTexture>;
  49955. /**
  49956. * Specifies the metallic scalar of the metallic/roughness workflow.
  49957. * Can also be used to scale the metalness values of the metallic texture.
  49958. */
  49959. protected _metallic: Nullable<number>;
  49960. /**
  49961. * Specifies the roughness scalar of the metallic/roughness workflow.
  49962. * Can also be used to scale the roughness values of the metallic texture.
  49963. */
  49964. protected _roughness: Nullable<number>;
  49965. /**
  49966. * Specifies the an F0 factor to help configuring the material F0.
  49967. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49968. * to 0.5 the previously hard coded value stays the same.
  49969. * Can also be used to scale the F0 values of the metallic texture.
  49970. */
  49971. protected _metallicF0Factor: number;
  49972. /**
  49973. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49974. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49975. * your expectation as it multiplies with the texture data.
  49976. */
  49977. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  49978. /**
  49979. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49980. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49981. */
  49982. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49983. /**
  49984. * Stores surface normal data used to displace a mesh in a texture.
  49985. */
  49986. protected _bumpTexture: Nullable<BaseTexture>;
  49987. /**
  49988. * Stores the pre-calculated light information of a mesh in a texture.
  49989. */
  49990. protected _lightmapTexture: Nullable<BaseTexture>;
  49991. /**
  49992. * The color of a material in ambient lighting.
  49993. */
  49994. protected _ambientColor: Color3;
  49995. /**
  49996. * AKA Diffuse Color in other nomenclature.
  49997. */
  49998. protected _albedoColor: Color3;
  49999. /**
  50000. * AKA Specular Color in other nomenclature.
  50001. */
  50002. protected _reflectivityColor: Color3;
  50003. /**
  50004. * The color applied when light is reflected from a material.
  50005. */
  50006. protected _reflectionColor: Color3;
  50007. /**
  50008. * The color applied when light is emitted from a material.
  50009. */
  50010. protected _emissiveColor: Color3;
  50011. /**
  50012. * AKA Glossiness in other nomenclature.
  50013. */
  50014. protected _microSurface: number;
  50015. /**
  50016. * Specifies that the material will use the light map as a show map.
  50017. */
  50018. protected _useLightmapAsShadowmap: boolean;
  50019. /**
  50020. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50021. * makes the reflect vector face the model (under horizon).
  50022. */
  50023. protected _useHorizonOcclusion: boolean;
  50024. /**
  50025. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50026. * too much the area relying on ambient texture to define their ambient occlusion.
  50027. */
  50028. protected _useRadianceOcclusion: boolean;
  50029. /**
  50030. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50031. */
  50032. protected _useAlphaFromAlbedoTexture: boolean;
  50033. /**
  50034. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50035. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50036. */
  50037. protected _useSpecularOverAlpha: boolean;
  50038. /**
  50039. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50040. */
  50041. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50042. /**
  50043. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50044. */
  50045. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50046. /**
  50047. * Specifies if the metallic texture contains the roughness information in its green channel.
  50048. */
  50049. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50050. /**
  50051. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50052. */
  50053. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50054. /**
  50055. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50056. */
  50057. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50058. /**
  50059. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50060. */
  50061. protected _useAmbientInGrayScale: boolean;
  50062. /**
  50063. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50064. * The material will try to infer what glossiness each pixel should be.
  50065. */
  50066. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50067. /**
  50068. * Defines the falloff type used in this material.
  50069. * It by default is Physical.
  50070. */
  50071. protected _lightFalloff: number;
  50072. /**
  50073. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50074. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50075. */
  50076. protected _useRadianceOverAlpha: boolean;
  50077. /**
  50078. * Allows using an object space normal map (instead of tangent space).
  50079. */
  50080. protected _useObjectSpaceNormalMap: boolean;
  50081. /**
  50082. * Allows using the bump map in parallax mode.
  50083. */
  50084. protected _useParallax: boolean;
  50085. /**
  50086. * Allows using the bump map in parallax occlusion mode.
  50087. */
  50088. protected _useParallaxOcclusion: boolean;
  50089. /**
  50090. * Controls the scale bias of the parallax mode.
  50091. */
  50092. protected _parallaxScaleBias: number;
  50093. /**
  50094. * If sets to true, disables all the lights affecting the material.
  50095. */
  50096. protected _disableLighting: boolean;
  50097. /**
  50098. * Number of Simultaneous lights allowed on the material.
  50099. */
  50100. protected _maxSimultaneousLights: number;
  50101. /**
  50102. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50103. */
  50104. protected _invertNormalMapX: boolean;
  50105. /**
  50106. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50107. */
  50108. protected _invertNormalMapY: boolean;
  50109. /**
  50110. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50111. */
  50112. protected _twoSidedLighting: boolean;
  50113. /**
  50114. * Defines the alpha limits in alpha test mode.
  50115. */
  50116. protected _alphaCutOff: number;
  50117. /**
  50118. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50119. */
  50120. protected _forceAlphaTest: boolean;
  50121. /**
  50122. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50123. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50124. */
  50125. protected _useAlphaFresnel: boolean;
  50126. /**
  50127. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50128. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50129. */
  50130. protected _useLinearAlphaFresnel: boolean;
  50131. /**
  50132. * The transparency mode of the material.
  50133. */
  50134. protected _transparencyMode: Nullable<number>;
  50135. /**
  50136. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50137. * from cos thetav and roughness:
  50138. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50139. */
  50140. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50141. /**
  50142. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50143. */
  50144. protected _forceIrradianceInFragment: boolean;
  50145. /**
  50146. * Force normal to face away from face.
  50147. */
  50148. protected _forceNormalForward: boolean;
  50149. /**
  50150. * Enables specular anti aliasing in the PBR shader.
  50151. * It will both interacts on the Geometry for analytical and IBL lighting.
  50152. * It also prefilter the roughness map based on the bump values.
  50153. */
  50154. protected _enableSpecularAntiAliasing: boolean;
  50155. /**
  50156. * Default configuration related to image processing available in the PBR Material.
  50157. */
  50158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50159. /**
  50160. * Keep track of the image processing observer to allow dispose and replace.
  50161. */
  50162. private _imageProcessingObserver;
  50163. /**
  50164. * Attaches a new image processing configuration to the PBR Material.
  50165. * @param configuration
  50166. */
  50167. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50168. /**
  50169. * Stores the available render targets.
  50170. */
  50171. private _renderTargets;
  50172. /**
  50173. * Sets the global ambient color for the material used in lighting calculations.
  50174. */
  50175. private _globalAmbientColor;
  50176. /**
  50177. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50178. */
  50179. private _useLogarithmicDepth;
  50180. /**
  50181. * If set to true, no lighting calculations will be applied.
  50182. */
  50183. private _unlit;
  50184. private _debugMode;
  50185. /**
  50186. * @hidden
  50187. * This is reserved for the inspector.
  50188. * Defines the material debug mode.
  50189. * It helps seeing only some components of the material while troubleshooting.
  50190. */
  50191. debugMode: number;
  50192. /**
  50193. * @hidden
  50194. * This is reserved for the inspector.
  50195. * Specify from where on screen the debug mode should start.
  50196. * The value goes from -1 (full screen) to 1 (not visible)
  50197. * It helps with side by side comparison against the final render
  50198. * This defaults to -1
  50199. */
  50200. private debugLimit;
  50201. /**
  50202. * @hidden
  50203. * This is reserved for the inspector.
  50204. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50205. * You can use the factor to better multiply the final value.
  50206. */
  50207. private debugFactor;
  50208. /**
  50209. * Defines the clear coat layer parameters for the material.
  50210. */
  50211. readonly clearCoat: PBRClearCoatConfiguration;
  50212. /**
  50213. * Defines the anisotropic parameters for the material.
  50214. */
  50215. readonly anisotropy: PBRAnisotropicConfiguration;
  50216. /**
  50217. * Defines the BRDF parameters for the material.
  50218. */
  50219. readonly brdf: PBRBRDFConfiguration;
  50220. /**
  50221. * Defines the Sheen parameters for the material.
  50222. */
  50223. readonly sheen: PBRSheenConfiguration;
  50224. /**
  50225. * Defines the SubSurface parameters for the material.
  50226. */
  50227. readonly subSurface: PBRSubSurfaceConfiguration;
  50228. /**
  50229. * Custom callback helping to override the default shader used in the material.
  50230. */
  50231. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50232. protected _rebuildInParallel: boolean;
  50233. /**
  50234. * Instantiates a new PBRMaterial instance.
  50235. *
  50236. * @param name The material name
  50237. * @param scene The scene the material will be use in.
  50238. */
  50239. constructor(name: string, scene: Scene);
  50240. /**
  50241. * Gets a boolean indicating that current material needs to register RTT
  50242. */
  50243. get hasRenderTargetTextures(): boolean;
  50244. /**
  50245. * Gets the name of the material class.
  50246. */
  50247. getClassName(): string;
  50248. /**
  50249. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50250. */
  50251. get useLogarithmicDepth(): boolean;
  50252. /**
  50253. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50254. */
  50255. set useLogarithmicDepth(value: boolean);
  50256. /**
  50257. * Gets the current transparency mode.
  50258. */
  50259. get transparencyMode(): Nullable<number>;
  50260. /**
  50261. * Sets the transparency mode of the material.
  50262. *
  50263. * | Value | Type | Description |
  50264. * | ----- | ----------------------------------- | ----------- |
  50265. * | 0 | OPAQUE | |
  50266. * | 1 | ALPHATEST | |
  50267. * | 2 | ALPHABLEND | |
  50268. * | 3 | ALPHATESTANDBLEND | |
  50269. *
  50270. */
  50271. set transparencyMode(value: Nullable<number>);
  50272. /**
  50273. * Returns true if alpha blending should be disabled.
  50274. */
  50275. private get _disableAlphaBlending();
  50276. /**
  50277. * Specifies whether or not this material should be rendered in alpha blend mode.
  50278. */
  50279. needAlphaBlending(): boolean;
  50280. /**
  50281. * Specifies if the mesh will require alpha blending.
  50282. * @param mesh - BJS mesh.
  50283. */
  50284. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50285. /**
  50286. * Specifies whether or not this material should be rendered in alpha test mode.
  50287. */
  50288. needAlphaTesting(): boolean;
  50289. /**
  50290. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50291. */
  50292. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50293. /**
  50294. * Gets the texture used for the alpha test.
  50295. */
  50296. getAlphaTestTexture(): Nullable<BaseTexture>;
  50297. /**
  50298. * Specifies that the submesh is ready to be used.
  50299. * @param mesh - BJS mesh.
  50300. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50301. * @param useInstances - Specifies that instances should be used.
  50302. * @returns - boolean indicating that the submesh is ready or not.
  50303. */
  50304. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50305. /**
  50306. * Specifies if the material uses metallic roughness workflow.
  50307. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50308. */
  50309. isMetallicWorkflow(): boolean;
  50310. private _prepareEffect;
  50311. private _prepareDefines;
  50312. /**
  50313. * Force shader compilation
  50314. */
  50315. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50316. /**
  50317. * Initializes the uniform buffer layout for the shader.
  50318. */
  50319. buildUniformLayout(): void;
  50320. /**
  50321. * Unbinds the material from the mesh
  50322. */
  50323. unbind(): void;
  50324. /**
  50325. * Binds the submesh data.
  50326. * @param world - The world matrix.
  50327. * @param mesh - The BJS mesh.
  50328. * @param subMesh - A submesh of the BJS mesh.
  50329. */
  50330. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50331. /**
  50332. * Returns the animatable textures.
  50333. * @returns - Array of animatable textures.
  50334. */
  50335. getAnimatables(): IAnimatable[];
  50336. /**
  50337. * Returns the texture used for reflections.
  50338. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50339. */
  50340. private _getReflectionTexture;
  50341. /**
  50342. * Returns an array of the actively used textures.
  50343. * @returns - Array of BaseTextures
  50344. */
  50345. getActiveTextures(): BaseTexture[];
  50346. /**
  50347. * Checks to see if a texture is used in the material.
  50348. * @param texture - Base texture to use.
  50349. * @returns - Boolean specifying if a texture is used in the material.
  50350. */
  50351. hasTexture(texture: BaseTexture): boolean;
  50352. /**
  50353. * Disposes the resources of the material.
  50354. * @param forceDisposeEffect - Forces the disposal of effects.
  50355. * @param forceDisposeTextures - Forces the disposal of all textures.
  50356. */
  50357. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50358. }
  50359. }
  50360. declare module BABYLON {
  50361. /**
  50362. * The Physically based material of BJS.
  50363. *
  50364. * This offers the main features of a standard PBR material.
  50365. * For more information, please refer to the documentation :
  50366. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50367. */
  50368. export class PBRMaterial extends PBRBaseMaterial {
  50369. /**
  50370. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50371. */
  50372. static readonly PBRMATERIAL_OPAQUE: number;
  50373. /**
  50374. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50375. */
  50376. static readonly PBRMATERIAL_ALPHATEST: number;
  50377. /**
  50378. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50379. */
  50380. static readonly PBRMATERIAL_ALPHABLEND: number;
  50381. /**
  50382. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50383. * They are also discarded below the alpha cutoff threshold to improve performances.
  50384. */
  50385. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50386. /**
  50387. * Defines the default value of how much AO map is occluding the analytical lights
  50388. * (point spot...).
  50389. */
  50390. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50391. /**
  50392. * Intensity of the direct lights e.g. the four lights available in your scene.
  50393. * This impacts both the direct diffuse and specular highlights.
  50394. */
  50395. directIntensity: number;
  50396. /**
  50397. * Intensity of the emissive part of the material.
  50398. * This helps controlling the emissive effect without modifying the emissive color.
  50399. */
  50400. emissiveIntensity: number;
  50401. /**
  50402. * Intensity of the environment e.g. how much the environment will light the object
  50403. * either through harmonics for rough material or through the refelction for shiny ones.
  50404. */
  50405. environmentIntensity: number;
  50406. /**
  50407. * This is a special control allowing the reduction of the specular highlights coming from the
  50408. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50409. */
  50410. specularIntensity: number;
  50411. /**
  50412. * Debug Control allowing disabling the bump map on this material.
  50413. */
  50414. disableBumpMap: boolean;
  50415. /**
  50416. * AKA Diffuse Texture in standard nomenclature.
  50417. */
  50418. albedoTexture: BaseTexture;
  50419. /**
  50420. * AKA Occlusion Texture in other nomenclature.
  50421. */
  50422. ambientTexture: BaseTexture;
  50423. /**
  50424. * AKA Occlusion Texture Intensity in other nomenclature.
  50425. */
  50426. ambientTextureStrength: number;
  50427. /**
  50428. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50429. * 1 means it completely occludes it
  50430. * 0 mean it has no impact
  50431. */
  50432. ambientTextureImpactOnAnalyticalLights: number;
  50433. /**
  50434. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  50435. */
  50436. opacityTexture: BaseTexture;
  50437. /**
  50438. * Stores the reflection values in a texture.
  50439. */
  50440. reflectionTexture: Nullable<BaseTexture>;
  50441. /**
  50442. * Stores the emissive values in a texture.
  50443. */
  50444. emissiveTexture: BaseTexture;
  50445. /**
  50446. * AKA Specular texture in other nomenclature.
  50447. */
  50448. reflectivityTexture: BaseTexture;
  50449. /**
  50450. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50451. */
  50452. metallicTexture: BaseTexture;
  50453. /**
  50454. * Specifies the metallic scalar of the metallic/roughness workflow.
  50455. * Can also be used to scale the metalness values of the metallic texture.
  50456. */
  50457. metallic: Nullable<number>;
  50458. /**
  50459. * Specifies the roughness scalar of the metallic/roughness workflow.
  50460. * Can also be used to scale the roughness values of the metallic texture.
  50461. */
  50462. roughness: Nullable<number>;
  50463. /**
  50464. * Specifies the an F0 factor to help configuring the material F0.
  50465. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50466. * to 0.5 the previously hard coded value stays the same.
  50467. * Can also be used to scale the F0 values of the metallic texture.
  50468. */
  50469. metallicF0Factor: number;
  50470. /**
  50471. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50472. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50473. * your expectation as it multiplies with the texture data.
  50474. */
  50475. useMetallicF0FactorFromMetallicTexture: boolean;
  50476. /**
  50477. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50478. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50479. */
  50480. microSurfaceTexture: BaseTexture;
  50481. /**
  50482. * Stores surface normal data used to displace a mesh in a texture.
  50483. */
  50484. bumpTexture: BaseTexture;
  50485. /**
  50486. * Stores the pre-calculated light information of a mesh in a texture.
  50487. */
  50488. lightmapTexture: BaseTexture;
  50489. /**
  50490. * Stores the refracted light information in a texture.
  50491. */
  50492. get refractionTexture(): Nullable<BaseTexture>;
  50493. set refractionTexture(value: Nullable<BaseTexture>);
  50494. /**
  50495. * The color of a material in ambient lighting.
  50496. */
  50497. ambientColor: Color3;
  50498. /**
  50499. * AKA Diffuse Color in other nomenclature.
  50500. */
  50501. albedoColor: Color3;
  50502. /**
  50503. * AKA Specular Color in other nomenclature.
  50504. */
  50505. reflectivityColor: Color3;
  50506. /**
  50507. * The color reflected from the material.
  50508. */
  50509. reflectionColor: Color3;
  50510. /**
  50511. * The color emitted from the material.
  50512. */
  50513. emissiveColor: Color3;
  50514. /**
  50515. * AKA Glossiness in other nomenclature.
  50516. */
  50517. microSurface: number;
  50518. /**
  50519. * source material index of refraction (IOR)' / 'destination material IOR.
  50520. */
  50521. get indexOfRefraction(): number;
  50522. set indexOfRefraction(value: number);
  50523. /**
  50524. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50525. */
  50526. get invertRefractionY(): boolean;
  50527. set invertRefractionY(value: boolean);
  50528. /**
  50529. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50530. * Materials half opaque for instance using refraction could benefit from this control.
  50531. */
  50532. get linkRefractionWithTransparency(): boolean;
  50533. set linkRefractionWithTransparency(value: boolean);
  50534. /**
  50535. * If true, the light map contains occlusion information instead of lighting info.
  50536. */
  50537. useLightmapAsShadowmap: boolean;
  50538. /**
  50539. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50540. */
  50541. useAlphaFromAlbedoTexture: boolean;
  50542. /**
  50543. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50544. */
  50545. forceAlphaTest: boolean;
  50546. /**
  50547. * Defines the alpha limits in alpha test mode.
  50548. */
  50549. alphaCutOff: number;
  50550. /**
  50551. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50552. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50553. */
  50554. useSpecularOverAlpha: boolean;
  50555. /**
  50556. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50557. */
  50558. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50559. /**
  50560. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50561. */
  50562. useRoughnessFromMetallicTextureAlpha: boolean;
  50563. /**
  50564. * Specifies if the metallic texture contains the roughness information in its green channel.
  50565. */
  50566. useRoughnessFromMetallicTextureGreen: boolean;
  50567. /**
  50568. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50569. */
  50570. useMetallnessFromMetallicTextureBlue: boolean;
  50571. /**
  50572. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50573. */
  50574. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50575. /**
  50576. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50577. */
  50578. useAmbientInGrayScale: boolean;
  50579. /**
  50580. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50581. * The material will try to infer what glossiness each pixel should be.
  50582. */
  50583. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50584. /**
  50585. * BJS is using an harcoded light falloff based on a manually sets up range.
  50586. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50587. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50588. */
  50589. get usePhysicalLightFalloff(): boolean;
  50590. /**
  50591. * BJS is using an harcoded light falloff based on a manually sets up range.
  50592. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50593. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50594. */
  50595. set usePhysicalLightFalloff(value: boolean);
  50596. /**
  50597. * In order to support the falloff compatibility with gltf, a special mode has been added
  50598. * to reproduce the gltf light falloff.
  50599. */
  50600. get useGLTFLightFalloff(): boolean;
  50601. /**
  50602. * In order to support the falloff compatibility with gltf, a special mode has been added
  50603. * to reproduce the gltf light falloff.
  50604. */
  50605. set useGLTFLightFalloff(value: boolean);
  50606. /**
  50607. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50608. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50609. */
  50610. useRadianceOverAlpha: boolean;
  50611. /**
  50612. * Allows using an object space normal map (instead of tangent space).
  50613. */
  50614. useObjectSpaceNormalMap: boolean;
  50615. /**
  50616. * Allows using the bump map in parallax mode.
  50617. */
  50618. useParallax: boolean;
  50619. /**
  50620. * Allows using the bump map in parallax occlusion mode.
  50621. */
  50622. useParallaxOcclusion: boolean;
  50623. /**
  50624. * Controls the scale bias of the parallax mode.
  50625. */
  50626. parallaxScaleBias: number;
  50627. /**
  50628. * If sets to true, disables all the lights affecting the material.
  50629. */
  50630. disableLighting: boolean;
  50631. /**
  50632. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50633. */
  50634. forceIrradianceInFragment: boolean;
  50635. /**
  50636. * Number of Simultaneous lights allowed on the material.
  50637. */
  50638. maxSimultaneousLights: number;
  50639. /**
  50640. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50641. */
  50642. invertNormalMapX: boolean;
  50643. /**
  50644. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50645. */
  50646. invertNormalMapY: boolean;
  50647. /**
  50648. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50649. */
  50650. twoSidedLighting: boolean;
  50651. /**
  50652. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50653. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50654. */
  50655. useAlphaFresnel: boolean;
  50656. /**
  50657. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50658. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50659. */
  50660. useLinearAlphaFresnel: boolean;
  50661. /**
  50662. * Let user defines the brdf lookup texture used for IBL.
  50663. * A default 8bit version is embedded but you could point at :
  50664. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50665. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50666. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50667. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50668. */
  50669. environmentBRDFTexture: Nullable<BaseTexture>;
  50670. /**
  50671. * Force normal to face away from face.
  50672. */
  50673. forceNormalForward: boolean;
  50674. /**
  50675. * Enables specular anti aliasing in the PBR shader.
  50676. * It will both interacts on the Geometry for analytical and IBL lighting.
  50677. * It also prefilter the roughness map based on the bump values.
  50678. */
  50679. enableSpecularAntiAliasing: boolean;
  50680. /**
  50681. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50682. * makes the reflect vector face the model (under horizon).
  50683. */
  50684. useHorizonOcclusion: boolean;
  50685. /**
  50686. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50687. * too much the area relying on ambient texture to define their ambient occlusion.
  50688. */
  50689. useRadianceOcclusion: boolean;
  50690. /**
  50691. * If set to true, no lighting calculations will be applied.
  50692. */
  50693. unlit: boolean;
  50694. /**
  50695. * Gets the image processing configuration used either in this material.
  50696. */
  50697. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  50698. /**
  50699. * Sets the Default image processing configuration used either in the this material.
  50700. *
  50701. * If sets to null, the scene one is in use.
  50702. */
  50703. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  50704. /**
  50705. * Gets wether the color curves effect is enabled.
  50706. */
  50707. get cameraColorCurvesEnabled(): boolean;
  50708. /**
  50709. * Sets wether the color curves effect is enabled.
  50710. */
  50711. set cameraColorCurvesEnabled(value: boolean);
  50712. /**
  50713. * Gets wether the color grading effect is enabled.
  50714. */
  50715. get cameraColorGradingEnabled(): boolean;
  50716. /**
  50717. * Gets wether the color grading effect is enabled.
  50718. */
  50719. set cameraColorGradingEnabled(value: boolean);
  50720. /**
  50721. * Gets wether tonemapping is enabled or not.
  50722. */
  50723. get cameraToneMappingEnabled(): boolean;
  50724. /**
  50725. * Sets wether tonemapping is enabled or not
  50726. */
  50727. set cameraToneMappingEnabled(value: boolean);
  50728. /**
  50729. * The camera exposure used on this material.
  50730. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50731. * This corresponds to a photographic exposure.
  50732. */
  50733. get cameraExposure(): number;
  50734. /**
  50735. * The camera exposure used on this material.
  50736. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50737. * This corresponds to a photographic exposure.
  50738. */
  50739. set cameraExposure(value: number);
  50740. /**
  50741. * Gets The camera contrast used on this material.
  50742. */
  50743. get cameraContrast(): number;
  50744. /**
  50745. * Sets The camera contrast used on this material.
  50746. */
  50747. set cameraContrast(value: number);
  50748. /**
  50749. * Gets the Color Grading 2D Lookup Texture.
  50750. */
  50751. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50752. /**
  50753. * Sets the Color Grading 2D Lookup Texture.
  50754. */
  50755. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50756. /**
  50757. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50758. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50759. * 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;
  50760. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50761. */
  50762. get cameraColorCurves(): Nullable<ColorCurves>;
  50763. /**
  50764. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50765. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50766. * 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;
  50767. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50768. */
  50769. set cameraColorCurves(value: Nullable<ColorCurves>);
  50770. /**
  50771. * Instantiates a new PBRMaterial instance.
  50772. *
  50773. * @param name The material name
  50774. * @param scene The scene the material will be use in.
  50775. */
  50776. constructor(name: string, scene: Scene);
  50777. /**
  50778. * Returns the name of this material class.
  50779. */
  50780. getClassName(): string;
  50781. /**
  50782. * Makes a duplicate of the current material.
  50783. * @param name - name to use for the new material.
  50784. */
  50785. clone(name: string): PBRMaterial;
  50786. /**
  50787. * Serializes this PBR Material.
  50788. * @returns - An object with the serialized material.
  50789. */
  50790. serialize(): any;
  50791. /**
  50792. * Parses a PBR Material from a serialized object.
  50793. * @param source - Serialized object.
  50794. * @param scene - BJS scene instance.
  50795. * @param rootUrl - url for the scene object
  50796. * @returns - PBRMaterial
  50797. */
  50798. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50799. }
  50800. }
  50801. declare module BABYLON {
  50802. /**
  50803. * Direct draw surface info
  50804. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50805. */
  50806. export interface DDSInfo {
  50807. /**
  50808. * Width of the texture
  50809. */
  50810. width: number;
  50811. /**
  50812. * Width of the texture
  50813. */
  50814. height: number;
  50815. /**
  50816. * Number of Mipmaps for the texture
  50817. * @see https://en.wikipedia.org/wiki/Mipmap
  50818. */
  50819. mipmapCount: number;
  50820. /**
  50821. * If the textures format is a known fourCC format
  50822. * @see https://www.fourcc.org/
  50823. */
  50824. isFourCC: boolean;
  50825. /**
  50826. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50827. */
  50828. isRGB: boolean;
  50829. /**
  50830. * If the texture is a lumincance format
  50831. */
  50832. isLuminance: boolean;
  50833. /**
  50834. * If this is a cube texture
  50835. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50836. */
  50837. isCube: boolean;
  50838. /**
  50839. * If the texture is a compressed format eg. FOURCC_DXT1
  50840. */
  50841. isCompressed: boolean;
  50842. /**
  50843. * The dxgiFormat of the texture
  50844. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50845. */
  50846. dxgiFormat: number;
  50847. /**
  50848. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50849. */
  50850. textureType: number;
  50851. /**
  50852. * Sphericle polynomial created for the dds texture
  50853. */
  50854. sphericalPolynomial?: SphericalPolynomial;
  50855. }
  50856. /**
  50857. * Class used to provide DDS decompression tools
  50858. */
  50859. export class DDSTools {
  50860. /**
  50861. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50862. */
  50863. static StoreLODInAlphaChannel: boolean;
  50864. /**
  50865. * Gets DDS information from an array buffer
  50866. * @param arrayBuffer defines the array buffer to read data from
  50867. * @returns the DDS information
  50868. */
  50869. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50870. private static _FloatView;
  50871. private static _Int32View;
  50872. private static _ToHalfFloat;
  50873. private static _FromHalfFloat;
  50874. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50875. private static _GetHalfFloatRGBAArrayBuffer;
  50876. private static _GetFloatRGBAArrayBuffer;
  50877. private static _GetFloatAsUIntRGBAArrayBuffer;
  50878. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50879. private static _GetRGBAArrayBuffer;
  50880. private static _ExtractLongWordOrder;
  50881. private static _GetRGBArrayBuffer;
  50882. private static _GetLuminanceArrayBuffer;
  50883. /**
  50884. * Uploads DDS Levels to a Babylon Texture
  50885. * @hidden
  50886. */
  50887. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50888. }
  50889. interface ThinEngine {
  50890. /**
  50891. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50892. * @param rootUrl defines the url where the file to load is located
  50893. * @param scene defines the current scene
  50894. * @param lodScale defines scale to apply to the mip map selection
  50895. * @param lodOffset defines offset to apply to the mip map selection
  50896. * @param onLoad defines an optional callback raised when the texture is loaded
  50897. * @param onError defines an optional callback raised if there is an issue to load the texture
  50898. * @param format defines the format of the data
  50899. * @param forcedExtension defines the extension to use to pick the right loader
  50900. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50901. * @returns the cube texture as an InternalTexture
  50902. */
  50903. 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;
  50904. }
  50905. }
  50906. declare module BABYLON {
  50907. /**
  50908. * Implementation of the DDS Texture Loader.
  50909. * @hidden
  50910. */
  50911. export class _DDSTextureLoader implements IInternalTextureLoader {
  50912. /**
  50913. * Defines wether the loader supports cascade loading the different faces.
  50914. */
  50915. readonly supportCascades: boolean;
  50916. /**
  50917. * This returns if the loader support the current file information.
  50918. * @param extension defines the file extension of the file being loaded
  50919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50920. * @param fallback defines the fallback internal texture if any
  50921. * @param isBase64 defines whether the texture is encoded as a base64
  50922. * @param isBuffer defines whether the texture data are stored as a buffer
  50923. * @returns true if the loader can load the specified file
  50924. */
  50925. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50926. /**
  50927. * Transform the url before loading if required.
  50928. * @param rootUrl the url of the texture
  50929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50930. * @returns the transformed texture
  50931. */
  50932. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50933. /**
  50934. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50935. * @param rootUrl the url of the texture
  50936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50937. * @returns the fallback texture
  50938. */
  50939. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50940. /**
  50941. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50942. * @param data contains the texture data
  50943. * @param texture defines the BabylonJS internal texture
  50944. * @param createPolynomials will be true if polynomials have been requested
  50945. * @param onLoad defines the callback to trigger once the texture is ready
  50946. * @param onError defines the callback to trigger in case of error
  50947. */
  50948. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50949. /**
  50950. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50951. * @param data contains the texture data
  50952. * @param texture defines the BabylonJS internal texture
  50953. * @param callback defines the method to call once ready to upload
  50954. */
  50955. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50956. }
  50957. }
  50958. declare module BABYLON {
  50959. /**
  50960. * Implementation of the ENV Texture Loader.
  50961. * @hidden
  50962. */
  50963. export class _ENVTextureLoader implements IInternalTextureLoader {
  50964. /**
  50965. * Defines wether the loader supports cascade loading the different faces.
  50966. */
  50967. readonly supportCascades: boolean;
  50968. /**
  50969. * This returns if the loader support the current file information.
  50970. * @param extension defines the file extension of the file being loaded
  50971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50972. * @param fallback defines the fallback internal texture if any
  50973. * @param isBase64 defines whether the texture is encoded as a base64
  50974. * @param isBuffer defines whether the texture data are stored as a buffer
  50975. * @returns true if the loader can load the specified file
  50976. */
  50977. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50978. /**
  50979. * Transform the url before loading if required.
  50980. * @param rootUrl the url of the texture
  50981. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50982. * @returns the transformed texture
  50983. */
  50984. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50985. /**
  50986. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50987. * @param rootUrl the url of the texture
  50988. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50989. * @returns the fallback texture
  50990. */
  50991. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50992. /**
  50993. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50994. * @param data contains the texture data
  50995. * @param texture defines the BabylonJS internal texture
  50996. * @param createPolynomials will be true if polynomials have been requested
  50997. * @param onLoad defines the callback to trigger once the texture is ready
  50998. * @param onError defines the callback to trigger in case of error
  50999. */
  51000. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51001. /**
  51002. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51003. * @param data contains the texture data
  51004. * @param texture defines the BabylonJS internal texture
  51005. * @param callback defines the method to call once ready to upload
  51006. */
  51007. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51008. }
  51009. }
  51010. declare module BABYLON {
  51011. /**
  51012. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51013. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51014. */
  51015. export class KhronosTextureContainer {
  51016. /** contents of the KTX container file */
  51017. arrayBuffer: any;
  51018. private static HEADER_LEN;
  51019. private static COMPRESSED_2D;
  51020. private static COMPRESSED_3D;
  51021. private static TEX_2D;
  51022. private static TEX_3D;
  51023. /**
  51024. * Gets the openGL type
  51025. */
  51026. glType: number;
  51027. /**
  51028. * Gets the openGL type size
  51029. */
  51030. glTypeSize: number;
  51031. /**
  51032. * Gets the openGL format
  51033. */
  51034. glFormat: number;
  51035. /**
  51036. * Gets the openGL internal format
  51037. */
  51038. glInternalFormat: number;
  51039. /**
  51040. * Gets the base internal format
  51041. */
  51042. glBaseInternalFormat: number;
  51043. /**
  51044. * Gets image width in pixel
  51045. */
  51046. pixelWidth: number;
  51047. /**
  51048. * Gets image height in pixel
  51049. */
  51050. pixelHeight: number;
  51051. /**
  51052. * Gets image depth in pixels
  51053. */
  51054. pixelDepth: number;
  51055. /**
  51056. * Gets the number of array elements
  51057. */
  51058. numberOfArrayElements: number;
  51059. /**
  51060. * Gets the number of faces
  51061. */
  51062. numberOfFaces: number;
  51063. /**
  51064. * Gets the number of mipmap levels
  51065. */
  51066. numberOfMipmapLevels: number;
  51067. /**
  51068. * Gets the bytes of key value data
  51069. */
  51070. bytesOfKeyValueData: number;
  51071. /**
  51072. * Gets the load type
  51073. */
  51074. loadType: number;
  51075. /**
  51076. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51077. */
  51078. isInvalid: boolean;
  51079. /**
  51080. * Creates a new KhronosTextureContainer
  51081. * @param arrayBuffer contents of the KTX container file
  51082. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51083. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51084. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51085. */
  51086. constructor(
  51087. /** contents of the KTX container file */
  51088. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51089. /**
  51090. * Uploads KTX content to a Babylon Texture.
  51091. * It is assumed that the texture has already been created & is currently bound
  51092. * @hidden
  51093. */
  51094. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51095. private _upload2DCompressedLevels;
  51096. }
  51097. }
  51098. declare module BABYLON {
  51099. /**
  51100. * Implementation of the KTX Texture Loader.
  51101. * @hidden
  51102. */
  51103. export class _KTXTextureLoader implements IInternalTextureLoader {
  51104. /**
  51105. * Defines wether the loader supports cascade loading the different faces.
  51106. */
  51107. readonly supportCascades: boolean;
  51108. /**
  51109. * This returns if the loader support the current file information.
  51110. * @param extension defines the file extension of the file being loaded
  51111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51112. * @param fallback defines the fallback internal texture if any
  51113. * @param isBase64 defines whether the texture is encoded as a base64
  51114. * @param isBuffer defines whether the texture data are stored as a buffer
  51115. * @returns true if the loader can load the specified file
  51116. */
  51117. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51118. /**
  51119. * Transform the url before loading if required.
  51120. * @param rootUrl the url of the texture
  51121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51122. * @returns the transformed texture
  51123. */
  51124. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51125. /**
  51126. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51127. * @param rootUrl the url of the texture
  51128. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51129. * @returns the fallback texture
  51130. */
  51131. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51132. /**
  51133. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51134. * @param data contains the texture data
  51135. * @param texture defines the BabylonJS internal texture
  51136. * @param createPolynomials will be true if polynomials have been requested
  51137. * @param onLoad defines the callback to trigger once the texture is ready
  51138. * @param onError defines the callback to trigger in case of error
  51139. */
  51140. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51141. /**
  51142. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51143. * @param data contains the texture data
  51144. * @param texture defines the BabylonJS internal texture
  51145. * @param callback defines the method to call once ready to upload
  51146. */
  51147. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51148. }
  51149. }
  51150. declare module BABYLON {
  51151. /** @hidden */
  51152. export var _forceSceneHelpersToBundle: boolean;
  51153. interface Scene {
  51154. /**
  51155. * Creates a default light for the scene.
  51156. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51157. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51158. */
  51159. createDefaultLight(replace?: boolean): void;
  51160. /**
  51161. * Creates a default camera for the scene.
  51162. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51163. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51164. * @param replace has default false, when true replaces the active camera in the scene
  51165. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51166. */
  51167. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51168. /**
  51169. * Creates a default camera and a default light.
  51170. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51171. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51172. * @param replace has the default false, when true replaces the active camera/light in the scene
  51173. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51174. */
  51175. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51176. /**
  51177. * Creates a new sky box
  51178. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51179. * @param environmentTexture defines the texture to use as environment texture
  51180. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51181. * @param scale defines the overall scale of the skybox
  51182. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51183. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51184. * @returns a new mesh holding the sky box
  51185. */
  51186. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51187. /**
  51188. * Creates a new environment
  51189. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51190. * @param options defines the options you can use to configure the environment
  51191. * @returns the new EnvironmentHelper
  51192. */
  51193. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51194. /**
  51195. * Creates a new VREXperienceHelper
  51196. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51197. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51198. * @returns a new VREXperienceHelper
  51199. */
  51200. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51201. /**
  51202. * Creates a new WebXRDefaultExperience
  51203. * @see http://doc.babylonjs.com/how_to/webxr
  51204. * @param options experience options
  51205. * @returns a promise for a new WebXRDefaultExperience
  51206. */
  51207. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51208. }
  51209. }
  51210. declare module BABYLON {
  51211. /**
  51212. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51213. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51214. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51215. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51216. */
  51217. export class VideoDome extends TransformNode {
  51218. /**
  51219. * Define the video source as a Monoscopic panoramic 360 video.
  51220. */
  51221. static readonly MODE_MONOSCOPIC: number;
  51222. /**
  51223. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51224. */
  51225. static readonly MODE_TOPBOTTOM: number;
  51226. /**
  51227. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51228. */
  51229. static readonly MODE_SIDEBYSIDE: number;
  51230. private _halfDome;
  51231. private _useDirectMapping;
  51232. /**
  51233. * The video texture being displayed on the sphere
  51234. */
  51235. protected _videoTexture: VideoTexture;
  51236. /**
  51237. * Gets the video texture being displayed on the sphere
  51238. */
  51239. get videoTexture(): VideoTexture;
  51240. /**
  51241. * The skybox material
  51242. */
  51243. protected _material: BackgroundMaterial;
  51244. /**
  51245. * The surface used for the skybox
  51246. */
  51247. protected _mesh: Mesh;
  51248. /**
  51249. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51250. */
  51251. private _halfDomeMask;
  51252. /**
  51253. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51254. * Also see the options.resolution property.
  51255. */
  51256. get fovMultiplier(): number;
  51257. set fovMultiplier(value: number);
  51258. private _videoMode;
  51259. /**
  51260. * Gets or set the current video mode for the video. It can be:
  51261. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51262. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51263. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51264. */
  51265. get videoMode(): number;
  51266. set videoMode(value: number);
  51267. /**
  51268. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51269. *
  51270. */
  51271. get halfDome(): boolean;
  51272. /**
  51273. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51274. */
  51275. set halfDome(enabled: boolean);
  51276. /**
  51277. * Oberserver used in Stereoscopic VR Mode.
  51278. */
  51279. private _onBeforeCameraRenderObserver;
  51280. /**
  51281. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51282. * @param name Element's name, child elements will append suffixes for their own names.
  51283. * @param urlsOrVideo defines the url(s) or the video element to use
  51284. * @param options An object containing optional or exposed sub element properties
  51285. */
  51286. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51287. resolution?: number;
  51288. clickToPlay?: boolean;
  51289. autoPlay?: boolean;
  51290. loop?: boolean;
  51291. size?: number;
  51292. poster?: string;
  51293. faceForward?: boolean;
  51294. useDirectMapping?: boolean;
  51295. halfDomeMode?: boolean;
  51296. }, scene: Scene);
  51297. private _changeVideoMode;
  51298. /**
  51299. * Releases resources associated with this node.
  51300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51302. */
  51303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51304. }
  51305. }
  51306. declare module BABYLON {
  51307. /**
  51308. * This class can be used to get instrumentation data from a Babylon engine
  51309. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51310. */
  51311. export class EngineInstrumentation implements IDisposable {
  51312. /**
  51313. * Define the instrumented engine.
  51314. */
  51315. engine: Engine;
  51316. private _captureGPUFrameTime;
  51317. private _gpuFrameTimeToken;
  51318. private _gpuFrameTime;
  51319. private _captureShaderCompilationTime;
  51320. private _shaderCompilationTime;
  51321. private _onBeginFrameObserver;
  51322. private _onEndFrameObserver;
  51323. private _onBeforeShaderCompilationObserver;
  51324. private _onAfterShaderCompilationObserver;
  51325. /**
  51326. * Gets the perf counter used for GPU frame time
  51327. */
  51328. get gpuFrameTimeCounter(): PerfCounter;
  51329. /**
  51330. * Gets the GPU frame time capture status
  51331. */
  51332. get captureGPUFrameTime(): boolean;
  51333. /**
  51334. * Enable or disable the GPU frame time capture
  51335. */
  51336. set captureGPUFrameTime(value: boolean);
  51337. /**
  51338. * Gets the perf counter used for shader compilation time
  51339. */
  51340. get shaderCompilationTimeCounter(): PerfCounter;
  51341. /**
  51342. * Gets the shader compilation time capture status
  51343. */
  51344. get captureShaderCompilationTime(): boolean;
  51345. /**
  51346. * Enable or disable the shader compilation time capture
  51347. */
  51348. set captureShaderCompilationTime(value: boolean);
  51349. /**
  51350. * Instantiates a new engine instrumentation.
  51351. * This class can be used to get instrumentation data from a Babylon engine
  51352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51353. * @param engine Defines the engine to instrument
  51354. */
  51355. constructor(
  51356. /**
  51357. * Define the instrumented engine.
  51358. */
  51359. engine: Engine);
  51360. /**
  51361. * Dispose and release associated resources.
  51362. */
  51363. dispose(): void;
  51364. }
  51365. }
  51366. declare module BABYLON {
  51367. /**
  51368. * This class can be used to get instrumentation data from a Babylon engine
  51369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51370. */
  51371. export class SceneInstrumentation implements IDisposable {
  51372. /**
  51373. * Defines the scene to instrument
  51374. */
  51375. scene: Scene;
  51376. private _captureActiveMeshesEvaluationTime;
  51377. private _activeMeshesEvaluationTime;
  51378. private _captureRenderTargetsRenderTime;
  51379. private _renderTargetsRenderTime;
  51380. private _captureFrameTime;
  51381. private _frameTime;
  51382. private _captureRenderTime;
  51383. private _renderTime;
  51384. private _captureInterFrameTime;
  51385. private _interFrameTime;
  51386. private _captureParticlesRenderTime;
  51387. private _particlesRenderTime;
  51388. private _captureSpritesRenderTime;
  51389. private _spritesRenderTime;
  51390. private _capturePhysicsTime;
  51391. private _physicsTime;
  51392. private _captureAnimationsTime;
  51393. private _animationsTime;
  51394. private _captureCameraRenderTime;
  51395. private _cameraRenderTime;
  51396. private _onBeforeActiveMeshesEvaluationObserver;
  51397. private _onAfterActiveMeshesEvaluationObserver;
  51398. private _onBeforeRenderTargetsRenderObserver;
  51399. private _onAfterRenderTargetsRenderObserver;
  51400. private _onAfterRenderObserver;
  51401. private _onBeforeDrawPhaseObserver;
  51402. private _onAfterDrawPhaseObserver;
  51403. private _onBeforeAnimationsObserver;
  51404. private _onBeforeParticlesRenderingObserver;
  51405. private _onAfterParticlesRenderingObserver;
  51406. private _onBeforeSpritesRenderingObserver;
  51407. private _onAfterSpritesRenderingObserver;
  51408. private _onBeforePhysicsObserver;
  51409. private _onAfterPhysicsObserver;
  51410. private _onAfterAnimationsObserver;
  51411. private _onBeforeCameraRenderObserver;
  51412. private _onAfterCameraRenderObserver;
  51413. /**
  51414. * Gets the perf counter used for active meshes evaluation time
  51415. */
  51416. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  51417. /**
  51418. * Gets the active meshes evaluation time capture status
  51419. */
  51420. get captureActiveMeshesEvaluationTime(): boolean;
  51421. /**
  51422. * Enable or disable the active meshes evaluation time capture
  51423. */
  51424. set captureActiveMeshesEvaluationTime(value: boolean);
  51425. /**
  51426. * Gets the perf counter used for render targets render time
  51427. */
  51428. get renderTargetsRenderTimeCounter(): PerfCounter;
  51429. /**
  51430. * Gets the render targets render time capture status
  51431. */
  51432. get captureRenderTargetsRenderTime(): boolean;
  51433. /**
  51434. * Enable or disable the render targets render time capture
  51435. */
  51436. set captureRenderTargetsRenderTime(value: boolean);
  51437. /**
  51438. * Gets the perf counter used for particles render time
  51439. */
  51440. get particlesRenderTimeCounter(): PerfCounter;
  51441. /**
  51442. * Gets the particles render time capture status
  51443. */
  51444. get captureParticlesRenderTime(): boolean;
  51445. /**
  51446. * Enable or disable the particles render time capture
  51447. */
  51448. set captureParticlesRenderTime(value: boolean);
  51449. /**
  51450. * Gets the perf counter used for sprites render time
  51451. */
  51452. get spritesRenderTimeCounter(): PerfCounter;
  51453. /**
  51454. * Gets the sprites render time capture status
  51455. */
  51456. get captureSpritesRenderTime(): boolean;
  51457. /**
  51458. * Enable or disable the sprites render time capture
  51459. */
  51460. set captureSpritesRenderTime(value: boolean);
  51461. /**
  51462. * Gets the perf counter used for physics time
  51463. */
  51464. get physicsTimeCounter(): PerfCounter;
  51465. /**
  51466. * Gets the physics time capture status
  51467. */
  51468. get capturePhysicsTime(): boolean;
  51469. /**
  51470. * Enable or disable the physics time capture
  51471. */
  51472. set capturePhysicsTime(value: boolean);
  51473. /**
  51474. * Gets the perf counter used for animations time
  51475. */
  51476. get animationsTimeCounter(): PerfCounter;
  51477. /**
  51478. * Gets the animations time capture status
  51479. */
  51480. get captureAnimationsTime(): boolean;
  51481. /**
  51482. * Enable or disable the animations time capture
  51483. */
  51484. set captureAnimationsTime(value: boolean);
  51485. /**
  51486. * Gets the perf counter used for frame time capture
  51487. */
  51488. get frameTimeCounter(): PerfCounter;
  51489. /**
  51490. * Gets the frame time capture status
  51491. */
  51492. get captureFrameTime(): boolean;
  51493. /**
  51494. * Enable or disable the frame time capture
  51495. */
  51496. set captureFrameTime(value: boolean);
  51497. /**
  51498. * Gets the perf counter used for inter-frames time capture
  51499. */
  51500. get interFrameTimeCounter(): PerfCounter;
  51501. /**
  51502. * Gets the inter-frames time capture status
  51503. */
  51504. get captureInterFrameTime(): boolean;
  51505. /**
  51506. * Enable or disable the inter-frames time capture
  51507. */
  51508. set captureInterFrameTime(value: boolean);
  51509. /**
  51510. * Gets the perf counter used for render time capture
  51511. */
  51512. get renderTimeCounter(): PerfCounter;
  51513. /**
  51514. * Gets the render time capture status
  51515. */
  51516. get captureRenderTime(): boolean;
  51517. /**
  51518. * Enable or disable the render time capture
  51519. */
  51520. set captureRenderTime(value: boolean);
  51521. /**
  51522. * Gets the perf counter used for camera render time capture
  51523. */
  51524. get cameraRenderTimeCounter(): PerfCounter;
  51525. /**
  51526. * Gets the camera render time capture status
  51527. */
  51528. get captureCameraRenderTime(): boolean;
  51529. /**
  51530. * Enable or disable the camera render time capture
  51531. */
  51532. set captureCameraRenderTime(value: boolean);
  51533. /**
  51534. * Gets the perf counter used for draw calls
  51535. */
  51536. get drawCallsCounter(): PerfCounter;
  51537. /**
  51538. * Instantiates a new scene instrumentation.
  51539. * This class can be used to get instrumentation data from a Babylon engine
  51540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51541. * @param scene Defines the scene to instrument
  51542. */
  51543. constructor(
  51544. /**
  51545. * Defines the scene to instrument
  51546. */
  51547. scene: Scene);
  51548. /**
  51549. * Dispose and release associated resources.
  51550. */
  51551. dispose(): void;
  51552. }
  51553. }
  51554. declare module BABYLON {
  51555. /** @hidden */
  51556. export var glowMapGenerationPixelShader: {
  51557. name: string;
  51558. shader: string;
  51559. };
  51560. }
  51561. declare module BABYLON {
  51562. /** @hidden */
  51563. export var glowMapGenerationVertexShader: {
  51564. name: string;
  51565. shader: string;
  51566. };
  51567. }
  51568. declare module BABYLON {
  51569. /**
  51570. * Effect layer options. This helps customizing the behaviour
  51571. * of the effect layer.
  51572. */
  51573. export interface IEffectLayerOptions {
  51574. /**
  51575. * Multiplication factor apply to the canvas size to compute the render target size
  51576. * used to generated the objects (the smaller the faster).
  51577. */
  51578. mainTextureRatio: number;
  51579. /**
  51580. * Enforces a fixed size texture to ensure effect stability across devices.
  51581. */
  51582. mainTextureFixedSize?: number;
  51583. /**
  51584. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51585. */
  51586. alphaBlendingMode: number;
  51587. /**
  51588. * The camera attached to the layer.
  51589. */
  51590. camera: Nullable<Camera>;
  51591. /**
  51592. * The rendering group to draw the layer in.
  51593. */
  51594. renderingGroupId: number;
  51595. }
  51596. /**
  51597. * The effect layer Helps adding post process effect blended with the main pass.
  51598. *
  51599. * This can be for instance use to generate glow or higlight effects on the scene.
  51600. *
  51601. * The effect layer class can not be used directly and is intented to inherited from to be
  51602. * customized per effects.
  51603. */
  51604. export abstract class EffectLayer {
  51605. private _vertexBuffers;
  51606. private _indexBuffer;
  51607. private _cachedDefines;
  51608. private _effectLayerMapGenerationEffect;
  51609. private _effectLayerOptions;
  51610. private _mergeEffect;
  51611. protected _scene: Scene;
  51612. protected _engine: Engine;
  51613. protected _maxSize: number;
  51614. protected _mainTextureDesiredSize: ISize;
  51615. protected _mainTexture: RenderTargetTexture;
  51616. protected _shouldRender: boolean;
  51617. protected _postProcesses: PostProcess[];
  51618. protected _textures: BaseTexture[];
  51619. protected _emissiveTextureAndColor: {
  51620. texture: Nullable<BaseTexture>;
  51621. color: Color4;
  51622. };
  51623. /**
  51624. * The name of the layer
  51625. */
  51626. name: string;
  51627. /**
  51628. * The clear color of the texture used to generate the glow map.
  51629. */
  51630. neutralColor: Color4;
  51631. /**
  51632. * Specifies wether the highlight layer is enabled or not.
  51633. */
  51634. isEnabled: boolean;
  51635. /**
  51636. * Gets the camera attached to the layer.
  51637. */
  51638. get camera(): Nullable<Camera>;
  51639. /**
  51640. * Gets the rendering group id the layer should render in.
  51641. */
  51642. get renderingGroupId(): number;
  51643. set renderingGroupId(renderingGroupId: number);
  51644. /**
  51645. * An event triggered when the effect layer has been disposed.
  51646. */
  51647. onDisposeObservable: Observable<EffectLayer>;
  51648. /**
  51649. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51650. */
  51651. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51652. /**
  51653. * An event triggered when the generated texture is being merged in the scene.
  51654. */
  51655. onBeforeComposeObservable: Observable<EffectLayer>;
  51656. /**
  51657. * An event triggered when the mesh is rendered into the effect render target.
  51658. */
  51659. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51660. /**
  51661. * An event triggered after the mesh has been rendered into the effect render target.
  51662. */
  51663. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51664. /**
  51665. * An event triggered when the generated texture has been merged in the scene.
  51666. */
  51667. onAfterComposeObservable: Observable<EffectLayer>;
  51668. /**
  51669. * An event triggered when the efffect layer changes its size.
  51670. */
  51671. onSizeChangedObservable: Observable<EffectLayer>;
  51672. /** @hidden */
  51673. static _SceneComponentInitialization: (scene: Scene) => void;
  51674. /**
  51675. * Instantiates a new effect Layer and references it in the scene.
  51676. * @param name The name of the layer
  51677. * @param scene The scene to use the layer in
  51678. */
  51679. constructor(
  51680. /** The Friendly of the effect in the scene */
  51681. name: string, scene: Scene);
  51682. /**
  51683. * Get the effect name of the layer.
  51684. * @return The effect name
  51685. */
  51686. abstract getEffectName(): string;
  51687. /**
  51688. * Checks for the readiness of the element composing the layer.
  51689. * @param subMesh the mesh to check for
  51690. * @param useInstances specify wether or not to use instances to render the mesh
  51691. * @return true if ready otherwise, false
  51692. */
  51693. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51694. /**
  51695. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51696. * @returns true if the effect requires stencil during the main canvas render pass.
  51697. */
  51698. abstract needStencil(): boolean;
  51699. /**
  51700. * Create the merge effect. This is the shader use to blit the information back
  51701. * to the main canvas at the end of the scene rendering.
  51702. * @returns The effect containing the shader used to merge the effect on the main canvas
  51703. */
  51704. protected abstract _createMergeEffect(): Effect;
  51705. /**
  51706. * Creates the render target textures and post processes used in the effect layer.
  51707. */
  51708. protected abstract _createTextureAndPostProcesses(): void;
  51709. /**
  51710. * Implementation specific of rendering the generating effect on the main canvas.
  51711. * @param effect The effect used to render through
  51712. */
  51713. protected abstract _internalRender(effect: Effect): void;
  51714. /**
  51715. * Sets the required values for both the emissive texture and and the main color.
  51716. */
  51717. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51718. /**
  51719. * Free any resources and references associated to a mesh.
  51720. * Internal use
  51721. * @param mesh The mesh to free.
  51722. */
  51723. abstract _disposeMesh(mesh: Mesh): void;
  51724. /**
  51725. * Serializes this layer (Glow or Highlight for example)
  51726. * @returns a serialized layer object
  51727. */
  51728. abstract serialize?(): any;
  51729. /**
  51730. * Initializes the effect layer with the required options.
  51731. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51732. */
  51733. protected _init(options: Partial<IEffectLayerOptions>): void;
  51734. /**
  51735. * Generates the index buffer of the full screen quad blending to the main canvas.
  51736. */
  51737. private _generateIndexBuffer;
  51738. /**
  51739. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51740. */
  51741. private _generateVertexBuffer;
  51742. /**
  51743. * Sets the main texture desired size which is the closest power of two
  51744. * of the engine canvas size.
  51745. */
  51746. private _setMainTextureSize;
  51747. /**
  51748. * Creates the main texture for the effect layer.
  51749. */
  51750. protected _createMainTexture(): void;
  51751. /**
  51752. * Adds specific effects defines.
  51753. * @param defines The defines to add specifics to.
  51754. */
  51755. protected _addCustomEffectDefines(defines: string[]): void;
  51756. /**
  51757. * Checks for the readiness of the element composing the layer.
  51758. * @param subMesh the mesh to check for
  51759. * @param useInstances specify wether or not to use instances to render the mesh
  51760. * @param emissiveTexture the associated emissive texture used to generate the glow
  51761. * @return true if ready otherwise, false
  51762. */
  51763. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51764. /**
  51765. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51766. */
  51767. render(): void;
  51768. /**
  51769. * Determine if a given mesh will be used in the current effect.
  51770. * @param mesh mesh to test
  51771. * @returns true if the mesh will be used
  51772. */
  51773. hasMesh(mesh: AbstractMesh): boolean;
  51774. /**
  51775. * Returns true if the layer contains information to display, otherwise false.
  51776. * @returns true if the glow layer should be rendered
  51777. */
  51778. shouldRender(): boolean;
  51779. /**
  51780. * Returns true if the mesh should render, otherwise false.
  51781. * @param mesh The mesh to render
  51782. * @returns true if it should render otherwise false
  51783. */
  51784. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51785. /**
  51786. * Returns true if the mesh can be rendered, otherwise false.
  51787. * @param mesh The mesh to render
  51788. * @param material The material used on the mesh
  51789. * @returns true if it can be rendered otherwise false
  51790. */
  51791. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51792. /**
  51793. * Returns true if the mesh should render, otherwise false.
  51794. * @param mesh The mesh to render
  51795. * @returns true if it should render otherwise false
  51796. */
  51797. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51798. /**
  51799. * Renders the submesh passed in parameter to the generation map.
  51800. */
  51801. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51802. /**
  51803. * Defines wether the current material of the mesh should be use to render the effect.
  51804. * @param mesh defines the current mesh to render
  51805. */
  51806. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51807. /**
  51808. * Rebuild the required buffers.
  51809. * @hidden Internal use only.
  51810. */
  51811. _rebuild(): void;
  51812. /**
  51813. * Dispose only the render target textures and post process.
  51814. */
  51815. private _disposeTextureAndPostProcesses;
  51816. /**
  51817. * Dispose the highlight layer and free resources.
  51818. */
  51819. dispose(): void;
  51820. /**
  51821. * Gets the class name of the effect layer
  51822. * @returns the string with the class name of the effect layer
  51823. */
  51824. getClassName(): string;
  51825. /**
  51826. * Creates an effect layer from parsed effect layer data
  51827. * @param parsedEffectLayer defines effect layer data
  51828. * @param scene defines the current scene
  51829. * @param rootUrl defines the root URL containing the effect layer information
  51830. * @returns a parsed effect Layer
  51831. */
  51832. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51833. }
  51834. }
  51835. declare module BABYLON {
  51836. interface AbstractScene {
  51837. /**
  51838. * The list of effect layers (highlights/glow) added to the scene
  51839. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51840. * @see http://doc.babylonjs.com/how_to/glow_layer
  51841. */
  51842. effectLayers: Array<EffectLayer>;
  51843. /**
  51844. * Removes the given effect layer from this scene.
  51845. * @param toRemove defines the effect layer to remove
  51846. * @returns the index of the removed effect layer
  51847. */
  51848. removeEffectLayer(toRemove: EffectLayer): number;
  51849. /**
  51850. * Adds the given effect layer to this scene
  51851. * @param newEffectLayer defines the effect layer to add
  51852. */
  51853. addEffectLayer(newEffectLayer: EffectLayer): void;
  51854. }
  51855. /**
  51856. * Defines the layer scene component responsible to manage any effect layers
  51857. * in a given scene.
  51858. */
  51859. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51860. /**
  51861. * The component name helpfull to identify the component in the list of scene components.
  51862. */
  51863. readonly name: string;
  51864. /**
  51865. * The scene the component belongs to.
  51866. */
  51867. scene: Scene;
  51868. private _engine;
  51869. private _renderEffects;
  51870. private _needStencil;
  51871. private _previousStencilState;
  51872. /**
  51873. * Creates a new instance of the component for the given scene
  51874. * @param scene Defines the scene to register the component in
  51875. */
  51876. constructor(scene: Scene);
  51877. /**
  51878. * Registers the component in a given scene
  51879. */
  51880. register(): void;
  51881. /**
  51882. * Rebuilds the elements related to this component in case of
  51883. * context lost for instance.
  51884. */
  51885. rebuild(): void;
  51886. /**
  51887. * Serializes the component data to the specified json object
  51888. * @param serializationObject The object to serialize to
  51889. */
  51890. serialize(serializationObject: any): void;
  51891. /**
  51892. * Adds all the elements from the container to the scene
  51893. * @param container the container holding the elements
  51894. */
  51895. addFromContainer(container: AbstractScene): void;
  51896. /**
  51897. * Removes all the elements in the container from the scene
  51898. * @param container contains the elements to remove
  51899. * @param dispose if the removed element should be disposed (default: false)
  51900. */
  51901. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51902. /**
  51903. * Disposes the component and the associated ressources.
  51904. */
  51905. dispose(): void;
  51906. private _isReadyForMesh;
  51907. private _renderMainTexture;
  51908. private _setStencil;
  51909. private _setStencilBack;
  51910. private _draw;
  51911. private _drawCamera;
  51912. private _drawRenderingGroup;
  51913. }
  51914. }
  51915. declare module BABYLON {
  51916. /** @hidden */
  51917. export var glowMapMergePixelShader: {
  51918. name: string;
  51919. shader: string;
  51920. };
  51921. }
  51922. declare module BABYLON {
  51923. /** @hidden */
  51924. export var glowMapMergeVertexShader: {
  51925. name: string;
  51926. shader: string;
  51927. };
  51928. }
  51929. declare module BABYLON {
  51930. interface AbstractScene {
  51931. /**
  51932. * Return a the first highlight layer of the scene with a given name.
  51933. * @param name The name of the highlight layer to look for.
  51934. * @return The highlight layer if found otherwise null.
  51935. */
  51936. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51937. }
  51938. /**
  51939. * Glow layer options. This helps customizing the behaviour
  51940. * of the glow layer.
  51941. */
  51942. export interface IGlowLayerOptions {
  51943. /**
  51944. * Multiplication factor apply to the canvas size to compute the render target size
  51945. * used to generated the glowing objects (the smaller the faster).
  51946. */
  51947. mainTextureRatio: number;
  51948. /**
  51949. * Enforces a fixed size texture to ensure resize independant blur.
  51950. */
  51951. mainTextureFixedSize?: number;
  51952. /**
  51953. * How big is the kernel of the blur texture.
  51954. */
  51955. blurKernelSize: number;
  51956. /**
  51957. * The camera attached to the layer.
  51958. */
  51959. camera: Nullable<Camera>;
  51960. /**
  51961. * Enable MSAA by chosing the number of samples.
  51962. */
  51963. mainTextureSamples?: number;
  51964. /**
  51965. * The rendering group to draw the layer in.
  51966. */
  51967. renderingGroupId: number;
  51968. }
  51969. /**
  51970. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51971. *
  51972. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  51973. *
  51974. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51975. */
  51976. export class GlowLayer extends EffectLayer {
  51977. /**
  51978. * Effect Name of the layer.
  51979. */
  51980. static readonly EffectName: string;
  51981. /**
  51982. * The default blur kernel size used for the glow.
  51983. */
  51984. static DefaultBlurKernelSize: number;
  51985. /**
  51986. * The default texture size ratio used for the glow.
  51987. */
  51988. static DefaultTextureRatio: number;
  51989. /**
  51990. * Sets the kernel size of the blur.
  51991. */
  51992. set blurKernelSize(value: number);
  51993. /**
  51994. * Gets the kernel size of the blur.
  51995. */
  51996. get blurKernelSize(): number;
  51997. /**
  51998. * Sets the glow intensity.
  51999. */
  52000. set intensity(value: number);
  52001. /**
  52002. * Gets the glow intensity.
  52003. */
  52004. get intensity(): number;
  52005. private _options;
  52006. private _intensity;
  52007. private _horizontalBlurPostprocess1;
  52008. private _verticalBlurPostprocess1;
  52009. private _horizontalBlurPostprocess2;
  52010. private _verticalBlurPostprocess2;
  52011. private _blurTexture1;
  52012. private _blurTexture2;
  52013. private _postProcesses1;
  52014. private _postProcesses2;
  52015. private _includedOnlyMeshes;
  52016. private _excludedMeshes;
  52017. private _meshesUsingTheirOwnMaterials;
  52018. /**
  52019. * Callback used to let the user override the color selection on a per mesh basis
  52020. */
  52021. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52022. /**
  52023. * Callback used to let the user override the texture selection on a per mesh basis
  52024. */
  52025. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52026. /**
  52027. * Instantiates a new glow Layer and references it to the scene.
  52028. * @param name The name of the layer
  52029. * @param scene The scene to use the layer in
  52030. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52031. */
  52032. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52033. /**
  52034. * Get the effect name of the layer.
  52035. * @return The effect name
  52036. */
  52037. getEffectName(): string;
  52038. /**
  52039. * Create the merge effect. This is the shader use to blit the information back
  52040. * to the main canvas at the end of the scene rendering.
  52041. */
  52042. protected _createMergeEffect(): Effect;
  52043. /**
  52044. * Creates the render target textures and post processes used in the glow layer.
  52045. */
  52046. protected _createTextureAndPostProcesses(): void;
  52047. /**
  52048. * Checks for the readiness of the element composing the layer.
  52049. * @param subMesh the mesh to check for
  52050. * @param useInstances specify wether or not to use instances to render the mesh
  52051. * @param emissiveTexture the associated emissive texture used to generate the glow
  52052. * @return true if ready otherwise, false
  52053. */
  52054. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52055. /**
  52056. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52057. */
  52058. needStencil(): boolean;
  52059. /**
  52060. * Returns true if the mesh can be rendered, otherwise false.
  52061. * @param mesh The mesh to render
  52062. * @param material The material used on the mesh
  52063. * @returns true if it can be rendered otherwise false
  52064. */
  52065. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52066. /**
  52067. * Implementation specific of rendering the generating effect on the main canvas.
  52068. * @param effect The effect used to render through
  52069. */
  52070. protected _internalRender(effect: Effect): void;
  52071. /**
  52072. * Sets the required values for both the emissive texture and and the main color.
  52073. */
  52074. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52075. /**
  52076. * Returns true if the mesh should render, otherwise false.
  52077. * @param mesh The mesh to render
  52078. * @returns true if it should render otherwise false
  52079. */
  52080. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52081. /**
  52082. * Adds specific effects defines.
  52083. * @param defines The defines to add specifics to.
  52084. */
  52085. protected _addCustomEffectDefines(defines: string[]): void;
  52086. /**
  52087. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52088. * @param mesh The mesh to exclude from the glow layer
  52089. */
  52090. addExcludedMesh(mesh: Mesh): void;
  52091. /**
  52092. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52093. * @param mesh The mesh to remove
  52094. */
  52095. removeExcludedMesh(mesh: Mesh): void;
  52096. /**
  52097. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52098. * @param mesh The mesh to include in the glow layer
  52099. */
  52100. addIncludedOnlyMesh(mesh: Mesh): void;
  52101. /**
  52102. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52103. * @param mesh The mesh to remove
  52104. */
  52105. removeIncludedOnlyMesh(mesh: Mesh): void;
  52106. /**
  52107. * Determine if a given mesh will be used in the glow layer
  52108. * @param mesh The mesh to test
  52109. * @returns true if the mesh will be highlighted by the current glow layer
  52110. */
  52111. hasMesh(mesh: AbstractMesh): boolean;
  52112. /**
  52113. * Defines wether the current material of the mesh should be use to render the effect.
  52114. * @param mesh defines the current mesh to render
  52115. */
  52116. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52117. /**
  52118. * Add a mesh to be rendered through its own material and not with emissive only.
  52119. * @param mesh The mesh for which we need to use its material
  52120. */
  52121. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52122. /**
  52123. * Remove a mesh from being rendered through its own material and not with emissive only.
  52124. * @param mesh The mesh for which we need to not use its material
  52125. */
  52126. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52127. /**
  52128. * Free any resources and references associated to a mesh.
  52129. * Internal use
  52130. * @param mesh The mesh to free.
  52131. * @hidden
  52132. */
  52133. _disposeMesh(mesh: Mesh): void;
  52134. /**
  52135. * Gets the class name of the effect layer
  52136. * @returns the string with the class name of the effect layer
  52137. */
  52138. getClassName(): string;
  52139. /**
  52140. * Serializes this glow layer
  52141. * @returns a serialized glow layer object
  52142. */
  52143. serialize(): any;
  52144. /**
  52145. * Creates a Glow Layer from parsed glow layer data
  52146. * @param parsedGlowLayer defines glow layer data
  52147. * @param scene defines the current scene
  52148. * @param rootUrl defines the root URL containing the glow layer information
  52149. * @returns a parsed Glow Layer
  52150. */
  52151. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52152. }
  52153. }
  52154. declare module BABYLON {
  52155. /** @hidden */
  52156. export var glowBlurPostProcessPixelShader: {
  52157. name: string;
  52158. shader: string;
  52159. };
  52160. }
  52161. declare module BABYLON {
  52162. interface AbstractScene {
  52163. /**
  52164. * Return a the first highlight layer of the scene with a given name.
  52165. * @param name The name of the highlight layer to look for.
  52166. * @return The highlight layer if found otherwise null.
  52167. */
  52168. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52169. }
  52170. /**
  52171. * Highlight layer options. This helps customizing the behaviour
  52172. * of the highlight layer.
  52173. */
  52174. export interface IHighlightLayerOptions {
  52175. /**
  52176. * Multiplication factor apply to the canvas size to compute the render target size
  52177. * used to generated the glowing objects (the smaller the faster).
  52178. */
  52179. mainTextureRatio: number;
  52180. /**
  52181. * Enforces a fixed size texture to ensure resize independant blur.
  52182. */
  52183. mainTextureFixedSize?: number;
  52184. /**
  52185. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52186. * of the picture to blur (the smaller the faster).
  52187. */
  52188. blurTextureSizeRatio: number;
  52189. /**
  52190. * How big in texel of the blur texture is the vertical blur.
  52191. */
  52192. blurVerticalSize: number;
  52193. /**
  52194. * How big in texel of the blur texture is the horizontal blur.
  52195. */
  52196. blurHorizontalSize: number;
  52197. /**
  52198. * Alpha blending mode used to apply the blur. Default is combine.
  52199. */
  52200. alphaBlendingMode: number;
  52201. /**
  52202. * The camera attached to the layer.
  52203. */
  52204. camera: Nullable<Camera>;
  52205. /**
  52206. * Should we display highlight as a solid stroke?
  52207. */
  52208. isStroke?: boolean;
  52209. /**
  52210. * The rendering group to draw the layer in.
  52211. */
  52212. renderingGroupId: number;
  52213. }
  52214. /**
  52215. * The highlight layer Helps adding a glow effect around a mesh.
  52216. *
  52217. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52218. * glowy meshes to your scene.
  52219. *
  52220. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52221. */
  52222. export class HighlightLayer extends EffectLayer {
  52223. name: string;
  52224. /**
  52225. * Effect Name of the highlight layer.
  52226. */
  52227. static readonly EffectName: string;
  52228. /**
  52229. * The neutral color used during the preparation of the glow effect.
  52230. * This is black by default as the blend operation is a blend operation.
  52231. */
  52232. static NeutralColor: Color4;
  52233. /**
  52234. * Stencil value used for glowing meshes.
  52235. */
  52236. static GlowingMeshStencilReference: number;
  52237. /**
  52238. * Stencil value used for the other meshes in the scene.
  52239. */
  52240. static NormalMeshStencilReference: number;
  52241. /**
  52242. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52243. */
  52244. innerGlow: boolean;
  52245. /**
  52246. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52247. */
  52248. outerGlow: boolean;
  52249. /**
  52250. * Specifies the horizontal size of the blur.
  52251. */
  52252. set blurHorizontalSize(value: number);
  52253. /**
  52254. * Specifies the vertical size of the blur.
  52255. */
  52256. set blurVerticalSize(value: number);
  52257. /**
  52258. * Gets the horizontal size of the blur.
  52259. */
  52260. get blurHorizontalSize(): number;
  52261. /**
  52262. * Gets the vertical size of the blur.
  52263. */
  52264. get blurVerticalSize(): number;
  52265. /**
  52266. * An event triggered when the highlight layer is being blurred.
  52267. */
  52268. onBeforeBlurObservable: Observable<HighlightLayer>;
  52269. /**
  52270. * An event triggered when the highlight layer has been blurred.
  52271. */
  52272. onAfterBlurObservable: Observable<HighlightLayer>;
  52273. private _instanceGlowingMeshStencilReference;
  52274. private _options;
  52275. private _downSamplePostprocess;
  52276. private _horizontalBlurPostprocess;
  52277. private _verticalBlurPostprocess;
  52278. private _blurTexture;
  52279. private _meshes;
  52280. private _excludedMeshes;
  52281. /**
  52282. * Instantiates a new highlight Layer and references it to the scene..
  52283. * @param name The name of the layer
  52284. * @param scene The scene to use the layer in
  52285. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52286. */
  52287. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52288. /**
  52289. * Get the effect name of the layer.
  52290. * @return The effect name
  52291. */
  52292. getEffectName(): string;
  52293. /**
  52294. * Create the merge effect. This is the shader use to blit the information back
  52295. * to the main canvas at the end of the scene rendering.
  52296. */
  52297. protected _createMergeEffect(): Effect;
  52298. /**
  52299. * Creates the render target textures and post processes used in the highlight layer.
  52300. */
  52301. protected _createTextureAndPostProcesses(): void;
  52302. /**
  52303. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52304. */
  52305. needStencil(): boolean;
  52306. /**
  52307. * Checks for the readiness of the element composing the layer.
  52308. * @param subMesh the mesh to check for
  52309. * @param useInstances specify wether or not to use instances to render the mesh
  52310. * @param emissiveTexture the associated emissive texture used to generate the glow
  52311. * @return true if ready otherwise, false
  52312. */
  52313. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52314. /**
  52315. * Implementation specific of rendering the generating effect on the main canvas.
  52316. * @param effect The effect used to render through
  52317. */
  52318. protected _internalRender(effect: Effect): void;
  52319. /**
  52320. * Returns true if the layer contains information to display, otherwise false.
  52321. */
  52322. shouldRender(): boolean;
  52323. /**
  52324. * Returns true if the mesh should render, otherwise false.
  52325. * @param mesh The mesh to render
  52326. * @returns true if it should render otherwise false
  52327. */
  52328. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52329. /**
  52330. * Sets the required values for both the emissive texture and and the main color.
  52331. */
  52332. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52333. /**
  52334. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52335. * @param mesh The mesh to exclude from the highlight layer
  52336. */
  52337. addExcludedMesh(mesh: Mesh): void;
  52338. /**
  52339. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52340. * @param mesh The mesh to highlight
  52341. */
  52342. removeExcludedMesh(mesh: Mesh): void;
  52343. /**
  52344. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52345. * @param mesh mesh to test
  52346. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52347. */
  52348. hasMesh(mesh: AbstractMesh): boolean;
  52349. /**
  52350. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52351. * @param mesh The mesh to highlight
  52352. * @param color The color of the highlight
  52353. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52354. */
  52355. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52356. /**
  52357. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52358. * @param mesh The mesh to highlight
  52359. */
  52360. removeMesh(mesh: Mesh): void;
  52361. /**
  52362. * Force the stencil to the normal expected value for none glowing parts
  52363. */
  52364. private _defaultStencilReference;
  52365. /**
  52366. * Free any resources and references associated to a mesh.
  52367. * Internal use
  52368. * @param mesh The mesh to free.
  52369. * @hidden
  52370. */
  52371. _disposeMesh(mesh: Mesh): void;
  52372. /**
  52373. * Dispose the highlight layer and free resources.
  52374. */
  52375. dispose(): void;
  52376. /**
  52377. * Gets the class name of the effect layer
  52378. * @returns the string with the class name of the effect layer
  52379. */
  52380. getClassName(): string;
  52381. /**
  52382. * Serializes this Highlight layer
  52383. * @returns a serialized Highlight layer object
  52384. */
  52385. serialize(): any;
  52386. /**
  52387. * Creates a Highlight layer from parsed Highlight layer data
  52388. * @param parsedHightlightLayer defines the Highlight layer data
  52389. * @param scene defines the current scene
  52390. * @param rootUrl defines the root URL containing the Highlight layer information
  52391. * @returns a parsed Highlight layer
  52392. */
  52393. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52394. }
  52395. }
  52396. declare module BABYLON {
  52397. interface AbstractScene {
  52398. /**
  52399. * The list of layers (background and foreground) of the scene
  52400. */
  52401. layers: Array<Layer>;
  52402. }
  52403. /**
  52404. * Defines the layer scene component responsible to manage any layers
  52405. * in a given scene.
  52406. */
  52407. export class LayerSceneComponent implements ISceneComponent {
  52408. /**
  52409. * The component name helpfull to identify the component in the list of scene components.
  52410. */
  52411. readonly name: string;
  52412. /**
  52413. * The scene the component belongs to.
  52414. */
  52415. scene: Scene;
  52416. private _engine;
  52417. /**
  52418. * Creates a new instance of the component for the given scene
  52419. * @param scene Defines the scene to register the component in
  52420. */
  52421. constructor(scene: Scene);
  52422. /**
  52423. * Registers the component in a given scene
  52424. */
  52425. register(): void;
  52426. /**
  52427. * Rebuilds the elements related to this component in case of
  52428. * context lost for instance.
  52429. */
  52430. rebuild(): void;
  52431. /**
  52432. * Disposes the component and the associated ressources.
  52433. */
  52434. dispose(): void;
  52435. private _draw;
  52436. private _drawCameraPredicate;
  52437. private _drawCameraBackground;
  52438. private _drawCameraForeground;
  52439. private _drawRenderTargetPredicate;
  52440. private _drawRenderTargetBackground;
  52441. private _drawRenderTargetForeground;
  52442. /**
  52443. * Adds all the elements from the container to the scene
  52444. * @param container the container holding the elements
  52445. */
  52446. addFromContainer(container: AbstractScene): void;
  52447. /**
  52448. * Removes all the elements in the container from the scene
  52449. * @param container contains the elements to remove
  52450. * @param dispose if the removed element should be disposed (default: false)
  52451. */
  52452. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52453. }
  52454. }
  52455. declare module BABYLON {
  52456. /** @hidden */
  52457. export var layerPixelShader: {
  52458. name: string;
  52459. shader: string;
  52460. };
  52461. }
  52462. declare module BABYLON {
  52463. /** @hidden */
  52464. export var layerVertexShader: {
  52465. name: string;
  52466. shader: string;
  52467. };
  52468. }
  52469. declare module BABYLON {
  52470. /**
  52471. * This represents a full screen 2d layer.
  52472. * This can be useful to display a picture in the background of your scene for instance.
  52473. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52474. */
  52475. export class Layer {
  52476. /**
  52477. * Define the name of the layer.
  52478. */
  52479. name: string;
  52480. /**
  52481. * Define the texture the layer should display.
  52482. */
  52483. texture: Nullable<Texture>;
  52484. /**
  52485. * Is the layer in background or foreground.
  52486. */
  52487. isBackground: boolean;
  52488. /**
  52489. * Define the color of the layer (instead of texture).
  52490. */
  52491. color: Color4;
  52492. /**
  52493. * Define the scale of the layer in order to zoom in out of the texture.
  52494. */
  52495. scale: Vector2;
  52496. /**
  52497. * Define an offset for the layer in order to shift the texture.
  52498. */
  52499. offset: Vector2;
  52500. /**
  52501. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52502. */
  52503. alphaBlendingMode: number;
  52504. /**
  52505. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52506. * Alpha test will not mix with the background color in case of transparency.
  52507. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52508. */
  52509. alphaTest: boolean;
  52510. /**
  52511. * Define a mask to restrict the layer to only some of the scene cameras.
  52512. */
  52513. layerMask: number;
  52514. /**
  52515. * Define the list of render target the layer is visible into.
  52516. */
  52517. renderTargetTextures: RenderTargetTexture[];
  52518. /**
  52519. * Define if the layer is only used in renderTarget or if it also
  52520. * renders in the main frame buffer of the canvas.
  52521. */
  52522. renderOnlyInRenderTargetTextures: boolean;
  52523. private _scene;
  52524. private _vertexBuffers;
  52525. private _indexBuffer;
  52526. private _effect;
  52527. private _previousDefines;
  52528. /**
  52529. * An event triggered when the layer is disposed.
  52530. */
  52531. onDisposeObservable: Observable<Layer>;
  52532. private _onDisposeObserver;
  52533. /**
  52534. * Back compatibility with callback before the onDisposeObservable existed.
  52535. * The set callback will be triggered when the layer has been disposed.
  52536. */
  52537. set onDispose(callback: () => void);
  52538. /**
  52539. * An event triggered before rendering the scene
  52540. */
  52541. onBeforeRenderObservable: Observable<Layer>;
  52542. private _onBeforeRenderObserver;
  52543. /**
  52544. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52545. * The set callback will be triggered just before rendering the layer.
  52546. */
  52547. set onBeforeRender(callback: () => void);
  52548. /**
  52549. * An event triggered after rendering the scene
  52550. */
  52551. onAfterRenderObservable: Observable<Layer>;
  52552. private _onAfterRenderObserver;
  52553. /**
  52554. * Back compatibility with callback before the onAfterRenderObservable existed.
  52555. * The set callback will be triggered just after rendering the layer.
  52556. */
  52557. set onAfterRender(callback: () => void);
  52558. /**
  52559. * Instantiates a new layer.
  52560. * This represents a full screen 2d layer.
  52561. * This can be useful to display a picture in the background of your scene for instance.
  52562. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52563. * @param name Define the name of the layer in the scene
  52564. * @param imgUrl Define the url of the texture to display in the layer
  52565. * @param scene Define the scene the layer belongs to
  52566. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52567. * @param color Defines a color for the layer
  52568. */
  52569. constructor(
  52570. /**
  52571. * Define the name of the layer.
  52572. */
  52573. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52574. private _createIndexBuffer;
  52575. /** @hidden */
  52576. _rebuild(): void;
  52577. /**
  52578. * Renders the layer in the scene.
  52579. */
  52580. render(): void;
  52581. /**
  52582. * Disposes and releases the associated ressources.
  52583. */
  52584. dispose(): void;
  52585. }
  52586. }
  52587. declare module BABYLON {
  52588. /** @hidden */
  52589. export var lensFlarePixelShader: {
  52590. name: string;
  52591. shader: string;
  52592. };
  52593. }
  52594. declare module BABYLON {
  52595. /** @hidden */
  52596. export var lensFlareVertexShader: {
  52597. name: string;
  52598. shader: string;
  52599. };
  52600. }
  52601. declare module BABYLON {
  52602. /**
  52603. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52604. * It is usually composed of several `lensFlare`.
  52605. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52606. */
  52607. export class LensFlareSystem {
  52608. /**
  52609. * Define the name of the lens flare system
  52610. */
  52611. name: string;
  52612. /**
  52613. * List of lens flares used in this system.
  52614. */
  52615. lensFlares: LensFlare[];
  52616. /**
  52617. * Define a limit from the border the lens flare can be visible.
  52618. */
  52619. borderLimit: number;
  52620. /**
  52621. * Define a viewport border we do not want to see the lens flare in.
  52622. */
  52623. viewportBorder: number;
  52624. /**
  52625. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52626. */
  52627. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52628. /**
  52629. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52630. */
  52631. layerMask: number;
  52632. /**
  52633. * Define the id of the lens flare system in the scene.
  52634. * (equal to name by default)
  52635. */
  52636. id: string;
  52637. private _scene;
  52638. private _emitter;
  52639. private _vertexBuffers;
  52640. private _indexBuffer;
  52641. private _effect;
  52642. private _positionX;
  52643. private _positionY;
  52644. private _isEnabled;
  52645. /** @hidden */
  52646. static _SceneComponentInitialization: (scene: Scene) => void;
  52647. /**
  52648. * Instantiates a lens flare system.
  52649. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52650. * It is usually composed of several `lensFlare`.
  52651. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52652. * @param name Define the name of the lens flare system in the scene
  52653. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52654. * @param scene Define the scene the lens flare system belongs to
  52655. */
  52656. constructor(
  52657. /**
  52658. * Define the name of the lens flare system
  52659. */
  52660. name: string, emitter: any, scene: Scene);
  52661. /**
  52662. * Define if the lens flare system is enabled.
  52663. */
  52664. get isEnabled(): boolean;
  52665. set isEnabled(value: boolean);
  52666. /**
  52667. * Get the scene the effects belongs to.
  52668. * @returns the scene holding the lens flare system
  52669. */
  52670. getScene(): Scene;
  52671. /**
  52672. * Get the emitter of the lens flare system.
  52673. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52674. * @returns the emitter of the lens flare system
  52675. */
  52676. getEmitter(): any;
  52677. /**
  52678. * Set the emitter of the lens flare system.
  52679. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52680. * @param newEmitter Define the new emitter of the system
  52681. */
  52682. setEmitter(newEmitter: any): void;
  52683. /**
  52684. * Get the lens flare system emitter position.
  52685. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52686. * @returns the position
  52687. */
  52688. getEmitterPosition(): Vector3;
  52689. /**
  52690. * @hidden
  52691. */
  52692. computeEffectivePosition(globalViewport: Viewport): boolean;
  52693. /** @hidden */
  52694. _isVisible(): boolean;
  52695. /**
  52696. * @hidden
  52697. */
  52698. render(): boolean;
  52699. /**
  52700. * Dispose and release the lens flare with its associated resources.
  52701. */
  52702. dispose(): void;
  52703. /**
  52704. * Parse a lens flare system from a JSON repressentation
  52705. * @param parsedLensFlareSystem Define the JSON to parse
  52706. * @param scene Define the scene the parsed system should be instantiated in
  52707. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52708. * @returns the parsed system
  52709. */
  52710. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52711. /**
  52712. * Serialize the current Lens Flare System into a JSON representation.
  52713. * @returns the serialized JSON
  52714. */
  52715. serialize(): any;
  52716. }
  52717. }
  52718. declare module BABYLON {
  52719. /**
  52720. * This represents one of the lens effect in a `lensFlareSystem`.
  52721. * It controls one of the indiviual texture used in the effect.
  52722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52723. */
  52724. export class LensFlare {
  52725. /**
  52726. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52727. */
  52728. size: number;
  52729. /**
  52730. * 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.
  52731. */
  52732. position: number;
  52733. /**
  52734. * Define the lens color.
  52735. */
  52736. color: Color3;
  52737. /**
  52738. * Define the lens texture.
  52739. */
  52740. texture: Nullable<Texture>;
  52741. /**
  52742. * Define the alpha mode to render this particular lens.
  52743. */
  52744. alphaMode: number;
  52745. private _system;
  52746. /**
  52747. * Creates a new Lens Flare.
  52748. * This represents one of the lens effect in a `lensFlareSystem`.
  52749. * It controls one of the indiviual texture used in the effect.
  52750. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52751. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52752. * @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.
  52753. * @param color Define the lens color
  52754. * @param imgUrl Define the lens texture url
  52755. * @param system Define the `lensFlareSystem` this flare is part of
  52756. * @returns The newly created Lens Flare
  52757. */
  52758. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52759. /**
  52760. * Instantiates a new Lens Flare.
  52761. * This represents one of the lens effect in a `lensFlareSystem`.
  52762. * It controls one of the indiviual texture used in the effect.
  52763. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52764. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52765. * @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.
  52766. * @param color Define the lens color
  52767. * @param imgUrl Define the lens texture url
  52768. * @param system Define the `lensFlareSystem` this flare is part of
  52769. */
  52770. constructor(
  52771. /**
  52772. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52773. */
  52774. size: number,
  52775. /**
  52776. * 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.
  52777. */
  52778. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52779. /**
  52780. * Dispose and release the lens flare with its associated resources.
  52781. */
  52782. dispose(): void;
  52783. }
  52784. }
  52785. declare module BABYLON {
  52786. interface AbstractScene {
  52787. /**
  52788. * The list of lens flare system added to the scene
  52789. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52790. */
  52791. lensFlareSystems: Array<LensFlareSystem>;
  52792. /**
  52793. * Removes the given lens flare system from this scene.
  52794. * @param toRemove The lens flare system to remove
  52795. * @returns The index of the removed lens flare system
  52796. */
  52797. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52798. /**
  52799. * Adds the given lens flare system to this scene
  52800. * @param newLensFlareSystem The lens flare system to add
  52801. */
  52802. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52803. /**
  52804. * Gets a lens flare system using its name
  52805. * @param name defines the name to look for
  52806. * @returns the lens flare system or null if not found
  52807. */
  52808. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52809. /**
  52810. * Gets a lens flare system using its id
  52811. * @param id defines the id to look for
  52812. * @returns the lens flare system or null if not found
  52813. */
  52814. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52815. }
  52816. /**
  52817. * Defines the lens flare scene component responsible to manage any lens flares
  52818. * in a given scene.
  52819. */
  52820. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52821. /**
  52822. * The component name helpfull to identify the component in the list of scene components.
  52823. */
  52824. readonly name: string;
  52825. /**
  52826. * The scene the component belongs to.
  52827. */
  52828. scene: Scene;
  52829. /**
  52830. * Creates a new instance of the component for the given scene
  52831. * @param scene Defines the scene to register the component in
  52832. */
  52833. constructor(scene: Scene);
  52834. /**
  52835. * Registers the component in a given scene
  52836. */
  52837. register(): void;
  52838. /**
  52839. * Rebuilds the elements related to this component in case of
  52840. * context lost for instance.
  52841. */
  52842. rebuild(): void;
  52843. /**
  52844. * Adds all the elements from the container to the scene
  52845. * @param container the container holding the elements
  52846. */
  52847. addFromContainer(container: AbstractScene): void;
  52848. /**
  52849. * Removes all the elements in the container from the scene
  52850. * @param container contains the elements to remove
  52851. * @param dispose if the removed element should be disposed (default: false)
  52852. */
  52853. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52854. /**
  52855. * Serializes the component data to the specified json object
  52856. * @param serializationObject The object to serialize to
  52857. */
  52858. serialize(serializationObject: any): void;
  52859. /**
  52860. * Disposes the component and the associated ressources.
  52861. */
  52862. dispose(): void;
  52863. private _draw;
  52864. }
  52865. }
  52866. declare module BABYLON {
  52867. /**
  52868. * Defines the shadow generator component responsible to manage any shadow generators
  52869. * in a given scene.
  52870. */
  52871. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52872. /**
  52873. * The component name helpfull to identify the component in the list of scene components.
  52874. */
  52875. readonly name: string;
  52876. /**
  52877. * The scene the component belongs to.
  52878. */
  52879. scene: Scene;
  52880. /**
  52881. * Creates a new instance of the component for the given scene
  52882. * @param scene Defines the scene to register the component in
  52883. */
  52884. constructor(scene: Scene);
  52885. /**
  52886. * Registers the component in a given scene
  52887. */
  52888. register(): void;
  52889. /**
  52890. * Rebuilds the elements related to this component in case of
  52891. * context lost for instance.
  52892. */
  52893. rebuild(): void;
  52894. /**
  52895. * Serializes the component data to the specified json object
  52896. * @param serializationObject The object to serialize to
  52897. */
  52898. serialize(serializationObject: any): void;
  52899. /**
  52900. * Adds all the elements from the container to the scene
  52901. * @param container the container holding the elements
  52902. */
  52903. addFromContainer(container: AbstractScene): void;
  52904. /**
  52905. * Removes all the elements in the container from the scene
  52906. * @param container contains the elements to remove
  52907. * @param dispose if the removed element should be disposed (default: false)
  52908. */
  52909. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52910. /**
  52911. * Rebuilds the elements related to this component in case of
  52912. * context lost for instance.
  52913. */
  52914. dispose(): void;
  52915. private _gatherRenderTargets;
  52916. }
  52917. }
  52918. declare module BABYLON {
  52919. /**
  52920. * A point light is a light defined by an unique point in world space.
  52921. * The light is emitted in every direction from this point.
  52922. * A good example of a point light is a standard light bulb.
  52923. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52924. */
  52925. export class PointLight extends ShadowLight {
  52926. private _shadowAngle;
  52927. /**
  52928. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52929. * This specifies what angle the shadow will use to be created.
  52930. *
  52931. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52932. */
  52933. get shadowAngle(): number;
  52934. /**
  52935. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52936. * This specifies what angle the shadow will use to be created.
  52937. *
  52938. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52939. */
  52940. set shadowAngle(value: number);
  52941. /**
  52942. * Gets the direction if it has been set.
  52943. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52944. */
  52945. get direction(): Vector3;
  52946. /**
  52947. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52948. */
  52949. set direction(value: Vector3);
  52950. /**
  52951. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52952. * A PointLight emits the light in every direction.
  52953. * It can cast shadows.
  52954. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52955. * ```javascript
  52956. * var pointLight = new PointLight("pl", camera.position, scene);
  52957. * ```
  52958. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52959. * @param name The light friendly name
  52960. * @param position The position of the point light in the scene
  52961. * @param scene The scene the lights belongs to
  52962. */
  52963. constructor(name: string, position: Vector3, scene: Scene);
  52964. /**
  52965. * Returns the string "PointLight"
  52966. * @returns the class name
  52967. */
  52968. getClassName(): string;
  52969. /**
  52970. * Returns the integer 0.
  52971. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52972. */
  52973. getTypeID(): number;
  52974. /**
  52975. * Specifies wether or not the shadowmap should be a cube texture.
  52976. * @returns true if the shadowmap needs to be a cube texture.
  52977. */
  52978. needCube(): boolean;
  52979. /**
  52980. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52981. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52982. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52983. */
  52984. getShadowDirection(faceIndex?: number): Vector3;
  52985. /**
  52986. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52987. * - fov = PI / 2
  52988. * - aspect ratio : 1.0
  52989. * - z-near and far equal to the active camera minZ and maxZ.
  52990. * Returns the PointLight.
  52991. */
  52992. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52993. protected _buildUniformLayout(): void;
  52994. /**
  52995. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52996. * @param effect The effect to update
  52997. * @param lightIndex The index of the light in the effect to update
  52998. * @returns The point light
  52999. */
  53000. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53001. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53002. /**
  53003. * Prepares the list of defines specific to the light type.
  53004. * @param defines the list of defines
  53005. * @param lightIndex defines the index of the light for the effect
  53006. */
  53007. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53008. }
  53009. }
  53010. declare module BABYLON {
  53011. /**
  53012. * Header information of HDR texture files.
  53013. */
  53014. export interface HDRInfo {
  53015. /**
  53016. * The height of the texture in pixels.
  53017. */
  53018. height: number;
  53019. /**
  53020. * The width of the texture in pixels.
  53021. */
  53022. width: number;
  53023. /**
  53024. * The index of the beginning of the data in the binary file.
  53025. */
  53026. dataPosition: number;
  53027. }
  53028. /**
  53029. * This groups tools to convert HDR texture to native colors array.
  53030. */
  53031. export class HDRTools {
  53032. private static Ldexp;
  53033. private static Rgbe2float;
  53034. private static readStringLine;
  53035. /**
  53036. * Reads header information from an RGBE texture stored in a native array.
  53037. * More information on this format are available here:
  53038. * https://en.wikipedia.org/wiki/RGBE_image_format
  53039. *
  53040. * @param uint8array The binary file stored in native array.
  53041. * @return The header information.
  53042. */
  53043. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53044. /**
  53045. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53046. * This RGBE texture needs to store the information as a panorama.
  53047. *
  53048. * More information on this format are available here:
  53049. * https://en.wikipedia.org/wiki/RGBE_image_format
  53050. *
  53051. * @param buffer The binary file stored in an array buffer.
  53052. * @param size The expected size of the extracted cubemap.
  53053. * @return The Cube Map information.
  53054. */
  53055. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53056. /**
  53057. * Returns the pixels data extracted from an RGBE texture.
  53058. * This pixels will be stored left to right up to down in the R G B order in one array.
  53059. *
  53060. * More information on this format are available here:
  53061. * https://en.wikipedia.org/wiki/RGBE_image_format
  53062. *
  53063. * @param uint8array The binary file stored in an array buffer.
  53064. * @param hdrInfo The header information of the file.
  53065. * @return The pixels data in RGB right to left up to down order.
  53066. */
  53067. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53068. private static RGBE_ReadPixels_RLE;
  53069. }
  53070. }
  53071. declare module BABYLON {
  53072. /**
  53073. * This represents a texture coming from an HDR input.
  53074. *
  53075. * The only supported format is currently panorama picture stored in RGBE format.
  53076. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53077. */
  53078. export class HDRCubeTexture extends BaseTexture {
  53079. private static _facesMapping;
  53080. private _generateHarmonics;
  53081. private _noMipmap;
  53082. private _textureMatrix;
  53083. private _size;
  53084. private _onLoad;
  53085. private _onError;
  53086. /**
  53087. * The texture URL.
  53088. */
  53089. url: string;
  53090. /**
  53091. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53092. */
  53093. coordinatesMode: number;
  53094. protected _isBlocking: boolean;
  53095. /**
  53096. * Sets wether or not the texture is blocking during loading.
  53097. */
  53098. set isBlocking(value: boolean);
  53099. /**
  53100. * Gets wether or not the texture is blocking during loading.
  53101. */
  53102. get isBlocking(): boolean;
  53103. protected _rotationY: number;
  53104. /**
  53105. * Sets texture matrix rotation angle around Y axis in radians.
  53106. */
  53107. set rotationY(value: number);
  53108. /**
  53109. * Gets texture matrix rotation angle around Y axis radians.
  53110. */
  53111. get rotationY(): number;
  53112. /**
  53113. * Gets or sets the center of the bounding box associated with the cube texture
  53114. * It must define where the camera used to render the texture was set
  53115. */
  53116. boundingBoxPosition: Vector3;
  53117. private _boundingBoxSize;
  53118. /**
  53119. * Gets or sets the size of the bounding box associated with the cube texture
  53120. * When defined, the cubemap will switch to local mode
  53121. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53122. * @example https://www.babylonjs-playground.com/#RNASML
  53123. */
  53124. set boundingBoxSize(value: Vector3);
  53125. get boundingBoxSize(): Vector3;
  53126. /**
  53127. * Instantiates an HDRTexture from the following parameters.
  53128. *
  53129. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53130. * @param scene The scene the texture will be used in
  53131. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53132. * @param noMipmap Forces to not generate the mipmap if true
  53133. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53134. * @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)
  53135. * @param reserved Reserved flag for internal use.
  53136. */
  53137. 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>);
  53138. /**
  53139. * Get the current class name of the texture useful for serialization or dynamic coding.
  53140. * @returns "HDRCubeTexture"
  53141. */
  53142. getClassName(): string;
  53143. /**
  53144. * Occurs when the file is raw .hdr file.
  53145. */
  53146. private loadTexture;
  53147. clone(): HDRCubeTexture;
  53148. delayLoad(): void;
  53149. /**
  53150. * Get the texture reflection matrix used to rotate/transform the reflection.
  53151. * @returns the reflection matrix
  53152. */
  53153. getReflectionTextureMatrix(): Matrix;
  53154. /**
  53155. * Set the texture reflection matrix used to rotate/transform the reflection.
  53156. * @param value Define the reflection matrix to set
  53157. */
  53158. setReflectionTextureMatrix(value: Matrix): void;
  53159. /**
  53160. * Parses a JSON representation of an HDR Texture in order to create the texture
  53161. * @param parsedTexture Define the JSON representation
  53162. * @param scene Define the scene the texture should be created in
  53163. * @param rootUrl Define the root url in case we need to load relative dependencies
  53164. * @returns the newly created texture after parsing
  53165. */
  53166. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53167. serialize(): any;
  53168. }
  53169. }
  53170. declare module BABYLON {
  53171. /**
  53172. * Class used to control physics engine
  53173. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53174. */
  53175. export class PhysicsEngine implements IPhysicsEngine {
  53176. private _physicsPlugin;
  53177. /**
  53178. * Global value used to control the smallest number supported by the simulation
  53179. */
  53180. static Epsilon: number;
  53181. private _impostors;
  53182. private _joints;
  53183. private _subTimeStep;
  53184. /**
  53185. * Gets the gravity vector used by the simulation
  53186. */
  53187. gravity: Vector3;
  53188. /**
  53189. * Factory used to create the default physics plugin.
  53190. * @returns The default physics plugin
  53191. */
  53192. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53193. /**
  53194. * Creates a new Physics Engine
  53195. * @param gravity defines the gravity vector used by the simulation
  53196. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53197. */
  53198. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53199. /**
  53200. * Sets the gravity vector used by the simulation
  53201. * @param gravity defines the gravity vector to use
  53202. */
  53203. setGravity(gravity: Vector3): void;
  53204. /**
  53205. * Set the time step of the physics engine.
  53206. * Default is 1/60.
  53207. * To slow it down, enter 1/600 for example.
  53208. * To speed it up, 1/30
  53209. * @param newTimeStep defines the new timestep to apply to this world.
  53210. */
  53211. setTimeStep(newTimeStep?: number): void;
  53212. /**
  53213. * Get the time step of the physics engine.
  53214. * @returns the current time step
  53215. */
  53216. getTimeStep(): number;
  53217. /**
  53218. * Set the sub time step of the physics engine.
  53219. * Default is 0 meaning there is no sub steps
  53220. * To increase physics resolution precision, set a small value (like 1 ms)
  53221. * @param subTimeStep defines the new sub timestep used for physics resolution.
  53222. */
  53223. setSubTimeStep(subTimeStep?: number): void;
  53224. /**
  53225. * Get the sub time step of the physics engine.
  53226. * @returns the current sub time step
  53227. */
  53228. getSubTimeStep(): number;
  53229. /**
  53230. * Release all resources
  53231. */
  53232. dispose(): void;
  53233. /**
  53234. * Gets the name of the current physics plugin
  53235. * @returns the name of the plugin
  53236. */
  53237. getPhysicsPluginName(): string;
  53238. /**
  53239. * Adding a new impostor for the impostor tracking.
  53240. * This will be done by the impostor itself.
  53241. * @param impostor the impostor to add
  53242. */
  53243. addImpostor(impostor: PhysicsImpostor): void;
  53244. /**
  53245. * Remove an impostor from the engine.
  53246. * This impostor and its mesh will not longer be updated by the physics engine.
  53247. * @param impostor the impostor to remove
  53248. */
  53249. removeImpostor(impostor: PhysicsImpostor): void;
  53250. /**
  53251. * Add a joint to the physics engine
  53252. * @param mainImpostor defines the main impostor to which the joint is added.
  53253. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53254. * @param joint defines the joint that will connect both impostors.
  53255. */
  53256. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53257. /**
  53258. * Removes a joint from the simulation
  53259. * @param mainImpostor defines the impostor used with the joint
  53260. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53261. * @param joint defines the joint to remove
  53262. */
  53263. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53264. /**
  53265. * Called by the scene. No need to call it.
  53266. * @param delta defines the timespam between frames
  53267. */
  53268. _step(delta: number): void;
  53269. /**
  53270. * Gets the current plugin used to run the simulation
  53271. * @returns current plugin
  53272. */
  53273. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53274. /**
  53275. * Gets the list of physic impostors
  53276. * @returns an array of PhysicsImpostor
  53277. */
  53278. getImpostors(): Array<PhysicsImpostor>;
  53279. /**
  53280. * Gets the impostor for a physics enabled object
  53281. * @param object defines the object impersonated by the impostor
  53282. * @returns the PhysicsImpostor or null if not found
  53283. */
  53284. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53285. /**
  53286. * Gets the impostor for a physics body object
  53287. * @param body defines physics body used by the impostor
  53288. * @returns the PhysicsImpostor or null if not found
  53289. */
  53290. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53291. /**
  53292. * Does a raycast in the physics world
  53293. * @param from when should the ray start?
  53294. * @param to when should the ray end?
  53295. * @returns PhysicsRaycastResult
  53296. */
  53297. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53298. }
  53299. }
  53300. declare module BABYLON {
  53301. /** @hidden */
  53302. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53303. private _useDeltaForWorldStep;
  53304. world: any;
  53305. name: string;
  53306. private _physicsMaterials;
  53307. private _fixedTimeStep;
  53308. private _cannonRaycastResult;
  53309. private _raycastResult;
  53310. private _physicsBodysToRemoveAfterStep;
  53311. BJSCANNON: any;
  53312. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53313. setGravity(gravity: Vector3): void;
  53314. setTimeStep(timeStep: number): void;
  53315. getTimeStep(): number;
  53316. executeStep(delta: number): void;
  53317. private _removeMarkedPhysicsBodiesFromWorld;
  53318. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53319. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53320. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53321. private _processChildMeshes;
  53322. removePhysicsBody(impostor: PhysicsImpostor): void;
  53323. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53324. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53325. private _addMaterial;
  53326. private _checkWithEpsilon;
  53327. private _createShape;
  53328. private _createHeightmap;
  53329. private _minus90X;
  53330. private _plus90X;
  53331. private _tmpPosition;
  53332. private _tmpDeltaPosition;
  53333. private _tmpUnityRotation;
  53334. private _updatePhysicsBodyTransformation;
  53335. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53336. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53337. isSupported(): boolean;
  53338. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53339. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53340. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53341. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53342. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53343. getBodyMass(impostor: PhysicsImpostor): number;
  53344. getBodyFriction(impostor: PhysicsImpostor): number;
  53345. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53346. getBodyRestitution(impostor: PhysicsImpostor): number;
  53347. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53348. sleepBody(impostor: PhysicsImpostor): void;
  53349. wakeUpBody(impostor: PhysicsImpostor): void;
  53350. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53351. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53352. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53353. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53354. getRadius(impostor: PhysicsImpostor): number;
  53355. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53356. dispose(): void;
  53357. private _extendNamespace;
  53358. /**
  53359. * Does a raycast in the physics world
  53360. * @param from when should the ray start?
  53361. * @param to when should the ray end?
  53362. * @returns PhysicsRaycastResult
  53363. */
  53364. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53365. }
  53366. }
  53367. declare module BABYLON {
  53368. /** @hidden */
  53369. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53370. world: any;
  53371. name: string;
  53372. BJSOIMO: any;
  53373. private _raycastResult;
  53374. constructor(iterations?: number, oimoInjection?: any);
  53375. setGravity(gravity: Vector3): void;
  53376. setTimeStep(timeStep: number): void;
  53377. getTimeStep(): number;
  53378. private _tmpImpostorsArray;
  53379. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53380. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53381. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53382. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53383. private _tmpPositionVector;
  53384. removePhysicsBody(impostor: PhysicsImpostor): void;
  53385. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53386. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53387. isSupported(): boolean;
  53388. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53389. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53390. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53391. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53392. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53393. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53395. getBodyMass(impostor: PhysicsImpostor): number;
  53396. getBodyFriction(impostor: PhysicsImpostor): number;
  53397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53398. getBodyRestitution(impostor: PhysicsImpostor): number;
  53399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53400. sleepBody(impostor: PhysicsImpostor): void;
  53401. wakeUpBody(impostor: PhysicsImpostor): void;
  53402. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53403. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53404. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53405. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53406. getRadius(impostor: PhysicsImpostor): number;
  53407. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53408. dispose(): void;
  53409. /**
  53410. * Does a raycast in the physics world
  53411. * @param from when should the ray start?
  53412. * @param to when should the ray end?
  53413. * @returns PhysicsRaycastResult
  53414. */
  53415. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53416. }
  53417. }
  53418. declare module BABYLON {
  53419. /**
  53420. * Class containing static functions to help procedurally build meshes
  53421. */
  53422. export class RibbonBuilder {
  53423. /**
  53424. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53425. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53426. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53427. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53428. * * 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
  53429. * * 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
  53430. * * 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
  53431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53432. * * 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
  53433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53434. * * 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
  53435. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53436. * * 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
  53437. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53439. * @param name defines the name of the mesh
  53440. * @param options defines the options used to create the mesh
  53441. * @param scene defines the hosting scene
  53442. * @returns the ribbon mesh
  53443. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53445. */
  53446. static CreateRibbon(name: string, options: {
  53447. pathArray: Vector3[][];
  53448. closeArray?: boolean;
  53449. closePath?: boolean;
  53450. offset?: number;
  53451. updatable?: boolean;
  53452. sideOrientation?: number;
  53453. frontUVs?: Vector4;
  53454. backUVs?: Vector4;
  53455. instance?: Mesh;
  53456. invertUV?: boolean;
  53457. uvs?: Vector2[];
  53458. colors?: Color4[];
  53459. }, scene?: Nullable<Scene>): Mesh;
  53460. }
  53461. }
  53462. declare module BABYLON {
  53463. /**
  53464. * Class containing static functions to help procedurally build meshes
  53465. */
  53466. export class ShapeBuilder {
  53467. /**
  53468. * 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.
  53469. * * 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.
  53470. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53471. * * 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.
  53472. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53473. * * 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
  53474. * * 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
  53475. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53477. * * 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
  53478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53480. * @param name defines the name of the mesh
  53481. * @param options defines the options used to create the mesh
  53482. * @param scene defines the hosting scene
  53483. * @returns the extruded shape mesh
  53484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53486. */
  53487. static ExtrudeShape(name: string, options: {
  53488. shape: Vector3[];
  53489. path: Vector3[];
  53490. scale?: number;
  53491. rotation?: number;
  53492. cap?: number;
  53493. updatable?: boolean;
  53494. sideOrientation?: number;
  53495. frontUVs?: Vector4;
  53496. backUVs?: Vector4;
  53497. instance?: Mesh;
  53498. invertUV?: boolean;
  53499. }, scene?: Nullable<Scene>): Mesh;
  53500. /**
  53501. * Creates an custom extruded shape mesh.
  53502. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53503. * * 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.
  53504. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53505. * * 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
  53506. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53507. * * 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
  53508. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53509. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53510. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53511. * * 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
  53512. * * 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
  53513. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53515. * * 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
  53516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53518. * @param name defines the name of the mesh
  53519. * @param options defines the options used to create the mesh
  53520. * @param scene defines the hosting scene
  53521. * @returns the custom extruded shape mesh
  53522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53523. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53525. */
  53526. static ExtrudeShapeCustom(name: string, options: {
  53527. shape: Vector3[];
  53528. path: Vector3[];
  53529. scaleFunction?: any;
  53530. rotationFunction?: any;
  53531. ribbonCloseArray?: boolean;
  53532. ribbonClosePath?: boolean;
  53533. cap?: number;
  53534. updatable?: boolean;
  53535. sideOrientation?: number;
  53536. frontUVs?: Vector4;
  53537. backUVs?: Vector4;
  53538. instance?: Mesh;
  53539. invertUV?: boolean;
  53540. }, scene?: Nullable<Scene>): Mesh;
  53541. private static _ExtrudeShapeGeneric;
  53542. }
  53543. }
  53544. declare module BABYLON {
  53545. /**
  53546. * AmmoJS Physics plugin
  53547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53548. * @see https://github.com/kripken/ammo.js/
  53549. */
  53550. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53551. private _useDeltaForWorldStep;
  53552. /**
  53553. * Reference to the Ammo library
  53554. */
  53555. bjsAMMO: any;
  53556. /**
  53557. * Created ammoJS world which physics bodies are added to
  53558. */
  53559. world: any;
  53560. /**
  53561. * Name of the plugin
  53562. */
  53563. name: string;
  53564. private _timeStep;
  53565. private _fixedTimeStep;
  53566. private _maxSteps;
  53567. private _tmpQuaternion;
  53568. private _tmpAmmoTransform;
  53569. private _tmpAmmoQuaternion;
  53570. private _tmpAmmoConcreteContactResultCallback;
  53571. private _collisionConfiguration;
  53572. private _dispatcher;
  53573. private _overlappingPairCache;
  53574. private _solver;
  53575. private _softBodySolver;
  53576. private _tmpAmmoVectorA;
  53577. private _tmpAmmoVectorB;
  53578. private _tmpAmmoVectorC;
  53579. private _tmpAmmoVectorD;
  53580. private _tmpContactCallbackResult;
  53581. private _tmpAmmoVectorRCA;
  53582. private _tmpAmmoVectorRCB;
  53583. private _raycastResult;
  53584. private static readonly DISABLE_COLLISION_FLAG;
  53585. private static readonly KINEMATIC_FLAG;
  53586. private static readonly DISABLE_DEACTIVATION_FLAG;
  53587. /**
  53588. * Initializes the ammoJS plugin
  53589. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53590. * @param ammoInjection can be used to inject your own ammo reference
  53591. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53592. */
  53593. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53594. /**
  53595. * Sets the gravity of the physics world (m/(s^2))
  53596. * @param gravity Gravity to set
  53597. */
  53598. setGravity(gravity: Vector3): void;
  53599. /**
  53600. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53601. * @param timeStep timestep to use in seconds
  53602. */
  53603. setTimeStep(timeStep: number): void;
  53604. /**
  53605. * 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)
  53606. * @param fixedTimeStep fixedTimeStep to use in seconds
  53607. */
  53608. setFixedTimeStep(fixedTimeStep: number): void;
  53609. /**
  53610. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53611. * @param maxSteps the maximum number of steps by the physics engine per frame
  53612. */
  53613. setMaxSteps(maxSteps: number): void;
  53614. /**
  53615. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53616. * @returns the current timestep in seconds
  53617. */
  53618. getTimeStep(): number;
  53619. /**
  53620. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53621. */
  53622. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53623. private _isImpostorInContact;
  53624. private _isImpostorPairInContact;
  53625. private _stepSimulation;
  53626. /**
  53627. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53628. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53629. * After the step the babylon meshes are set to the position of the physics imposters
  53630. * @param delta amount of time to step forward
  53631. * @param impostors array of imposters to update before/after the step
  53632. */
  53633. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53634. /**
  53635. * Update babylon mesh to match physics world object
  53636. * @param impostor imposter to match
  53637. */
  53638. private _afterSoftStep;
  53639. /**
  53640. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53641. * @param impostor imposter to match
  53642. */
  53643. private _ropeStep;
  53644. /**
  53645. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53646. * @param impostor imposter to match
  53647. */
  53648. private _softbodyOrClothStep;
  53649. private _tmpVector;
  53650. private _tmpMatrix;
  53651. /**
  53652. * Applies an impulse on the imposter
  53653. * @param impostor imposter to apply impulse to
  53654. * @param force amount of force to be applied to the imposter
  53655. * @param contactPoint the location to apply the impulse on the imposter
  53656. */
  53657. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53658. /**
  53659. * Applies a force on the imposter
  53660. * @param impostor imposter to apply force
  53661. * @param force amount of force to be applied to the imposter
  53662. * @param contactPoint the location to apply the force on the imposter
  53663. */
  53664. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53665. /**
  53666. * Creates a physics body using the plugin
  53667. * @param impostor the imposter to create the physics body on
  53668. */
  53669. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53670. /**
  53671. * Removes the physics body from the imposter and disposes of the body's memory
  53672. * @param impostor imposter to remove the physics body from
  53673. */
  53674. removePhysicsBody(impostor: PhysicsImpostor): void;
  53675. /**
  53676. * Generates a joint
  53677. * @param impostorJoint the imposter joint to create the joint with
  53678. */
  53679. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53680. /**
  53681. * Removes a joint
  53682. * @param impostorJoint the imposter joint to remove the joint from
  53683. */
  53684. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53685. private _addMeshVerts;
  53686. /**
  53687. * Initialise the soft body vertices to match its object's (mesh) vertices
  53688. * Softbody vertices (nodes) are in world space and to match this
  53689. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53690. * @param impostor to create the softbody for
  53691. */
  53692. private _softVertexData;
  53693. /**
  53694. * Create an impostor's soft body
  53695. * @param impostor to create the softbody for
  53696. */
  53697. private _createSoftbody;
  53698. /**
  53699. * Create cloth for an impostor
  53700. * @param impostor to create the softbody for
  53701. */
  53702. private _createCloth;
  53703. /**
  53704. * Create rope for an impostor
  53705. * @param impostor to create the softbody for
  53706. */
  53707. private _createRope;
  53708. /**
  53709. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53710. * @param impostor to create the custom physics shape for
  53711. */
  53712. private _createCustom;
  53713. private _addHullVerts;
  53714. private _createShape;
  53715. /**
  53716. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53717. * @param impostor imposter containing the physics body and babylon object
  53718. */
  53719. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53720. /**
  53721. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53722. * @param impostor imposter containing the physics body and babylon object
  53723. * @param newPosition new position
  53724. * @param newRotation new rotation
  53725. */
  53726. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53727. /**
  53728. * If this plugin is supported
  53729. * @returns true if its supported
  53730. */
  53731. isSupported(): boolean;
  53732. /**
  53733. * Sets the linear velocity of the physics body
  53734. * @param impostor imposter to set the velocity on
  53735. * @param velocity velocity to set
  53736. */
  53737. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53738. /**
  53739. * Sets the angular velocity of the physics body
  53740. * @param impostor imposter to set the velocity on
  53741. * @param velocity velocity to set
  53742. */
  53743. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53744. /**
  53745. * gets the linear velocity
  53746. * @param impostor imposter to get linear velocity from
  53747. * @returns linear velocity
  53748. */
  53749. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53750. /**
  53751. * gets the angular velocity
  53752. * @param impostor imposter to get angular velocity from
  53753. * @returns angular velocity
  53754. */
  53755. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53756. /**
  53757. * Sets the mass of physics body
  53758. * @param impostor imposter to set the mass on
  53759. * @param mass mass to set
  53760. */
  53761. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53762. /**
  53763. * Gets the mass of the physics body
  53764. * @param impostor imposter to get the mass from
  53765. * @returns mass
  53766. */
  53767. getBodyMass(impostor: PhysicsImpostor): number;
  53768. /**
  53769. * Gets friction of the impostor
  53770. * @param impostor impostor to get friction from
  53771. * @returns friction value
  53772. */
  53773. getBodyFriction(impostor: PhysicsImpostor): number;
  53774. /**
  53775. * Sets friction of the impostor
  53776. * @param impostor impostor to set friction on
  53777. * @param friction friction value
  53778. */
  53779. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53780. /**
  53781. * Gets restitution of the impostor
  53782. * @param impostor impostor to get restitution from
  53783. * @returns restitution value
  53784. */
  53785. getBodyRestitution(impostor: PhysicsImpostor): number;
  53786. /**
  53787. * Sets resitution of the impostor
  53788. * @param impostor impostor to set resitution on
  53789. * @param restitution resitution value
  53790. */
  53791. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53792. /**
  53793. * Gets pressure inside the impostor
  53794. * @param impostor impostor to get pressure from
  53795. * @returns pressure value
  53796. */
  53797. getBodyPressure(impostor: PhysicsImpostor): number;
  53798. /**
  53799. * Sets pressure inside a soft body impostor
  53800. * Cloth and rope must remain 0 pressure
  53801. * @param impostor impostor to set pressure on
  53802. * @param pressure pressure value
  53803. */
  53804. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53805. /**
  53806. * Gets stiffness of the impostor
  53807. * @param impostor impostor to get stiffness from
  53808. * @returns pressure value
  53809. */
  53810. getBodyStiffness(impostor: PhysicsImpostor): number;
  53811. /**
  53812. * Sets stiffness of the impostor
  53813. * @param impostor impostor to set stiffness on
  53814. * @param stiffness stiffness value from 0 to 1
  53815. */
  53816. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53817. /**
  53818. * Gets velocityIterations of the impostor
  53819. * @param impostor impostor to get velocity iterations from
  53820. * @returns velocityIterations value
  53821. */
  53822. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53823. /**
  53824. * Sets velocityIterations of the impostor
  53825. * @param impostor impostor to set velocity iterations on
  53826. * @param velocityIterations velocityIterations value
  53827. */
  53828. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53829. /**
  53830. * Gets positionIterations of the impostor
  53831. * @param impostor impostor to get position iterations from
  53832. * @returns positionIterations value
  53833. */
  53834. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53835. /**
  53836. * Sets positionIterations of the impostor
  53837. * @param impostor impostor to set position on
  53838. * @param positionIterations positionIterations value
  53839. */
  53840. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53841. /**
  53842. * Append an anchor to a cloth object
  53843. * @param impostor is the cloth impostor to add anchor to
  53844. * @param otherImpostor is the rigid impostor to anchor to
  53845. * @param width ratio across width from 0 to 1
  53846. * @param height ratio up height from 0 to 1
  53847. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53848. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53849. */
  53850. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53851. /**
  53852. * Append an hook to a rope object
  53853. * @param impostor is the rope impostor to add hook to
  53854. * @param otherImpostor is the rigid impostor to hook to
  53855. * @param length ratio along the rope from 0 to 1
  53856. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53857. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53858. */
  53859. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53860. /**
  53861. * Sleeps the physics body and stops it from being active
  53862. * @param impostor impostor to sleep
  53863. */
  53864. sleepBody(impostor: PhysicsImpostor): void;
  53865. /**
  53866. * Activates the physics body
  53867. * @param impostor impostor to activate
  53868. */
  53869. wakeUpBody(impostor: PhysicsImpostor): void;
  53870. /**
  53871. * Updates the distance parameters of the joint
  53872. * @param joint joint to update
  53873. * @param maxDistance maximum distance of the joint
  53874. * @param minDistance minimum distance of the joint
  53875. */
  53876. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53877. /**
  53878. * Sets a motor on the joint
  53879. * @param joint joint to set motor on
  53880. * @param speed speed of the motor
  53881. * @param maxForce maximum force of the motor
  53882. * @param motorIndex index of the motor
  53883. */
  53884. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53885. /**
  53886. * Sets the motors limit
  53887. * @param joint joint to set limit on
  53888. * @param upperLimit upper limit
  53889. * @param lowerLimit lower limit
  53890. */
  53891. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53892. /**
  53893. * Syncs the position and rotation of a mesh with the impostor
  53894. * @param mesh mesh to sync
  53895. * @param impostor impostor to update the mesh with
  53896. */
  53897. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53898. /**
  53899. * Gets the radius of the impostor
  53900. * @param impostor impostor to get radius from
  53901. * @returns the radius
  53902. */
  53903. getRadius(impostor: PhysicsImpostor): number;
  53904. /**
  53905. * Gets the box size of the impostor
  53906. * @param impostor impostor to get box size from
  53907. * @param result the resulting box size
  53908. */
  53909. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53910. /**
  53911. * Disposes of the impostor
  53912. */
  53913. dispose(): void;
  53914. /**
  53915. * Does a raycast in the physics world
  53916. * @param from when should the ray start?
  53917. * @param to when should the ray end?
  53918. * @returns PhysicsRaycastResult
  53919. */
  53920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53921. }
  53922. }
  53923. declare module BABYLON {
  53924. interface AbstractScene {
  53925. /**
  53926. * The list of reflection probes added to the scene
  53927. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53928. */
  53929. reflectionProbes: Array<ReflectionProbe>;
  53930. /**
  53931. * Removes the given reflection probe from this scene.
  53932. * @param toRemove The reflection probe to remove
  53933. * @returns The index of the removed reflection probe
  53934. */
  53935. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53936. /**
  53937. * Adds the given reflection probe to this scene.
  53938. * @param newReflectionProbe The reflection probe to add
  53939. */
  53940. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53941. }
  53942. /**
  53943. * Class used to generate realtime reflection / refraction cube textures
  53944. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53945. */
  53946. export class ReflectionProbe {
  53947. /** defines the name of the probe */
  53948. name: string;
  53949. private _scene;
  53950. private _renderTargetTexture;
  53951. private _projectionMatrix;
  53952. private _viewMatrix;
  53953. private _target;
  53954. private _add;
  53955. private _attachedMesh;
  53956. private _invertYAxis;
  53957. /** Gets or sets probe position (center of the cube map) */
  53958. position: Vector3;
  53959. /**
  53960. * Creates a new reflection probe
  53961. * @param name defines the name of the probe
  53962. * @param size defines the texture resolution (for each face)
  53963. * @param scene defines the hosting scene
  53964. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53965. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53966. */
  53967. constructor(
  53968. /** defines the name of the probe */
  53969. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53970. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53971. get samples(): number;
  53972. set samples(value: number);
  53973. /** Gets or sets the refresh rate to use (on every frame by default) */
  53974. get refreshRate(): number;
  53975. set refreshRate(value: number);
  53976. /**
  53977. * Gets the hosting scene
  53978. * @returns a Scene
  53979. */
  53980. getScene(): Scene;
  53981. /** Gets the internal CubeTexture used to render to */
  53982. get cubeTexture(): RenderTargetTexture;
  53983. /** Gets the list of meshes to render */
  53984. get renderList(): Nullable<AbstractMesh[]>;
  53985. /**
  53986. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53987. * @param mesh defines the mesh to attach to
  53988. */
  53989. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53990. /**
  53991. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53992. * @param renderingGroupId The rendering group id corresponding to its index
  53993. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53994. */
  53995. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53996. /**
  53997. * Clean all associated resources
  53998. */
  53999. dispose(): void;
  54000. /**
  54001. * Converts the reflection probe information to a readable string for debug purpose.
  54002. * @param fullDetails Supports for multiple levels of logging within scene loading
  54003. * @returns the human readable reflection probe info
  54004. */
  54005. toString(fullDetails?: boolean): string;
  54006. /**
  54007. * Get the class name of the relfection probe.
  54008. * @returns "ReflectionProbe"
  54009. */
  54010. getClassName(): string;
  54011. /**
  54012. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54013. * @returns The JSON representation of the texture
  54014. */
  54015. serialize(): any;
  54016. /**
  54017. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54018. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54019. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54020. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54021. * @returns The parsed reflection probe if successful
  54022. */
  54023. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54024. }
  54025. }
  54026. declare module BABYLON {
  54027. /** @hidden */
  54028. export var _BabylonLoaderRegistered: boolean;
  54029. /**
  54030. * Helps setting up some configuration for the babylon file loader.
  54031. */
  54032. export class BabylonFileLoaderConfiguration {
  54033. /**
  54034. * The loader does not allow injecting custom physix engine into the plugins.
  54035. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54036. * So you could set this variable to your engine import to make it work.
  54037. */
  54038. static LoaderInjectedPhysicsEngine: any;
  54039. }
  54040. }
  54041. declare module BABYLON {
  54042. /**
  54043. * The Physically based simple base material of BJS.
  54044. *
  54045. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54046. * It is used as the base class for both the specGloss and metalRough conventions.
  54047. */
  54048. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54049. /**
  54050. * Number of Simultaneous lights allowed on the material.
  54051. */
  54052. maxSimultaneousLights: number;
  54053. /**
  54054. * If sets to true, disables all the lights affecting the material.
  54055. */
  54056. disableLighting: boolean;
  54057. /**
  54058. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54059. */
  54060. environmentTexture: BaseTexture;
  54061. /**
  54062. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54063. */
  54064. invertNormalMapX: boolean;
  54065. /**
  54066. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54067. */
  54068. invertNormalMapY: boolean;
  54069. /**
  54070. * Normal map used in the model.
  54071. */
  54072. normalTexture: BaseTexture;
  54073. /**
  54074. * Emissivie color used to self-illuminate the model.
  54075. */
  54076. emissiveColor: Color3;
  54077. /**
  54078. * Emissivie texture used to self-illuminate the model.
  54079. */
  54080. emissiveTexture: BaseTexture;
  54081. /**
  54082. * Occlusion Channel Strenght.
  54083. */
  54084. occlusionStrength: number;
  54085. /**
  54086. * Occlusion Texture of the material (adding extra occlusion effects).
  54087. */
  54088. occlusionTexture: BaseTexture;
  54089. /**
  54090. * Defines the alpha limits in alpha test mode.
  54091. */
  54092. alphaCutOff: number;
  54093. /**
  54094. * Gets the current double sided mode.
  54095. */
  54096. get doubleSided(): boolean;
  54097. /**
  54098. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54099. */
  54100. set doubleSided(value: boolean);
  54101. /**
  54102. * Stores the pre-calculated light information of a mesh in a texture.
  54103. */
  54104. lightmapTexture: BaseTexture;
  54105. /**
  54106. * If true, the light map contains occlusion information instead of lighting info.
  54107. */
  54108. useLightmapAsShadowmap: boolean;
  54109. /**
  54110. * Instantiates a new PBRMaterial instance.
  54111. *
  54112. * @param name The material name
  54113. * @param scene The scene the material will be use in.
  54114. */
  54115. constructor(name: string, scene: Scene);
  54116. getClassName(): string;
  54117. }
  54118. }
  54119. declare module BABYLON {
  54120. /**
  54121. * The PBR material of BJS following the metal roughness convention.
  54122. *
  54123. * This fits to the PBR convention in the GLTF definition:
  54124. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54125. */
  54126. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54127. /**
  54128. * The base color has two different interpretations depending on the value of metalness.
  54129. * When the material is a metal, the base color is the specific measured reflectance value
  54130. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54131. * of the material.
  54132. */
  54133. baseColor: Color3;
  54134. /**
  54135. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54136. * well as opacity information in the alpha channel.
  54137. */
  54138. baseTexture: BaseTexture;
  54139. /**
  54140. * Specifies the metallic scalar value of the material.
  54141. * Can also be used to scale the metalness values of the metallic texture.
  54142. */
  54143. metallic: number;
  54144. /**
  54145. * Specifies the roughness scalar value of the material.
  54146. * Can also be used to scale the roughness values of the metallic texture.
  54147. */
  54148. roughness: number;
  54149. /**
  54150. * Texture containing both the metallic value in the B channel and the
  54151. * roughness value in the G channel to keep better precision.
  54152. */
  54153. metallicRoughnessTexture: BaseTexture;
  54154. /**
  54155. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54156. *
  54157. * @param name The material name
  54158. * @param scene The scene the material will be use in.
  54159. */
  54160. constructor(name: string, scene: Scene);
  54161. /**
  54162. * Return the currrent class name of the material.
  54163. */
  54164. getClassName(): string;
  54165. /**
  54166. * Makes a duplicate of the current material.
  54167. * @param name - name to use for the new material.
  54168. */
  54169. clone(name: string): PBRMetallicRoughnessMaterial;
  54170. /**
  54171. * Serialize the material to a parsable JSON object.
  54172. */
  54173. serialize(): any;
  54174. /**
  54175. * Parses a JSON object correponding to the serialize function.
  54176. */
  54177. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54178. }
  54179. }
  54180. declare module BABYLON {
  54181. /**
  54182. * The PBR material of BJS following the specular glossiness convention.
  54183. *
  54184. * This fits to the PBR convention in the GLTF definition:
  54185. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54186. */
  54187. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54188. /**
  54189. * Specifies the diffuse color of the material.
  54190. */
  54191. diffuseColor: Color3;
  54192. /**
  54193. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54194. * channel.
  54195. */
  54196. diffuseTexture: BaseTexture;
  54197. /**
  54198. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54199. */
  54200. specularColor: Color3;
  54201. /**
  54202. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54203. */
  54204. glossiness: number;
  54205. /**
  54206. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54207. */
  54208. specularGlossinessTexture: BaseTexture;
  54209. /**
  54210. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54211. *
  54212. * @param name The material name
  54213. * @param scene The scene the material will be use in.
  54214. */
  54215. constructor(name: string, scene: Scene);
  54216. /**
  54217. * Return the currrent class name of the material.
  54218. */
  54219. getClassName(): string;
  54220. /**
  54221. * Makes a duplicate of the current material.
  54222. * @param name - name to use for the new material.
  54223. */
  54224. clone(name: string): PBRSpecularGlossinessMaterial;
  54225. /**
  54226. * Serialize the material to a parsable JSON object.
  54227. */
  54228. serialize(): any;
  54229. /**
  54230. * Parses a JSON object correponding to the serialize function.
  54231. */
  54232. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54233. }
  54234. }
  54235. declare module BABYLON {
  54236. /**
  54237. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54238. * It can help converting any input color in a desired output one. This can then be used to create effects
  54239. * from sepia, black and white to sixties or futuristic rendering...
  54240. *
  54241. * The only supported format is currently 3dl.
  54242. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54243. */
  54244. export class ColorGradingTexture extends BaseTexture {
  54245. /**
  54246. * The current texture matrix. (will always be identity in color grading texture)
  54247. */
  54248. private _textureMatrix;
  54249. /**
  54250. * The texture URL.
  54251. */
  54252. url: string;
  54253. /**
  54254. * Empty line regex stored for GC.
  54255. */
  54256. private static _noneEmptyLineRegex;
  54257. private _engine;
  54258. /**
  54259. * Instantiates a ColorGradingTexture from the following parameters.
  54260. *
  54261. * @param url The location of the color gradind data (currently only supporting 3dl)
  54262. * @param scene The scene the texture will be used in
  54263. */
  54264. constructor(url: string, scene: Scene);
  54265. /**
  54266. * Returns the texture matrix used in most of the material.
  54267. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54268. */
  54269. getTextureMatrix(): Matrix;
  54270. /**
  54271. * Occurs when the file being loaded is a .3dl LUT file.
  54272. */
  54273. private load3dlTexture;
  54274. /**
  54275. * Starts the loading process of the texture.
  54276. */
  54277. private loadTexture;
  54278. /**
  54279. * Clones the color gradind texture.
  54280. */
  54281. clone(): ColorGradingTexture;
  54282. /**
  54283. * Called during delayed load for textures.
  54284. */
  54285. delayLoad(): void;
  54286. /**
  54287. * Parses a color grading texture serialized by Babylon.
  54288. * @param parsedTexture The texture information being parsedTexture
  54289. * @param scene The scene to load the texture in
  54290. * @param rootUrl The root url of the data assets to load
  54291. * @return A color gradind texture
  54292. */
  54293. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54294. /**
  54295. * Serializes the LUT texture to json format.
  54296. */
  54297. serialize(): any;
  54298. }
  54299. }
  54300. declare module BABYLON {
  54301. /**
  54302. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54303. */
  54304. export class EquiRectangularCubeTexture extends BaseTexture {
  54305. /** The six faces of the cube. */
  54306. private static _FacesMapping;
  54307. private _noMipmap;
  54308. private _onLoad;
  54309. private _onError;
  54310. /** The size of the cubemap. */
  54311. private _size;
  54312. /** The buffer of the image. */
  54313. private _buffer;
  54314. /** The width of the input image. */
  54315. private _width;
  54316. /** The height of the input image. */
  54317. private _height;
  54318. /** The URL to the image. */
  54319. url: string;
  54320. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54321. coordinatesMode: number;
  54322. /**
  54323. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54324. * @param url The location of the image
  54325. * @param scene The scene the texture will be used in
  54326. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54327. * @param noMipmap Forces to not generate the mipmap if true
  54328. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54329. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54330. * @param onLoad — defines a callback called when texture is loaded
  54331. * @param onError — defines a callback called if there is an error
  54332. */
  54333. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54334. /**
  54335. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54336. */
  54337. private loadImage;
  54338. /**
  54339. * Convert the image buffer into a cubemap and create a CubeTexture.
  54340. */
  54341. private loadTexture;
  54342. /**
  54343. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54344. * @param buffer The ArrayBuffer that should be converted.
  54345. * @returns The buffer as Float32Array.
  54346. */
  54347. private getFloat32ArrayFromArrayBuffer;
  54348. /**
  54349. * Get the current class name of the texture useful for serialization or dynamic coding.
  54350. * @returns "EquiRectangularCubeTexture"
  54351. */
  54352. getClassName(): string;
  54353. /**
  54354. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54355. * @returns A clone of the current EquiRectangularCubeTexture.
  54356. */
  54357. clone(): EquiRectangularCubeTexture;
  54358. }
  54359. }
  54360. declare module BABYLON {
  54361. /**
  54362. * Based on jsTGALoader - Javascript loader for TGA file
  54363. * By Vincent Thibault
  54364. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54365. */
  54366. export class TGATools {
  54367. private static _TYPE_INDEXED;
  54368. private static _TYPE_RGB;
  54369. private static _TYPE_GREY;
  54370. private static _TYPE_RLE_INDEXED;
  54371. private static _TYPE_RLE_RGB;
  54372. private static _TYPE_RLE_GREY;
  54373. private static _ORIGIN_MASK;
  54374. private static _ORIGIN_SHIFT;
  54375. private static _ORIGIN_BL;
  54376. private static _ORIGIN_BR;
  54377. private static _ORIGIN_UL;
  54378. private static _ORIGIN_UR;
  54379. /**
  54380. * Gets the header of a TGA file
  54381. * @param data defines the TGA data
  54382. * @returns the header
  54383. */
  54384. static GetTGAHeader(data: Uint8Array): any;
  54385. /**
  54386. * Uploads TGA content to a Babylon Texture
  54387. * @hidden
  54388. */
  54389. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54390. /** @hidden */
  54391. 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;
  54392. /** @hidden */
  54393. 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;
  54394. /** @hidden */
  54395. 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;
  54396. /** @hidden */
  54397. 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;
  54398. /** @hidden */
  54399. 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;
  54400. /** @hidden */
  54401. 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;
  54402. }
  54403. }
  54404. declare module BABYLON {
  54405. /**
  54406. * Implementation of the TGA Texture Loader.
  54407. * @hidden
  54408. */
  54409. export class _TGATextureLoader implements IInternalTextureLoader {
  54410. /**
  54411. * Defines wether the loader supports cascade loading the different faces.
  54412. */
  54413. readonly supportCascades: boolean;
  54414. /**
  54415. * This returns if the loader support the current file information.
  54416. * @param extension defines the file extension of the file being loaded
  54417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54418. * @param fallback defines the fallback internal texture if any
  54419. * @param isBase64 defines whether the texture is encoded as a base64
  54420. * @param isBuffer defines whether the texture data are stored as a buffer
  54421. * @returns true if the loader can load the specified file
  54422. */
  54423. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54424. /**
  54425. * Transform the url before loading if required.
  54426. * @param rootUrl the url of the texture
  54427. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54428. * @returns the transformed texture
  54429. */
  54430. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54431. /**
  54432. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54433. * @param rootUrl the url of the texture
  54434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54435. * @returns the fallback texture
  54436. */
  54437. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54438. /**
  54439. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54440. * @param data contains the texture data
  54441. * @param texture defines the BabylonJS internal texture
  54442. * @param createPolynomials will be true if polynomials have been requested
  54443. * @param onLoad defines the callback to trigger once the texture is ready
  54444. * @param onError defines the callback to trigger in case of error
  54445. */
  54446. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54447. /**
  54448. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54449. * @param data contains the texture data
  54450. * @param texture defines the BabylonJS internal texture
  54451. * @param callback defines the method to call once ready to upload
  54452. */
  54453. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54454. }
  54455. }
  54456. declare module BABYLON {
  54457. /**
  54458. * Info about the .basis files
  54459. */
  54460. class BasisFileInfo {
  54461. /**
  54462. * If the file has alpha
  54463. */
  54464. hasAlpha: boolean;
  54465. /**
  54466. * Info about each image of the basis file
  54467. */
  54468. images: Array<{
  54469. levels: Array<{
  54470. width: number;
  54471. height: number;
  54472. transcodedPixels: ArrayBufferView;
  54473. }>;
  54474. }>;
  54475. }
  54476. /**
  54477. * Result of transcoding a basis file
  54478. */
  54479. class TranscodeResult {
  54480. /**
  54481. * Info about the .basis file
  54482. */
  54483. fileInfo: BasisFileInfo;
  54484. /**
  54485. * Format to use when loading the file
  54486. */
  54487. format: number;
  54488. }
  54489. /**
  54490. * Configuration options for the Basis transcoder
  54491. */
  54492. export class BasisTranscodeConfiguration {
  54493. /**
  54494. * Supported compression formats used to determine the supported output format of the transcoder
  54495. */
  54496. supportedCompressionFormats?: {
  54497. /**
  54498. * etc1 compression format
  54499. */
  54500. etc1?: boolean;
  54501. /**
  54502. * s3tc compression format
  54503. */
  54504. s3tc?: boolean;
  54505. /**
  54506. * pvrtc compression format
  54507. */
  54508. pvrtc?: boolean;
  54509. /**
  54510. * etc2 compression format
  54511. */
  54512. etc2?: boolean;
  54513. };
  54514. /**
  54515. * If mipmap levels should be loaded for transcoded images (Default: true)
  54516. */
  54517. loadMipmapLevels?: boolean;
  54518. /**
  54519. * Index of a single image to load (Default: all images)
  54520. */
  54521. loadSingleImage?: number;
  54522. }
  54523. /**
  54524. * Used to load .Basis files
  54525. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54526. */
  54527. export class BasisTools {
  54528. private static _IgnoreSupportedFormats;
  54529. /**
  54530. * URL to use when loading the basis transcoder
  54531. */
  54532. static JSModuleURL: string;
  54533. /**
  54534. * URL to use when loading the wasm module for the transcoder
  54535. */
  54536. static WasmModuleURL: string;
  54537. /**
  54538. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54539. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54540. * @returns internal format corresponding to the Basis format
  54541. */
  54542. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54543. private static _WorkerPromise;
  54544. private static _Worker;
  54545. private static _actionId;
  54546. private static _CreateWorkerAsync;
  54547. /**
  54548. * Transcodes a loaded image file to compressed pixel data
  54549. * @param imageData image data to transcode
  54550. * @param config configuration options for the transcoding
  54551. * @returns a promise resulting in the transcoded image
  54552. */
  54553. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54554. /**
  54555. * Loads a texture from the transcode result
  54556. * @param texture texture load to
  54557. * @param transcodeResult the result of transcoding the basis file to load from
  54558. */
  54559. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54560. }
  54561. }
  54562. declare module BABYLON {
  54563. /**
  54564. * Loader for .basis file format
  54565. */
  54566. export class _BasisTextureLoader implements IInternalTextureLoader {
  54567. /**
  54568. * Defines whether the loader supports cascade loading the different faces.
  54569. */
  54570. readonly supportCascades: boolean;
  54571. /**
  54572. * This returns if the loader support the current file information.
  54573. * @param extension defines the file extension of the file being loaded
  54574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54575. * @param fallback defines the fallback internal texture if any
  54576. * @param isBase64 defines whether the texture is encoded as a base64
  54577. * @param isBuffer defines whether the texture data are stored as a buffer
  54578. * @returns true if the loader can load the specified file
  54579. */
  54580. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54581. /**
  54582. * Transform the url before loading if required.
  54583. * @param rootUrl the url of the texture
  54584. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54585. * @returns the transformed texture
  54586. */
  54587. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54588. /**
  54589. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54590. * @param rootUrl the url of the texture
  54591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54592. * @returns the fallback texture
  54593. */
  54594. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54595. /**
  54596. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54597. * @param data contains the texture data
  54598. * @param texture defines the BabylonJS internal texture
  54599. * @param createPolynomials will be true if polynomials have been requested
  54600. * @param onLoad defines the callback to trigger once the texture is ready
  54601. * @param onError defines the callback to trigger in case of error
  54602. */
  54603. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54604. /**
  54605. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54606. * @param data contains the texture data
  54607. * @param texture defines the BabylonJS internal texture
  54608. * @param callback defines the method to call once ready to upload
  54609. */
  54610. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54611. }
  54612. }
  54613. declare module BABYLON {
  54614. /**
  54615. * 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.
  54616. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54617. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54618. */
  54619. export class CustomProceduralTexture extends ProceduralTexture {
  54620. private _animate;
  54621. private _time;
  54622. private _config;
  54623. private _texturePath;
  54624. /**
  54625. * Instantiates a new Custom Procedural Texture.
  54626. * 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.
  54627. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54629. * @param name Define the name of the texture
  54630. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54631. * @param size Define the size of the texture to create
  54632. * @param scene Define the scene the texture belongs to
  54633. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54634. * @param generateMipMaps Define if the texture should creates mip maps or not
  54635. */
  54636. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54637. private _loadJson;
  54638. /**
  54639. * Is the texture ready to be used ? (rendered at least once)
  54640. * @returns true if ready, otherwise, false.
  54641. */
  54642. isReady(): boolean;
  54643. /**
  54644. * Render the texture to its associated render target.
  54645. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54646. */
  54647. render(useCameraPostProcess?: boolean): void;
  54648. /**
  54649. * Update the list of dependant textures samplers in the shader.
  54650. */
  54651. updateTextures(): void;
  54652. /**
  54653. * Update the uniform values of the procedural texture in the shader.
  54654. */
  54655. updateShaderUniforms(): void;
  54656. /**
  54657. * Define if the texture animates or not.
  54658. */
  54659. get animate(): boolean;
  54660. set animate(value: boolean);
  54661. }
  54662. }
  54663. declare module BABYLON {
  54664. /** @hidden */
  54665. export var noisePixelShader: {
  54666. name: string;
  54667. shader: string;
  54668. };
  54669. }
  54670. declare module BABYLON {
  54671. /**
  54672. * Class used to generate noise procedural textures
  54673. */
  54674. export class NoiseProceduralTexture extends ProceduralTexture {
  54675. private _time;
  54676. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54677. brightness: number;
  54678. /** Defines the number of octaves to process */
  54679. octaves: number;
  54680. /** Defines the level of persistence (0.8 by default) */
  54681. persistence: number;
  54682. /** Gets or sets animation speed factor (default is 1) */
  54683. animationSpeedFactor: number;
  54684. /**
  54685. * Creates a new NoiseProceduralTexture
  54686. * @param name defines the name fo the texture
  54687. * @param size defines the size of the texture (default is 256)
  54688. * @param scene defines the hosting scene
  54689. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54690. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54691. */
  54692. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54693. private _updateShaderUniforms;
  54694. protected _getDefines(): string;
  54695. /** Generate the current state of the procedural texture */
  54696. render(useCameraPostProcess?: boolean): void;
  54697. /**
  54698. * Serializes this noise procedural texture
  54699. * @returns a serialized noise procedural texture object
  54700. */
  54701. serialize(): any;
  54702. /**
  54703. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54704. * @param parsedTexture defines parsed texture data
  54705. * @param scene defines the current scene
  54706. * @param rootUrl defines the root URL containing noise procedural texture information
  54707. * @returns a parsed NoiseProceduralTexture
  54708. */
  54709. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54710. }
  54711. }
  54712. declare module BABYLON {
  54713. /**
  54714. * Raw cube texture where the raw buffers are passed in
  54715. */
  54716. export class RawCubeTexture extends CubeTexture {
  54717. /**
  54718. * Creates a cube texture where the raw buffers are passed in.
  54719. * @param scene defines the scene the texture is attached to
  54720. * @param data defines the array of data to use to create each face
  54721. * @param size defines the size of the textures
  54722. * @param format defines the format of the data
  54723. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54724. * @param generateMipMaps defines if the engine should generate the mip levels
  54725. * @param invertY defines if data must be stored with Y axis inverted
  54726. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54727. * @param compression defines the compression used (null by default)
  54728. */
  54729. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54730. /**
  54731. * Updates the raw cube texture.
  54732. * @param data defines the data to store
  54733. * @param format defines the data format
  54734. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54735. * @param invertY defines if data must be stored with Y axis inverted
  54736. * @param compression defines the compression used (null by default)
  54737. * @param level defines which level of the texture to update
  54738. */
  54739. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54740. /**
  54741. * Updates a raw cube texture with RGBD encoded data.
  54742. * @param data defines the array of data [mipmap][face] to use to create each face
  54743. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54744. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54745. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54746. * @returns a promsie that resolves when the operation is complete
  54747. */
  54748. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54749. /**
  54750. * Clones the raw cube texture.
  54751. * @return a new cube texture
  54752. */
  54753. clone(): CubeTexture;
  54754. /** @hidden */
  54755. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54756. }
  54757. }
  54758. declare module BABYLON {
  54759. /**
  54760. * Class used to store 3D textures containing user data
  54761. */
  54762. export class RawTexture3D extends Texture {
  54763. /** Gets or sets the texture format to use */
  54764. format: number;
  54765. private _engine;
  54766. /**
  54767. * Create a new RawTexture3D
  54768. * @param data defines the data of the texture
  54769. * @param width defines the width of the texture
  54770. * @param height defines the height of the texture
  54771. * @param depth defines the depth of the texture
  54772. * @param format defines the texture format to use
  54773. * @param scene defines the hosting scene
  54774. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54775. * @param invertY defines if texture must be stored with Y axis inverted
  54776. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54777. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54778. */
  54779. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54780. /** Gets or sets the texture format to use */
  54781. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54782. /**
  54783. * Update the texture with new data
  54784. * @param data defines the data to store in the texture
  54785. */
  54786. update(data: ArrayBufferView): void;
  54787. }
  54788. }
  54789. declare module BABYLON {
  54790. /**
  54791. * Class used to store 2D array textures containing user data
  54792. */
  54793. export class RawTexture2DArray extends Texture {
  54794. /** Gets or sets the texture format to use */
  54795. format: number;
  54796. private _engine;
  54797. /**
  54798. * Create a new RawTexture2DArray
  54799. * @param data defines the data of the texture
  54800. * @param width defines the width of the texture
  54801. * @param height defines the height of the texture
  54802. * @param depth defines the number of layers of the texture
  54803. * @param format defines the texture format to use
  54804. * @param scene defines the hosting scene
  54805. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54806. * @param invertY defines if texture must be stored with Y axis inverted
  54807. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54808. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54809. */
  54810. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54811. /** Gets or sets the texture format to use */
  54812. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54813. /**
  54814. * Update the texture with new data
  54815. * @param data defines the data to store in the texture
  54816. */
  54817. update(data: ArrayBufferView): void;
  54818. }
  54819. }
  54820. declare module BABYLON {
  54821. /**
  54822. * Creates a refraction texture used by refraction channel of the standard material.
  54823. * It is like a mirror but to see through a material.
  54824. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54825. */
  54826. export class RefractionTexture extends RenderTargetTexture {
  54827. /**
  54828. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54829. * 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.
  54830. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54831. */
  54832. refractionPlane: Plane;
  54833. /**
  54834. * Define how deep under the surface we should see.
  54835. */
  54836. depth: number;
  54837. /**
  54838. * Creates a refraction texture used by refraction channel of the standard material.
  54839. * It is like a mirror but to see through a material.
  54840. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54841. * @param name Define the texture name
  54842. * @param size Define the size of the underlying texture
  54843. * @param scene Define the scene the refraction belongs to
  54844. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54845. */
  54846. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54847. /**
  54848. * Clone the refraction texture.
  54849. * @returns the cloned texture
  54850. */
  54851. clone(): RefractionTexture;
  54852. /**
  54853. * Serialize the texture to a JSON representation you could use in Parse later on
  54854. * @returns the serialized JSON representation
  54855. */
  54856. serialize(): any;
  54857. }
  54858. }
  54859. declare module BABYLON {
  54860. /**
  54861. * Defines the options related to the creation of an HtmlElementTexture
  54862. */
  54863. export interface IHtmlElementTextureOptions {
  54864. /**
  54865. * Defines wether mip maps should be created or not.
  54866. */
  54867. generateMipMaps?: boolean;
  54868. /**
  54869. * Defines the sampling mode of the texture.
  54870. */
  54871. samplingMode?: number;
  54872. /**
  54873. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54874. */
  54875. engine: Nullable<ThinEngine>;
  54876. /**
  54877. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54878. */
  54879. scene: Nullable<Scene>;
  54880. }
  54881. /**
  54882. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54883. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54884. * is automatically managed.
  54885. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54886. * in your application.
  54887. *
  54888. * As the update is not automatic, you need to call them manually.
  54889. */
  54890. export class HtmlElementTexture extends BaseTexture {
  54891. /**
  54892. * The texture URL.
  54893. */
  54894. element: HTMLVideoElement | HTMLCanvasElement;
  54895. private static readonly DefaultOptions;
  54896. private _textureMatrix;
  54897. private _engine;
  54898. private _isVideo;
  54899. private _generateMipMaps;
  54900. private _samplingMode;
  54901. /**
  54902. * Instantiates a HtmlElementTexture from the following parameters.
  54903. *
  54904. * @param name Defines the name of the texture
  54905. * @param element Defines the video or canvas the texture is filled with
  54906. * @param options Defines the other none mandatory texture creation options
  54907. */
  54908. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54909. private _createInternalTexture;
  54910. /**
  54911. * Returns the texture matrix used in most of the material.
  54912. */
  54913. getTextureMatrix(): Matrix;
  54914. /**
  54915. * Updates the content of the texture.
  54916. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54917. */
  54918. update(invertY?: Nullable<boolean>): void;
  54919. }
  54920. }
  54921. declare module BABYLON {
  54922. /**
  54923. * Enum used to define the target of a block
  54924. */
  54925. export enum NodeMaterialBlockTargets {
  54926. /** Vertex shader */
  54927. Vertex = 1,
  54928. /** Fragment shader */
  54929. Fragment = 2,
  54930. /** Neutral */
  54931. Neutral = 4,
  54932. /** Vertex and Fragment */
  54933. VertexAndFragment = 3
  54934. }
  54935. }
  54936. declare module BABYLON {
  54937. /**
  54938. * Defines the kind of connection point for node based material
  54939. */
  54940. export enum NodeMaterialBlockConnectionPointTypes {
  54941. /** Float */
  54942. Float = 1,
  54943. /** Int */
  54944. Int = 2,
  54945. /** Vector2 */
  54946. Vector2 = 4,
  54947. /** Vector3 */
  54948. Vector3 = 8,
  54949. /** Vector4 */
  54950. Vector4 = 16,
  54951. /** Color3 */
  54952. Color3 = 32,
  54953. /** Color4 */
  54954. Color4 = 64,
  54955. /** Matrix */
  54956. Matrix = 128,
  54957. /** Detect type based on connection */
  54958. AutoDetect = 1024,
  54959. /** Output type that will be defined by input type */
  54960. BasedOnInput = 2048
  54961. }
  54962. }
  54963. declare module BABYLON {
  54964. /**
  54965. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54966. */
  54967. export enum NodeMaterialBlockConnectionPointMode {
  54968. /** Value is an uniform */
  54969. Uniform = 0,
  54970. /** Value is a mesh attribute */
  54971. Attribute = 1,
  54972. /** Value is a varying between vertex and fragment shaders */
  54973. Varying = 2,
  54974. /** Mode is undefined */
  54975. Undefined = 3
  54976. }
  54977. }
  54978. declare module BABYLON {
  54979. /**
  54980. * Enum used to define system values e.g. values automatically provided by the system
  54981. */
  54982. export enum NodeMaterialSystemValues {
  54983. /** World */
  54984. World = 1,
  54985. /** View */
  54986. View = 2,
  54987. /** Projection */
  54988. Projection = 3,
  54989. /** ViewProjection */
  54990. ViewProjection = 4,
  54991. /** WorldView */
  54992. WorldView = 5,
  54993. /** WorldViewProjection */
  54994. WorldViewProjection = 6,
  54995. /** CameraPosition */
  54996. CameraPosition = 7,
  54997. /** Fog Color */
  54998. FogColor = 8,
  54999. /** Delta time */
  55000. DeltaTime = 9
  55001. }
  55002. }
  55003. declare module BABYLON {
  55004. /**
  55005. * Root class for all node material optimizers
  55006. */
  55007. export class NodeMaterialOptimizer {
  55008. /**
  55009. * Function used to optimize a NodeMaterial graph
  55010. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55011. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55012. */
  55013. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55014. }
  55015. }
  55016. declare module BABYLON {
  55017. /**
  55018. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55019. */
  55020. export class TransformBlock extends NodeMaterialBlock {
  55021. /**
  55022. * Defines the value to use to complement W value to transform it to a Vector4
  55023. */
  55024. complementW: number;
  55025. /**
  55026. * Defines the value to use to complement z value to transform it to a Vector4
  55027. */
  55028. complementZ: number;
  55029. /**
  55030. * Creates a new TransformBlock
  55031. * @param name defines the block name
  55032. */
  55033. constructor(name: string);
  55034. /**
  55035. * Gets the current class name
  55036. * @returns the class name
  55037. */
  55038. getClassName(): string;
  55039. /**
  55040. * Gets the vector input
  55041. */
  55042. get vector(): NodeMaterialConnectionPoint;
  55043. /**
  55044. * Gets the output component
  55045. */
  55046. get output(): NodeMaterialConnectionPoint;
  55047. /**
  55048. * Gets the matrix transform input
  55049. */
  55050. get transform(): NodeMaterialConnectionPoint;
  55051. protected _buildBlock(state: NodeMaterialBuildState): this;
  55052. serialize(): any;
  55053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55054. protected _dumpPropertiesCode(): string;
  55055. }
  55056. }
  55057. declare module BABYLON {
  55058. /**
  55059. * Block used to output the vertex position
  55060. */
  55061. export class VertexOutputBlock extends NodeMaterialBlock {
  55062. /**
  55063. * Creates a new VertexOutputBlock
  55064. * @param name defines the block name
  55065. */
  55066. constructor(name: string);
  55067. /**
  55068. * Gets the current class name
  55069. * @returns the class name
  55070. */
  55071. getClassName(): string;
  55072. /**
  55073. * Gets the vector input component
  55074. */
  55075. get vector(): NodeMaterialConnectionPoint;
  55076. protected _buildBlock(state: NodeMaterialBuildState): this;
  55077. }
  55078. }
  55079. declare module BABYLON {
  55080. /**
  55081. * Block used to output the final color
  55082. */
  55083. export class FragmentOutputBlock extends NodeMaterialBlock {
  55084. /**
  55085. * Create a new FragmentOutputBlock
  55086. * @param name defines the block name
  55087. */
  55088. constructor(name: string);
  55089. /**
  55090. * Gets the current class name
  55091. * @returns the class name
  55092. */
  55093. getClassName(): string;
  55094. /**
  55095. * Gets the rgba input component
  55096. */
  55097. get rgba(): NodeMaterialConnectionPoint;
  55098. /**
  55099. * Gets the rgb input component
  55100. */
  55101. get rgb(): NodeMaterialConnectionPoint;
  55102. /**
  55103. * Gets the a input component
  55104. */
  55105. get a(): NodeMaterialConnectionPoint;
  55106. protected _buildBlock(state: NodeMaterialBuildState): this;
  55107. }
  55108. }
  55109. declare module BABYLON {
  55110. /**
  55111. * Block used to read a reflection texture from a sampler
  55112. */
  55113. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55114. private _define3DName;
  55115. private _defineCubicName;
  55116. private _defineExplicitName;
  55117. private _defineProjectionName;
  55118. private _defineLocalCubicName;
  55119. private _defineSphericalName;
  55120. private _definePlanarName;
  55121. private _defineEquirectangularName;
  55122. private _defineMirroredEquirectangularFixedName;
  55123. private _defineEquirectangularFixedName;
  55124. private _defineSkyboxName;
  55125. private _cubeSamplerName;
  55126. private _2DSamplerName;
  55127. private _positionUVWName;
  55128. private _directionWName;
  55129. private _reflectionCoordsName;
  55130. private _reflection2DCoordsName;
  55131. private _reflectionColorName;
  55132. private _reflectionMatrixName;
  55133. /**
  55134. * Gets or sets the texture associated with the node
  55135. */
  55136. texture: Nullable<BaseTexture>;
  55137. /**
  55138. * Create a new TextureBlock
  55139. * @param name defines the block name
  55140. */
  55141. constructor(name: string);
  55142. /**
  55143. * Gets the current class name
  55144. * @returns the class name
  55145. */
  55146. getClassName(): string;
  55147. /**
  55148. * Gets the world position input component
  55149. */
  55150. get position(): NodeMaterialConnectionPoint;
  55151. /**
  55152. * Gets the world position input component
  55153. */
  55154. get worldPosition(): NodeMaterialConnectionPoint;
  55155. /**
  55156. * Gets the world normal input component
  55157. */
  55158. get worldNormal(): NodeMaterialConnectionPoint;
  55159. /**
  55160. * Gets the world input component
  55161. */
  55162. get world(): NodeMaterialConnectionPoint;
  55163. /**
  55164. * Gets the camera (or eye) position component
  55165. */
  55166. get cameraPosition(): NodeMaterialConnectionPoint;
  55167. /**
  55168. * Gets the view input component
  55169. */
  55170. get view(): NodeMaterialConnectionPoint;
  55171. /**
  55172. * Gets the rgb output component
  55173. */
  55174. get rgb(): NodeMaterialConnectionPoint;
  55175. /**
  55176. * Gets the r output component
  55177. */
  55178. get r(): NodeMaterialConnectionPoint;
  55179. /**
  55180. * Gets the g output component
  55181. */
  55182. get g(): NodeMaterialConnectionPoint;
  55183. /**
  55184. * Gets the b output component
  55185. */
  55186. get b(): NodeMaterialConnectionPoint;
  55187. autoConfigure(material: NodeMaterial): void;
  55188. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55189. isReady(): boolean;
  55190. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55191. private _injectVertexCode;
  55192. private _writeOutput;
  55193. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55194. protected _dumpPropertiesCode(): string;
  55195. serialize(): any;
  55196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55197. }
  55198. }
  55199. declare module BABYLON {
  55200. /**
  55201. * Interface used to configure the node material editor
  55202. */
  55203. export interface INodeMaterialEditorOptions {
  55204. /** Define the URl to load node editor script */
  55205. editorURL?: string;
  55206. }
  55207. /** @hidden */
  55208. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55209. /** BONES */
  55210. NUM_BONE_INFLUENCERS: number;
  55211. BonesPerMesh: number;
  55212. BONETEXTURE: boolean;
  55213. /** MORPH TARGETS */
  55214. MORPHTARGETS: boolean;
  55215. MORPHTARGETS_NORMAL: boolean;
  55216. MORPHTARGETS_TANGENT: boolean;
  55217. MORPHTARGETS_UV: boolean;
  55218. NUM_MORPH_INFLUENCERS: number;
  55219. /** IMAGE PROCESSING */
  55220. IMAGEPROCESSING: boolean;
  55221. VIGNETTE: boolean;
  55222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55223. VIGNETTEBLENDMODEOPAQUE: boolean;
  55224. TONEMAPPING: boolean;
  55225. TONEMAPPING_ACES: boolean;
  55226. CONTRAST: boolean;
  55227. EXPOSURE: boolean;
  55228. COLORCURVES: boolean;
  55229. COLORGRADING: boolean;
  55230. COLORGRADING3D: boolean;
  55231. SAMPLER3DGREENDEPTH: boolean;
  55232. SAMPLER3DBGRMAP: boolean;
  55233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55234. /** MISC. */
  55235. BUMPDIRECTUV: number;
  55236. constructor();
  55237. setValue(name: string, value: boolean): void;
  55238. }
  55239. /**
  55240. * Class used to configure NodeMaterial
  55241. */
  55242. export interface INodeMaterialOptions {
  55243. /**
  55244. * Defines if blocks should emit comments
  55245. */
  55246. emitComments: boolean;
  55247. }
  55248. /**
  55249. * Class used to create a node based material built by assembling shader blocks
  55250. */
  55251. export class NodeMaterial extends PushMaterial {
  55252. private static _BuildIdGenerator;
  55253. private _options;
  55254. private _vertexCompilationState;
  55255. private _fragmentCompilationState;
  55256. private _sharedData;
  55257. private _buildId;
  55258. private _buildWasSuccessful;
  55259. private _cachedWorldViewMatrix;
  55260. private _cachedWorldViewProjectionMatrix;
  55261. private _optimizers;
  55262. private _animationFrame;
  55263. /** Define the URl to load node editor script */
  55264. static EditorURL: string;
  55265. private BJSNODEMATERIALEDITOR;
  55266. /** Get the inspector from bundle or global */
  55267. private _getGlobalNodeMaterialEditor;
  55268. /**
  55269. * Gets or sets data used by visual editor
  55270. * @see https://nme.babylonjs.com
  55271. */
  55272. editorData: any;
  55273. /**
  55274. * 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)
  55275. */
  55276. ignoreAlpha: boolean;
  55277. /**
  55278. * Defines the maximum number of lights that can be used in the material
  55279. */
  55280. maxSimultaneousLights: number;
  55281. /**
  55282. * Observable raised when the material is built
  55283. */
  55284. onBuildObservable: Observable<NodeMaterial>;
  55285. /**
  55286. * Gets or sets the root nodes of the material vertex shader
  55287. */
  55288. _vertexOutputNodes: NodeMaterialBlock[];
  55289. /**
  55290. * Gets or sets the root nodes of the material fragment (pixel) shader
  55291. */
  55292. _fragmentOutputNodes: NodeMaterialBlock[];
  55293. /** Gets or sets options to control the node material overall behavior */
  55294. get options(): INodeMaterialOptions;
  55295. set options(options: INodeMaterialOptions);
  55296. /**
  55297. * Default configuration related to image processing available in the standard Material.
  55298. */
  55299. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55300. /**
  55301. * Gets the image processing configuration used either in this material.
  55302. */
  55303. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55304. /**
  55305. * Sets the Default image processing configuration used either in the this material.
  55306. *
  55307. * If sets to null, the scene one is in use.
  55308. */
  55309. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55310. /**
  55311. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55312. */
  55313. attachedBlocks: NodeMaterialBlock[];
  55314. /**
  55315. * Create a new node based material
  55316. * @param name defines the material name
  55317. * @param scene defines the hosting scene
  55318. * @param options defines creation option
  55319. */
  55320. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55321. /**
  55322. * Gets the current class name of the material e.g. "NodeMaterial"
  55323. * @returns the class name
  55324. */
  55325. getClassName(): string;
  55326. /**
  55327. * Keep track of the image processing observer to allow dispose and replace.
  55328. */
  55329. private _imageProcessingObserver;
  55330. /**
  55331. * Attaches a new image processing configuration to the Standard Material.
  55332. * @param configuration
  55333. */
  55334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55335. /**
  55336. * Get a block by its name
  55337. * @param name defines the name of the block to retrieve
  55338. * @returns the required block or null if not found
  55339. */
  55340. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55341. /**
  55342. * Get a block by its name
  55343. * @param predicate defines the predicate used to find the good candidate
  55344. * @returns the required block or null if not found
  55345. */
  55346. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55347. /**
  55348. * Get an input block by its name
  55349. * @param predicate defines the predicate used to find the good candidate
  55350. * @returns the required input block or null if not found
  55351. */
  55352. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55353. /**
  55354. * Gets the list of input blocks attached to this material
  55355. * @returns an array of InputBlocks
  55356. */
  55357. getInputBlocks(): InputBlock[];
  55358. /**
  55359. * Adds a new optimizer to the list of optimizers
  55360. * @param optimizer defines the optimizers to add
  55361. * @returns the current material
  55362. */
  55363. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55364. /**
  55365. * Remove an optimizer from the list of optimizers
  55366. * @param optimizer defines the optimizers to remove
  55367. * @returns the current material
  55368. */
  55369. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55370. /**
  55371. * Add a new block to the list of output nodes
  55372. * @param node defines the node to add
  55373. * @returns the current material
  55374. */
  55375. addOutputNode(node: NodeMaterialBlock): this;
  55376. /**
  55377. * Remove a block from the list of root nodes
  55378. * @param node defines the node to remove
  55379. * @returns the current material
  55380. */
  55381. removeOutputNode(node: NodeMaterialBlock): this;
  55382. private _addVertexOutputNode;
  55383. private _removeVertexOutputNode;
  55384. private _addFragmentOutputNode;
  55385. private _removeFragmentOutputNode;
  55386. /**
  55387. * Specifies if the material will require alpha blending
  55388. * @returns a boolean specifying if alpha blending is needed
  55389. */
  55390. needAlphaBlending(): boolean;
  55391. /**
  55392. * Specifies if this material should be rendered in alpha test mode
  55393. * @returns a boolean specifying if an alpha test is needed.
  55394. */
  55395. needAlphaTesting(): boolean;
  55396. private _initializeBlock;
  55397. private _resetDualBlocks;
  55398. /**
  55399. * Remove a block from the current node material
  55400. * @param block defines the block to remove
  55401. */
  55402. removeBlock(block: NodeMaterialBlock): void;
  55403. /**
  55404. * Build the material and generates the inner effect
  55405. * @param verbose defines if the build should log activity
  55406. */
  55407. build(verbose?: boolean): void;
  55408. /**
  55409. * Runs an otpimization phase to try to improve the shader code
  55410. */
  55411. optimize(): void;
  55412. private _prepareDefinesForAttributes;
  55413. /**
  55414. * Get if the submesh is ready to be used and all its information available.
  55415. * Child classes can use it to update shaders
  55416. * @param mesh defines the mesh to check
  55417. * @param subMesh defines which submesh to check
  55418. * @param useInstances specifies that instances should be used
  55419. * @returns a boolean indicating that the submesh is ready or not
  55420. */
  55421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55422. /**
  55423. * Get a string representing the shaders built by the current node graph
  55424. */
  55425. get compiledShaders(): string;
  55426. /**
  55427. * Binds the world matrix to the material
  55428. * @param world defines the world transformation matrix
  55429. */
  55430. bindOnlyWorldMatrix(world: Matrix): void;
  55431. /**
  55432. * Binds the submesh to this material by preparing the effect and shader to draw
  55433. * @param world defines the world transformation matrix
  55434. * @param mesh defines the mesh containing the submesh
  55435. * @param subMesh defines the submesh to bind the material to
  55436. */
  55437. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55438. /**
  55439. * Gets the active textures from the material
  55440. * @returns an array of textures
  55441. */
  55442. getActiveTextures(): BaseTexture[];
  55443. /**
  55444. * Gets the list of texture blocks
  55445. * @returns an array of texture blocks
  55446. */
  55447. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55448. /**
  55449. * Specifies if the material uses a texture
  55450. * @param texture defines the texture to check against the material
  55451. * @returns a boolean specifying if the material uses the texture
  55452. */
  55453. hasTexture(texture: BaseTexture): boolean;
  55454. /**
  55455. * Disposes the material
  55456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55458. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55459. */
  55460. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55461. /** Creates the node editor window. */
  55462. private _createNodeEditor;
  55463. /**
  55464. * Launch the node material editor
  55465. * @param config Define the configuration of the editor
  55466. * @return a promise fulfilled when the node editor is visible
  55467. */
  55468. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55469. /**
  55470. * Clear the current material
  55471. */
  55472. clear(): void;
  55473. /**
  55474. * Clear the current material and set it to a default state
  55475. */
  55476. setToDefault(): void;
  55477. /**
  55478. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55479. * @param url defines the url to load from
  55480. * @returns a promise that will fullfil when the material is fully loaded
  55481. */
  55482. loadAsync(url: string): Promise<void>;
  55483. private _gatherBlocks;
  55484. /**
  55485. * Generate a string containing the code declaration required to create an equivalent of this material
  55486. * @returns a string
  55487. */
  55488. generateCode(): string;
  55489. /**
  55490. * Serializes this material in a JSON representation
  55491. * @returns the serialized material object
  55492. */
  55493. serialize(): any;
  55494. private _restoreConnections;
  55495. /**
  55496. * Clear the current graph and load a new one from a serialization object
  55497. * @param source defines the JSON representation of the material
  55498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55499. */
  55500. loadFromSerialization(source: any, rootUrl?: string): void;
  55501. /**
  55502. * Creates a node material from parsed material data
  55503. * @param source defines the JSON representation of the material
  55504. * @param scene defines the hosting scene
  55505. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55506. * @returns a new node material
  55507. */
  55508. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55509. /**
  55510. * Creates a new node material set to default basic configuration
  55511. * @param name defines the name of the material
  55512. * @param scene defines the hosting scene
  55513. * @returns a new NodeMaterial
  55514. */
  55515. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55516. }
  55517. }
  55518. declare module BABYLON {
  55519. /**
  55520. * Block used to read a texture from a sampler
  55521. */
  55522. export class TextureBlock extends NodeMaterialBlock {
  55523. private _defineName;
  55524. private _linearDefineName;
  55525. private _tempTextureRead;
  55526. private _samplerName;
  55527. private _transformedUVName;
  55528. private _textureTransformName;
  55529. private _textureInfoName;
  55530. private _mainUVName;
  55531. private _mainUVDefineName;
  55532. /**
  55533. * Gets or sets the texture associated with the node
  55534. */
  55535. texture: Nullable<Texture>;
  55536. /**
  55537. * Create a new TextureBlock
  55538. * @param name defines the block name
  55539. */
  55540. constructor(name: string);
  55541. /**
  55542. * Gets the current class name
  55543. * @returns the class name
  55544. */
  55545. getClassName(): string;
  55546. /**
  55547. * Gets the uv input component
  55548. */
  55549. get uv(): NodeMaterialConnectionPoint;
  55550. /**
  55551. * Gets the rgba output component
  55552. */
  55553. get rgba(): NodeMaterialConnectionPoint;
  55554. /**
  55555. * Gets the rgb output component
  55556. */
  55557. get rgb(): NodeMaterialConnectionPoint;
  55558. /**
  55559. * Gets the r output component
  55560. */
  55561. get r(): NodeMaterialConnectionPoint;
  55562. /**
  55563. * Gets the g output component
  55564. */
  55565. get g(): NodeMaterialConnectionPoint;
  55566. /**
  55567. * Gets the b output component
  55568. */
  55569. get b(): NodeMaterialConnectionPoint;
  55570. /**
  55571. * Gets the a output component
  55572. */
  55573. get a(): NodeMaterialConnectionPoint;
  55574. get target(): NodeMaterialBlockTargets;
  55575. autoConfigure(material: NodeMaterial): void;
  55576. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55578. private _getTextureBase;
  55579. isReady(): boolean;
  55580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55581. private get _isMixed();
  55582. private _injectVertexCode;
  55583. private _writeTextureRead;
  55584. private _writeOutput;
  55585. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55586. protected _dumpPropertiesCode(): string;
  55587. serialize(): any;
  55588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55589. }
  55590. }
  55591. declare module BABYLON {
  55592. /**
  55593. * Class used to store shared data between 2 NodeMaterialBuildState
  55594. */
  55595. export class NodeMaterialBuildStateSharedData {
  55596. /**
  55597. * Gets the list of emitted varyings
  55598. */
  55599. temps: string[];
  55600. /**
  55601. * Gets the list of emitted varyings
  55602. */
  55603. varyings: string[];
  55604. /**
  55605. * Gets the varying declaration string
  55606. */
  55607. varyingDeclaration: string;
  55608. /**
  55609. * Input blocks
  55610. */
  55611. inputBlocks: InputBlock[];
  55612. /**
  55613. * Input blocks
  55614. */
  55615. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55616. /**
  55617. * Bindable blocks (Blocks that need to set data to the effect)
  55618. */
  55619. bindableBlocks: NodeMaterialBlock[];
  55620. /**
  55621. * List of blocks that can provide a compilation fallback
  55622. */
  55623. blocksWithFallbacks: NodeMaterialBlock[];
  55624. /**
  55625. * List of blocks that can provide a define update
  55626. */
  55627. blocksWithDefines: NodeMaterialBlock[];
  55628. /**
  55629. * List of blocks that can provide a repeatable content
  55630. */
  55631. repeatableContentBlocks: NodeMaterialBlock[];
  55632. /**
  55633. * List of blocks that can provide a dynamic list of uniforms
  55634. */
  55635. dynamicUniformBlocks: NodeMaterialBlock[];
  55636. /**
  55637. * List of blocks that can block the isReady function for the material
  55638. */
  55639. blockingBlocks: NodeMaterialBlock[];
  55640. /**
  55641. * Gets the list of animated inputs
  55642. */
  55643. animatedInputs: InputBlock[];
  55644. /**
  55645. * Build Id used to avoid multiple recompilations
  55646. */
  55647. buildId: number;
  55648. /** List of emitted variables */
  55649. variableNames: {
  55650. [key: string]: number;
  55651. };
  55652. /** List of emitted defines */
  55653. defineNames: {
  55654. [key: string]: number;
  55655. };
  55656. /** Should emit comments? */
  55657. emitComments: boolean;
  55658. /** Emit build activity */
  55659. verbose: boolean;
  55660. /** Gets or sets the hosting scene */
  55661. scene: Scene;
  55662. /**
  55663. * Gets the compilation hints emitted at compilation time
  55664. */
  55665. hints: {
  55666. needWorldViewMatrix: boolean;
  55667. needWorldViewProjectionMatrix: boolean;
  55668. needAlphaBlending: boolean;
  55669. needAlphaTesting: boolean;
  55670. };
  55671. /**
  55672. * List of compilation checks
  55673. */
  55674. checks: {
  55675. emitVertex: boolean;
  55676. emitFragment: boolean;
  55677. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55678. };
  55679. /** Creates a new shared data */
  55680. constructor();
  55681. /**
  55682. * Emits console errors and exceptions if there is a failing check
  55683. */
  55684. emitErrors(): void;
  55685. }
  55686. }
  55687. declare module BABYLON {
  55688. /**
  55689. * Class used to store node based material build state
  55690. */
  55691. export class NodeMaterialBuildState {
  55692. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55693. supportUniformBuffers: boolean;
  55694. /**
  55695. * Gets the list of emitted attributes
  55696. */
  55697. attributes: string[];
  55698. /**
  55699. * Gets the list of emitted uniforms
  55700. */
  55701. uniforms: string[];
  55702. /**
  55703. * Gets the list of emitted constants
  55704. */
  55705. constants: string[];
  55706. /**
  55707. * Gets the list of emitted samplers
  55708. */
  55709. samplers: string[];
  55710. /**
  55711. * Gets the list of emitted functions
  55712. */
  55713. functions: {
  55714. [key: string]: string;
  55715. };
  55716. /**
  55717. * Gets the list of emitted extensions
  55718. */
  55719. extensions: {
  55720. [key: string]: string;
  55721. };
  55722. /**
  55723. * Gets the target of the compilation state
  55724. */
  55725. target: NodeMaterialBlockTargets;
  55726. /**
  55727. * Gets the list of emitted counters
  55728. */
  55729. counters: {
  55730. [key: string]: number;
  55731. };
  55732. /**
  55733. * Shared data between multiple NodeMaterialBuildState instances
  55734. */
  55735. sharedData: NodeMaterialBuildStateSharedData;
  55736. /** @hidden */
  55737. _vertexState: NodeMaterialBuildState;
  55738. /** @hidden */
  55739. _attributeDeclaration: string;
  55740. /** @hidden */
  55741. _uniformDeclaration: string;
  55742. /** @hidden */
  55743. _constantDeclaration: string;
  55744. /** @hidden */
  55745. _samplerDeclaration: string;
  55746. /** @hidden */
  55747. _varyingTransfer: string;
  55748. private _repeatableContentAnchorIndex;
  55749. /** @hidden */
  55750. _builtCompilationString: string;
  55751. /**
  55752. * Gets the emitted compilation strings
  55753. */
  55754. compilationString: string;
  55755. /**
  55756. * Finalize the compilation strings
  55757. * @param state defines the current compilation state
  55758. */
  55759. finalize(state: NodeMaterialBuildState): void;
  55760. /** @hidden */
  55761. get _repeatableContentAnchor(): string;
  55762. /** @hidden */
  55763. _getFreeVariableName(prefix: string): string;
  55764. /** @hidden */
  55765. _getFreeDefineName(prefix: string): string;
  55766. /** @hidden */
  55767. _excludeVariableName(name: string): void;
  55768. /** @hidden */
  55769. _emit2DSampler(name: string): void;
  55770. /** @hidden */
  55771. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55772. /** @hidden */
  55773. _emitExtension(name: string, extension: string): void;
  55774. /** @hidden */
  55775. _emitFunction(name: string, code: string, comments: string): void;
  55776. /** @hidden */
  55777. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55778. replaceStrings?: {
  55779. search: RegExp;
  55780. replace: string;
  55781. }[];
  55782. repeatKey?: string;
  55783. }): string;
  55784. /** @hidden */
  55785. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55786. repeatKey?: string;
  55787. removeAttributes?: boolean;
  55788. removeUniforms?: boolean;
  55789. removeVaryings?: boolean;
  55790. removeIfDef?: boolean;
  55791. replaceStrings?: {
  55792. search: RegExp;
  55793. replace: string;
  55794. }[];
  55795. }, storeKey?: string): void;
  55796. /** @hidden */
  55797. _registerTempVariable(name: string): boolean;
  55798. /** @hidden */
  55799. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55800. /** @hidden */
  55801. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55802. /** @hidden */
  55803. _emitFloat(value: number): string;
  55804. }
  55805. }
  55806. declare module BABYLON {
  55807. /**
  55808. * Defines a block that can be used inside a node based material
  55809. */
  55810. export class NodeMaterialBlock {
  55811. private _buildId;
  55812. private _buildTarget;
  55813. private _target;
  55814. private _isFinalMerger;
  55815. private _isInput;
  55816. protected _isUnique: boolean;
  55817. /** @hidden */
  55818. _codeVariableName: string;
  55819. /** @hidden */
  55820. _inputs: NodeMaterialConnectionPoint[];
  55821. /** @hidden */
  55822. _outputs: NodeMaterialConnectionPoint[];
  55823. /** @hidden */
  55824. _preparationId: number;
  55825. /**
  55826. * Gets or sets the name of the block
  55827. */
  55828. name: string;
  55829. /**
  55830. * Gets or sets the unique id of the node
  55831. */
  55832. uniqueId: number;
  55833. /**
  55834. * Gets or sets the comments associated with this block
  55835. */
  55836. comments: string;
  55837. /**
  55838. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55839. */
  55840. get isUnique(): boolean;
  55841. /**
  55842. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55843. */
  55844. get isFinalMerger(): boolean;
  55845. /**
  55846. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55847. */
  55848. get isInput(): boolean;
  55849. /**
  55850. * Gets or sets the build Id
  55851. */
  55852. get buildId(): number;
  55853. set buildId(value: number);
  55854. /**
  55855. * Gets or sets the target of the block
  55856. */
  55857. get target(): NodeMaterialBlockTargets;
  55858. set target(value: NodeMaterialBlockTargets);
  55859. /**
  55860. * Gets the list of input points
  55861. */
  55862. get inputs(): NodeMaterialConnectionPoint[];
  55863. /** Gets the list of output points */
  55864. get outputs(): NodeMaterialConnectionPoint[];
  55865. /**
  55866. * Find an input by its name
  55867. * @param name defines the name of the input to look for
  55868. * @returns the input or null if not found
  55869. */
  55870. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55871. /**
  55872. * Find an output by its name
  55873. * @param name defines the name of the outputto look for
  55874. * @returns the output or null if not found
  55875. */
  55876. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55877. /**
  55878. * Creates a new NodeMaterialBlock
  55879. * @param name defines the block name
  55880. * @param target defines the target of that block (Vertex by default)
  55881. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55882. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55883. */
  55884. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55885. /**
  55886. * Initialize the block and prepare the context for build
  55887. * @param state defines the state that will be used for the build
  55888. */
  55889. initialize(state: NodeMaterialBuildState): void;
  55890. /**
  55891. * Bind data to effect. Will only be called for blocks with isBindable === true
  55892. * @param effect defines the effect to bind data to
  55893. * @param nodeMaterial defines the hosting NodeMaterial
  55894. * @param mesh defines the mesh that will be rendered
  55895. */
  55896. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55897. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55898. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55899. protected _writeFloat(value: number): string;
  55900. /**
  55901. * Gets the current class name e.g. "NodeMaterialBlock"
  55902. * @returns the class name
  55903. */
  55904. getClassName(): string;
  55905. /**
  55906. * Register a new input. Must be called inside a block constructor
  55907. * @param name defines the connection point name
  55908. * @param type defines the connection point type
  55909. * @param isOptional defines a boolean indicating that this input can be omitted
  55910. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55911. * @returns the current block
  55912. */
  55913. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55914. /**
  55915. * Register a new output. Must be called inside a block constructor
  55916. * @param name defines the connection point name
  55917. * @param type defines the connection point type
  55918. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55919. * @returns the current block
  55920. */
  55921. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55922. /**
  55923. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55924. * @param forOutput defines an optional connection point to check compatibility with
  55925. * @returns the first available input or null
  55926. */
  55927. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55928. /**
  55929. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55930. * @param forBlock defines an optional block to check compatibility with
  55931. * @returns the first available input or null
  55932. */
  55933. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55934. /**
  55935. * Gets the sibling of the given output
  55936. * @param current defines the current output
  55937. * @returns the next output in the list or null
  55938. */
  55939. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55940. /**
  55941. * Connect current block with another block
  55942. * @param other defines the block to connect with
  55943. * @param options define the various options to help pick the right connections
  55944. * @returns the current block
  55945. */
  55946. connectTo(other: NodeMaterialBlock, options?: {
  55947. input?: string;
  55948. output?: string;
  55949. outputSwizzle?: string;
  55950. }): this | undefined;
  55951. protected _buildBlock(state: NodeMaterialBuildState): void;
  55952. /**
  55953. * Add uniforms, samplers and uniform buffers at compilation time
  55954. * @param state defines the state to update
  55955. * @param nodeMaterial defines the node material requesting the update
  55956. * @param defines defines the material defines to update
  55957. * @param uniformBuffers defines the list of uniform buffer names
  55958. */
  55959. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55960. /**
  55961. * Add potential fallbacks if shader compilation fails
  55962. * @param mesh defines the mesh to be rendered
  55963. * @param fallbacks defines the current prioritized list of fallbacks
  55964. */
  55965. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55966. /**
  55967. * Initialize defines for shader compilation
  55968. * @param mesh defines the mesh to be rendered
  55969. * @param nodeMaterial defines the node material requesting the update
  55970. * @param defines defines the material defines to update
  55971. * @param useInstances specifies that instances should be used
  55972. */
  55973. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55974. /**
  55975. * Update defines for shader compilation
  55976. * @param mesh defines the mesh to be rendered
  55977. * @param nodeMaterial defines the node material requesting the update
  55978. * @param defines defines the material defines to update
  55979. * @param useInstances specifies that instances should be used
  55980. */
  55981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55982. /**
  55983. * Lets the block try to connect some inputs automatically
  55984. * @param material defines the hosting NodeMaterial
  55985. */
  55986. autoConfigure(material: NodeMaterial): void;
  55987. /**
  55988. * Function called when a block is declared as repeatable content generator
  55989. * @param vertexShaderState defines the current compilation state for the vertex shader
  55990. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55991. * @param mesh defines the mesh to be rendered
  55992. * @param defines defines the material defines to update
  55993. */
  55994. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55995. /**
  55996. * Checks if the block is ready
  55997. * @param mesh defines the mesh to be rendered
  55998. * @param nodeMaterial defines the node material requesting the update
  55999. * @param defines defines the material defines to update
  56000. * @param useInstances specifies that instances should be used
  56001. * @returns true if the block is ready
  56002. */
  56003. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56004. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56005. private _processBuild;
  56006. /**
  56007. * Compile the current node and generate the shader code
  56008. * @param state defines the current compilation state (uniforms, samplers, current string)
  56009. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56010. * @returns true if already built
  56011. */
  56012. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56013. protected _inputRename(name: string): string;
  56014. protected _outputRename(name: string): string;
  56015. protected _dumpPropertiesCode(): string;
  56016. /** @hidden */
  56017. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56018. /** @hidden */
  56019. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56020. /**
  56021. * Clone the current block to a new identical block
  56022. * @param scene defines the hosting scene
  56023. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56024. * @returns a copy of the current block
  56025. */
  56026. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56027. /**
  56028. * Serializes this block in a JSON representation
  56029. * @returns the serialized block object
  56030. */
  56031. serialize(): any;
  56032. /** @hidden */
  56033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56034. /**
  56035. * Release resources
  56036. */
  56037. dispose(): void;
  56038. }
  56039. }
  56040. declare module BABYLON {
  56041. /**
  56042. * Enum defining the type of animations supported by InputBlock
  56043. */
  56044. export enum AnimatedInputBlockTypes {
  56045. /** No animation */
  56046. None = 0,
  56047. /** Time based animation. Will only work for floats */
  56048. Time = 1
  56049. }
  56050. }
  56051. declare module BABYLON {
  56052. /**
  56053. * Block used to expose an input value
  56054. */
  56055. export class InputBlock extends NodeMaterialBlock {
  56056. private _mode;
  56057. private _associatedVariableName;
  56058. private _storedValue;
  56059. private _valueCallback;
  56060. private _type;
  56061. private _animationType;
  56062. /** Gets or set a value used to limit the range of float values */
  56063. min: number;
  56064. /** Gets or set a value used to limit the range of float values */
  56065. max: number;
  56066. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56067. matrixMode: number;
  56068. /** @hidden */
  56069. _systemValue: Nullable<NodeMaterialSystemValues>;
  56070. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56071. visibleInInspector: boolean;
  56072. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56073. isConstant: boolean;
  56074. /** Gets or sets the group to use to display this block in the Inspector */
  56075. groupInInspector: string;
  56076. /**
  56077. * Gets or sets the connection point type (default is float)
  56078. */
  56079. get type(): NodeMaterialBlockConnectionPointTypes;
  56080. /**
  56081. * Creates a new InputBlock
  56082. * @param name defines the block name
  56083. * @param target defines the target of that block (Vertex by default)
  56084. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56085. */
  56086. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56087. /**
  56088. * Gets the output component
  56089. */
  56090. get output(): NodeMaterialConnectionPoint;
  56091. /**
  56092. * Set the source of this connection point to a vertex attribute
  56093. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56094. * @returns the current connection point
  56095. */
  56096. setAsAttribute(attributeName?: string): InputBlock;
  56097. /**
  56098. * Set the source of this connection point to a system value
  56099. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56100. * @returns the current connection point
  56101. */
  56102. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56103. /**
  56104. * Gets or sets the value of that point.
  56105. * Please note that this value will be ignored if valueCallback is defined
  56106. */
  56107. get value(): any;
  56108. set value(value: any);
  56109. /**
  56110. * Gets or sets a callback used to get the value of that point.
  56111. * Please note that setting this value will force the connection point to ignore the value property
  56112. */
  56113. get valueCallback(): () => any;
  56114. set valueCallback(value: () => any);
  56115. /**
  56116. * Gets or sets the associated variable name in the shader
  56117. */
  56118. get associatedVariableName(): string;
  56119. set associatedVariableName(value: string);
  56120. /** Gets or sets the type of animation applied to the input */
  56121. get animationType(): AnimatedInputBlockTypes;
  56122. set animationType(value: AnimatedInputBlockTypes);
  56123. /**
  56124. * Gets a boolean indicating that this connection point not defined yet
  56125. */
  56126. get isUndefined(): boolean;
  56127. /**
  56128. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56129. * In this case the connection point name must be the name of the uniform to use.
  56130. * Can only be set on inputs
  56131. */
  56132. get isUniform(): boolean;
  56133. set isUniform(value: boolean);
  56134. /**
  56135. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56136. * In this case the connection point name must be the name of the attribute to use
  56137. * Can only be set on inputs
  56138. */
  56139. get isAttribute(): boolean;
  56140. set isAttribute(value: boolean);
  56141. /**
  56142. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56143. * Can only be set on exit points
  56144. */
  56145. get isVarying(): boolean;
  56146. set isVarying(value: boolean);
  56147. /**
  56148. * Gets a boolean indicating that the current connection point is a system value
  56149. */
  56150. get isSystemValue(): boolean;
  56151. /**
  56152. * Gets or sets the current well known value or null if not defined as a system value
  56153. */
  56154. get systemValue(): Nullable<NodeMaterialSystemValues>;
  56155. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  56156. /**
  56157. * Gets the current class name
  56158. * @returns the class name
  56159. */
  56160. getClassName(): string;
  56161. /**
  56162. * Animate the input if animationType !== None
  56163. * @param scene defines the rendering scene
  56164. */
  56165. animate(scene: Scene): void;
  56166. private _emitDefine;
  56167. initialize(state: NodeMaterialBuildState): void;
  56168. /**
  56169. * Set the input block to its default value (based on its type)
  56170. */
  56171. setDefaultValue(): void;
  56172. private _emitConstant;
  56173. private _emit;
  56174. /** @hidden */
  56175. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56176. /** @hidden */
  56177. _transmit(effect: Effect, scene: Scene): void;
  56178. protected _buildBlock(state: NodeMaterialBuildState): void;
  56179. protected _dumpPropertiesCode(): string;
  56180. serialize(): any;
  56181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56182. }
  56183. }
  56184. declare module BABYLON {
  56185. /**
  56186. * Enum used to define the compatibility state between two connection points
  56187. */
  56188. export enum NodeMaterialConnectionPointCompatibilityStates {
  56189. /** Points are compatibles */
  56190. Compatible = 0,
  56191. /** Points are incompatible because of their types */
  56192. TypeIncompatible = 1,
  56193. /** Points are incompatible because of their targets (vertex vs fragment) */
  56194. TargetIncompatible = 2
  56195. }
  56196. /**
  56197. * Defines the direction of a connection point
  56198. */
  56199. export enum NodeMaterialConnectionPointDirection {
  56200. /** Input */
  56201. Input = 0,
  56202. /** Output */
  56203. Output = 1
  56204. }
  56205. /**
  56206. * Defines a connection point for a block
  56207. */
  56208. export class NodeMaterialConnectionPoint {
  56209. /** @hidden */
  56210. _ownerBlock: NodeMaterialBlock;
  56211. /** @hidden */
  56212. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56213. private _endpoints;
  56214. private _associatedVariableName;
  56215. private _direction;
  56216. /** @hidden */
  56217. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56218. /** @hidden */
  56219. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56220. private _type;
  56221. /** @hidden */
  56222. _enforceAssociatedVariableName: boolean;
  56223. /** Gets the direction of the point */
  56224. get direction(): NodeMaterialConnectionPointDirection;
  56225. /**
  56226. * Gets or sets the additional types supported by this connection point
  56227. */
  56228. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56229. /**
  56230. * Gets or sets the additional types excluded by this connection point
  56231. */
  56232. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56233. /**
  56234. * Observable triggered when this point is connected
  56235. */
  56236. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56237. /**
  56238. * Gets or sets the associated variable name in the shader
  56239. */
  56240. get associatedVariableName(): string;
  56241. set associatedVariableName(value: string);
  56242. /**
  56243. * Gets or sets the connection point type (default is float)
  56244. */
  56245. get type(): NodeMaterialBlockConnectionPointTypes;
  56246. set type(value: NodeMaterialBlockConnectionPointTypes);
  56247. /**
  56248. * Gets or sets the connection point name
  56249. */
  56250. name: string;
  56251. /**
  56252. * Gets or sets a boolean indicating that this connection point can be omitted
  56253. */
  56254. isOptional: boolean;
  56255. /**
  56256. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56257. */
  56258. define: string;
  56259. /** @hidden */
  56260. _prioritizeVertex: boolean;
  56261. private _target;
  56262. /** Gets or sets the target of that connection point */
  56263. get target(): NodeMaterialBlockTargets;
  56264. set target(value: NodeMaterialBlockTargets);
  56265. /**
  56266. * Gets a boolean indicating that the current point is connected
  56267. */
  56268. get isConnected(): boolean;
  56269. /**
  56270. * Gets a boolean indicating that the current point is connected to an input block
  56271. */
  56272. get isConnectedToInputBlock(): boolean;
  56273. /**
  56274. * Gets a the connected input block (if any)
  56275. */
  56276. get connectInputBlock(): Nullable<InputBlock>;
  56277. /** Get the other side of the connection (if any) */
  56278. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  56279. /** Get the block that owns this connection point */
  56280. get ownerBlock(): NodeMaterialBlock;
  56281. /** Get the block connected on the other side of this connection (if any) */
  56282. get sourceBlock(): Nullable<NodeMaterialBlock>;
  56283. /** Get the block connected on the endpoints of this connection (if any) */
  56284. get connectedBlocks(): Array<NodeMaterialBlock>;
  56285. /** Gets the list of connected endpoints */
  56286. get endpoints(): NodeMaterialConnectionPoint[];
  56287. /** Gets a boolean indicating if that output point is connected to at least one input */
  56288. get hasEndpoints(): boolean;
  56289. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56290. get isConnectedInVertexShader(): boolean;
  56291. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56292. get isConnectedInFragmentShader(): boolean;
  56293. /**
  56294. * Creates a new connection point
  56295. * @param name defines the connection point name
  56296. * @param ownerBlock defines the block hosting this connection point
  56297. * @param direction defines the direction of the connection point
  56298. */
  56299. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  56300. /**
  56301. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56302. * @returns the class name
  56303. */
  56304. getClassName(): string;
  56305. /**
  56306. * Gets a boolean indicating if the current point can be connected to another point
  56307. * @param connectionPoint defines the other connection point
  56308. * @returns a boolean
  56309. */
  56310. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56311. /**
  56312. * Gets a number indicating if the current point can be connected to another point
  56313. * @param connectionPoint defines the other connection point
  56314. * @returns a number defining the compatibility state
  56315. */
  56316. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  56317. /**
  56318. * Connect this point to another connection point
  56319. * @param connectionPoint defines the other connection point
  56320. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56321. * @returns the current connection point
  56322. */
  56323. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56324. /**
  56325. * Disconnect this point from one of his endpoint
  56326. * @param endpoint defines the other connection point
  56327. * @returns the current connection point
  56328. */
  56329. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56330. /**
  56331. * Serializes this point in a JSON representation
  56332. * @returns the serialized point object
  56333. */
  56334. serialize(): any;
  56335. /**
  56336. * Release resources
  56337. */
  56338. dispose(): void;
  56339. }
  56340. }
  56341. declare module BABYLON {
  56342. /**
  56343. * Block used to add support for vertex skinning (bones)
  56344. */
  56345. export class BonesBlock extends NodeMaterialBlock {
  56346. /**
  56347. * Creates a new BonesBlock
  56348. * @param name defines the block name
  56349. */
  56350. constructor(name: string);
  56351. /**
  56352. * Initialize the block and prepare the context for build
  56353. * @param state defines the state that will be used for the build
  56354. */
  56355. initialize(state: NodeMaterialBuildState): void;
  56356. /**
  56357. * Gets the current class name
  56358. * @returns the class name
  56359. */
  56360. getClassName(): string;
  56361. /**
  56362. * Gets the matrix indices input component
  56363. */
  56364. get matricesIndices(): NodeMaterialConnectionPoint;
  56365. /**
  56366. * Gets the matrix weights input component
  56367. */
  56368. get matricesWeights(): NodeMaterialConnectionPoint;
  56369. /**
  56370. * Gets the extra matrix indices input component
  56371. */
  56372. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  56373. /**
  56374. * Gets the extra matrix weights input component
  56375. */
  56376. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  56377. /**
  56378. * Gets the world input component
  56379. */
  56380. get world(): NodeMaterialConnectionPoint;
  56381. /**
  56382. * Gets the output component
  56383. */
  56384. get output(): NodeMaterialConnectionPoint;
  56385. autoConfigure(material: NodeMaterial): void;
  56386. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56389. protected _buildBlock(state: NodeMaterialBuildState): this;
  56390. }
  56391. }
  56392. declare module BABYLON {
  56393. /**
  56394. * Block used to add support for instances
  56395. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56396. */
  56397. export class InstancesBlock extends NodeMaterialBlock {
  56398. /**
  56399. * Creates a new InstancesBlock
  56400. * @param name defines the block name
  56401. */
  56402. constructor(name: string);
  56403. /**
  56404. * Gets the current class name
  56405. * @returns the class name
  56406. */
  56407. getClassName(): string;
  56408. /**
  56409. * Gets the first world row input component
  56410. */
  56411. get world0(): NodeMaterialConnectionPoint;
  56412. /**
  56413. * Gets the second world row input component
  56414. */
  56415. get world1(): NodeMaterialConnectionPoint;
  56416. /**
  56417. * Gets the third world row input component
  56418. */
  56419. get world2(): NodeMaterialConnectionPoint;
  56420. /**
  56421. * Gets the forth world row input component
  56422. */
  56423. get world3(): NodeMaterialConnectionPoint;
  56424. /**
  56425. * Gets the world input component
  56426. */
  56427. get world(): NodeMaterialConnectionPoint;
  56428. /**
  56429. * Gets the output component
  56430. */
  56431. get output(): NodeMaterialConnectionPoint;
  56432. autoConfigure(material: NodeMaterial): void;
  56433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56434. protected _buildBlock(state: NodeMaterialBuildState): this;
  56435. }
  56436. }
  56437. declare module BABYLON {
  56438. /**
  56439. * Block used to add morph targets support to vertex shader
  56440. */
  56441. export class MorphTargetsBlock extends NodeMaterialBlock {
  56442. private _repeatableContentAnchor;
  56443. private _repeatebleContentGenerated;
  56444. /**
  56445. * Create a new MorphTargetsBlock
  56446. * @param name defines the block name
  56447. */
  56448. constructor(name: string);
  56449. /**
  56450. * Gets the current class name
  56451. * @returns the class name
  56452. */
  56453. getClassName(): string;
  56454. /**
  56455. * Gets the position input component
  56456. */
  56457. get position(): NodeMaterialConnectionPoint;
  56458. /**
  56459. * Gets the normal input component
  56460. */
  56461. get normal(): NodeMaterialConnectionPoint;
  56462. /**
  56463. * Gets the tangent input component
  56464. */
  56465. get tangent(): NodeMaterialConnectionPoint;
  56466. /**
  56467. * Gets the tangent input component
  56468. */
  56469. get uv(): NodeMaterialConnectionPoint;
  56470. /**
  56471. * Gets the position output component
  56472. */
  56473. get positionOutput(): NodeMaterialConnectionPoint;
  56474. /**
  56475. * Gets the normal output component
  56476. */
  56477. get normalOutput(): NodeMaterialConnectionPoint;
  56478. /**
  56479. * Gets the tangent output component
  56480. */
  56481. get tangentOutput(): NodeMaterialConnectionPoint;
  56482. /**
  56483. * Gets the tangent output component
  56484. */
  56485. get uvOutput(): NodeMaterialConnectionPoint;
  56486. initialize(state: NodeMaterialBuildState): void;
  56487. autoConfigure(material: NodeMaterial): void;
  56488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56489. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56490. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56491. protected _buildBlock(state: NodeMaterialBuildState): this;
  56492. }
  56493. }
  56494. declare module BABYLON {
  56495. /**
  56496. * Block used to get data information from a light
  56497. */
  56498. export class LightInformationBlock extends NodeMaterialBlock {
  56499. private _lightDataUniformName;
  56500. private _lightColorUniformName;
  56501. private _lightTypeDefineName;
  56502. /**
  56503. * Gets or sets the light associated with this block
  56504. */
  56505. light: Nullable<Light>;
  56506. /**
  56507. * Creates a new LightInformationBlock
  56508. * @param name defines the block name
  56509. */
  56510. constructor(name: string);
  56511. /**
  56512. * Gets the current class name
  56513. * @returns the class name
  56514. */
  56515. getClassName(): string;
  56516. /**
  56517. * Gets the world position input component
  56518. */
  56519. get worldPosition(): NodeMaterialConnectionPoint;
  56520. /**
  56521. * Gets the direction output component
  56522. */
  56523. get direction(): NodeMaterialConnectionPoint;
  56524. /**
  56525. * Gets the direction output component
  56526. */
  56527. get color(): NodeMaterialConnectionPoint;
  56528. /**
  56529. * Gets the direction output component
  56530. */
  56531. get intensity(): NodeMaterialConnectionPoint;
  56532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56534. protected _buildBlock(state: NodeMaterialBuildState): this;
  56535. serialize(): any;
  56536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56537. }
  56538. }
  56539. declare module BABYLON {
  56540. /**
  56541. * Block used to add image processing support to fragment shader
  56542. */
  56543. export class ImageProcessingBlock extends NodeMaterialBlock {
  56544. /**
  56545. * Create a new ImageProcessingBlock
  56546. * @param name defines the block name
  56547. */
  56548. constructor(name: string);
  56549. /**
  56550. * Gets the current class name
  56551. * @returns the class name
  56552. */
  56553. getClassName(): string;
  56554. /**
  56555. * Gets the color input component
  56556. */
  56557. get color(): NodeMaterialConnectionPoint;
  56558. /**
  56559. * Gets the output component
  56560. */
  56561. get output(): NodeMaterialConnectionPoint;
  56562. /**
  56563. * Initialize the block and prepare the context for build
  56564. * @param state defines the state that will be used for the build
  56565. */
  56566. initialize(state: NodeMaterialBuildState): void;
  56567. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56569. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56570. protected _buildBlock(state: NodeMaterialBuildState): this;
  56571. }
  56572. }
  56573. declare module BABYLON {
  56574. /**
  56575. * Block used to pertub normals based on a normal map
  56576. */
  56577. export class PerturbNormalBlock extends NodeMaterialBlock {
  56578. private _tangentSpaceParameterName;
  56579. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56580. invertX: boolean;
  56581. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56582. invertY: boolean;
  56583. /**
  56584. * Create a new PerturbNormalBlock
  56585. * @param name defines the block name
  56586. */
  56587. constructor(name: string);
  56588. /**
  56589. * Gets the current class name
  56590. * @returns the class name
  56591. */
  56592. getClassName(): string;
  56593. /**
  56594. * Gets the world position input component
  56595. */
  56596. get worldPosition(): NodeMaterialConnectionPoint;
  56597. /**
  56598. * Gets the world normal input component
  56599. */
  56600. get worldNormal(): NodeMaterialConnectionPoint;
  56601. /**
  56602. * Gets the uv input component
  56603. */
  56604. get uv(): NodeMaterialConnectionPoint;
  56605. /**
  56606. * Gets the normal map color input component
  56607. */
  56608. get normalMapColor(): NodeMaterialConnectionPoint;
  56609. /**
  56610. * Gets the strength input component
  56611. */
  56612. get strength(): NodeMaterialConnectionPoint;
  56613. /**
  56614. * Gets the output component
  56615. */
  56616. get output(): NodeMaterialConnectionPoint;
  56617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56619. autoConfigure(material: NodeMaterial): void;
  56620. protected _buildBlock(state: NodeMaterialBuildState): this;
  56621. protected _dumpPropertiesCode(): string;
  56622. serialize(): any;
  56623. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56624. }
  56625. }
  56626. declare module BABYLON {
  56627. /**
  56628. * Block used to discard a pixel if a value is smaller than a cutoff
  56629. */
  56630. export class DiscardBlock extends NodeMaterialBlock {
  56631. /**
  56632. * Create a new DiscardBlock
  56633. * @param name defines the block name
  56634. */
  56635. constructor(name: string);
  56636. /**
  56637. * Gets the current class name
  56638. * @returns the class name
  56639. */
  56640. getClassName(): string;
  56641. /**
  56642. * Gets the color input component
  56643. */
  56644. get value(): NodeMaterialConnectionPoint;
  56645. /**
  56646. * Gets the cutoff input component
  56647. */
  56648. get cutoff(): NodeMaterialConnectionPoint;
  56649. protected _buildBlock(state: NodeMaterialBuildState): this;
  56650. }
  56651. }
  56652. declare module BABYLON {
  56653. /**
  56654. * Block used to test if the fragment shader is front facing
  56655. */
  56656. export class FrontFacingBlock extends NodeMaterialBlock {
  56657. /**
  56658. * Creates a new FrontFacingBlock
  56659. * @param name defines the block name
  56660. */
  56661. constructor(name: string);
  56662. /**
  56663. * Gets the current class name
  56664. * @returns the class name
  56665. */
  56666. getClassName(): string;
  56667. /**
  56668. * Gets the output component
  56669. */
  56670. get output(): NodeMaterialConnectionPoint;
  56671. protected _buildBlock(state: NodeMaterialBuildState): this;
  56672. }
  56673. }
  56674. declare module BABYLON {
  56675. /**
  56676. * Block used to get the derivative value on x and y of a given input
  56677. */
  56678. export class DerivativeBlock extends NodeMaterialBlock {
  56679. /**
  56680. * Create a new DerivativeBlock
  56681. * @param name defines the block name
  56682. */
  56683. constructor(name: string);
  56684. /**
  56685. * Gets the current class name
  56686. * @returns the class name
  56687. */
  56688. getClassName(): string;
  56689. /**
  56690. * Gets the input component
  56691. */
  56692. get input(): NodeMaterialConnectionPoint;
  56693. /**
  56694. * Gets the derivative output on x
  56695. */
  56696. get dx(): NodeMaterialConnectionPoint;
  56697. /**
  56698. * Gets the derivative output on y
  56699. */
  56700. get dy(): NodeMaterialConnectionPoint;
  56701. protected _buildBlock(state: NodeMaterialBuildState): this;
  56702. }
  56703. }
  56704. declare module BABYLON {
  56705. /**
  56706. * Block used to add support for scene fog
  56707. */
  56708. export class FogBlock extends NodeMaterialBlock {
  56709. private _fogDistanceName;
  56710. private _fogParameters;
  56711. /**
  56712. * Create a new FogBlock
  56713. * @param name defines the block name
  56714. */
  56715. constructor(name: string);
  56716. /**
  56717. * Gets the current class name
  56718. * @returns the class name
  56719. */
  56720. getClassName(): string;
  56721. /**
  56722. * Gets the world position input component
  56723. */
  56724. get worldPosition(): NodeMaterialConnectionPoint;
  56725. /**
  56726. * Gets the view input component
  56727. */
  56728. get view(): NodeMaterialConnectionPoint;
  56729. /**
  56730. * Gets the color input component
  56731. */
  56732. get input(): NodeMaterialConnectionPoint;
  56733. /**
  56734. * Gets the fog color input component
  56735. */
  56736. get fogColor(): NodeMaterialConnectionPoint;
  56737. /**
  56738. * Gets the output component
  56739. */
  56740. get output(): NodeMaterialConnectionPoint;
  56741. autoConfigure(material: NodeMaterial): void;
  56742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56743. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56744. protected _buildBlock(state: NodeMaterialBuildState): this;
  56745. }
  56746. }
  56747. declare module BABYLON {
  56748. /**
  56749. * Block used to add light in the fragment shader
  56750. */
  56751. export class LightBlock extends NodeMaterialBlock {
  56752. private _lightId;
  56753. /**
  56754. * Gets or sets the light associated with this block
  56755. */
  56756. light: Nullable<Light>;
  56757. /**
  56758. * Create a new LightBlock
  56759. * @param name defines the block name
  56760. */
  56761. constructor(name: string);
  56762. /**
  56763. * Gets the current class name
  56764. * @returns the class name
  56765. */
  56766. getClassName(): string;
  56767. /**
  56768. * Gets the world position input component
  56769. */
  56770. get worldPosition(): NodeMaterialConnectionPoint;
  56771. /**
  56772. * Gets the world normal input component
  56773. */
  56774. get worldNormal(): NodeMaterialConnectionPoint;
  56775. /**
  56776. * Gets the camera (or eye) position component
  56777. */
  56778. get cameraPosition(): NodeMaterialConnectionPoint;
  56779. /**
  56780. * Gets the glossiness component
  56781. */
  56782. get glossiness(): NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the glossinness power component
  56785. */
  56786. get glossPower(): NodeMaterialConnectionPoint;
  56787. /**
  56788. * Gets the diffuse color component
  56789. */
  56790. get diffuseColor(): NodeMaterialConnectionPoint;
  56791. /**
  56792. * Gets the specular color component
  56793. */
  56794. get specularColor(): NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the diffuse output component
  56797. */
  56798. get diffuseOutput(): NodeMaterialConnectionPoint;
  56799. /**
  56800. * Gets the specular output component
  56801. */
  56802. get specularOutput(): NodeMaterialConnectionPoint;
  56803. autoConfigure(material: NodeMaterial): void;
  56804. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56805. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56807. private _injectVertexCode;
  56808. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56809. serialize(): any;
  56810. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56811. }
  56812. }
  56813. declare module BABYLON {
  56814. /**
  56815. * Block used to multiply 2 values
  56816. */
  56817. export class MultiplyBlock extends NodeMaterialBlock {
  56818. /**
  56819. * Creates a new MultiplyBlock
  56820. * @param name defines the block name
  56821. */
  56822. constructor(name: string);
  56823. /**
  56824. * Gets the current class name
  56825. * @returns the class name
  56826. */
  56827. getClassName(): string;
  56828. /**
  56829. * Gets the left operand input component
  56830. */
  56831. get left(): NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the right operand input component
  56834. */
  56835. get right(): NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the output component
  56838. */
  56839. get output(): NodeMaterialConnectionPoint;
  56840. protected _buildBlock(state: NodeMaterialBuildState): this;
  56841. }
  56842. }
  56843. declare module BABYLON {
  56844. /**
  56845. * Block used to add 2 vectors
  56846. */
  56847. export class AddBlock extends NodeMaterialBlock {
  56848. /**
  56849. * Creates a new AddBlock
  56850. * @param name defines the block name
  56851. */
  56852. constructor(name: string);
  56853. /**
  56854. * Gets the current class name
  56855. * @returns the class name
  56856. */
  56857. getClassName(): string;
  56858. /**
  56859. * Gets the left operand input component
  56860. */
  56861. get left(): NodeMaterialConnectionPoint;
  56862. /**
  56863. * Gets the right operand input component
  56864. */
  56865. get right(): NodeMaterialConnectionPoint;
  56866. /**
  56867. * Gets the output component
  56868. */
  56869. get output(): NodeMaterialConnectionPoint;
  56870. protected _buildBlock(state: NodeMaterialBuildState): this;
  56871. }
  56872. }
  56873. declare module BABYLON {
  56874. /**
  56875. * Block used to scale a vector by a float
  56876. */
  56877. export class ScaleBlock extends NodeMaterialBlock {
  56878. /**
  56879. * Creates a new ScaleBlock
  56880. * @param name defines the block name
  56881. */
  56882. constructor(name: string);
  56883. /**
  56884. * Gets the current class name
  56885. * @returns the class name
  56886. */
  56887. getClassName(): string;
  56888. /**
  56889. * Gets the input component
  56890. */
  56891. get input(): NodeMaterialConnectionPoint;
  56892. /**
  56893. * Gets the factor input component
  56894. */
  56895. get factor(): NodeMaterialConnectionPoint;
  56896. /**
  56897. * Gets the output component
  56898. */
  56899. get output(): NodeMaterialConnectionPoint;
  56900. protected _buildBlock(state: NodeMaterialBuildState): this;
  56901. }
  56902. }
  56903. declare module BABYLON {
  56904. /**
  56905. * Block used to clamp a float
  56906. */
  56907. export class ClampBlock extends NodeMaterialBlock {
  56908. /** Gets or sets the minimum range */
  56909. minimum: number;
  56910. /** Gets or sets the maximum range */
  56911. maximum: number;
  56912. /**
  56913. * Creates a new ClampBlock
  56914. * @param name defines the block name
  56915. */
  56916. constructor(name: string);
  56917. /**
  56918. * Gets the current class name
  56919. * @returns the class name
  56920. */
  56921. getClassName(): string;
  56922. /**
  56923. * Gets the value input component
  56924. */
  56925. get value(): NodeMaterialConnectionPoint;
  56926. /**
  56927. * Gets the output component
  56928. */
  56929. get output(): NodeMaterialConnectionPoint;
  56930. protected _buildBlock(state: NodeMaterialBuildState): this;
  56931. protected _dumpPropertiesCode(): string;
  56932. serialize(): any;
  56933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56934. }
  56935. }
  56936. declare module BABYLON {
  56937. /**
  56938. * Block used to apply a cross product between 2 vectors
  56939. */
  56940. export class CrossBlock extends NodeMaterialBlock {
  56941. /**
  56942. * Creates a new CrossBlock
  56943. * @param name defines the block name
  56944. */
  56945. constructor(name: string);
  56946. /**
  56947. * Gets the current class name
  56948. * @returns the class name
  56949. */
  56950. getClassName(): string;
  56951. /**
  56952. * Gets the left operand input component
  56953. */
  56954. get left(): NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the right operand input component
  56957. */
  56958. get right(): NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the output component
  56961. */
  56962. get output(): NodeMaterialConnectionPoint;
  56963. protected _buildBlock(state: NodeMaterialBuildState): this;
  56964. }
  56965. }
  56966. declare module BABYLON {
  56967. /**
  56968. * Block used to apply a dot product between 2 vectors
  56969. */
  56970. export class DotBlock extends NodeMaterialBlock {
  56971. /**
  56972. * Creates a new DotBlock
  56973. * @param name defines the block name
  56974. */
  56975. constructor(name: string);
  56976. /**
  56977. * Gets the current class name
  56978. * @returns the class name
  56979. */
  56980. getClassName(): string;
  56981. /**
  56982. * Gets the left operand input component
  56983. */
  56984. get left(): NodeMaterialConnectionPoint;
  56985. /**
  56986. * Gets the right operand input component
  56987. */
  56988. get right(): NodeMaterialConnectionPoint;
  56989. /**
  56990. * Gets the output component
  56991. */
  56992. get output(): NodeMaterialConnectionPoint;
  56993. protected _buildBlock(state: NodeMaterialBuildState): this;
  56994. }
  56995. }
  56996. declare module BABYLON {
  56997. /**
  56998. * Block used to remap a float from a range to a new one
  56999. */
  57000. export class RemapBlock extends NodeMaterialBlock {
  57001. /**
  57002. * Gets or sets the source range
  57003. */
  57004. sourceRange: Vector2;
  57005. /**
  57006. * Gets or sets the target range
  57007. */
  57008. targetRange: Vector2;
  57009. /**
  57010. * Creates a new RemapBlock
  57011. * @param name defines the block name
  57012. */
  57013. constructor(name: string);
  57014. /**
  57015. * Gets the current class name
  57016. * @returns the class name
  57017. */
  57018. getClassName(): string;
  57019. /**
  57020. * Gets the input component
  57021. */
  57022. get input(): NodeMaterialConnectionPoint;
  57023. /**
  57024. * Gets the source min input component
  57025. */
  57026. get sourceMin(): NodeMaterialConnectionPoint;
  57027. /**
  57028. * Gets the source max input component
  57029. */
  57030. get sourceMax(): NodeMaterialConnectionPoint;
  57031. /**
  57032. * Gets the target min input component
  57033. */
  57034. get targetMin(): NodeMaterialConnectionPoint;
  57035. /**
  57036. * Gets the target max input component
  57037. */
  57038. get targetMax(): NodeMaterialConnectionPoint;
  57039. /**
  57040. * Gets the output component
  57041. */
  57042. get output(): NodeMaterialConnectionPoint;
  57043. protected _buildBlock(state: NodeMaterialBuildState): this;
  57044. protected _dumpPropertiesCode(): string;
  57045. serialize(): any;
  57046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57047. }
  57048. }
  57049. declare module BABYLON {
  57050. /**
  57051. * Block used to normalize a vector
  57052. */
  57053. export class NormalizeBlock extends NodeMaterialBlock {
  57054. /**
  57055. * Creates a new NormalizeBlock
  57056. * @param name defines the block name
  57057. */
  57058. constructor(name: string);
  57059. /**
  57060. * Gets the current class name
  57061. * @returns the class name
  57062. */
  57063. getClassName(): string;
  57064. /**
  57065. * Gets the input component
  57066. */
  57067. get input(): NodeMaterialConnectionPoint;
  57068. /**
  57069. * Gets the output component
  57070. */
  57071. get output(): NodeMaterialConnectionPoint;
  57072. protected _buildBlock(state: NodeMaterialBuildState): this;
  57073. }
  57074. }
  57075. declare module BABYLON {
  57076. /**
  57077. * Operations supported by the Trigonometry block
  57078. */
  57079. export enum TrigonometryBlockOperations {
  57080. /** Cos */
  57081. Cos = 0,
  57082. /** Sin */
  57083. Sin = 1,
  57084. /** Abs */
  57085. Abs = 2,
  57086. /** Exp */
  57087. Exp = 3,
  57088. /** Exp2 */
  57089. Exp2 = 4,
  57090. /** Round */
  57091. Round = 5,
  57092. /** Floor */
  57093. Floor = 6,
  57094. /** Ceiling */
  57095. Ceiling = 7,
  57096. /** Square root */
  57097. Sqrt = 8,
  57098. /** Log */
  57099. Log = 9,
  57100. /** Tangent */
  57101. Tan = 10,
  57102. /** Arc tangent */
  57103. ArcTan = 11,
  57104. /** Arc cosinus */
  57105. ArcCos = 12,
  57106. /** Arc sinus */
  57107. ArcSin = 13,
  57108. /** Fraction */
  57109. Fract = 14,
  57110. /** Sign */
  57111. Sign = 15,
  57112. /** To radians (from degrees) */
  57113. Radians = 16,
  57114. /** To degrees (from radians) */
  57115. Degrees = 17
  57116. }
  57117. /**
  57118. * Block used to apply trigonometry operation to floats
  57119. */
  57120. export class TrigonometryBlock extends NodeMaterialBlock {
  57121. /**
  57122. * Gets or sets the operation applied by the block
  57123. */
  57124. operation: TrigonometryBlockOperations;
  57125. /**
  57126. * Creates a new TrigonometryBlock
  57127. * @param name defines the block name
  57128. */
  57129. constructor(name: string);
  57130. /**
  57131. * Gets the current class name
  57132. * @returns the class name
  57133. */
  57134. getClassName(): string;
  57135. /**
  57136. * Gets the input component
  57137. */
  57138. get input(): NodeMaterialConnectionPoint;
  57139. /**
  57140. * Gets the output component
  57141. */
  57142. get output(): NodeMaterialConnectionPoint;
  57143. protected _buildBlock(state: NodeMaterialBuildState): this;
  57144. serialize(): any;
  57145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57146. protected _dumpPropertiesCode(): string;
  57147. }
  57148. }
  57149. declare module BABYLON {
  57150. /**
  57151. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57152. */
  57153. export class ColorMergerBlock extends NodeMaterialBlock {
  57154. /**
  57155. * Create a new ColorMergerBlock
  57156. * @param name defines the block name
  57157. */
  57158. constructor(name: string);
  57159. /**
  57160. * Gets the current class name
  57161. * @returns the class name
  57162. */
  57163. getClassName(): string;
  57164. /**
  57165. * Gets the rgb component (input)
  57166. */
  57167. get rgbIn(): NodeMaterialConnectionPoint;
  57168. /**
  57169. * Gets the r component (input)
  57170. */
  57171. get r(): NodeMaterialConnectionPoint;
  57172. /**
  57173. * Gets the g component (input)
  57174. */
  57175. get g(): NodeMaterialConnectionPoint;
  57176. /**
  57177. * Gets the b component (input)
  57178. */
  57179. get b(): NodeMaterialConnectionPoint;
  57180. /**
  57181. * Gets the a component (input)
  57182. */
  57183. get a(): NodeMaterialConnectionPoint;
  57184. /**
  57185. * Gets the rgba component (output)
  57186. */
  57187. get rgba(): NodeMaterialConnectionPoint;
  57188. /**
  57189. * Gets the rgb component (output)
  57190. */
  57191. get rgbOut(): NodeMaterialConnectionPoint;
  57192. /**
  57193. * Gets the rgb component (output)
  57194. * @deprecated Please use rgbOut instead.
  57195. */
  57196. get rgb(): NodeMaterialConnectionPoint;
  57197. protected _buildBlock(state: NodeMaterialBuildState): this;
  57198. }
  57199. }
  57200. declare module BABYLON {
  57201. /**
  57202. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57203. */
  57204. export class VectorMergerBlock extends NodeMaterialBlock {
  57205. /**
  57206. * Create a new VectorMergerBlock
  57207. * @param name defines the block name
  57208. */
  57209. constructor(name: string);
  57210. /**
  57211. * Gets the current class name
  57212. * @returns the class name
  57213. */
  57214. getClassName(): string;
  57215. /**
  57216. * Gets the xyz component (input)
  57217. */
  57218. get xyzIn(): NodeMaterialConnectionPoint;
  57219. /**
  57220. * Gets the xy component (input)
  57221. */
  57222. get xyIn(): NodeMaterialConnectionPoint;
  57223. /**
  57224. * Gets the x component (input)
  57225. */
  57226. get x(): NodeMaterialConnectionPoint;
  57227. /**
  57228. * Gets the y component (input)
  57229. */
  57230. get y(): NodeMaterialConnectionPoint;
  57231. /**
  57232. * Gets the z component (input)
  57233. */
  57234. get z(): NodeMaterialConnectionPoint;
  57235. /**
  57236. * Gets the w component (input)
  57237. */
  57238. get w(): NodeMaterialConnectionPoint;
  57239. /**
  57240. * Gets the xyzw component (output)
  57241. */
  57242. get xyzw(): NodeMaterialConnectionPoint;
  57243. /**
  57244. * Gets the xyz component (output)
  57245. */
  57246. get xyzOut(): NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the xy component (output)
  57249. */
  57250. get xyOut(): NodeMaterialConnectionPoint;
  57251. /**
  57252. * Gets the xy component (output)
  57253. * @deprecated Please use xyOut instead.
  57254. */
  57255. get xy(): NodeMaterialConnectionPoint;
  57256. /**
  57257. * Gets the xyz component (output)
  57258. * @deprecated Please use xyzOut instead.
  57259. */
  57260. get xyz(): NodeMaterialConnectionPoint;
  57261. protected _buildBlock(state: NodeMaterialBuildState): this;
  57262. }
  57263. }
  57264. declare module BABYLON {
  57265. /**
  57266. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57267. */
  57268. export class ColorSplitterBlock extends NodeMaterialBlock {
  57269. /**
  57270. * Create a new ColorSplitterBlock
  57271. * @param name defines the block name
  57272. */
  57273. constructor(name: string);
  57274. /**
  57275. * Gets the current class name
  57276. * @returns the class name
  57277. */
  57278. getClassName(): string;
  57279. /**
  57280. * Gets the rgba component (input)
  57281. */
  57282. get rgba(): NodeMaterialConnectionPoint;
  57283. /**
  57284. * Gets the rgb component (input)
  57285. */
  57286. get rgbIn(): NodeMaterialConnectionPoint;
  57287. /**
  57288. * Gets the rgb component (output)
  57289. */
  57290. get rgbOut(): NodeMaterialConnectionPoint;
  57291. /**
  57292. * Gets the r component (output)
  57293. */
  57294. get r(): NodeMaterialConnectionPoint;
  57295. /**
  57296. * Gets the g component (output)
  57297. */
  57298. get g(): NodeMaterialConnectionPoint;
  57299. /**
  57300. * Gets the b component (output)
  57301. */
  57302. get b(): NodeMaterialConnectionPoint;
  57303. /**
  57304. * Gets the a component (output)
  57305. */
  57306. get a(): NodeMaterialConnectionPoint;
  57307. protected _inputRename(name: string): string;
  57308. protected _outputRename(name: string): string;
  57309. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57310. }
  57311. }
  57312. declare module BABYLON {
  57313. /**
  57314. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57315. */
  57316. export class VectorSplitterBlock extends NodeMaterialBlock {
  57317. /**
  57318. * Create a new VectorSplitterBlock
  57319. * @param name defines the block name
  57320. */
  57321. constructor(name: string);
  57322. /**
  57323. * Gets the current class name
  57324. * @returns the class name
  57325. */
  57326. getClassName(): string;
  57327. /**
  57328. * Gets the xyzw component (input)
  57329. */
  57330. get xyzw(): NodeMaterialConnectionPoint;
  57331. /**
  57332. * Gets the xyz component (input)
  57333. */
  57334. get xyzIn(): NodeMaterialConnectionPoint;
  57335. /**
  57336. * Gets the xy component (input)
  57337. */
  57338. get xyIn(): NodeMaterialConnectionPoint;
  57339. /**
  57340. * Gets the xyz component (output)
  57341. */
  57342. get xyzOut(): NodeMaterialConnectionPoint;
  57343. /**
  57344. * Gets the xy component (output)
  57345. */
  57346. get xyOut(): NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the x component (output)
  57349. */
  57350. get x(): NodeMaterialConnectionPoint;
  57351. /**
  57352. * Gets the y component (output)
  57353. */
  57354. get y(): NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the z component (output)
  57357. */
  57358. get z(): NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the w component (output)
  57361. */
  57362. get w(): NodeMaterialConnectionPoint;
  57363. protected _inputRename(name: string): string;
  57364. protected _outputRename(name: string): string;
  57365. protected _buildBlock(state: NodeMaterialBuildState): this;
  57366. }
  57367. }
  57368. declare module BABYLON {
  57369. /**
  57370. * Block used to lerp between 2 values
  57371. */
  57372. export class LerpBlock extends NodeMaterialBlock {
  57373. /**
  57374. * Creates a new LerpBlock
  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 left operand input component
  57385. */
  57386. get left(): NodeMaterialConnectionPoint;
  57387. /**
  57388. * Gets the right operand input component
  57389. */
  57390. get right(): NodeMaterialConnectionPoint;
  57391. /**
  57392. * Gets the gradient operand input component
  57393. */
  57394. get gradient(): NodeMaterialConnectionPoint;
  57395. /**
  57396. * Gets the output component
  57397. */
  57398. get output(): NodeMaterialConnectionPoint;
  57399. protected _buildBlock(state: NodeMaterialBuildState): this;
  57400. }
  57401. }
  57402. declare module BABYLON {
  57403. /**
  57404. * Block used to divide 2 vectors
  57405. */
  57406. export class DivideBlock extends NodeMaterialBlock {
  57407. /**
  57408. * Creates a new DivideBlock
  57409. * @param name defines the block name
  57410. */
  57411. constructor(name: string);
  57412. /**
  57413. * Gets the current class name
  57414. * @returns the class name
  57415. */
  57416. getClassName(): string;
  57417. /**
  57418. * Gets the left operand input component
  57419. */
  57420. get left(): NodeMaterialConnectionPoint;
  57421. /**
  57422. * Gets the right operand input component
  57423. */
  57424. get right(): NodeMaterialConnectionPoint;
  57425. /**
  57426. * Gets the output component
  57427. */
  57428. get output(): NodeMaterialConnectionPoint;
  57429. protected _buildBlock(state: NodeMaterialBuildState): this;
  57430. }
  57431. }
  57432. declare module BABYLON {
  57433. /**
  57434. * Block used to subtract 2 vectors
  57435. */
  57436. export class SubtractBlock extends NodeMaterialBlock {
  57437. /**
  57438. * Creates a new SubtractBlock
  57439. * @param name defines the block name
  57440. */
  57441. constructor(name: string);
  57442. /**
  57443. * Gets the current class name
  57444. * @returns the class name
  57445. */
  57446. getClassName(): string;
  57447. /**
  57448. * Gets the left operand input component
  57449. */
  57450. get left(): NodeMaterialConnectionPoint;
  57451. /**
  57452. * Gets the right operand input component
  57453. */
  57454. get right(): NodeMaterialConnectionPoint;
  57455. /**
  57456. * Gets the output component
  57457. */
  57458. get output(): NodeMaterialConnectionPoint;
  57459. protected _buildBlock(state: NodeMaterialBuildState): this;
  57460. }
  57461. }
  57462. declare module BABYLON {
  57463. /**
  57464. * Block used to step a value
  57465. */
  57466. export class StepBlock extends NodeMaterialBlock {
  57467. /**
  57468. * Creates a new StepBlock
  57469. * @param name defines the block name
  57470. */
  57471. constructor(name: string);
  57472. /**
  57473. * Gets the current class name
  57474. * @returns the class name
  57475. */
  57476. getClassName(): string;
  57477. /**
  57478. * Gets the value operand input component
  57479. */
  57480. get value(): NodeMaterialConnectionPoint;
  57481. /**
  57482. * Gets the edge operand input component
  57483. */
  57484. get edge(): NodeMaterialConnectionPoint;
  57485. /**
  57486. * Gets the output component
  57487. */
  57488. get output(): NodeMaterialConnectionPoint;
  57489. protected _buildBlock(state: NodeMaterialBuildState): this;
  57490. }
  57491. }
  57492. declare module BABYLON {
  57493. /**
  57494. * Block used to get the opposite (1 - x) of a value
  57495. */
  57496. export class OneMinusBlock extends NodeMaterialBlock {
  57497. /**
  57498. * Creates a new OneMinusBlock
  57499. * @param name defines the block name
  57500. */
  57501. constructor(name: string);
  57502. /**
  57503. * Gets the current class name
  57504. * @returns the class name
  57505. */
  57506. getClassName(): string;
  57507. /**
  57508. * Gets the input component
  57509. */
  57510. get input(): NodeMaterialConnectionPoint;
  57511. /**
  57512. * Gets the output component
  57513. */
  57514. get output(): NodeMaterialConnectionPoint;
  57515. protected _buildBlock(state: NodeMaterialBuildState): this;
  57516. }
  57517. }
  57518. declare module BABYLON {
  57519. /**
  57520. * Block used to get the view direction
  57521. */
  57522. export class ViewDirectionBlock extends NodeMaterialBlock {
  57523. /**
  57524. * Creates a new ViewDirectionBlock
  57525. * @param name defines the block name
  57526. */
  57527. constructor(name: string);
  57528. /**
  57529. * Gets the current class name
  57530. * @returns the class name
  57531. */
  57532. getClassName(): string;
  57533. /**
  57534. * Gets the world position component
  57535. */
  57536. get worldPosition(): NodeMaterialConnectionPoint;
  57537. /**
  57538. * Gets the camera position component
  57539. */
  57540. get cameraPosition(): NodeMaterialConnectionPoint;
  57541. /**
  57542. * Gets the output component
  57543. */
  57544. get output(): NodeMaterialConnectionPoint;
  57545. autoConfigure(material: NodeMaterial): void;
  57546. protected _buildBlock(state: NodeMaterialBuildState): this;
  57547. }
  57548. }
  57549. declare module BABYLON {
  57550. /**
  57551. * Block used to compute fresnel value
  57552. */
  57553. export class FresnelBlock extends NodeMaterialBlock {
  57554. /**
  57555. * Create a new FresnelBlock
  57556. * @param name defines the block name
  57557. */
  57558. constructor(name: string);
  57559. /**
  57560. * Gets the current class name
  57561. * @returns the class name
  57562. */
  57563. getClassName(): string;
  57564. /**
  57565. * Gets the world normal input component
  57566. */
  57567. get worldNormal(): NodeMaterialConnectionPoint;
  57568. /**
  57569. * Gets the view direction input component
  57570. */
  57571. get viewDirection(): NodeMaterialConnectionPoint;
  57572. /**
  57573. * Gets the bias input component
  57574. */
  57575. get bias(): NodeMaterialConnectionPoint;
  57576. /**
  57577. * Gets the camera (or eye) position component
  57578. */
  57579. get power(): NodeMaterialConnectionPoint;
  57580. /**
  57581. * Gets the fresnel output component
  57582. */
  57583. get fresnel(): NodeMaterialConnectionPoint;
  57584. autoConfigure(material: NodeMaterial): void;
  57585. protected _buildBlock(state: NodeMaterialBuildState): this;
  57586. }
  57587. }
  57588. declare module BABYLON {
  57589. /**
  57590. * Block used to get the max of 2 values
  57591. */
  57592. export class MaxBlock extends NodeMaterialBlock {
  57593. /**
  57594. * Creates a new MaxBlock
  57595. * @param name defines the block name
  57596. */
  57597. constructor(name: string);
  57598. /**
  57599. * Gets the current class name
  57600. * @returns the class name
  57601. */
  57602. getClassName(): string;
  57603. /**
  57604. * Gets the left operand input component
  57605. */
  57606. get left(): NodeMaterialConnectionPoint;
  57607. /**
  57608. * Gets the right operand input component
  57609. */
  57610. get right(): NodeMaterialConnectionPoint;
  57611. /**
  57612. * Gets the output component
  57613. */
  57614. get output(): NodeMaterialConnectionPoint;
  57615. protected _buildBlock(state: NodeMaterialBuildState): this;
  57616. }
  57617. }
  57618. declare module BABYLON {
  57619. /**
  57620. * Block used to get the min of 2 values
  57621. */
  57622. export class MinBlock extends NodeMaterialBlock {
  57623. /**
  57624. * Creates a new MinBlock
  57625. * @param name defines the block name
  57626. */
  57627. constructor(name: string);
  57628. /**
  57629. * Gets the current class name
  57630. * @returns the class name
  57631. */
  57632. getClassName(): string;
  57633. /**
  57634. * Gets the left operand input component
  57635. */
  57636. get left(): NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the right operand input component
  57639. */
  57640. get right(): NodeMaterialConnectionPoint;
  57641. /**
  57642. * Gets the output component
  57643. */
  57644. get output(): NodeMaterialConnectionPoint;
  57645. protected _buildBlock(state: NodeMaterialBuildState): this;
  57646. }
  57647. }
  57648. declare module BABYLON {
  57649. /**
  57650. * Block used to get the distance between 2 values
  57651. */
  57652. export class DistanceBlock extends NodeMaterialBlock {
  57653. /**
  57654. * Creates a new DistanceBlock
  57655. * @param name defines the block name
  57656. */
  57657. constructor(name: string);
  57658. /**
  57659. * Gets the current class name
  57660. * @returns the class name
  57661. */
  57662. getClassName(): string;
  57663. /**
  57664. * Gets the left operand input component
  57665. */
  57666. get left(): NodeMaterialConnectionPoint;
  57667. /**
  57668. * Gets the right operand input component
  57669. */
  57670. get right(): NodeMaterialConnectionPoint;
  57671. /**
  57672. * Gets the output component
  57673. */
  57674. get output(): NodeMaterialConnectionPoint;
  57675. protected _buildBlock(state: NodeMaterialBuildState): this;
  57676. }
  57677. }
  57678. declare module BABYLON {
  57679. /**
  57680. * Block used to get the length of a vector
  57681. */
  57682. export class LengthBlock extends NodeMaterialBlock {
  57683. /**
  57684. * Creates a new LengthBlock
  57685. * @param name defines the block name
  57686. */
  57687. constructor(name: string);
  57688. /**
  57689. * Gets the current class name
  57690. * @returns the class name
  57691. */
  57692. getClassName(): string;
  57693. /**
  57694. * Gets the value input component
  57695. */
  57696. get value(): NodeMaterialConnectionPoint;
  57697. /**
  57698. * Gets the output component
  57699. */
  57700. get output(): NodeMaterialConnectionPoint;
  57701. protected _buildBlock(state: NodeMaterialBuildState): this;
  57702. }
  57703. }
  57704. declare module BABYLON {
  57705. /**
  57706. * Block used to get negative version of a value (i.e. x * -1)
  57707. */
  57708. export class NegateBlock extends NodeMaterialBlock {
  57709. /**
  57710. * Creates a new NegateBlock
  57711. * @param name defines the block name
  57712. */
  57713. constructor(name: string);
  57714. /**
  57715. * Gets the current class name
  57716. * @returns the class name
  57717. */
  57718. getClassName(): string;
  57719. /**
  57720. * Gets the value input component
  57721. */
  57722. get value(): NodeMaterialConnectionPoint;
  57723. /**
  57724. * Gets the output component
  57725. */
  57726. get output(): NodeMaterialConnectionPoint;
  57727. protected _buildBlock(state: NodeMaterialBuildState): this;
  57728. }
  57729. }
  57730. declare module BABYLON {
  57731. /**
  57732. * Block used to get the value of the first parameter raised to the power of the second
  57733. */
  57734. export class PowBlock extends NodeMaterialBlock {
  57735. /**
  57736. * Creates a new PowBlock
  57737. * @param name defines the block name
  57738. */
  57739. constructor(name: string);
  57740. /**
  57741. * Gets the current class name
  57742. * @returns the class name
  57743. */
  57744. getClassName(): string;
  57745. /**
  57746. * Gets the value operand input component
  57747. */
  57748. get value(): NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the power operand input component
  57751. */
  57752. get power(): NodeMaterialConnectionPoint;
  57753. /**
  57754. * Gets the output component
  57755. */
  57756. get output(): NodeMaterialConnectionPoint;
  57757. protected _buildBlock(state: NodeMaterialBuildState): this;
  57758. }
  57759. }
  57760. declare module BABYLON {
  57761. /**
  57762. * Block used to get a random number
  57763. */
  57764. export class RandomNumberBlock extends NodeMaterialBlock {
  57765. /**
  57766. * Creates a new RandomNumberBlock
  57767. * @param name defines the block name
  57768. */
  57769. constructor(name: string);
  57770. /**
  57771. * Gets the current class name
  57772. * @returns the class name
  57773. */
  57774. getClassName(): string;
  57775. /**
  57776. * Gets the seed input component
  57777. */
  57778. get seed(): NodeMaterialConnectionPoint;
  57779. /**
  57780. * Gets the output component
  57781. */
  57782. get output(): NodeMaterialConnectionPoint;
  57783. protected _buildBlock(state: NodeMaterialBuildState): this;
  57784. }
  57785. }
  57786. declare module BABYLON {
  57787. /**
  57788. * Block used to compute arc tangent of 2 values
  57789. */
  57790. export class ArcTan2Block extends NodeMaterialBlock {
  57791. /**
  57792. * Creates a new ArcTan2Block
  57793. * @param name defines the block name
  57794. */
  57795. constructor(name: string);
  57796. /**
  57797. * Gets the current class name
  57798. * @returns the class name
  57799. */
  57800. getClassName(): string;
  57801. /**
  57802. * Gets the x operand input component
  57803. */
  57804. get x(): NodeMaterialConnectionPoint;
  57805. /**
  57806. * Gets the y operand input component
  57807. */
  57808. get y(): NodeMaterialConnectionPoint;
  57809. /**
  57810. * Gets the output component
  57811. */
  57812. get output(): NodeMaterialConnectionPoint;
  57813. protected _buildBlock(state: NodeMaterialBuildState): this;
  57814. }
  57815. }
  57816. declare module BABYLON {
  57817. /**
  57818. * Block used to smooth step a value
  57819. */
  57820. export class SmoothStepBlock extends NodeMaterialBlock {
  57821. /**
  57822. * Creates a new SmoothStepBlock
  57823. * @param name defines the block name
  57824. */
  57825. constructor(name: string);
  57826. /**
  57827. * Gets the current class name
  57828. * @returns the class name
  57829. */
  57830. getClassName(): string;
  57831. /**
  57832. * Gets the value operand input component
  57833. */
  57834. get value(): NodeMaterialConnectionPoint;
  57835. /**
  57836. * Gets the first edge operand input component
  57837. */
  57838. get edge0(): NodeMaterialConnectionPoint;
  57839. /**
  57840. * Gets the second edge operand input component
  57841. */
  57842. get edge1(): NodeMaterialConnectionPoint;
  57843. /**
  57844. * Gets the output component
  57845. */
  57846. get output(): NodeMaterialConnectionPoint;
  57847. protected _buildBlock(state: NodeMaterialBuildState): this;
  57848. }
  57849. }
  57850. declare module BABYLON {
  57851. /**
  57852. * Block used to get the reciprocal (1 / x) of a value
  57853. */
  57854. export class ReciprocalBlock extends NodeMaterialBlock {
  57855. /**
  57856. * Creates a new ReciprocalBlock
  57857. * @param name defines the block name
  57858. */
  57859. constructor(name: string);
  57860. /**
  57861. * Gets the current class name
  57862. * @returns the class name
  57863. */
  57864. getClassName(): string;
  57865. /**
  57866. * Gets the input component
  57867. */
  57868. get input(): NodeMaterialConnectionPoint;
  57869. /**
  57870. * Gets the output component
  57871. */
  57872. get output(): NodeMaterialConnectionPoint;
  57873. protected _buildBlock(state: NodeMaterialBuildState): this;
  57874. }
  57875. }
  57876. declare module BABYLON {
  57877. /**
  57878. * Block used to replace a color by another one
  57879. */
  57880. export class ReplaceColorBlock extends NodeMaterialBlock {
  57881. /**
  57882. * Creates a new ReplaceColorBlock
  57883. * @param name defines the block name
  57884. */
  57885. constructor(name: string);
  57886. /**
  57887. * Gets the current class name
  57888. * @returns the class name
  57889. */
  57890. getClassName(): string;
  57891. /**
  57892. * Gets the value input component
  57893. */
  57894. get value(): NodeMaterialConnectionPoint;
  57895. /**
  57896. * Gets the reference input component
  57897. */
  57898. get reference(): NodeMaterialConnectionPoint;
  57899. /**
  57900. * Gets the distance input component
  57901. */
  57902. get distance(): NodeMaterialConnectionPoint;
  57903. /**
  57904. * Gets the replacement input component
  57905. */
  57906. get replacement(): NodeMaterialConnectionPoint;
  57907. /**
  57908. * Gets the output component
  57909. */
  57910. get output(): NodeMaterialConnectionPoint;
  57911. protected _buildBlock(state: NodeMaterialBuildState): this;
  57912. }
  57913. }
  57914. declare module BABYLON {
  57915. /**
  57916. * Block used to posterize a value
  57917. * @see https://en.wikipedia.org/wiki/Posterization
  57918. */
  57919. export class PosterizeBlock extends NodeMaterialBlock {
  57920. /**
  57921. * Creates a new PosterizeBlock
  57922. * @param name defines the block name
  57923. */
  57924. constructor(name: string);
  57925. /**
  57926. * Gets the current class name
  57927. * @returns the class name
  57928. */
  57929. getClassName(): string;
  57930. /**
  57931. * Gets the value input component
  57932. */
  57933. get value(): NodeMaterialConnectionPoint;
  57934. /**
  57935. * Gets the steps input component
  57936. */
  57937. get steps(): NodeMaterialConnectionPoint;
  57938. /**
  57939. * Gets the output component
  57940. */
  57941. get output(): NodeMaterialConnectionPoint;
  57942. protected _buildBlock(state: NodeMaterialBuildState): this;
  57943. }
  57944. }
  57945. declare module BABYLON {
  57946. /**
  57947. * Operations supported by the Wave block
  57948. */
  57949. export enum WaveBlockKind {
  57950. /** SawTooth */
  57951. SawTooth = 0,
  57952. /** Square */
  57953. Square = 1,
  57954. /** Triangle */
  57955. Triangle = 2
  57956. }
  57957. /**
  57958. * Block used to apply wave operation to floats
  57959. */
  57960. export class WaveBlock extends NodeMaterialBlock {
  57961. /**
  57962. * Gets or sets the kibnd of wave to be applied by the block
  57963. */
  57964. kind: WaveBlockKind;
  57965. /**
  57966. * Creates a new WaveBlock
  57967. * @param name defines the block name
  57968. */
  57969. constructor(name: string);
  57970. /**
  57971. * Gets the current class name
  57972. * @returns the class name
  57973. */
  57974. getClassName(): string;
  57975. /**
  57976. * Gets the input component
  57977. */
  57978. get input(): NodeMaterialConnectionPoint;
  57979. /**
  57980. * Gets the output component
  57981. */
  57982. get output(): NodeMaterialConnectionPoint;
  57983. protected _buildBlock(state: NodeMaterialBuildState): this;
  57984. serialize(): any;
  57985. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57986. }
  57987. }
  57988. declare module BABYLON {
  57989. /**
  57990. * Class used to store a color step for the GradientBlock
  57991. */
  57992. export class GradientBlockColorStep {
  57993. /**
  57994. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  57995. */
  57996. step: number;
  57997. /**
  57998. * Gets or sets the color associated with this step
  57999. */
  58000. color: Color3;
  58001. /**
  58002. * Creates a new GradientBlockColorStep
  58003. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58004. * @param color defines the color associated with this step
  58005. */
  58006. constructor(
  58007. /**
  58008. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58009. */
  58010. step: number,
  58011. /**
  58012. * Gets or sets the color associated with this step
  58013. */
  58014. color: Color3);
  58015. }
  58016. /**
  58017. * Block used to return a color from a gradient based on an input value between 0 and 1
  58018. */
  58019. export class GradientBlock extends NodeMaterialBlock {
  58020. /**
  58021. * Gets or sets the list of color steps
  58022. */
  58023. colorSteps: GradientBlockColorStep[];
  58024. /**
  58025. * Creates a new GradientBlock
  58026. * @param name defines the block name
  58027. */
  58028. constructor(name: string);
  58029. /**
  58030. * Gets the current class name
  58031. * @returns the class name
  58032. */
  58033. getClassName(): string;
  58034. /**
  58035. * Gets the gradient input component
  58036. */
  58037. get gradient(): NodeMaterialConnectionPoint;
  58038. /**
  58039. * Gets the output component
  58040. */
  58041. get output(): NodeMaterialConnectionPoint;
  58042. private _writeColorConstant;
  58043. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58044. serialize(): any;
  58045. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58046. protected _dumpPropertiesCode(): string;
  58047. }
  58048. }
  58049. declare module BABYLON {
  58050. /**
  58051. * Block used to normalize lerp between 2 values
  58052. */
  58053. export class NLerpBlock extends NodeMaterialBlock {
  58054. /**
  58055. * Creates a new NLerpBlock
  58056. * @param name defines the block name
  58057. */
  58058. constructor(name: string);
  58059. /**
  58060. * Gets the current class name
  58061. * @returns the class name
  58062. */
  58063. getClassName(): string;
  58064. /**
  58065. * Gets the left operand input component
  58066. */
  58067. get left(): NodeMaterialConnectionPoint;
  58068. /**
  58069. * Gets the right operand input component
  58070. */
  58071. get right(): NodeMaterialConnectionPoint;
  58072. /**
  58073. * Gets the gradient operand input component
  58074. */
  58075. get gradient(): NodeMaterialConnectionPoint;
  58076. /**
  58077. * Gets the output component
  58078. */
  58079. get output(): NodeMaterialConnectionPoint;
  58080. protected _buildBlock(state: NodeMaterialBuildState): this;
  58081. }
  58082. }
  58083. declare module BABYLON {
  58084. /**
  58085. * block used to Generate a Worley Noise 3D Noise Pattern
  58086. */
  58087. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  58088. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58089. manhattanDistance: boolean;
  58090. /**
  58091. * Creates a new WorleyNoise3DBlock
  58092. * @param name defines the block name
  58093. */
  58094. constructor(name: string);
  58095. /**
  58096. * Gets the current class name
  58097. * @returns the class name
  58098. */
  58099. getClassName(): string;
  58100. /**
  58101. * Gets the seed input component
  58102. */
  58103. get seed(): NodeMaterialConnectionPoint;
  58104. /**
  58105. * Gets the jitter input component
  58106. */
  58107. get jitter(): NodeMaterialConnectionPoint;
  58108. /**
  58109. * Gets the output component
  58110. */
  58111. get output(): NodeMaterialConnectionPoint;
  58112. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58113. /**
  58114. * Exposes the properties to the UI?
  58115. */
  58116. protected _dumpPropertiesCode(): string;
  58117. /**
  58118. * Exposes the properties to the Seralize?
  58119. */
  58120. serialize(): any;
  58121. /**
  58122. * Exposes the properties to the deseralize?
  58123. */
  58124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58125. }
  58126. }
  58127. declare module BABYLON {
  58128. /**
  58129. * block used to Generate a Simplex Perlin 3d Noise Pattern
  58130. */
  58131. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  58132. /**
  58133. * Creates a new SimplexPerlin3DBlock
  58134. * @param name defines the block name
  58135. */
  58136. constructor(name: string);
  58137. /**
  58138. * Gets the current class name
  58139. * @returns the class name
  58140. */
  58141. getClassName(): string;
  58142. /**
  58143. * Gets the seed operand input component
  58144. */
  58145. get seed(): NodeMaterialConnectionPoint;
  58146. /**
  58147. * Gets the output component
  58148. */
  58149. get output(): NodeMaterialConnectionPoint;
  58150. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58151. }
  58152. }
  58153. declare module BABYLON {
  58154. /**
  58155. * Block used to blend normals
  58156. */
  58157. export class NormalBlendBlock extends NodeMaterialBlock {
  58158. /**
  58159. * Creates a new NormalBlendBlock
  58160. * @param name defines the block name
  58161. */
  58162. constructor(name: string);
  58163. /**
  58164. * Gets the current class name
  58165. * @returns the class name
  58166. */
  58167. getClassName(): string;
  58168. /**
  58169. * Gets the first input component
  58170. */
  58171. get normalMap0(): NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the second input component
  58174. */
  58175. get normalMap1(): NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the output component
  58178. */
  58179. get output(): NodeMaterialConnectionPoint;
  58180. protected _buildBlock(state: NodeMaterialBuildState): this;
  58181. }
  58182. }
  58183. declare module BABYLON {
  58184. /**
  58185. * Block used to rotate a 2d vector by a given angle
  58186. */
  58187. export class Rotate2dBlock extends NodeMaterialBlock {
  58188. /**
  58189. * Creates a new Rotate2dBlock
  58190. * @param name defines the block name
  58191. */
  58192. constructor(name: string);
  58193. /**
  58194. * Gets the current class name
  58195. * @returns the class name
  58196. */
  58197. getClassName(): string;
  58198. /**
  58199. * Gets the input vector
  58200. */
  58201. get input(): NodeMaterialConnectionPoint;
  58202. /**
  58203. * Gets the input angle
  58204. */
  58205. get angle(): NodeMaterialConnectionPoint;
  58206. /**
  58207. * Gets the output component
  58208. */
  58209. get output(): NodeMaterialConnectionPoint;
  58210. autoConfigure(material: NodeMaterial): void;
  58211. protected _buildBlock(state: NodeMaterialBuildState): this;
  58212. }
  58213. }
  58214. declare module BABYLON {
  58215. /**
  58216. * Block used to get the reflected vector from a direction and a normal
  58217. */
  58218. export class ReflectBlock extends NodeMaterialBlock {
  58219. /**
  58220. * Creates a new ReflectBlock
  58221. * @param name defines the block name
  58222. */
  58223. constructor(name: string);
  58224. /**
  58225. * Gets the current class name
  58226. * @returns the class name
  58227. */
  58228. getClassName(): string;
  58229. /**
  58230. * Gets the incident component
  58231. */
  58232. get incident(): NodeMaterialConnectionPoint;
  58233. /**
  58234. * Gets the normal component
  58235. */
  58236. get normal(): NodeMaterialConnectionPoint;
  58237. /**
  58238. * Gets the output component
  58239. */
  58240. get output(): NodeMaterialConnectionPoint;
  58241. protected _buildBlock(state: NodeMaterialBuildState): this;
  58242. }
  58243. }
  58244. declare module BABYLON {
  58245. /**
  58246. * Block used to get the refracted vector from a direction and a normal
  58247. */
  58248. export class RefractBlock extends NodeMaterialBlock {
  58249. /**
  58250. * Creates a new RefractBlock
  58251. * @param name defines the block name
  58252. */
  58253. constructor(name: string);
  58254. /**
  58255. * Gets the current class name
  58256. * @returns the class name
  58257. */
  58258. getClassName(): string;
  58259. /**
  58260. * Gets the incident component
  58261. */
  58262. get incident(): NodeMaterialConnectionPoint;
  58263. /**
  58264. * Gets the normal component
  58265. */
  58266. get normal(): NodeMaterialConnectionPoint;
  58267. /**
  58268. * Gets the index of refraction component
  58269. */
  58270. get ior(): NodeMaterialConnectionPoint;
  58271. /**
  58272. * Gets the output component
  58273. */
  58274. get output(): NodeMaterialConnectionPoint;
  58275. protected _buildBlock(state: NodeMaterialBuildState): this;
  58276. }
  58277. }
  58278. declare module BABYLON {
  58279. /**
  58280. * Block used to desaturate a color
  58281. */
  58282. export class DesaturateBlock extends NodeMaterialBlock {
  58283. /**
  58284. * Creates a new DesaturateBlock
  58285. * @param name defines the block name
  58286. */
  58287. constructor(name: string);
  58288. /**
  58289. * Gets the current class name
  58290. * @returns the class name
  58291. */
  58292. getClassName(): string;
  58293. /**
  58294. * Gets the color operand input component
  58295. */
  58296. get color(): NodeMaterialConnectionPoint;
  58297. /**
  58298. * Gets the level operand input component
  58299. */
  58300. get level(): NodeMaterialConnectionPoint;
  58301. /**
  58302. * Gets the output component
  58303. */
  58304. get output(): NodeMaterialConnectionPoint;
  58305. protected _buildBlock(state: NodeMaterialBuildState): this;
  58306. }
  58307. }
  58308. declare module BABYLON {
  58309. /**
  58310. * Effect Render Options
  58311. */
  58312. export interface IEffectRendererOptions {
  58313. /**
  58314. * Defines the vertices positions.
  58315. */
  58316. positions?: number[];
  58317. /**
  58318. * Defines the indices.
  58319. */
  58320. indices?: number[];
  58321. }
  58322. /**
  58323. * Helper class to render one or more effects
  58324. */
  58325. export class EffectRenderer {
  58326. private engine;
  58327. private static _DefaultOptions;
  58328. private _vertexBuffers;
  58329. private _indexBuffer;
  58330. private _ringBufferIndex;
  58331. private _ringScreenBuffer;
  58332. private _fullscreenViewport;
  58333. private _getNextFrameBuffer;
  58334. /**
  58335. * Creates an effect renderer
  58336. * @param engine the engine to use for rendering
  58337. * @param options defines the options of the effect renderer
  58338. */
  58339. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58340. /**
  58341. * Sets the current viewport in normalized coordinates 0-1
  58342. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58343. */
  58344. setViewport(viewport?: Viewport): void;
  58345. /**
  58346. * Binds the embedded attributes buffer to the effect.
  58347. * @param effect Defines the effect to bind the attributes for
  58348. */
  58349. bindBuffers(effect: Effect): void;
  58350. /**
  58351. * Sets the current effect wrapper to use during draw.
  58352. * The effect needs to be ready before calling this api.
  58353. * This also sets the default full screen position attribute.
  58354. * @param effectWrapper Defines the effect to draw with
  58355. */
  58356. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58357. /**
  58358. * Draws a full screen quad.
  58359. */
  58360. draw(): void;
  58361. /**
  58362. * renders one or more effects to a specified texture
  58363. * @param effectWrappers list of effects to renderer
  58364. * @param outputTexture texture to draw to, if null it will render to the screen
  58365. */
  58366. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58367. /**
  58368. * Disposes of the effect renderer
  58369. */
  58370. dispose(): void;
  58371. }
  58372. /**
  58373. * Options to create an EffectWrapper
  58374. */
  58375. interface EffectWrapperCreationOptions {
  58376. /**
  58377. * Engine to use to create the effect
  58378. */
  58379. engine: ThinEngine;
  58380. /**
  58381. * Fragment shader for the effect
  58382. */
  58383. fragmentShader: string;
  58384. /**
  58385. * Vertex shader for the effect
  58386. */
  58387. vertexShader?: string;
  58388. /**
  58389. * Attributes to use in the shader
  58390. */
  58391. attributeNames?: Array<string>;
  58392. /**
  58393. * Uniforms to use in the shader
  58394. */
  58395. uniformNames?: Array<string>;
  58396. /**
  58397. * Texture sampler names to use in the shader
  58398. */
  58399. samplerNames?: Array<string>;
  58400. /**
  58401. * The friendly name of the effect displayed in Spector.
  58402. */
  58403. name?: string;
  58404. }
  58405. /**
  58406. * Wraps an effect to be used for rendering
  58407. */
  58408. export class EffectWrapper {
  58409. /**
  58410. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58411. */
  58412. onApplyObservable: Observable<{}>;
  58413. /**
  58414. * The underlying effect
  58415. */
  58416. effect: Effect;
  58417. /**
  58418. * Creates an effect to be renderer
  58419. * @param creationOptions options to create the effect
  58420. */
  58421. constructor(creationOptions: EffectWrapperCreationOptions);
  58422. /**
  58423. * Disposes of the effect wrapper
  58424. */
  58425. dispose(): void;
  58426. }
  58427. }
  58428. declare module BABYLON {
  58429. /**
  58430. * Helper class to push actions to a pool of workers.
  58431. */
  58432. export class WorkerPool implements IDisposable {
  58433. private _workerInfos;
  58434. private _pendingActions;
  58435. /**
  58436. * Constructor
  58437. * @param workers Array of workers to use for actions
  58438. */
  58439. constructor(workers: Array<Worker>);
  58440. /**
  58441. * Terminates all workers and clears any pending actions.
  58442. */
  58443. dispose(): void;
  58444. /**
  58445. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58446. * pended until a worker has completed its action.
  58447. * @param action The action to perform. Call onComplete when the action is complete.
  58448. */
  58449. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58450. private _execute;
  58451. }
  58452. }
  58453. declare module BABYLON {
  58454. /**
  58455. * Configuration for Draco compression
  58456. */
  58457. export interface IDracoCompressionConfiguration {
  58458. /**
  58459. * Configuration for the decoder.
  58460. */
  58461. decoder: {
  58462. /**
  58463. * The url to the WebAssembly module.
  58464. */
  58465. wasmUrl?: string;
  58466. /**
  58467. * The url to the WebAssembly binary.
  58468. */
  58469. wasmBinaryUrl?: string;
  58470. /**
  58471. * The url to the fallback JavaScript module.
  58472. */
  58473. fallbackUrl?: string;
  58474. };
  58475. }
  58476. /**
  58477. * Draco compression (https://google.github.io/draco/)
  58478. *
  58479. * This class wraps the Draco module.
  58480. *
  58481. * **Encoder**
  58482. *
  58483. * The encoder is not currently implemented.
  58484. *
  58485. * **Decoder**
  58486. *
  58487. * 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.
  58488. *
  58489. * To update the configuration, use the following code:
  58490. * ```javascript
  58491. * DracoCompression.Configuration = {
  58492. * decoder: {
  58493. * wasmUrl: "<url to the WebAssembly library>",
  58494. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58495. * fallbackUrl: "<url to the fallback JavaScript library>",
  58496. * }
  58497. * };
  58498. * ```
  58499. *
  58500. * 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.
  58501. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58502. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58503. *
  58504. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58505. * ```javascript
  58506. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58507. * ```
  58508. *
  58509. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58510. */
  58511. export class DracoCompression implements IDisposable {
  58512. private _workerPoolPromise?;
  58513. private _decoderModulePromise?;
  58514. /**
  58515. * The configuration. Defaults to the following urls:
  58516. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58517. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58518. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58519. */
  58520. static Configuration: IDracoCompressionConfiguration;
  58521. /**
  58522. * Returns true if the decoder configuration is available.
  58523. */
  58524. static get DecoderAvailable(): boolean;
  58525. /**
  58526. * Default number of workers to create when creating the draco compression object.
  58527. */
  58528. static DefaultNumWorkers: number;
  58529. private static GetDefaultNumWorkers;
  58530. private static _Default;
  58531. /**
  58532. * Default instance for the draco compression object.
  58533. */
  58534. static get Default(): DracoCompression;
  58535. /**
  58536. * Constructor
  58537. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58538. */
  58539. constructor(numWorkers?: number);
  58540. /**
  58541. * Stop all async operations and release resources.
  58542. */
  58543. dispose(): void;
  58544. /**
  58545. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58546. * @returns a promise that resolves when ready
  58547. */
  58548. whenReadyAsync(): Promise<void>;
  58549. /**
  58550. * Decode Draco compressed mesh data to vertex data.
  58551. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58552. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58553. * @returns A promise that resolves with the decoded vertex data
  58554. */
  58555. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58556. [kind: string]: number;
  58557. }): Promise<VertexData>;
  58558. }
  58559. }
  58560. declare module BABYLON {
  58561. /**
  58562. * Class for building Constructive Solid Geometry
  58563. */
  58564. export class CSG {
  58565. private polygons;
  58566. /**
  58567. * The world matrix
  58568. */
  58569. matrix: Matrix;
  58570. /**
  58571. * Stores the position
  58572. */
  58573. position: Vector3;
  58574. /**
  58575. * Stores the rotation
  58576. */
  58577. rotation: Vector3;
  58578. /**
  58579. * Stores the rotation quaternion
  58580. */
  58581. rotationQuaternion: Nullable<Quaternion>;
  58582. /**
  58583. * Stores the scaling vector
  58584. */
  58585. scaling: Vector3;
  58586. /**
  58587. * Convert the Mesh to CSG
  58588. * @param mesh The Mesh to convert to CSG
  58589. * @returns A new CSG from the Mesh
  58590. */
  58591. static FromMesh(mesh: Mesh): CSG;
  58592. /**
  58593. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58594. * @param polygons Polygons used to construct a CSG solid
  58595. */
  58596. private static FromPolygons;
  58597. /**
  58598. * Clones, or makes a deep copy, of the CSG
  58599. * @returns A new CSG
  58600. */
  58601. clone(): CSG;
  58602. /**
  58603. * Unions this CSG with another CSG
  58604. * @param csg The CSG to union against this CSG
  58605. * @returns The unioned CSG
  58606. */
  58607. union(csg: CSG): CSG;
  58608. /**
  58609. * Unions this CSG with another CSG in place
  58610. * @param csg The CSG to union against this CSG
  58611. */
  58612. unionInPlace(csg: CSG): void;
  58613. /**
  58614. * Subtracts this CSG with another CSG
  58615. * @param csg The CSG to subtract against this CSG
  58616. * @returns A new CSG
  58617. */
  58618. subtract(csg: CSG): CSG;
  58619. /**
  58620. * Subtracts this CSG with another CSG in place
  58621. * @param csg The CSG to subtact against this CSG
  58622. */
  58623. subtractInPlace(csg: CSG): void;
  58624. /**
  58625. * Intersect this CSG with another CSG
  58626. * @param csg The CSG to intersect against this CSG
  58627. * @returns A new CSG
  58628. */
  58629. intersect(csg: CSG): CSG;
  58630. /**
  58631. * Intersects this CSG with another CSG in place
  58632. * @param csg The CSG to intersect against this CSG
  58633. */
  58634. intersectInPlace(csg: CSG): void;
  58635. /**
  58636. * Return a new CSG solid with solid and empty space switched. This solid is
  58637. * not modified.
  58638. * @returns A new CSG solid with solid and empty space switched
  58639. */
  58640. inverse(): CSG;
  58641. /**
  58642. * Inverses the CSG in place
  58643. */
  58644. inverseInPlace(): void;
  58645. /**
  58646. * This is used to keep meshes transformations so they can be restored
  58647. * when we build back a Babylon Mesh
  58648. * NB : All CSG operations are performed in world coordinates
  58649. * @param csg The CSG to copy the transform attributes from
  58650. * @returns This CSG
  58651. */
  58652. copyTransformAttributes(csg: CSG): CSG;
  58653. /**
  58654. * Build Raw mesh from CSG
  58655. * Coordinates here are in world space
  58656. * @param name The name of the mesh geometry
  58657. * @param scene The Scene
  58658. * @param keepSubMeshes Specifies if the submeshes should be kept
  58659. * @returns A new Mesh
  58660. */
  58661. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58662. /**
  58663. * Build Mesh from CSG taking material and transforms into account
  58664. * @param name The name of the Mesh
  58665. * @param material The material of the Mesh
  58666. * @param scene The Scene
  58667. * @param keepSubMeshes Specifies if submeshes should be kept
  58668. * @returns The new Mesh
  58669. */
  58670. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58671. }
  58672. }
  58673. declare module BABYLON {
  58674. /**
  58675. * Class used to create a trail following a mesh
  58676. */
  58677. export class TrailMesh extends Mesh {
  58678. private _generator;
  58679. private _autoStart;
  58680. private _running;
  58681. private _diameter;
  58682. private _length;
  58683. private _sectionPolygonPointsCount;
  58684. private _sectionVectors;
  58685. private _sectionNormalVectors;
  58686. private _beforeRenderObserver;
  58687. /**
  58688. * @constructor
  58689. * @param name The value used by scene.getMeshByName() to do a lookup.
  58690. * @param generator The mesh to generate a trail.
  58691. * @param scene The scene to add this mesh to.
  58692. * @param diameter Diameter of trailing mesh. Default is 1.
  58693. * @param length Length of trailing mesh. Default is 60.
  58694. * @param autoStart Automatically start trailing mesh. Default true.
  58695. */
  58696. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58697. /**
  58698. * "TrailMesh"
  58699. * @returns "TrailMesh"
  58700. */
  58701. getClassName(): string;
  58702. private _createMesh;
  58703. /**
  58704. * Start trailing mesh.
  58705. */
  58706. start(): void;
  58707. /**
  58708. * Stop trailing mesh.
  58709. */
  58710. stop(): void;
  58711. /**
  58712. * Update trailing mesh geometry.
  58713. */
  58714. update(): void;
  58715. /**
  58716. * Returns a new TrailMesh object.
  58717. * @param name is a string, the name given to the new mesh
  58718. * @param newGenerator use new generator object for cloned trail mesh
  58719. * @returns a new mesh
  58720. */
  58721. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58722. /**
  58723. * Serializes this trail mesh
  58724. * @param serializationObject object to write serialization to
  58725. */
  58726. serialize(serializationObject: any): void;
  58727. /**
  58728. * Parses a serialized trail mesh
  58729. * @param parsedMesh the serialized mesh
  58730. * @param scene the scene to create the trail mesh in
  58731. * @returns the created trail mesh
  58732. */
  58733. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58734. }
  58735. }
  58736. declare module BABYLON {
  58737. /**
  58738. * Class containing static functions to help procedurally build meshes
  58739. */
  58740. export class TiledBoxBuilder {
  58741. /**
  58742. * Creates a box mesh
  58743. * 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)
  58744. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58746. * * 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
  58747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58748. * @param name defines the name of the mesh
  58749. * @param options defines the options used to create the mesh
  58750. * @param scene defines the hosting scene
  58751. * @returns the box mesh
  58752. */
  58753. static CreateTiledBox(name: string, options: {
  58754. pattern?: number;
  58755. width?: number;
  58756. height?: number;
  58757. depth?: number;
  58758. tileSize?: number;
  58759. tileWidth?: number;
  58760. tileHeight?: number;
  58761. alignHorizontal?: number;
  58762. alignVertical?: number;
  58763. faceUV?: Vector4[];
  58764. faceColors?: Color4[];
  58765. sideOrientation?: number;
  58766. updatable?: boolean;
  58767. }, scene?: Nullable<Scene>): Mesh;
  58768. }
  58769. }
  58770. declare module BABYLON {
  58771. /**
  58772. * Class containing static functions to help procedurally build meshes
  58773. */
  58774. export class TorusKnotBuilder {
  58775. /**
  58776. * Creates a torus knot mesh
  58777. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58778. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58779. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58780. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58782. * * 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
  58783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58784. * @param name defines the name of the mesh
  58785. * @param options defines the options used to create the mesh
  58786. * @param scene defines the hosting scene
  58787. * @returns the torus knot mesh
  58788. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58789. */
  58790. static CreateTorusKnot(name: string, options: {
  58791. radius?: number;
  58792. tube?: number;
  58793. radialSegments?: number;
  58794. tubularSegments?: number;
  58795. p?: number;
  58796. q?: number;
  58797. updatable?: boolean;
  58798. sideOrientation?: number;
  58799. frontUVs?: Vector4;
  58800. backUVs?: Vector4;
  58801. }, scene: any): Mesh;
  58802. }
  58803. }
  58804. declare module BABYLON {
  58805. /**
  58806. * Polygon
  58807. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58808. */
  58809. export class Polygon {
  58810. /**
  58811. * Creates a rectangle
  58812. * @param xmin bottom X coord
  58813. * @param ymin bottom Y coord
  58814. * @param xmax top X coord
  58815. * @param ymax top Y coord
  58816. * @returns points that make the resulting rectation
  58817. */
  58818. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58819. /**
  58820. * Creates a circle
  58821. * @param radius radius of circle
  58822. * @param cx scale in x
  58823. * @param cy scale in y
  58824. * @param numberOfSides number of sides that make up the circle
  58825. * @returns points that make the resulting circle
  58826. */
  58827. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58828. /**
  58829. * Creates a polygon from input string
  58830. * @param input Input polygon data
  58831. * @returns the parsed points
  58832. */
  58833. static Parse(input: string): Vector2[];
  58834. /**
  58835. * Starts building a polygon from x and y coordinates
  58836. * @param x x coordinate
  58837. * @param y y coordinate
  58838. * @returns the started path2
  58839. */
  58840. static StartingAt(x: number, y: number): Path2;
  58841. }
  58842. /**
  58843. * Builds a polygon
  58844. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58845. */
  58846. export class PolygonMeshBuilder {
  58847. private _points;
  58848. private _outlinepoints;
  58849. private _holes;
  58850. private _name;
  58851. private _scene;
  58852. private _epoints;
  58853. private _eholes;
  58854. private _addToepoint;
  58855. /**
  58856. * Babylon reference to the earcut plugin.
  58857. */
  58858. bjsEarcut: any;
  58859. /**
  58860. * Creates a PolygonMeshBuilder
  58861. * @param name name of the builder
  58862. * @param contours Path of the polygon
  58863. * @param scene scene to add to when creating the mesh
  58864. * @param earcutInjection can be used to inject your own earcut reference
  58865. */
  58866. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58867. /**
  58868. * Adds a whole within the polygon
  58869. * @param hole Array of points defining the hole
  58870. * @returns this
  58871. */
  58872. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58873. /**
  58874. * Creates the polygon
  58875. * @param updatable If the mesh should be updatable
  58876. * @param depth The depth of the mesh created
  58877. * @returns the created mesh
  58878. */
  58879. build(updatable?: boolean, depth?: number): Mesh;
  58880. /**
  58881. * Creates the polygon
  58882. * @param depth The depth of the mesh created
  58883. * @returns the created VertexData
  58884. */
  58885. buildVertexData(depth?: number): VertexData;
  58886. /**
  58887. * Adds a side to the polygon
  58888. * @param positions points that make the polygon
  58889. * @param normals normals of the polygon
  58890. * @param uvs uvs of the polygon
  58891. * @param indices indices of the polygon
  58892. * @param bounds bounds of the polygon
  58893. * @param points points of the polygon
  58894. * @param depth depth of the polygon
  58895. * @param flip flip of the polygon
  58896. */
  58897. private addSide;
  58898. }
  58899. }
  58900. declare module BABYLON {
  58901. /**
  58902. * Class containing static functions to help procedurally build meshes
  58903. */
  58904. export class PolygonBuilder {
  58905. /**
  58906. * Creates a polygon mesh
  58907. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58908. * * 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
  58909. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58911. * * 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)
  58912. * * Remember you can only change the shape positions, not their number when updating a polygon
  58913. * @param name defines the name of the mesh
  58914. * @param options defines the options used to create the mesh
  58915. * @param scene defines the hosting scene
  58916. * @param earcutInjection can be used to inject your own earcut reference
  58917. * @returns the polygon mesh
  58918. */
  58919. static CreatePolygon(name: string, options: {
  58920. shape: Vector3[];
  58921. holes?: Vector3[][];
  58922. depth?: number;
  58923. faceUV?: Vector4[];
  58924. faceColors?: Color4[];
  58925. updatable?: boolean;
  58926. sideOrientation?: number;
  58927. frontUVs?: Vector4;
  58928. backUVs?: Vector4;
  58929. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58930. /**
  58931. * Creates an extruded polygon mesh, with depth in the Y direction.
  58932. * * 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)
  58933. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58934. * @param name defines the name of the mesh
  58935. * @param options defines the options used to create the mesh
  58936. * @param scene defines the hosting scene
  58937. * @param earcutInjection can be used to inject your own earcut reference
  58938. * @returns the polygon mesh
  58939. */
  58940. static ExtrudePolygon(name: string, options: {
  58941. shape: Vector3[];
  58942. holes?: Vector3[][];
  58943. depth?: number;
  58944. faceUV?: Vector4[];
  58945. faceColors?: Color4[];
  58946. updatable?: boolean;
  58947. sideOrientation?: number;
  58948. frontUVs?: Vector4;
  58949. backUVs?: Vector4;
  58950. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58951. }
  58952. }
  58953. declare module BABYLON {
  58954. /**
  58955. * Class containing static functions to help procedurally build meshes
  58956. */
  58957. export class LatheBuilder {
  58958. /**
  58959. * Creates lathe mesh.
  58960. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58961. * * 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
  58962. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58963. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58964. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58965. * * 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
  58966. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58967. * * 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
  58968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58969. * * 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
  58970. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58972. * @param name defines the name of the mesh
  58973. * @param options defines the options used to create the mesh
  58974. * @param scene defines the hosting scene
  58975. * @returns the lathe mesh
  58976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58977. */
  58978. static CreateLathe(name: string, options: {
  58979. shape: Vector3[];
  58980. radius?: number;
  58981. tessellation?: number;
  58982. clip?: number;
  58983. arc?: number;
  58984. closed?: boolean;
  58985. updatable?: boolean;
  58986. sideOrientation?: number;
  58987. frontUVs?: Vector4;
  58988. backUVs?: Vector4;
  58989. cap?: number;
  58990. invertUV?: boolean;
  58991. }, scene?: Nullable<Scene>): Mesh;
  58992. }
  58993. }
  58994. declare module BABYLON {
  58995. /**
  58996. * Class containing static functions to help procedurally build meshes
  58997. */
  58998. export class TiledPlaneBuilder {
  58999. /**
  59000. * Creates a tiled plane mesh
  59001. * * The parameter `pattern` will, depending on value, do nothing or
  59002. * * * flip (reflect about central vertical) alternate tiles across and up
  59003. * * * flip every tile on alternate rows
  59004. * * * rotate (180 degs) alternate tiles across and up
  59005. * * * rotate every tile on alternate rows
  59006. * * * flip and rotate alternate tiles across and up
  59007. * * * flip and rotate every tile on alternate rows
  59008. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59009. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59010. * * 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
  59011. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59012. * * 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)
  59013. * * 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)
  59014. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59015. * @param name defines the name of the mesh
  59016. * @param options defines the options used to create the mesh
  59017. * @param scene defines the hosting scene
  59018. * @returns the box mesh
  59019. */
  59020. static CreateTiledPlane(name: string, options: {
  59021. pattern?: number;
  59022. tileSize?: number;
  59023. tileWidth?: number;
  59024. tileHeight?: number;
  59025. size?: number;
  59026. width?: number;
  59027. height?: number;
  59028. alignHorizontal?: number;
  59029. alignVertical?: number;
  59030. sideOrientation?: number;
  59031. frontUVs?: Vector4;
  59032. backUVs?: Vector4;
  59033. updatable?: boolean;
  59034. }, scene?: Nullable<Scene>): Mesh;
  59035. }
  59036. }
  59037. declare module BABYLON {
  59038. /**
  59039. * Class containing static functions to help procedurally build meshes
  59040. */
  59041. export class TubeBuilder {
  59042. /**
  59043. * Creates a tube mesh.
  59044. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59045. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59046. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59047. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59048. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59049. * * 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)
  59050. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59051. * * 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
  59052. * * 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
  59053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59054. * * 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
  59055. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59057. * @param name defines the name of the mesh
  59058. * @param options defines the options used to create the mesh
  59059. * @param scene defines the hosting scene
  59060. * @returns the tube mesh
  59061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59062. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59063. */
  59064. static CreateTube(name: string, options: {
  59065. path: Vector3[];
  59066. radius?: number;
  59067. tessellation?: number;
  59068. radiusFunction?: {
  59069. (i: number, distance: number): number;
  59070. };
  59071. cap?: number;
  59072. arc?: number;
  59073. updatable?: boolean;
  59074. sideOrientation?: number;
  59075. frontUVs?: Vector4;
  59076. backUVs?: Vector4;
  59077. instance?: Mesh;
  59078. invertUV?: boolean;
  59079. }, scene?: Nullable<Scene>): Mesh;
  59080. }
  59081. }
  59082. declare module BABYLON {
  59083. /**
  59084. * Class containing static functions to help procedurally build meshes
  59085. */
  59086. export class IcoSphereBuilder {
  59087. /**
  59088. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59089. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59090. * * 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`)
  59091. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59092. * * 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
  59093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59094. * * 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
  59095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59096. * @param name defines the name of the mesh
  59097. * @param options defines the options used to create the mesh
  59098. * @param scene defines the hosting scene
  59099. * @returns the icosahedron mesh
  59100. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59101. */
  59102. static CreateIcoSphere(name: string, options: {
  59103. radius?: number;
  59104. radiusX?: number;
  59105. radiusY?: number;
  59106. radiusZ?: number;
  59107. flat?: boolean;
  59108. subdivisions?: number;
  59109. sideOrientation?: number;
  59110. frontUVs?: Vector4;
  59111. backUVs?: Vector4;
  59112. updatable?: boolean;
  59113. }, scene?: Nullable<Scene>): Mesh;
  59114. }
  59115. }
  59116. declare module BABYLON {
  59117. /**
  59118. * Class containing static functions to help procedurally build meshes
  59119. */
  59120. export class DecalBuilder {
  59121. /**
  59122. * Creates a decal mesh.
  59123. * 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
  59124. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59125. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59126. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59127. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59128. * @param name defines the name of the mesh
  59129. * @param sourceMesh defines the mesh where the decal must be applied
  59130. * @param options defines the options used to create the mesh
  59131. * @param scene defines the hosting scene
  59132. * @returns the decal mesh
  59133. * @see https://doc.babylonjs.com/how_to/decals
  59134. */
  59135. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59136. position?: Vector3;
  59137. normal?: Vector3;
  59138. size?: Vector3;
  59139. angle?: number;
  59140. }): Mesh;
  59141. }
  59142. }
  59143. declare module BABYLON {
  59144. /**
  59145. * Class containing static functions to help procedurally build meshes
  59146. */
  59147. export class MeshBuilder {
  59148. /**
  59149. * Creates a box mesh
  59150. * * The parameter `size` sets the size (float) of each box side (default 1)
  59151. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59152. * * 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)
  59153. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59155. * * 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
  59156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59157. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59158. * @param name defines the name of the mesh
  59159. * @param options defines the options used to create the mesh
  59160. * @param scene defines the hosting scene
  59161. * @returns the box mesh
  59162. */
  59163. static CreateBox(name: string, options: {
  59164. size?: number;
  59165. width?: number;
  59166. height?: number;
  59167. depth?: number;
  59168. faceUV?: Vector4[];
  59169. faceColors?: Color4[];
  59170. sideOrientation?: number;
  59171. frontUVs?: Vector4;
  59172. backUVs?: Vector4;
  59173. updatable?: boolean;
  59174. }, scene?: Nullable<Scene>): Mesh;
  59175. /**
  59176. * Creates a tiled box mesh
  59177. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59179. * @param name defines the name of the mesh
  59180. * @param options defines the options used to create the mesh
  59181. * @param scene defines the hosting scene
  59182. * @returns the tiled box mesh
  59183. */
  59184. static CreateTiledBox(name: string, options: {
  59185. pattern?: number;
  59186. size?: number;
  59187. width?: number;
  59188. height?: number;
  59189. depth: number;
  59190. tileSize?: number;
  59191. tileWidth?: number;
  59192. tileHeight?: number;
  59193. faceUV?: Vector4[];
  59194. faceColors?: Color4[];
  59195. alignHorizontal?: number;
  59196. alignVertical?: number;
  59197. sideOrientation?: number;
  59198. updatable?: boolean;
  59199. }, scene?: Nullable<Scene>): Mesh;
  59200. /**
  59201. * Creates a sphere mesh
  59202. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59203. * * 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`)
  59204. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59205. * * 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
  59206. * * 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)
  59207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59208. * * 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
  59209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59210. * @param name defines the name of the mesh
  59211. * @param options defines the options used to create the mesh
  59212. * @param scene defines the hosting scene
  59213. * @returns the sphere mesh
  59214. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59215. */
  59216. static CreateSphere(name: string, options: {
  59217. segments?: number;
  59218. diameter?: number;
  59219. diameterX?: number;
  59220. diameterY?: number;
  59221. diameterZ?: number;
  59222. arc?: number;
  59223. slice?: number;
  59224. sideOrientation?: number;
  59225. frontUVs?: Vector4;
  59226. backUVs?: Vector4;
  59227. updatable?: boolean;
  59228. }, scene?: Nullable<Scene>): Mesh;
  59229. /**
  59230. * Creates a plane polygonal mesh. By default, this is a disc
  59231. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59232. * * 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
  59233. * * 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
  59234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59235. * * 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
  59236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59237. * @param name defines the name of the mesh
  59238. * @param options defines the options used to create the mesh
  59239. * @param scene defines the hosting scene
  59240. * @returns the plane polygonal mesh
  59241. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59242. */
  59243. static CreateDisc(name: string, options: {
  59244. radius?: number;
  59245. tessellation?: number;
  59246. arc?: number;
  59247. updatable?: boolean;
  59248. sideOrientation?: number;
  59249. frontUVs?: Vector4;
  59250. backUVs?: Vector4;
  59251. }, scene?: Nullable<Scene>): Mesh;
  59252. /**
  59253. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59254. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59255. * * 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`)
  59256. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59257. * * 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
  59258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59259. * * 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
  59260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59261. * @param name defines the name of the mesh
  59262. * @param options defines the options used to create the mesh
  59263. * @param scene defines the hosting scene
  59264. * @returns the icosahedron mesh
  59265. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59266. */
  59267. static CreateIcoSphere(name: string, options: {
  59268. radius?: number;
  59269. radiusX?: number;
  59270. radiusY?: number;
  59271. radiusZ?: number;
  59272. flat?: boolean;
  59273. subdivisions?: number;
  59274. sideOrientation?: number;
  59275. frontUVs?: Vector4;
  59276. backUVs?: Vector4;
  59277. updatable?: boolean;
  59278. }, scene?: Nullable<Scene>): Mesh;
  59279. /**
  59280. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59281. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59282. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59283. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59284. * * 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
  59285. * * 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
  59286. * * 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
  59287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59288. * * 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
  59289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59290. * * 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
  59291. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59292. * * 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
  59293. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59295. * @param name defines the name of the mesh
  59296. * @param options defines the options used to create the mesh
  59297. * @param scene defines the hosting scene
  59298. * @returns the ribbon mesh
  59299. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59301. */
  59302. static CreateRibbon(name: string, options: {
  59303. pathArray: Vector3[][];
  59304. closeArray?: boolean;
  59305. closePath?: boolean;
  59306. offset?: number;
  59307. updatable?: boolean;
  59308. sideOrientation?: number;
  59309. frontUVs?: Vector4;
  59310. backUVs?: Vector4;
  59311. instance?: Mesh;
  59312. invertUV?: boolean;
  59313. uvs?: Vector2[];
  59314. colors?: Color4[];
  59315. }, scene?: Nullable<Scene>): Mesh;
  59316. /**
  59317. * Creates a cylinder or a cone mesh
  59318. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59319. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59320. * * 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.
  59321. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59322. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59323. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59324. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59325. * * 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).
  59326. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59327. * * 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).
  59328. * * 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
  59329. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59330. * * 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
  59331. * * 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.
  59332. * * If `enclose` is false, a ring surface is one element.
  59333. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59334. * * 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
  59335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59336. * * 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
  59337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59338. * @param name defines the name of the mesh
  59339. * @param options defines the options used to create the mesh
  59340. * @param scene defines the hosting scene
  59341. * @returns the cylinder mesh
  59342. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59343. */
  59344. static CreateCylinder(name: string, options: {
  59345. height?: number;
  59346. diameterTop?: number;
  59347. diameterBottom?: number;
  59348. diameter?: number;
  59349. tessellation?: number;
  59350. subdivisions?: number;
  59351. arc?: number;
  59352. faceColors?: Color4[];
  59353. faceUV?: Vector4[];
  59354. updatable?: boolean;
  59355. hasRings?: boolean;
  59356. enclose?: boolean;
  59357. cap?: number;
  59358. sideOrientation?: number;
  59359. frontUVs?: Vector4;
  59360. backUVs?: Vector4;
  59361. }, scene?: Nullable<Scene>): Mesh;
  59362. /**
  59363. * Creates a torus mesh
  59364. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59365. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59366. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59368. * * 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
  59369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59370. * @param name defines the name of the mesh
  59371. * @param options defines the options used to create the mesh
  59372. * @param scene defines the hosting scene
  59373. * @returns the torus mesh
  59374. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59375. */
  59376. static CreateTorus(name: string, options: {
  59377. diameter?: number;
  59378. thickness?: number;
  59379. tessellation?: number;
  59380. updatable?: boolean;
  59381. sideOrientation?: number;
  59382. frontUVs?: Vector4;
  59383. backUVs?: Vector4;
  59384. }, scene?: Nullable<Scene>): Mesh;
  59385. /**
  59386. * Creates a torus knot mesh
  59387. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59388. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59389. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59390. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59392. * * 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
  59393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59394. * @param name defines the name of the mesh
  59395. * @param options defines the options used to create the mesh
  59396. * @param scene defines the hosting scene
  59397. * @returns the torus knot mesh
  59398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59399. */
  59400. static CreateTorusKnot(name: string, options: {
  59401. radius?: number;
  59402. tube?: number;
  59403. radialSegments?: number;
  59404. tubularSegments?: number;
  59405. p?: number;
  59406. q?: number;
  59407. updatable?: boolean;
  59408. sideOrientation?: number;
  59409. frontUVs?: Vector4;
  59410. backUVs?: Vector4;
  59411. }, scene?: Nullable<Scene>): Mesh;
  59412. /**
  59413. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59414. * * 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
  59415. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59416. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59417. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59418. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59419. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59420. * * 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
  59421. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59424. * @param name defines the name of the new line system
  59425. * @param options defines the options used to create the line system
  59426. * @param scene defines the hosting scene
  59427. * @returns a new line system mesh
  59428. */
  59429. static CreateLineSystem(name: string, options: {
  59430. lines: Vector3[][];
  59431. updatable?: boolean;
  59432. instance?: Nullable<LinesMesh>;
  59433. colors?: Nullable<Color4[][]>;
  59434. useVertexAlpha?: boolean;
  59435. }, scene: Nullable<Scene>): LinesMesh;
  59436. /**
  59437. * Creates a line mesh
  59438. * 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
  59439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59440. * * The parameter `points` is an array successive Vector3
  59441. * * 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
  59442. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59444. * * When updating an instance, remember that only point positions can change, not the number of points
  59445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59447. * @param name defines the name of the new line system
  59448. * @param options defines the options used to create the line system
  59449. * @param scene defines the hosting scene
  59450. * @returns a new line mesh
  59451. */
  59452. static CreateLines(name: string, options: {
  59453. points: Vector3[];
  59454. updatable?: boolean;
  59455. instance?: Nullable<LinesMesh>;
  59456. colors?: Color4[];
  59457. useVertexAlpha?: boolean;
  59458. }, scene?: Nullable<Scene>): LinesMesh;
  59459. /**
  59460. * Creates a dashed line mesh
  59461. * * 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
  59462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59463. * * The parameter `points` is an array successive Vector3
  59464. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59465. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59466. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59467. * * 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
  59468. * * When updating an instance, remember that only point positions can change, not the number of points
  59469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59470. * @param name defines the name of the mesh
  59471. * @param options defines the options used to create the mesh
  59472. * @param scene defines the hosting scene
  59473. * @returns the dashed line mesh
  59474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59475. */
  59476. static CreateDashedLines(name: string, options: {
  59477. points: Vector3[];
  59478. dashSize?: number;
  59479. gapSize?: number;
  59480. dashNb?: number;
  59481. updatable?: boolean;
  59482. instance?: LinesMesh;
  59483. }, scene?: Nullable<Scene>): LinesMesh;
  59484. /**
  59485. * 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.
  59486. * * 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.
  59487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59488. * * 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.
  59489. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59490. * * 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
  59491. * * 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
  59492. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59494. * * 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
  59495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59497. * @param name defines the name of the mesh
  59498. * @param options defines the options used to create the mesh
  59499. * @param scene defines the hosting scene
  59500. * @returns the extruded shape mesh
  59501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59503. */
  59504. static ExtrudeShape(name: string, options: {
  59505. shape: Vector3[];
  59506. path: Vector3[];
  59507. scale?: number;
  59508. rotation?: number;
  59509. cap?: number;
  59510. updatable?: boolean;
  59511. sideOrientation?: number;
  59512. frontUVs?: Vector4;
  59513. backUVs?: Vector4;
  59514. instance?: Mesh;
  59515. invertUV?: boolean;
  59516. }, scene?: Nullable<Scene>): Mesh;
  59517. /**
  59518. * Creates an custom extruded shape mesh.
  59519. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59520. * * 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.
  59521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59522. * * 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
  59523. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59524. * * 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
  59525. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59526. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59527. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59528. * * 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
  59529. * * 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
  59530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59532. * * 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
  59533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59535. * @param name defines the name of the mesh
  59536. * @param options defines the options used to create the mesh
  59537. * @param scene defines the hosting scene
  59538. * @returns the custom extruded shape mesh
  59539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59542. */
  59543. static ExtrudeShapeCustom(name: string, options: {
  59544. shape: Vector3[];
  59545. path: Vector3[];
  59546. scaleFunction?: any;
  59547. rotationFunction?: any;
  59548. ribbonCloseArray?: boolean;
  59549. ribbonClosePath?: boolean;
  59550. cap?: number;
  59551. updatable?: boolean;
  59552. sideOrientation?: number;
  59553. frontUVs?: Vector4;
  59554. backUVs?: Vector4;
  59555. instance?: Mesh;
  59556. invertUV?: boolean;
  59557. }, scene?: Nullable<Scene>): Mesh;
  59558. /**
  59559. * Creates lathe mesh.
  59560. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59561. * * 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
  59562. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59563. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59564. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59565. * * 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
  59566. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59567. * * 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
  59568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59569. * * 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
  59570. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59572. * @param name defines the name of the mesh
  59573. * @param options defines the options used to create the mesh
  59574. * @param scene defines the hosting scene
  59575. * @returns the lathe mesh
  59576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59577. */
  59578. static CreateLathe(name: string, options: {
  59579. shape: Vector3[];
  59580. radius?: number;
  59581. tessellation?: number;
  59582. clip?: number;
  59583. arc?: number;
  59584. closed?: boolean;
  59585. updatable?: boolean;
  59586. sideOrientation?: number;
  59587. frontUVs?: Vector4;
  59588. backUVs?: Vector4;
  59589. cap?: number;
  59590. invertUV?: boolean;
  59591. }, scene?: Nullable<Scene>): Mesh;
  59592. /**
  59593. * Creates a tiled plane mesh
  59594. * * You can set a limited pattern arrangement with the tiles
  59595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59596. * * 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
  59597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59598. * @param name defines the name of the mesh
  59599. * @param options defines the options used to create the mesh
  59600. * @param scene defines the hosting scene
  59601. * @returns the plane mesh
  59602. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59603. */
  59604. static CreateTiledPlane(name: string, options: {
  59605. pattern?: number;
  59606. tileSize?: number;
  59607. tileWidth?: number;
  59608. tileHeight?: number;
  59609. size?: number;
  59610. width?: number;
  59611. height?: number;
  59612. alignHorizontal?: number;
  59613. alignVertical?: number;
  59614. sideOrientation?: number;
  59615. frontUVs?: Vector4;
  59616. backUVs?: Vector4;
  59617. updatable?: boolean;
  59618. }, scene?: Nullable<Scene>): Mesh;
  59619. /**
  59620. * Creates a plane mesh
  59621. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59622. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59623. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59625. * * 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
  59626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59627. * @param name defines the name of the mesh
  59628. * @param options defines the options used to create the mesh
  59629. * @param scene defines the hosting scene
  59630. * @returns the plane mesh
  59631. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59632. */
  59633. static CreatePlane(name: string, options: {
  59634. size?: number;
  59635. width?: number;
  59636. height?: number;
  59637. sideOrientation?: number;
  59638. frontUVs?: Vector4;
  59639. backUVs?: Vector4;
  59640. updatable?: boolean;
  59641. sourcePlane?: Plane;
  59642. }, scene?: Nullable<Scene>): Mesh;
  59643. /**
  59644. * Creates a ground mesh
  59645. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59646. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59648. * @param name defines the name of the mesh
  59649. * @param options defines the options used to create the mesh
  59650. * @param scene defines the hosting scene
  59651. * @returns the ground mesh
  59652. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59653. */
  59654. static CreateGround(name: string, options: {
  59655. width?: number;
  59656. height?: number;
  59657. subdivisions?: number;
  59658. subdivisionsX?: number;
  59659. subdivisionsY?: number;
  59660. updatable?: boolean;
  59661. }, scene?: Nullable<Scene>): Mesh;
  59662. /**
  59663. * Creates a tiled ground mesh
  59664. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59665. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59666. * * 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
  59667. * * 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
  59668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59669. * @param name defines the name of the mesh
  59670. * @param options defines the options used to create the mesh
  59671. * @param scene defines the hosting scene
  59672. * @returns the tiled ground mesh
  59673. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59674. */
  59675. static CreateTiledGround(name: string, options: {
  59676. xmin: number;
  59677. zmin: number;
  59678. xmax: number;
  59679. zmax: number;
  59680. subdivisions?: {
  59681. w: number;
  59682. h: number;
  59683. };
  59684. precision?: {
  59685. w: number;
  59686. h: number;
  59687. };
  59688. updatable?: boolean;
  59689. }, scene?: Nullable<Scene>): Mesh;
  59690. /**
  59691. * Creates a ground mesh from a height map
  59692. * * The parameter `url` sets the URL of the height map image resource.
  59693. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59694. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59695. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59696. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59697. * * 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.
  59698. * * 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).
  59699. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59701. * @param name defines the name of the mesh
  59702. * @param url defines the url to the height map
  59703. * @param options defines the options used to create the mesh
  59704. * @param scene defines the hosting scene
  59705. * @returns the ground mesh
  59706. * @see https://doc.babylonjs.com/babylon101/height_map
  59707. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59708. */
  59709. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59710. width?: number;
  59711. height?: number;
  59712. subdivisions?: number;
  59713. minHeight?: number;
  59714. maxHeight?: number;
  59715. colorFilter?: Color3;
  59716. alphaFilter?: number;
  59717. updatable?: boolean;
  59718. onReady?: (mesh: GroundMesh) => void;
  59719. }, scene?: Nullable<Scene>): GroundMesh;
  59720. /**
  59721. * Creates a polygon mesh
  59722. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59723. * * 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
  59724. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59726. * * 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)
  59727. * * Remember you can only change the shape positions, not their number when updating a polygon
  59728. * @param name defines the name of the mesh
  59729. * @param options defines the options used to create the mesh
  59730. * @param scene defines the hosting scene
  59731. * @param earcutInjection can be used to inject your own earcut reference
  59732. * @returns the polygon mesh
  59733. */
  59734. static CreatePolygon(name: string, options: {
  59735. shape: Vector3[];
  59736. holes?: Vector3[][];
  59737. depth?: number;
  59738. faceUV?: Vector4[];
  59739. faceColors?: Color4[];
  59740. updatable?: boolean;
  59741. sideOrientation?: number;
  59742. frontUVs?: Vector4;
  59743. backUVs?: Vector4;
  59744. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59745. /**
  59746. * Creates an extruded polygon mesh, with depth in the Y direction.
  59747. * * 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)
  59748. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59749. * @param name defines the name of the mesh
  59750. * @param options defines the options used to create the mesh
  59751. * @param scene defines the hosting scene
  59752. * @param earcutInjection can be used to inject your own earcut reference
  59753. * @returns the polygon mesh
  59754. */
  59755. static ExtrudePolygon(name: string, options: {
  59756. shape: Vector3[];
  59757. holes?: Vector3[][];
  59758. depth?: number;
  59759. faceUV?: Vector4[];
  59760. faceColors?: Color4[];
  59761. updatable?: boolean;
  59762. sideOrientation?: number;
  59763. frontUVs?: Vector4;
  59764. backUVs?: Vector4;
  59765. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59766. /**
  59767. * Creates a tube mesh.
  59768. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59769. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59770. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59771. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59772. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59773. * * 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)
  59774. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59775. * * 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
  59776. * * 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
  59777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59778. * * 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
  59779. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59781. * @param name defines the name of the mesh
  59782. * @param options defines the options used to create the mesh
  59783. * @param scene defines the hosting scene
  59784. * @returns the tube mesh
  59785. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59786. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59787. */
  59788. static CreateTube(name: string, options: {
  59789. path: Vector3[];
  59790. radius?: number;
  59791. tessellation?: number;
  59792. radiusFunction?: {
  59793. (i: number, distance: number): number;
  59794. };
  59795. cap?: number;
  59796. arc?: number;
  59797. updatable?: boolean;
  59798. sideOrientation?: number;
  59799. frontUVs?: Vector4;
  59800. backUVs?: Vector4;
  59801. instance?: Mesh;
  59802. invertUV?: boolean;
  59803. }, scene?: Nullable<Scene>): Mesh;
  59804. /**
  59805. * Creates a polyhedron mesh
  59806. * * 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
  59807. * * The parameter `size` (positive float, default 1) sets the polygon size
  59808. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59809. * * 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`
  59810. * * 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
  59811. * * 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)`)
  59812. * * 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
  59813. * * 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
  59814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59815. * * 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
  59816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59817. * @param name defines the name of the mesh
  59818. * @param options defines the options used to create the mesh
  59819. * @param scene defines the hosting scene
  59820. * @returns the polyhedron mesh
  59821. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59822. */
  59823. static CreatePolyhedron(name: string, options: {
  59824. type?: number;
  59825. size?: number;
  59826. sizeX?: number;
  59827. sizeY?: number;
  59828. sizeZ?: number;
  59829. custom?: any;
  59830. faceUV?: Vector4[];
  59831. faceColors?: Color4[];
  59832. flat?: boolean;
  59833. updatable?: boolean;
  59834. sideOrientation?: number;
  59835. frontUVs?: Vector4;
  59836. backUVs?: Vector4;
  59837. }, scene?: Nullable<Scene>): Mesh;
  59838. /**
  59839. * Creates a decal mesh.
  59840. * 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
  59841. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59842. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59843. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59844. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59845. * @param name defines the name of the mesh
  59846. * @param sourceMesh defines the mesh where the decal must be applied
  59847. * @param options defines the options used to create the mesh
  59848. * @param scene defines the hosting scene
  59849. * @returns the decal mesh
  59850. * @see https://doc.babylonjs.com/how_to/decals
  59851. */
  59852. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59853. position?: Vector3;
  59854. normal?: Vector3;
  59855. size?: Vector3;
  59856. angle?: number;
  59857. }): Mesh;
  59858. }
  59859. }
  59860. declare module BABYLON {
  59861. /**
  59862. * A simplifier interface for future simplification implementations
  59863. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59864. */
  59865. export interface ISimplifier {
  59866. /**
  59867. * Simplification of a given mesh according to the given settings.
  59868. * Since this requires computation, it is assumed that the function runs async.
  59869. * @param settings The settings of the simplification, including quality and distance
  59870. * @param successCallback A callback that will be called after the mesh was simplified.
  59871. * @param errorCallback in case of an error, this callback will be called. optional.
  59872. */
  59873. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59874. }
  59875. /**
  59876. * Expected simplification settings.
  59877. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59879. */
  59880. export interface ISimplificationSettings {
  59881. /**
  59882. * Gets or sets the expected quality
  59883. */
  59884. quality: number;
  59885. /**
  59886. * Gets or sets the distance when this optimized version should be used
  59887. */
  59888. distance: number;
  59889. /**
  59890. * Gets an already optimized mesh
  59891. */
  59892. optimizeMesh?: boolean;
  59893. }
  59894. /**
  59895. * Class used to specify simplification options
  59896. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59897. */
  59898. export class SimplificationSettings implements ISimplificationSettings {
  59899. /** expected quality */
  59900. quality: number;
  59901. /** distance when this optimized version should be used */
  59902. distance: number;
  59903. /** already optimized mesh */
  59904. optimizeMesh?: boolean | undefined;
  59905. /**
  59906. * Creates a SimplificationSettings
  59907. * @param quality expected quality
  59908. * @param distance distance when this optimized version should be used
  59909. * @param optimizeMesh already optimized mesh
  59910. */
  59911. constructor(
  59912. /** expected quality */
  59913. quality: number,
  59914. /** distance when this optimized version should be used */
  59915. distance: number,
  59916. /** already optimized mesh */
  59917. optimizeMesh?: boolean | undefined);
  59918. }
  59919. /**
  59920. * Interface used to define a simplification task
  59921. */
  59922. export interface ISimplificationTask {
  59923. /**
  59924. * Array of settings
  59925. */
  59926. settings: Array<ISimplificationSettings>;
  59927. /**
  59928. * Simplification type
  59929. */
  59930. simplificationType: SimplificationType;
  59931. /**
  59932. * Mesh to simplify
  59933. */
  59934. mesh: Mesh;
  59935. /**
  59936. * Callback called on success
  59937. */
  59938. successCallback?: () => void;
  59939. /**
  59940. * Defines if parallel processing can be used
  59941. */
  59942. parallelProcessing: boolean;
  59943. }
  59944. /**
  59945. * Queue used to order the simplification tasks
  59946. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59947. */
  59948. export class SimplificationQueue {
  59949. private _simplificationArray;
  59950. /**
  59951. * Gets a boolean indicating that the process is still running
  59952. */
  59953. running: boolean;
  59954. /**
  59955. * Creates a new queue
  59956. */
  59957. constructor();
  59958. /**
  59959. * Adds a new simplification task
  59960. * @param task defines a task to add
  59961. */
  59962. addTask(task: ISimplificationTask): void;
  59963. /**
  59964. * Execute next task
  59965. */
  59966. executeNext(): void;
  59967. /**
  59968. * Execute a simplification task
  59969. * @param task defines the task to run
  59970. */
  59971. runSimplification(task: ISimplificationTask): void;
  59972. private getSimplifier;
  59973. }
  59974. /**
  59975. * The implemented types of simplification
  59976. * At the moment only Quadratic Error Decimation is implemented
  59977. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59978. */
  59979. export enum SimplificationType {
  59980. /** Quadratic error decimation */
  59981. QUADRATIC = 0
  59982. }
  59983. }
  59984. declare module BABYLON {
  59985. interface Scene {
  59986. /** @hidden (Backing field) */
  59987. _simplificationQueue: SimplificationQueue;
  59988. /**
  59989. * Gets or sets the simplification queue attached to the scene
  59990. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59991. */
  59992. simplificationQueue: SimplificationQueue;
  59993. }
  59994. interface Mesh {
  59995. /**
  59996. * Simplify the mesh according to the given array of settings.
  59997. * Function will return immediately and will simplify async
  59998. * @param settings a collection of simplification settings
  59999. * @param parallelProcessing should all levels calculate parallel or one after the other
  60000. * @param simplificationType the type of simplification to run
  60001. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60002. * @returns the current mesh
  60003. */
  60004. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60005. }
  60006. /**
  60007. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60008. * created in a scene
  60009. */
  60010. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60011. /**
  60012. * The component name helpfull to identify the component in the list of scene components.
  60013. */
  60014. readonly name: string;
  60015. /**
  60016. * The scene the component belongs to.
  60017. */
  60018. scene: Scene;
  60019. /**
  60020. * Creates a new instance of the component for the given scene
  60021. * @param scene Defines the scene to register the component in
  60022. */
  60023. constructor(scene: Scene);
  60024. /**
  60025. * Registers the component in a given scene
  60026. */
  60027. register(): void;
  60028. /**
  60029. * Rebuilds the elements related to this component in case of
  60030. * context lost for instance.
  60031. */
  60032. rebuild(): void;
  60033. /**
  60034. * Disposes the component and the associated ressources
  60035. */
  60036. dispose(): void;
  60037. private _beforeCameraUpdate;
  60038. }
  60039. }
  60040. declare module BABYLON {
  60041. /**
  60042. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60043. */
  60044. export interface INavigationEnginePlugin {
  60045. /**
  60046. * plugin name
  60047. */
  60048. name: string;
  60049. /**
  60050. * Creates a navigation mesh
  60051. * @param meshes array of all the geometry used to compute the navigatio mesh
  60052. * @param parameters bunch of parameters used to filter geometry
  60053. */
  60054. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60055. /**
  60056. * Create a navigation mesh debug mesh
  60057. * @param scene is where the mesh will be added
  60058. * @returns debug display mesh
  60059. */
  60060. createDebugNavMesh(scene: Scene): Mesh;
  60061. /**
  60062. * Get a navigation mesh constrained position, closest to the parameter position
  60063. * @param position world position
  60064. * @returns the closest point to position constrained by the navigation mesh
  60065. */
  60066. getClosestPoint(position: Vector3): Vector3;
  60067. /**
  60068. * Get a navigation mesh constrained position, within a particular radius
  60069. * @param position world position
  60070. * @param maxRadius the maximum distance to the constrained world position
  60071. * @returns the closest point to position constrained by the navigation mesh
  60072. */
  60073. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60074. /**
  60075. * Compute the final position from a segment made of destination-position
  60076. * @param position world position
  60077. * @param destination world position
  60078. * @returns the resulting point along the navmesh
  60079. */
  60080. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60081. /**
  60082. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60083. * @param start world position
  60084. * @param end world position
  60085. * @returns array containing world position composing the path
  60086. */
  60087. computePath(start: Vector3, end: Vector3): Vector3[];
  60088. /**
  60089. * If this plugin is supported
  60090. * @returns true if plugin is supported
  60091. */
  60092. isSupported(): boolean;
  60093. /**
  60094. * Create a new Crowd so you can add agents
  60095. * @param maxAgents the maximum agent count in the crowd
  60096. * @param maxAgentRadius the maximum radius an agent can have
  60097. * @param scene to attach the crowd to
  60098. * @returns the crowd you can add agents to
  60099. */
  60100. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60101. /**
  60102. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60103. * The queries will try to find a solution within those bounds
  60104. * default is (1,1,1)
  60105. * @param extent x,y,z value that define the extent around the queries point of reference
  60106. */
  60107. setDefaultQueryExtent(extent: Vector3): void;
  60108. /**
  60109. * Get the Bounding box extent specified by setDefaultQueryExtent
  60110. * @returns the box extent values
  60111. */
  60112. getDefaultQueryExtent(): Vector3;
  60113. /**
  60114. * Release all resources
  60115. */
  60116. dispose(): void;
  60117. }
  60118. /**
  60119. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60120. */
  60121. export interface ICrowd {
  60122. /**
  60123. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60124. * You can attach anything to that node. The node position is updated in the scene update tick.
  60125. * @param pos world position that will be constrained by the navigation mesh
  60126. * @param parameters agent parameters
  60127. * @param transform hooked to the agent that will be update by the scene
  60128. * @returns agent index
  60129. */
  60130. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60131. /**
  60132. * Returns the agent position in world space
  60133. * @param index agent index returned by addAgent
  60134. * @returns world space position
  60135. */
  60136. getAgentPosition(index: number): Vector3;
  60137. /**
  60138. * Gets the agent velocity in world space
  60139. * @param index agent index returned by addAgent
  60140. * @returns world space velocity
  60141. */
  60142. getAgentVelocity(index: number): Vector3;
  60143. /**
  60144. * remove a particular agent previously created
  60145. * @param index agent index returned by addAgent
  60146. */
  60147. removeAgent(index: number): void;
  60148. /**
  60149. * get the list of all agents attached to this crowd
  60150. * @returns list of agent indices
  60151. */
  60152. getAgents(): number[];
  60153. /**
  60154. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60155. * @param deltaTime in seconds
  60156. */
  60157. update(deltaTime: number): void;
  60158. /**
  60159. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60160. * @param index agent index returned by addAgent
  60161. * @param destination targeted world position
  60162. */
  60163. agentGoto(index: number, destination: Vector3): void;
  60164. /**
  60165. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60166. * The queries will try to find a solution within those bounds
  60167. * default is (1,1,1)
  60168. * @param extent x,y,z value that define the extent around the queries point of reference
  60169. */
  60170. setDefaultQueryExtent(extent: Vector3): void;
  60171. /**
  60172. * Get the Bounding box extent specified by setDefaultQueryExtent
  60173. * @returns the box extent values
  60174. */
  60175. getDefaultQueryExtent(): Vector3;
  60176. /**
  60177. * Release all resources
  60178. */
  60179. dispose(): void;
  60180. }
  60181. /**
  60182. * Configures an agent
  60183. */
  60184. export interface IAgentParameters {
  60185. /**
  60186. * Agent radius. [Limit: >= 0]
  60187. */
  60188. radius: number;
  60189. /**
  60190. * Agent height. [Limit: > 0]
  60191. */
  60192. height: number;
  60193. /**
  60194. * Maximum allowed acceleration. [Limit: >= 0]
  60195. */
  60196. maxAcceleration: number;
  60197. /**
  60198. * Maximum allowed speed. [Limit: >= 0]
  60199. */
  60200. maxSpeed: number;
  60201. /**
  60202. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60203. */
  60204. collisionQueryRange: number;
  60205. /**
  60206. * The path visibility optimization range. [Limit: > 0]
  60207. */
  60208. pathOptimizationRange: number;
  60209. /**
  60210. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60211. */
  60212. separationWeight: number;
  60213. }
  60214. /**
  60215. * Configures the navigation mesh creation
  60216. */
  60217. export interface INavMeshParameters {
  60218. /**
  60219. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60220. */
  60221. cs: number;
  60222. /**
  60223. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60224. */
  60225. ch: number;
  60226. /**
  60227. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60228. */
  60229. walkableSlopeAngle: number;
  60230. /**
  60231. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60232. * be considered walkable. [Limit: >= 3] [Units: vx]
  60233. */
  60234. walkableHeight: number;
  60235. /**
  60236. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60237. */
  60238. walkableClimb: number;
  60239. /**
  60240. * The distance to erode/shrink the walkable area of the heightfield away from
  60241. * obstructions. [Limit: >=0] [Units: vx]
  60242. */
  60243. walkableRadius: number;
  60244. /**
  60245. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60246. */
  60247. maxEdgeLen: number;
  60248. /**
  60249. * The maximum distance a simplfied contour's border edges should deviate
  60250. * the original raw contour. [Limit: >=0] [Units: vx]
  60251. */
  60252. maxSimplificationError: number;
  60253. /**
  60254. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60255. */
  60256. minRegionArea: number;
  60257. /**
  60258. * Any regions with a span count smaller than this value will, if possible,
  60259. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60260. */
  60261. mergeRegionArea: number;
  60262. /**
  60263. * The maximum number of vertices allowed for polygons generated during the
  60264. * contour to polygon conversion process. [Limit: >= 3]
  60265. */
  60266. maxVertsPerPoly: number;
  60267. /**
  60268. * Sets the sampling distance to use when generating the detail mesh.
  60269. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60270. */
  60271. detailSampleDist: number;
  60272. /**
  60273. * The maximum distance the detail mesh surface should deviate from heightfield
  60274. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60275. */
  60276. detailSampleMaxError: number;
  60277. }
  60278. }
  60279. declare module BABYLON {
  60280. /**
  60281. * RecastJS navigation plugin
  60282. */
  60283. export class RecastJSPlugin implements INavigationEnginePlugin {
  60284. /**
  60285. * Reference to the Recast library
  60286. */
  60287. bjsRECAST: any;
  60288. /**
  60289. * plugin name
  60290. */
  60291. name: string;
  60292. /**
  60293. * the first navmesh created. We might extend this to support multiple navmeshes
  60294. */
  60295. navMesh: any;
  60296. /**
  60297. * Initializes the recastJS plugin
  60298. * @param recastInjection can be used to inject your own recast reference
  60299. */
  60300. constructor(recastInjection?: any);
  60301. /**
  60302. * Creates a navigation mesh
  60303. * @param meshes array of all the geometry used to compute the navigatio mesh
  60304. * @param parameters bunch of parameters used to filter geometry
  60305. */
  60306. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60307. /**
  60308. * Create a navigation mesh debug mesh
  60309. * @param scene is where the mesh will be added
  60310. * @returns debug display mesh
  60311. */
  60312. createDebugNavMesh(scene: Scene): Mesh;
  60313. /**
  60314. * Get a navigation mesh constrained position, closest to the parameter position
  60315. * @param position world position
  60316. * @returns the closest point to position constrained by the navigation mesh
  60317. */
  60318. getClosestPoint(position: Vector3): Vector3;
  60319. /**
  60320. * Get a navigation mesh constrained position, within a particular radius
  60321. * @param position world position
  60322. * @param maxRadius the maximum distance to the constrained world position
  60323. * @returns the closest point to position constrained by the navigation mesh
  60324. */
  60325. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60326. /**
  60327. * Compute the final position from a segment made of destination-position
  60328. * @param position world position
  60329. * @param destination world position
  60330. * @returns the resulting point along the navmesh
  60331. */
  60332. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60333. /**
  60334. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60335. * @param start world position
  60336. * @param end world position
  60337. * @returns array containing world position composing the path
  60338. */
  60339. computePath(start: Vector3, end: Vector3): Vector3[];
  60340. /**
  60341. * Create a new Crowd so you can add agents
  60342. * @param maxAgents the maximum agent count in the crowd
  60343. * @param maxAgentRadius the maximum radius an agent can have
  60344. * @param scene to attach the crowd to
  60345. * @returns the crowd you can add agents to
  60346. */
  60347. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60348. /**
  60349. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60350. * The queries will try to find a solution within those bounds
  60351. * default is (1,1,1)
  60352. * @param extent x,y,z value that define the extent around the queries point of reference
  60353. */
  60354. setDefaultQueryExtent(extent: Vector3): void;
  60355. /**
  60356. * Get the Bounding box extent specified by setDefaultQueryExtent
  60357. * @returns the box extent values
  60358. */
  60359. getDefaultQueryExtent(): Vector3;
  60360. /**
  60361. * Disposes
  60362. */
  60363. dispose(): void;
  60364. /**
  60365. * If this plugin is supported
  60366. * @returns true if plugin is supported
  60367. */
  60368. isSupported(): boolean;
  60369. }
  60370. /**
  60371. * Recast detour crowd implementation
  60372. */
  60373. export class RecastJSCrowd implements ICrowd {
  60374. /**
  60375. * Recast/detour plugin
  60376. */
  60377. bjsRECASTPlugin: RecastJSPlugin;
  60378. /**
  60379. * Link to the detour crowd
  60380. */
  60381. recastCrowd: any;
  60382. /**
  60383. * One transform per agent
  60384. */
  60385. transforms: TransformNode[];
  60386. /**
  60387. * All agents created
  60388. */
  60389. agents: number[];
  60390. /**
  60391. * Link to the scene is kept to unregister the crowd from the scene
  60392. */
  60393. private _scene;
  60394. /**
  60395. * Observer for crowd updates
  60396. */
  60397. private _onBeforeAnimationsObserver;
  60398. /**
  60399. * Constructor
  60400. * @param plugin recastJS plugin
  60401. * @param maxAgents the maximum agent count in the crowd
  60402. * @param maxAgentRadius the maximum radius an agent can have
  60403. * @param scene to attach the crowd to
  60404. * @returns the crowd you can add agents to
  60405. */
  60406. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60407. /**
  60408. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60409. * You can attach anything to that node. The node position is updated in the scene update tick.
  60410. * @param pos world position that will be constrained by the navigation mesh
  60411. * @param parameters agent parameters
  60412. * @param transform hooked to the agent that will be update by the scene
  60413. * @returns agent index
  60414. */
  60415. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60416. /**
  60417. * Returns the agent position in world space
  60418. * @param index agent index returned by addAgent
  60419. * @returns world space position
  60420. */
  60421. getAgentPosition(index: number): Vector3;
  60422. /**
  60423. * Returns the agent velocity in world space
  60424. * @param index agent index returned by addAgent
  60425. * @returns world space velocity
  60426. */
  60427. getAgentVelocity(index: number): Vector3;
  60428. /**
  60429. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60430. * @param index agent index returned by addAgent
  60431. * @param destination targeted world position
  60432. */
  60433. agentGoto(index: number, destination: Vector3): void;
  60434. /**
  60435. * remove a particular agent previously created
  60436. * @param index agent index returned by addAgent
  60437. */
  60438. removeAgent(index: number): void;
  60439. /**
  60440. * get the list of all agents attached to this crowd
  60441. * @returns list of agent indices
  60442. */
  60443. getAgents(): number[];
  60444. /**
  60445. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60446. * @param deltaTime in seconds
  60447. */
  60448. update(deltaTime: number): void;
  60449. /**
  60450. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60451. * The queries will try to find a solution within those bounds
  60452. * default is (1,1,1)
  60453. * @param extent x,y,z value that define the extent around the queries point of reference
  60454. */
  60455. setDefaultQueryExtent(extent: Vector3): void;
  60456. /**
  60457. * Get the Bounding box extent specified by setDefaultQueryExtent
  60458. * @returns the box extent values
  60459. */
  60460. getDefaultQueryExtent(): Vector3;
  60461. /**
  60462. * Release all resources
  60463. */
  60464. dispose(): void;
  60465. }
  60466. }
  60467. declare module BABYLON {
  60468. /**
  60469. * Class used to enable access to IndexedDB
  60470. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60471. */
  60472. export class Database implements IOfflineProvider {
  60473. private _callbackManifestChecked;
  60474. private _currentSceneUrl;
  60475. private _db;
  60476. private _enableSceneOffline;
  60477. private _enableTexturesOffline;
  60478. private _manifestVersionFound;
  60479. private _mustUpdateRessources;
  60480. private _hasReachedQuota;
  60481. private _isSupported;
  60482. private _idbFactory;
  60483. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60484. private static IsUASupportingBlobStorage;
  60485. /**
  60486. * Gets a boolean indicating if Database storate is enabled (off by default)
  60487. */
  60488. static IDBStorageEnabled: boolean;
  60489. /**
  60490. * Gets a boolean indicating if scene must be saved in the database
  60491. */
  60492. get enableSceneOffline(): boolean;
  60493. /**
  60494. * Gets a boolean indicating if textures must be saved in the database
  60495. */
  60496. get enableTexturesOffline(): boolean;
  60497. /**
  60498. * Creates a new Database
  60499. * @param urlToScene defines the url to load the scene
  60500. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60501. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60502. */
  60503. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60504. private static _ParseURL;
  60505. private static _ReturnFullUrlLocation;
  60506. private _checkManifestFile;
  60507. /**
  60508. * Open the database and make it available
  60509. * @param successCallback defines the callback to call on success
  60510. * @param errorCallback defines the callback to call on error
  60511. */
  60512. open(successCallback: () => void, errorCallback: () => void): void;
  60513. /**
  60514. * Loads an image from the database
  60515. * @param url defines the url to load from
  60516. * @param image defines the target DOM image
  60517. */
  60518. loadImage(url: string, image: HTMLImageElement): void;
  60519. private _loadImageFromDBAsync;
  60520. private _saveImageIntoDBAsync;
  60521. private _checkVersionFromDB;
  60522. private _loadVersionFromDBAsync;
  60523. private _saveVersionIntoDBAsync;
  60524. /**
  60525. * Loads a file from database
  60526. * @param url defines the URL to load from
  60527. * @param sceneLoaded defines a callback to call on success
  60528. * @param progressCallBack defines a callback to call when progress changed
  60529. * @param errorCallback defines a callback to call on error
  60530. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60531. */
  60532. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60533. private _loadFileAsync;
  60534. private _saveFileAsync;
  60535. /**
  60536. * Validates if xhr data is correct
  60537. * @param xhr defines the request to validate
  60538. * @param dataType defines the expected data type
  60539. * @returns true if data is correct
  60540. */
  60541. private static _ValidateXHRData;
  60542. }
  60543. }
  60544. declare module BABYLON {
  60545. /** @hidden */
  60546. export var gpuUpdateParticlesPixelShader: {
  60547. name: string;
  60548. shader: string;
  60549. };
  60550. }
  60551. declare module BABYLON {
  60552. /** @hidden */
  60553. export var gpuUpdateParticlesVertexShader: {
  60554. name: string;
  60555. shader: string;
  60556. };
  60557. }
  60558. declare module BABYLON {
  60559. /** @hidden */
  60560. export var clipPlaneFragmentDeclaration2: {
  60561. name: string;
  60562. shader: string;
  60563. };
  60564. }
  60565. declare module BABYLON {
  60566. /** @hidden */
  60567. export var gpuRenderParticlesPixelShader: {
  60568. name: string;
  60569. shader: string;
  60570. };
  60571. }
  60572. declare module BABYLON {
  60573. /** @hidden */
  60574. export var clipPlaneVertexDeclaration2: {
  60575. name: string;
  60576. shader: string;
  60577. };
  60578. }
  60579. declare module BABYLON {
  60580. /** @hidden */
  60581. export var gpuRenderParticlesVertexShader: {
  60582. name: string;
  60583. shader: string;
  60584. };
  60585. }
  60586. declare module BABYLON {
  60587. /**
  60588. * This represents a GPU particle system in Babylon
  60589. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60590. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60591. */
  60592. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60593. /**
  60594. * The layer mask we are rendering the particles through.
  60595. */
  60596. layerMask: number;
  60597. private _capacity;
  60598. private _activeCount;
  60599. private _currentActiveCount;
  60600. private _accumulatedCount;
  60601. private _renderEffect;
  60602. private _updateEffect;
  60603. private _buffer0;
  60604. private _buffer1;
  60605. private _spriteBuffer;
  60606. private _updateVAO;
  60607. private _renderVAO;
  60608. private _targetIndex;
  60609. private _sourceBuffer;
  60610. private _targetBuffer;
  60611. private _engine;
  60612. private _currentRenderId;
  60613. private _started;
  60614. private _stopped;
  60615. private _timeDelta;
  60616. private _randomTexture;
  60617. private _randomTexture2;
  60618. private _attributesStrideSize;
  60619. private _updateEffectOptions;
  60620. private _randomTextureSize;
  60621. private _actualFrame;
  60622. private readonly _rawTextureWidth;
  60623. /**
  60624. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60625. */
  60626. static get IsSupported(): boolean;
  60627. /**
  60628. * An event triggered when the system is disposed.
  60629. */
  60630. onDisposeObservable: Observable<GPUParticleSystem>;
  60631. /**
  60632. * Gets the maximum number of particles active at the same time.
  60633. * @returns The max number of active particles.
  60634. */
  60635. getCapacity(): number;
  60636. /**
  60637. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60638. * to override the particles.
  60639. */
  60640. forceDepthWrite: boolean;
  60641. /**
  60642. * Gets or set the number of active particles
  60643. */
  60644. get activeParticleCount(): number;
  60645. set activeParticleCount(value: number);
  60646. private _preWarmDone;
  60647. /**
  60648. * Is this system ready to be used/rendered
  60649. * @return true if the system is ready
  60650. */
  60651. isReady(): boolean;
  60652. /**
  60653. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60654. * @returns True if it has been started, otherwise false.
  60655. */
  60656. isStarted(): boolean;
  60657. /**
  60658. * Starts the particle system and begins to emit
  60659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60660. */
  60661. start(delay?: number): void;
  60662. /**
  60663. * Stops the particle system.
  60664. */
  60665. stop(): void;
  60666. /**
  60667. * Remove all active particles
  60668. */
  60669. reset(): void;
  60670. /**
  60671. * Returns the string "GPUParticleSystem"
  60672. * @returns a string containing the class name
  60673. */
  60674. getClassName(): string;
  60675. private _colorGradientsTexture;
  60676. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60677. /**
  60678. * Adds a new color gradient
  60679. * @param gradient defines the gradient to use (between 0 and 1)
  60680. * @param color1 defines the color to affect to the specified gradient
  60681. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60682. * @returns the current particle system
  60683. */
  60684. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60685. /**
  60686. * Remove a specific color gradient
  60687. * @param gradient defines the gradient to remove
  60688. * @returns the current particle system
  60689. */
  60690. removeColorGradient(gradient: number): GPUParticleSystem;
  60691. private _angularSpeedGradientsTexture;
  60692. private _sizeGradientsTexture;
  60693. private _velocityGradientsTexture;
  60694. private _limitVelocityGradientsTexture;
  60695. private _dragGradientsTexture;
  60696. private _addFactorGradient;
  60697. /**
  60698. * Adds a new size gradient
  60699. * @param gradient defines the gradient to use (between 0 and 1)
  60700. * @param factor defines the size factor to affect to the specified gradient
  60701. * @returns the current particle system
  60702. */
  60703. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60704. /**
  60705. * Remove a specific size gradient
  60706. * @param gradient defines the gradient to remove
  60707. * @returns the current particle system
  60708. */
  60709. removeSizeGradient(gradient: number): GPUParticleSystem;
  60710. /**
  60711. * Adds a new angular speed gradient
  60712. * @param gradient defines the gradient to use (between 0 and 1)
  60713. * @param factor defines the angular speed to affect to the specified gradient
  60714. * @returns the current particle system
  60715. */
  60716. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60717. /**
  60718. * Remove a specific angular speed gradient
  60719. * @param gradient defines the gradient to remove
  60720. * @returns the current particle system
  60721. */
  60722. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60723. /**
  60724. * Adds a new velocity gradient
  60725. * @param gradient defines the gradient to use (between 0 and 1)
  60726. * @param factor defines the velocity to affect to the specified gradient
  60727. * @returns the current particle system
  60728. */
  60729. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60730. /**
  60731. * Remove a specific velocity gradient
  60732. * @param gradient defines the gradient to remove
  60733. * @returns the current particle system
  60734. */
  60735. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60736. /**
  60737. * Adds a new limit velocity gradient
  60738. * @param gradient defines the gradient to use (between 0 and 1)
  60739. * @param factor defines the limit velocity value to affect to the specified gradient
  60740. * @returns the current particle system
  60741. */
  60742. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60743. /**
  60744. * Remove a specific limit velocity gradient
  60745. * @param gradient defines the gradient to remove
  60746. * @returns the current particle system
  60747. */
  60748. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60749. /**
  60750. * Adds a new drag gradient
  60751. * @param gradient defines the gradient to use (between 0 and 1)
  60752. * @param factor defines the drag value to affect to the specified gradient
  60753. * @returns the current particle system
  60754. */
  60755. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60756. /**
  60757. * Remove a specific drag gradient
  60758. * @param gradient defines the gradient to remove
  60759. * @returns the current particle system
  60760. */
  60761. removeDragGradient(gradient: number): GPUParticleSystem;
  60762. /**
  60763. * Not supported by GPUParticleSystem
  60764. * @param gradient defines the gradient to use (between 0 and 1)
  60765. * @param factor defines the emit rate value to affect to the specified gradient
  60766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60767. * @returns the current particle system
  60768. */
  60769. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60770. /**
  60771. * Not supported by GPUParticleSystem
  60772. * @param gradient defines the gradient to remove
  60773. * @returns the current particle system
  60774. */
  60775. removeEmitRateGradient(gradient: number): IParticleSystem;
  60776. /**
  60777. * Not supported by GPUParticleSystem
  60778. * @param gradient defines the gradient to use (between 0 and 1)
  60779. * @param factor defines the start size value to affect to the specified gradient
  60780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60781. * @returns the current particle system
  60782. */
  60783. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60784. /**
  60785. * Not supported by GPUParticleSystem
  60786. * @param gradient defines the gradient to remove
  60787. * @returns the current particle system
  60788. */
  60789. removeStartSizeGradient(gradient: number): IParticleSystem;
  60790. /**
  60791. * Not supported by GPUParticleSystem
  60792. * @param gradient defines the gradient to use (between 0 and 1)
  60793. * @param min defines the color remap minimal range
  60794. * @param max defines the color remap maximal range
  60795. * @returns the current particle system
  60796. */
  60797. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60798. /**
  60799. * Not supported by GPUParticleSystem
  60800. * @param gradient defines the gradient to remove
  60801. * @returns the current particle system
  60802. */
  60803. removeColorRemapGradient(): IParticleSystem;
  60804. /**
  60805. * Not supported by GPUParticleSystem
  60806. * @param gradient defines the gradient to use (between 0 and 1)
  60807. * @param min defines the alpha remap minimal range
  60808. * @param max defines the alpha remap maximal range
  60809. * @returns the current particle system
  60810. */
  60811. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60812. /**
  60813. * Not supported by GPUParticleSystem
  60814. * @param gradient defines the gradient to remove
  60815. * @returns the current particle system
  60816. */
  60817. removeAlphaRemapGradient(): IParticleSystem;
  60818. /**
  60819. * Not supported by GPUParticleSystem
  60820. * @param gradient defines the gradient to use (between 0 and 1)
  60821. * @param color defines the color to affect to the specified gradient
  60822. * @returns the current particle system
  60823. */
  60824. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60825. /**
  60826. * Not supported by GPUParticleSystem
  60827. * @param gradient defines the gradient to remove
  60828. * @returns the current particle system
  60829. */
  60830. removeRampGradient(): IParticleSystem;
  60831. /**
  60832. * Not supported by GPUParticleSystem
  60833. * @returns the list of ramp gradients
  60834. */
  60835. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60836. /**
  60837. * Not supported by GPUParticleSystem
  60838. * Gets or sets a boolean indicating that ramp gradients must be used
  60839. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60840. */
  60841. get useRampGradients(): boolean;
  60842. set useRampGradients(value: boolean);
  60843. /**
  60844. * Not supported by GPUParticleSystem
  60845. * @param gradient defines the gradient to use (between 0 and 1)
  60846. * @param factor defines the life time factor to affect to the specified gradient
  60847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60848. * @returns the current particle system
  60849. */
  60850. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60851. /**
  60852. * Not supported by GPUParticleSystem
  60853. * @param gradient defines the gradient to remove
  60854. * @returns the current particle system
  60855. */
  60856. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60857. /**
  60858. * Instantiates a GPU particle system.
  60859. * 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.
  60860. * @param name The name of the particle system
  60861. * @param options The options used to create the system
  60862. * @param scene The scene the particle system belongs to
  60863. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60864. */
  60865. constructor(name: string, options: Partial<{
  60866. capacity: number;
  60867. randomTextureSize: number;
  60868. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60869. protected _reset(): void;
  60870. private _createUpdateVAO;
  60871. private _createRenderVAO;
  60872. private _initialize;
  60873. /** @hidden */
  60874. _recreateUpdateEffect(): void;
  60875. /** @hidden */
  60876. _recreateRenderEffect(): void;
  60877. /**
  60878. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60879. * @param preWarm defines if we are in the pre-warmimg phase
  60880. */
  60881. animate(preWarm?: boolean): void;
  60882. private _createFactorGradientTexture;
  60883. private _createSizeGradientTexture;
  60884. private _createAngularSpeedGradientTexture;
  60885. private _createVelocityGradientTexture;
  60886. private _createLimitVelocityGradientTexture;
  60887. private _createDragGradientTexture;
  60888. private _createColorGradientTexture;
  60889. /**
  60890. * Renders the particle system in its current state
  60891. * @param preWarm defines if the system should only update the particles but not render them
  60892. * @returns the current number of particles
  60893. */
  60894. render(preWarm?: boolean): number;
  60895. /**
  60896. * Rebuilds the particle system
  60897. */
  60898. rebuild(): void;
  60899. private _releaseBuffers;
  60900. private _releaseVAOs;
  60901. /**
  60902. * Disposes the particle system and free the associated resources
  60903. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60904. */
  60905. dispose(disposeTexture?: boolean): void;
  60906. /**
  60907. * Clones the particle system.
  60908. * @param name The name of the cloned object
  60909. * @param newEmitter The new emitter to use
  60910. * @returns the cloned particle system
  60911. */
  60912. clone(name: string, newEmitter: any): GPUParticleSystem;
  60913. /**
  60914. * Serializes the particle system to a JSON object.
  60915. * @returns the JSON object
  60916. */
  60917. serialize(): any;
  60918. /**
  60919. * Parses a JSON object to create a GPU particle system.
  60920. * @param parsedParticleSystem The JSON object to parse
  60921. * @param scene The scene to create the particle system in
  60922. * @param rootUrl The root url to use to load external dependencies like texture
  60923. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60924. * @returns the parsed GPU particle system
  60925. */
  60926. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60927. }
  60928. }
  60929. declare module BABYLON {
  60930. /**
  60931. * Represents a set of particle systems working together to create a specific effect
  60932. */
  60933. export class ParticleSystemSet implements IDisposable {
  60934. /**
  60935. * Gets or sets base Assets URL
  60936. */
  60937. static BaseAssetsUrl: string;
  60938. private _emitterCreationOptions;
  60939. private _emitterNode;
  60940. /**
  60941. * Gets the particle system list
  60942. */
  60943. systems: IParticleSystem[];
  60944. /**
  60945. * Gets the emitter node used with this set
  60946. */
  60947. get emitterNode(): Nullable<TransformNode>;
  60948. /**
  60949. * Creates a new emitter mesh as a sphere
  60950. * @param options defines the options used to create the sphere
  60951. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60952. * @param scene defines the hosting scene
  60953. */
  60954. setEmitterAsSphere(options: {
  60955. diameter: number;
  60956. segments: number;
  60957. color: Color3;
  60958. }, renderingGroupId: number, scene: Scene): void;
  60959. /**
  60960. * Starts all particle systems of the set
  60961. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60962. */
  60963. start(emitter?: AbstractMesh): void;
  60964. /**
  60965. * Release all associated resources
  60966. */
  60967. dispose(): void;
  60968. /**
  60969. * Serialize the set into a JSON compatible object
  60970. * @returns a JSON compatible representation of the set
  60971. */
  60972. serialize(): any;
  60973. /**
  60974. * Parse a new ParticleSystemSet from a serialized source
  60975. * @param data defines a JSON compatible representation of the set
  60976. * @param scene defines the hosting scene
  60977. * @param gpu defines if we want GPU particles or CPU particles
  60978. * @returns a new ParticleSystemSet
  60979. */
  60980. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60981. }
  60982. }
  60983. declare module BABYLON {
  60984. /**
  60985. * This class is made for on one-liner static method to help creating particle system set.
  60986. */
  60987. export class ParticleHelper {
  60988. /**
  60989. * Gets or sets base Assets URL
  60990. */
  60991. static BaseAssetsUrl: string;
  60992. /**
  60993. * Create a default particle system that you can tweak
  60994. * @param emitter defines the emitter to use
  60995. * @param capacity defines the system capacity (default is 500 particles)
  60996. * @param scene defines the hosting scene
  60997. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60998. * @returns the new Particle system
  60999. */
  61000. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61001. /**
  61002. * This is the main static method (one-liner) of this helper to create different particle systems
  61003. * @param type This string represents the type to the particle system to create
  61004. * @param scene The scene where the particle system should live
  61005. * @param gpu If the system will use gpu
  61006. * @returns the ParticleSystemSet created
  61007. */
  61008. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61009. /**
  61010. * Static function used to export a particle system to a ParticleSystemSet variable.
  61011. * Please note that the emitter shape is not exported
  61012. * @param systems defines the particle systems to export
  61013. * @returns the created particle system set
  61014. */
  61015. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61016. }
  61017. }
  61018. declare module BABYLON {
  61019. interface Engine {
  61020. /**
  61021. * Create an effect to use with particle systems.
  61022. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61023. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61024. * @param uniformsNames defines a list of attribute names
  61025. * @param samplers defines an array of string used to represent textures
  61026. * @param defines defines the string containing the defines to use to compile the shaders
  61027. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61028. * @param onCompiled defines a function to call when the effect creation is successful
  61029. * @param onError defines a function to call when the effect creation has failed
  61030. * @returns the new Effect
  61031. */
  61032. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61033. }
  61034. interface Mesh {
  61035. /**
  61036. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61037. * @returns an array of IParticleSystem
  61038. */
  61039. getEmittedParticleSystems(): IParticleSystem[];
  61040. /**
  61041. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61042. * @returns an array of IParticleSystem
  61043. */
  61044. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61045. }
  61046. /**
  61047. * @hidden
  61048. */
  61049. export var _IDoNeedToBeInTheBuild: number;
  61050. }
  61051. declare module BABYLON {
  61052. /** Defines the 4 color options */
  61053. export enum PointColor {
  61054. /** color value */
  61055. Color = 2,
  61056. /** uv value */
  61057. UV = 1,
  61058. /** random value */
  61059. Random = 0,
  61060. /** stated value */
  61061. Stated = 3
  61062. }
  61063. /**
  61064. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61065. * 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.
  61066. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61067. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61068. *
  61069. * Full documentation here : TO BE ENTERED
  61070. */
  61071. export class PointsCloudSystem implements IDisposable {
  61072. /**
  61073. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61074. * Example : var p = SPS.particles[i];
  61075. */
  61076. particles: CloudPoint[];
  61077. /**
  61078. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61079. */
  61080. nbParticles: number;
  61081. /**
  61082. * This a counter for your own usage. It's not set by any SPS functions.
  61083. */
  61084. counter: number;
  61085. /**
  61086. * The PCS name. This name is also given to the underlying mesh.
  61087. */
  61088. name: string;
  61089. /**
  61090. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61091. */
  61092. mesh: Mesh;
  61093. /**
  61094. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61095. * Please read :
  61096. */
  61097. vars: any;
  61098. /**
  61099. * @hidden
  61100. */
  61101. _size: number;
  61102. private _scene;
  61103. private _promises;
  61104. private _positions;
  61105. private _indices;
  61106. private _normals;
  61107. private _colors;
  61108. private _uvs;
  61109. private _indices32;
  61110. private _positions32;
  61111. private _colors32;
  61112. private _uvs32;
  61113. private _updatable;
  61114. private _isVisibilityBoxLocked;
  61115. private _alwaysVisible;
  61116. private _groups;
  61117. private _groupCounter;
  61118. private _computeParticleColor;
  61119. private _computeParticleTexture;
  61120. private _computeParticleRotation;
  61121. private _computeBoundingBox;
  61122. private _isReady;
  61123. /**
  61124. * Creates a PCS (Points Cloud System) object
  61125. * @param name (String) is the PCS name, this will be the underlying mesh name
  61126. * @param pointSize (number) is the size for each point
  61127. * @param scene (Scene) is the scene in which the PCS is added
  61128. * @param options defines the options of the PCS e.g.
  61129. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61130. */
  61131. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61132. updatable?: boolean;
  61133. });
  61134. /**
  61135. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61136. * If no points were added to the PCS, the returned mesh is just a single point.
  61137. * @returns a promise for the created mesh
  61138. */
  61139. buildMeshAsync(): Promise<Mesh>;
  61140. /**
  61141. * @hidden
  61142. */
  61143. private _buildMesh;
  61144. private _addParticle;
  61145. private _randomUnitVector;
  61146. private _getColorIndicesForCoord;
  61147. private _setPointsColorOrUV;
  61148. private _colorFromTexture;
  61149. private _calculateDensity;
  61150. /**
  61151. * Adds points to the PCS in random positions within a unit sphere
  61152. * @param nb (positive integer) the number of particles to be created from this model
  61153. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61154. * @returns the number of groups in the system
  61155. */
  61156. addPoints(nb: number, pointFunction?: any): number;
  61157. /**
  61158. * Adds points to the PCS from the surface of the model shape
  61159. * @param mesh is any Mesh object that will be used as a surface model for the points
  61160. * @param nb (positive integer) the number of particles to be created from this model
  61161. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61162. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61163. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61164. * @returns the number of groups in the system
  61165. */
  61166. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61167. /**
  61168. * Adds points to the PCS inside the model shape
  61169. * @param mesh is any Mesh object that will be used as a surface model for the points
  61170. * @param nb (positive integer) the number of particles to be created from this model
  61171. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61172. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61173. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61174. * @returns the number of groups in the system
  61175. */
  61176. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61177. /**
  61178. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61179. * This method calls `updateParticle()` for each particle of the SPS.
  61180. * For an animated SPS, it is usually called within the render loop.
  61181. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61182. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61183. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61184. * @returns the PCS.
  61185. */
  61186. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61187. /**
  61188. * Disposes the PCS.
  61189. */
  61190. dispose(): void;
  61191. /**
  61192. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61193. * doc :
  61194. * @returns the PCS.
  61195. */
  61196. refreshVisibleSize(): PointsCloudSystem;
  61197. /**
  61198. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61199. * @param size the size (float) of the visibility box
  61200. * note : this doesn't lock the PCS mesh bounding box.
  61201. * doc :
  61202. */
  61203. setVisibilityBox(size: number): void;
  61204. /**
  61205. * Gets whether the PCS is always visible or not
  61206. * doc :
  61207. */
  61208. get isAlwaysVisible(): boolean;
  61209. /**
  61210. * Sets the PCS as always visible or not
  61211. * doc :
  61212. */
  61213. set isAlwaysVisible(val: boolean);
  61214. /**
  61215. * Tells to `setParticles()` to compute the particle rotations or not
  61216. * Default value : false. The PCS is faster when it's set to false
  61217. * Note : particle rotations are only applied to parent particles
  61218. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61219. */
  61220. set computeParticleRotation(val: boolean);
  61221. /**
  61222. * Tells to `setParticles()` to compute the particle colors or not.
  61223. * Default value : true. The PCS is faster when it's set to false.
  61224. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61225. */
  61226. set computeParticleColor(val: boolean);
  61227. set computeParticleTexture(val: boolean);
  61228. /**
  61229. * Gets if `setParticles()` computes the particle colors or not.
  61230. * Default value : false. The PCS is faster when it's set to false.
  61231. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61232. */
  61233. get computeParticleColor(): boolean;
  61234. /**
  61235. * Gets if `setParticles()` computes the particle textures or not.
  61236. * Default value : false. The PCS is faster when it's set to false.
  61237. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61238. */
  61239. get computeParticleTexture(): boolean;
  61240. /**
  61241. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61242. */
  61243. set computeBoundingBox(val: boolean);
  61244. /**
  61245. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61246. */
  61247. get computeBoundingBox(): boolean;
  61248. /**
  61249. * This function does nothing. It may be overwritten to set all the particle first values.
  61250. * The PCS doesn't call this function, you may have to call it by your own.
  61251. * doc :
  61252. */
  61253. initParticles(): void;
  61254. /**
  61255. * This function does nothing. It may be overwritten to recycle a particle
  61256. * The PCS doesn't call this function, you can to call it
  61257. * doc :
  61258. * @param particle The particle to recycle
  61259. * @returns the recycled particle
  61260. */
  61261. recycleParticle(particle: CloudPoint): CloudPoint;
  61262. /**
  61263. * Updates a particle : this function should be overwritten by the user.
  61264. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61265. * doc :
  61266. * @example : just set a particle position or velocity and recycle conditions
  61267. * @param particle The particle to update
  61268. * @returns the updated particle
  61269. */
  61270. updateParticle(particle: CloudPoint): CloudPoint;
  61271. /**
  61272. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61273. * This does nothing and may be overwritten by the user.
  61274. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61275. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61276. * @param update the boolean update value actually passed to setParticles()
  61277. */
  61278. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61279. /**
  61280. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61281. * This will be passed three parameters.
  61282. * This does nothing and may be overwritten by the user.
  61283. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61284. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61285. * @param update the boolean update value actually passed to setParticles()
  61286. */
  61287. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61288. }
  61289. }
  61290. declare module BABYLON {
  61291. /**
  61292. * Represents one particle of a points cloud system.
  61293. */
  61294. export class CloudPoint {
  61295. /**
  61296. * particle global index
  61297. */
  61298. idx: number;
  61299. /**
  61300. * The color of the particle
  61301. */
  61302. color: Nullable<Color4>;
  61303. /**
  61304. * The world space position of the particle.
  61305. */
  61306. position: Vector3;
  61307. /**
  61308. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61309. */
  61310. rotation: Vector3;
  61311. /**
  61312. * The world space rotation quaternion of the particle.
  61313. */
  61314. rotationQuaternion: Nullable<Quaternion>;
  61315. /**
  61316. * The uv of the particle.
  61317. */
  61318. uv: Nullable<Vector2>;
  61319. /**
  61320. * The current speed of the particle.
  61321. */
  61322. velocity: Vector3;
  61323. /**
  61324. * The pivot point in the particle local space.
  61325. */
  61326. pivot: Vector3;
  61327. /**
  61328. * Must the particle be translated from its pivot point in its local space ?
  61329. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61330. * Default : false
  61331. */
  61332. translateFromPivot: boolean;
  61333. /**
  61334. * Index of this particle in the global "positions" array (Internal use)
  61335. * @hidden
  61336. */
  61337. _pos: number;
  61338. /**
  61339. * @hidden Index of this particle in the global "indices" array (Internal use)
  61340. */
  61341. _ind: number;
  61342. /**
  61343. * Group this particle belongs to
  61344. */
  61345. _group: PointsGroup;
  61346. /**
  61347. * Group id of this particle
  61348. */
  61349. groupId: number;
  61350. /**
  61351. * Index of the particle in its group id (Internal use)
  61352. */
  61353. idxInGroup: number;
  61354. /**
  61355. * @hidden Particle BoundingInfo object (Internal use)
  61356. */
  61357. _boundingInfo: BoundingInfo;
  61358. /**
  61359. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61360. */
  61361. _pcs: PointsCloudSystem;
  61362. /**
  61363. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61364. */
  61365. _stillInvisible: boolean;
  61366. /**
  61367. * @hidden Last computed particle rotation matrix
  61368. */
  61369. _rotationMatrix: number[];
  61370. /**
  61371. * Parent particle Id, if any.
  61372. * Default null.
  61373. */
  61374. parentId: Nullable<number>;
  61375. /**
  61376. * @hidden Internal global position in the PCS.
  61377. */
  61378. _globalPosition: Vector3;
  61379. /**
  61380. * Creates a Point Cloud object.
  61381. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61382. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61383. * @param group (PointsGroup) is the group the particle belongs to
  61384. * @param groupId (integer) is the group identifier in the PCS.
  61385. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61386. * @param pcs defines the PCS it is associated to
  61387. */
  61388. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61389. /**
  61390. * get point size
  61391. */
  61392. get size(): Vector3;
  61393. /**
  61394. * Set point size
  61395. */
  61396. set size(scale: Vector3);
  61397. /**
  61398. * Legacy support, changed quaternion to rotationQuaternion
  61399. */
  61400. get quaternion(): Nullable<Quaternion>;
  61401. /**
  61402. * Legacy support, changed quaternion to rotationQuaternion
  61403. */
  61404. set quaternion(q: Nullable<Quaternion>);
  61405. /**
  61406. * Returns a boolean. True if the particle intersects a mesh, else false
  61407. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61408. * @param target is the object (point or mesh) what the intersection is computed against
  61409. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61410. * @returns true if it intersects
  61411. */
  61412. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61413. /**
  61414. * get the rotation matrix of the particle
  61415. * @hidden
  61416. */
  61417. getRotationMatrix(m: Matrix): void;
  61418. }
  61419. /**
  61420. * Represents a group of points in a points cloud system
  61421. * * PCS internal tool, don't use it manually.
  61422. */
  61423. export class PointsGroup {
  61424. /**
  61425. * The group id
  61426. * @hidden
  61427. */
  61428. groupID: number;
  61429. /**
  61430. * image data for group (internal use)
  61431. * @hidden
  61432. */
  61433. _groupImageData: Nullable<ArrayBufferView>;
  61434. /**
  61435. * Image Width (internal use)
  61436. * @hidden
  61437. */
  61438. _groupImgWidth: number;
  61439. /**
  61440. * Image Height (internal use)
  61441. * @hidden
  61442. */
  61443. _groupImgHeight: number;
  61444. /**
  61445. * Custom position function (internal use)
  61446. * @hidden
  61447. */
  61448. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61449. /**
  61450. * density per facet for surface points
  61451. * @hidden
  61452. */
  61453. _groupDensity: number[];
  61454. /**
  61455. * Only when points are colored by texture carries pointer to texture list array
  61456. * @hidden
  61457. */
  61458. _textureNb: number;
  61459. /**
  61460. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61461. * PCS internal tool, don't use it manually.
  61462. * @hidden
  61463. */
  61464. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61465. }
  61466. }
  61467. declare module BABYLON {
  61468. interface Scene {
  61469. /** @hidden (Backing field) */
  61470. _physicsEngine: Nullable<IPhysicsEngine>;
  61471. /** @hidden */
  61472. _physicsTimeAccumulator: number;
  61473. /**
  61474. * Gets the current physics engine
  61475. * @returns a IPhysicsEngine or null if none attached
  61476. */
  61477. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61478. /**
  61479. * Enables physics to the current scene
  61480. * @param gravity defines the scene's gravity for the physics engine
  61481. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61482. * @return a boolean indicating if the physics engine was initialized
  61483. */
  61484. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61485. /**
  61486. * Disables and disposes the physics engine associated with the scene
  61487. */
  61488. disablePhysicsEngine(): void;
  61489. /**
  61490. * Gets a boolean indicating if there is an active physics engine
  61491. * @returns a boolean indicating if there is an active physics engine
  61492. */
  61493. isPhysicsEnabled(): boolean;
  61494. /**
  61495. * Deletes a physics compound impostor
  61496. * @param compound defines the compound to delete
  61497. */
  61498. deleteCompoundImpostor(compound: any): void;
  61499. /**
  61500. * An event triggered when physic simulation is about to be run
  61501. */
  61502. onBeforePhysicsObservable: Observable<Scene>;
  61503. /**
  61504. * An event triggered when physic simulation has been done
  61505. */
  61506. onAfterPhysicsObservable: Observable<Scene>;
  61507. }
  61508. interface AbstractMesh {
  61509. /** @hidden */
  61510. _physicsImpostor: Nullable<PhysicsImpostor>;
  61511. /**
  61512. * Gets or sets impostor used for physic simulation
  61513. * @see http://doc.babylonjs.com/features/physics_engine
  61514. */
  61515. physicsImpostor: Nullable<PhysicsImpostor>;
  61516. /**
  61517. * Gets the current physics impostor
  61518. * @see http://doc.babylonjs.com/features/physics_engine
  61519. * @returns a physics impostor or null
  61520. */
  61521. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61522. /** Apply a physic impulse to the mesh
  61523. * @param force defines the force to apply
  61524. * @param contactPoint defines where to apply the force
  61525. * @returns the current mesh
  61526. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61527. */
  61528. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61529. /**
  61530. * Creates a physic joint between two meshes
  61531. * @param otherMesh defines the other mesh to use
  61532. * @param pivot1 defines the pivot to use on this mesh
  61533. * @param pivot2 defines the pivot to use on the other mesh
  61534. * @param options defines additional options (can be plugin dependent)
  61535. * @returns the current mesh
  61536. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61537. */
  61538. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61539. /** @hidden */
  61540. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61541. }
  61542. /**
  61543. * Defines the physics engine scene component responsible to manage a physics engine
  61544. */
  61545. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61546. /**
  61547. * The component name helpful to identify the component in the list of scene components.
  61548. */
  61549. readonly name: string;
  61550. /**
  61551. * The scene the component belongs to.
  61552. */
  61553. scene: Scene;
  61554. /**
  61555. * Creates a new instance of the component for the given scene
  61556. * @param scene Defines the scene to register the component in
  61557. */
  61558. constructor(scene: Scene);
  61559. /**
  61560. * Registers the component in a given scene
  61561. */
  61562. register(): void;
  61563. /**
  61564. * Rebuilds the elements related to this component in case of
  61565. * context lost for instance.
  61566. */
  61567. rebuild(): void;
  61568. /**
  61569. * Disposes the component and the associated ressources
  61570. */
  61571. dispose(): void;
  61572. }
  61573. }
  61574. declare module BABYLON {
  61575. /**
  61576. * A helper for physics simulations
  61577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61578. */
  61579. export class PhysicsHelper {
  61580. private _scene;
  61581. private _physicsEngine;
  61582. /**
  61583. * Initializes the Physics helper
  61584. * @param scene Babylon.js scene
  61585. */
  61586. constructor(scene: Scene);
  61587. /**
  61588. * Applies a radial explosion impulse
  61589. * @param origin the origin of the explosion
  61590. * @param radiusOrEventOptions the radius or the options of radial explosion
  61591. * @param strength the explosion strength
  61592. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61593. * @returns A physics radial explosion event, or null
  61594. */
  61595. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61596. /**
  61597. * Applies a radial explosion force
  61598. * @param origin the origin of the explosion
  61599. * @param radiusOrEventOptions the radius or the options of radial explosion
  61600. * @param strength the explosion strength
  61601. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61602. * @returns A physics radial explosion event, or null
  61603. */
  61604. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61605. /**
  61606. * Creates a gravitational field
  61607. * @param origin the origin of the explosion
  61608. * @param radiusOrEventOptions the radius or the options of radial explosion
  61609. * @param strength the explosion strength
  61610. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61611. * @returns A physics gravitational field event, or null
  61612. */
  61613. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61614. /**
  61615. * Creates a physics updraft event
  61616. * @param origin the origin of the updraft
  61617. * @param radiusOrEventOptions the radius or the options of the updraft
  61618. * @param strength the strength of the updraft
  61619. * @param height the height of the updraft
  61620. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61621. * @returns A physics updraft event, or null
  61622. */
  61623. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61624. /**
  61625. * Creates a physics vortex event
  61626. * @param origin the of the vortex
  61627. * @param radiusOrEventOptions the radius or the options of the vortex
  61628. * @param strength the strength of the vortex
  61629. * @param height the height of the vortex
  61630. * @returns a Physics vortex event, or null
  61631. * A physics vortex event or null
  61632. */
  61633. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61634. }
  61635. /**
  61636. * Represents a physics radial explosion event
  61637. */
  61638. class PhysicsRadialExplosionEvent {
  61639. private _scene;
  61640. private _options;
  61641. private _sphere;
  61642. private _dataFetched;
  61643. /**
  61644. * Initializes a radial explosioin event
  61645. * @param _scene BabylonJS scene
  61646. * @param _options The options for the vortex event
  61647. */
  61648. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61649. /**
  61650. * Returns the data related to the radial explosion event (sphere).
  61651. * @returns The radial explosion event data
  61652. */
  61653. getData(): PhysicsRadialExplosionEventData;
  61654. /**
  61655. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61656. * @param impostor A physics imposter
  61657. * @param origin the origin of the explosion
  61658. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61659. */
  61660. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61661. /**
  61662. * Triggers affecterd impostors callbacks
  61663. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61664. */
  61665. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61666. /**
  61667. * Disposes the sphere.
  61668. * @param force Specifies if the sphere should be disposed by force
  61669. */
  61670. dispose(force?: boolean): void;
  61671. /*** Helpers ***/
  61672. private _prepareSphere;
  61673. private _intersectsWithSphere;
  61674. }
  61675. /**
  61676. * Represents a gravitational field event
  61677. */
  61678. class PhysicsGravitationalFieldEvent {
  61679. private _physicsHelper;
  61680. private _scene;
  61681. private _origin;
  61682. private _options;
  61683. private _tickCallback;
  61684. private _sphere;
  61685. private _dataFetched;
  61686. /**
  61687. * Initializes the physics gravitational field event
  61688. * @param _physicsHelper A physics helper
  61689. * @param _scene BabylonJS scene
  61690. * @param _origin The origin position of the gravitational field event
  61691. * @param _options The options for the vortex event
  61692. */
  61693. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61694. /**
  61695. * Returns the data related to the gravitational field event (sphere).
  61696. * @returns A gravitational field event
  61697. */
  61698. getData(): PhysicsGravitationalFieldEventData;
  61699. /**
  61700. * Enables the gravitational field.
  61701. */
  61702. enable(): void;
  61703. /**
  61704. * Disables the gravitational field.
  61705. */
  61706. disable(): void;
  61707. /**
  61708. * Disposes the sphere.
  61709. * @param force The force to dispose from the gravitational field event
  61710. */
  61711. dispose(force?: boolean): void;
  61712. private _tick;
  61713. }
  61714. /**
  61715. * Represents a physics updraft event
  61716. */
  61717. class PhysicsUpdraftEvent {
  61718. private _scene;
  61719. private _origin;
  61720. private _options;
  61721. private _physicsEngine;
  61722. private _originTop;
  61723. private _originDirection;
  61724. private _tickCallback;
  61725. private _cylinder;
  61726. private _cylinderPosition;
  61727. private _dataFetched;
  61728. /**
  61729. * Initializes the physics updraft event
  61730. * @param _scene BabylonJS scene
  61731. * @param _origin The origin position of the updraft
  61732. * @param _options The options for the updraft event
  61733. */
  61734. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61735. /**
  61736. * Returns the data related to the updraft event (cylinder).
  61737. * @returns A physics updraft event
  61738. */
  61739. getData(): PhysicsUpdraftEventData;
  61740. /**
  61741. * Enables the updraft.
  61742. */
  61743. enable(): void;
  61744. /**
  61745. * Disables the updraft.
  61746. */
  61747. disable(): void;
  61748. /**
  61749. * Disposes the cylinder.
  61750. * @param force Specifies if the updraft should be disposed by force
  61751. */
  61752. dispose(force?: boolean): void;
  61753. private getImpostorHitData;
  61754. private _tick;
  61755. /*** Helpers ***/
  61756. private _prepareCylinder;
  61757. private _intersectsWithCylinder;
  61758. }
  61759. /**
  61760. * Represents a physics vortex event
  61761. */
  61762. class PhysicsVortexEvent {
  61763. private _scene;
  61764. private _origin;
  61765. private _options;
  61766. private _physicsEngine;
  61767. private _originTop;
  61768. private _tickCallback;
  61769. private _cylinder;
  61770. private _cylinderPosition;
  61771. private _dataFetched;
  61772. /**
  61773. * Initializes the physics vortex event
  61774. * @param _scene The BabylonJS scene
  61775. * @param _origin The origin position of the vortex
  61776. * @param _options The options for the vortex event
  61777. */
  61778. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61779. /**
  61780. * Returns the data related to the vortex event (cylinder).
  61781. * @returns The physics vortex event data
  61782. */
  61783. getData(): PhysicsVortexEventData;
  61784. /**
  61785. * Enables the vortex.
  61786. */
  61787. enable(): void;
  61788. /**
  61789. * Disables the cortex.
  61790. */
  61791. disable(): void;
  61792. /**
  61793. * Disposes the sphere.
  61794. * @param force
  61795. */
  61796. dispose(force?: boolean): void;
  61797. private getImpostorHitData;
  61798. private _tick;
  61799. /*** Helpers ***/
  61800. private _prepareCylinder;
  61801. private _intersectsWithCylinder;
  61802. }
  61803. /**
  61804. * Options fot the radial explosion event
  61805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61806. */
  61807. export class PhysicsRadialExplosionEventOptions {
  61808. /**
  61809. * The radius of the sphere for the radial explosion.
  61810. */
  61811. radius: number;
  61812. /**
  61813. * The strenth of the explosion.
  61814. */
  61815. strength: number;
  61816. /**
  61817. * The strenght of the force in correspondence to the distance of the affected object
  61818. */
  61819. falloff: PhysicsRadialImpulseFalloff;
  61820. /**
  61821. * Sphere options for the radial explosion.
  61822. */
  61823. sphere: {
  61824. segments: number;
  61825. diameter: number;
  61826. };
  61827. /**
  61828. * Sphere options for the radial explosion.
  61829. */
  61830. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61831. }
  61832. /**
  61833. * Options fot the updraft event
  61834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61835. */
  61836. export class PhysicsUpdraftEventOptions {
  61837. /**
  61838. * The radius of the cylinder for the vortex
  61839. */
  61840. radius: number;
  61841. /**
  61842. * The strenth of the updraft.
  61843. */
  61844. strength: number;
  61845. /**
  61846. * The height of the cylinder for the updraft.
  61847. */
  61848. height: number;
  61849. /**
  61850. * The mode for the the updraft.
  61851. */
  61852. updraftMode: PhysicsUpdraftMode;
  61853. }
  61854. /**
  61855. * Options fot the vortex event
  61856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61857. */
  61858. export class PhysicsVortexEventOptions {
  61859. /**
  61860. * The radius of the cylinder for the vortex
  61861. */
  61862. radius: number;
  61863. /**
  61864. * The strenth of the vortex.
  61865. */
  61866. strength: number;
  61867. /**
  61868. * The height of the cylinder for the vortex.
  61869. */
  61870. height: number;
  61871. /**
  61872. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61873. */
  61874. centripetalForceThreshold: number;
  61875. /**
  61876. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61877. */
  61878. centripetalForceMultiplier: number;
  61879. /**
  61880. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61881. */
  61882. centrifugalForceMultiplier: number;
  61883. /**
  61884. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61885. */
  61886. updraftForceMultiplier: number;
  61887. }
  61888. /**
  61889. * The strenght of the force in correspondence to the distance of the affected object
  61890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61891. */
  61892. export enum PhysicsRadialImpulseFalloff {
  61893. /** Defines that impulse is constant in strength across it's whole radius */
  61894. Constant = 0,
  61895. /** Defines that impulse gets weaker if it's further from the origin */
  61896. Linear = 1
  61897. }
  61898. /**
  61899. * The strength of the force in correspondence to the distance of the affected object
  61900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61901. */
  61902. export enum PhysicsUpdraftMode {
  61903. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61904. Center = 0,
  61905. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61906. Perpendicular = 1
  61907. }
  61908. /**
  61909. * Interface for a physics hit data
  61910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61911. */
  61912. export interface PhysicsHitData {
  61913. /**
  61914. * The force applied at the contact point
  61915. */
  61916. force: Vector3;
  61917. /**
  61918. * The contact point
  61919. */
  61920. contactPoint: Vector3;
  61921. /**
  61922. * The distance from the origin to the contact point
  61923. */
  61924. distanceFromOrigin: number;
  61925. }
  61926. /**
  61927. * Interface for radial explosion event data
  61928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61929. */
  61930. export interface PhysicsRadialExplosionEventData {
  61931. /**
  61932. * A sphere used for the radial explosion event
  61933. */
  61934. sphere: Mesh;
  61935. }
  61936. /**
  61937. * Interface for gravitational field event data
  61938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61939. */
  61940. export interface PhysicsGravitationalFieldEventData {
  61941. /**
  61942. * A sphere mesh used for the gravitational field event
  61943. */
  61944. sphere: Mesh;
  61945. }
  61946. /**
  61947. * Interface for updraft event data
  61948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61949. */
  61950. export interface PhysicsUpdraftEventData {
  61951. /**
  61952. * A cylinder used for the updraft event
  61953. */
  61954. cylinder: Mesh;
  61955. }
  61956. /**
  61957. * Interface for vortex event data
  61958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61959. */
  61960. export interface PhysicsVortexEventData {
  61961. /**
  61962. * A cylinder used for the vortex event
  61963. */
  61964. cylinder: Mesh;
  61965. }
  61966. /**
  61967. * Interface for an affected physics impostor
  61968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61969. */
  61970. export interface PhysicsAffectedImpostorWithData {
  61971. /**
  61972. * The impostor affected by the effect
  61973. */
  61974. impostor: PhysicsImpostor;
  61975. /**
  61976. * The data about the hit/horce from the explosion
  61977. */
  61978. hitData: PhysicsHitData;
  61979. }
  61980. }
  61981. declare module BABYLON {
  61982. /** @hidden */
  61983. export var blackAndWhitePixelShader: {
  61984. name: string;
  61985. shader: string;
  61986. };
  61987. }
  61988. declare module BABYLON {
  61989. /**
  61990. * Post process used to render in black and white
  61991. */
  61992. export class BlackAndWhitePostProcess extends PostProcess {
  61993. /**
  61994. * Linear about to convert he result to black and white (default: 1)
  61995. */
  61996. degree: number;
  61997. /**
  61998. * Creates a black and white post process
  61999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62000. * @param name The name of the effect.
  62001. * @param options The required width/height ratio to downsize to before computing the render pass.
  62002. * @param camera The camera to apply the render pass to.
  62003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62004. * @param engine The engine which the post process will be applied. (default: current engine)
  62005. * @param reusable If the post process can be reused on the same frame. (default: false)
  62006. */
  62007. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62008. }
  62009. }
  62010. declare module BABYLON {
  62011. /**
  62012. * This represents a set of one or more post processes in Babylon.
  62013. * A post process can be used to apply a shader to a texture after it is rendered.
  62014. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62015. */
  62016. export class PostProcessRenderEffect {
  62017. private _postProcesses;
  62018. private _getPostProcesses;
  62019. private _singleInstance;
  62020. private _cameras;
  62021. private _indicesForCamera;
  62022. /**
  62023. * Name of the effect
  62024. * @hidden
  62025. */
  62026. _name: string;
  62027. /**
  62028. * Instantiates a post process render effect.
  62029. * A post process can be used to apply a shader to a texture after it is rendered.
  62030. * @param engine The engine the effect is tied to
  62031. * @param name The name of the effect
  62032. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62033. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62034. */
  62035. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62036. /**
  62037. * Checks if all the post processes in the effect are supported.
  62038. */
  62039. get isSupported(): boolean;
  62040. /**
  62041. * Updates the current state of the effect
  62042. * @hidden
  62043. */
  62044. _update(): void;
  62045. /**
  62046. * Attaches the effect on cameras
  62047. * @param cameras The camera to attach to.
  62048. * @hidden
  62049. */
  62050. _attachCameras(cameras: Camera): void;
  62051. /**
  62052. * Attaches the effect on cameras
  62053. * @param cameras The camera to attach to.
  62054. * @hidden
  62055. */
  62056. _attachCameras(cameras: Camera[]): void;
  62057. /**
  62058. * Detaches the effect on cameras
  62059. * @param cameras The camera to detatch from.
  62060. * @hidden
  62061. */
  62062. _detachCameras(cameras: Camera): void;
  62063. /**
  62064. * Detatches the effect on cameras
  62065. * @param cameras The camera to detatch from.
  62066. * @hidden
  62067. */
  62068. _detachCameras(cameras: Camera[]): void;
  62069. /**
  62070. * Enables the effect on given cameras
  62071. * @param cameras The camera to enable.
  62072. * @hidden
  62073. */
  62074. _enable(cameras: Camera): void;
  62075. /**
  62076. * Enables the effect on given cameras
  62077. * @param cameras The camera to enable.
  62078. * @hidden
  62079. */
  62080. _enable(cameras: Nullable<Camera[]>): void;
  62081. /**
  62082. * Disables the effect on the given cameras
  62083. * @param cameras The camera to disable.
  62084. * @hidden
  62085. */
  62086. _disable(cameras: Camera): void;
  62087. /**
  62088. * Disables the effect on the given cameras
  62089. * @param cameras The camera to disable.
  62090. * @hidden
  62091. */
  62092. _disable(cameras: Nullable<Camera[]>): void;
  62093. /**
  62094. * Gets a list of the post processes contained in the effect.
  62095. * @param camera The camera to get the post processes on.
  62096. * @returns The list of the post processes in the effect.
  62097. */
  62098. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62099. }
  62100. }
  62101. declare module BABYLON {
  62102. /** @hidden */
  62103. export var extractHighlightsPixelShader: {
  62104. name: string;
  62105. shader: string;
  62106. };
  62107. }
  62108. declare module BABYLON {
  62109. /**
  62110. * 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.
  62111. */
  62112. export class ExtractHighlightsPostProcess extends PostProcess {
  62113. /**
  62114. * The luminance threshold, pixels below this value will be set to black.
  62115. */
  62116. threshold: number;
  62117. /** @hidden */
  62118. _exposure: number;
  62119. /**
  62120. * Post process which has the input texture to be used when performing highlight extraction
  62121. * @hidden
  62122. */
  62123. _inputPostProcess: Nullable<PostProcess>;
  62124. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62125. }
  62126. }
  62127. declare module BABYLON {
  62128. /** @hidden */
  62129. export var bloomMergePixelShader: {
  62130. name: string;
  62131. shader: string;
  62132. };
  62133. }
  62134. declare module BABYLON {
  62135. /**
  62136. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62137. */
  62138. export class BloomMergePostProcess extends PostProcess {
  62139. /** Weight of the bloom to be added to the original input. */
  62140. weight: number;
  62141. /**
  62142. * Creates a new instance of @see BloomMergePostProcess
  62143. * @param name The name of the effect.
  62144. * @param originalFromInput Post process which's input will be used for the merge.
  62145. * @param blurred Blurred highlights post process which's output will be used.
  62146. * @param weight Weight of the bloom to be added to the original input.
  62147. * @param options The required width/height ratio to downsize to before computing the render pass.
  62148. * @param camera The camera to apply the render pass to.
  62149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62150. * @param engine The engine which the post process will be applied. (default: current engine)
  62151. * @param reusable If the post process can be reused on the same frame. (default: false)
  62152. * @param textureType Type of textures used when performing the post process. (default: 0)
  62153. * @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)
  62154. */
  62155. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62156. /** Weight of the bloom to be added to the original input. */
  62157. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62158. }
  62159. }
  62160. declare module BABYLON {
  62161. /**
  62162. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62163. */
  62164. export class BloomEffect extends PostProcessRenderEffect {
  62165. private bloomScale;
  62166. /**
  62167. * @hidden Internal
  62168. */
  62169. _effects: Array<PostProcess>;
  62170. /**
  62171. * @hidden Internal
  62172. */
  62173. _downscale: ExtractHighlightsPostProcess;
  62174. private _blurX;
  62175. private _blurY;
  62176. private _merge;
  62177. /**
  62178. * The luminance threshold to find bright areas of the image to bloom.
  62179. */
  62180. get threshold(): number;
  62181. set threshold(value: number);
  62182. /**
  62183. * The strength of the bloom.
  62184. */
  62185. get weight(): number;
  62186. set weight(value: number);
  62187. /**
  62188. * Specifies the size of the bloom blur kernel, relative to the final output size
  62189. */
  62190. get kernel(): number;
  62191. set kernel(value: number);
  62192. /**
  62193. * Creates a new instance of @see BloomEffect
  62194. * @param scene The scene the effect belongs to.
  62195. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62196. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62197. * @param bloomWeight The the strength of bloom.
  62198. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62199. * @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)
  62200. */
  62201. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62202. /**
  62203. * Disposes each of the internal effects for a given camera.
  62204. * @param camera The camera to dispose the effect on.
  62205. */
  62206. disposeEffects(camera: Camera): void;
  62207. /**
  62208. * @hidden Internal
  62209. */
  62210. _updateEffects(): void;
  62211. /**
  62212. * Internal
  62213. * @returns if all the contained post processes are ready.
  62214. * @hidden
  62215. */
  62216. _isReady(): boolean;
  62217. }
  62218. }
  62219. declare module BABYLON {
  62220. /** @hidden */
  62221. export var chromaticAberrationPixelShader: {
  62222. name: string;
  62223. shader: string;
  62224. };
  62225. }
  62226. declare module BABYLON {
  62227. /**
  62228. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62229. */
  62230. export class ChromaticAberrationPostProcess extends PostProcess {
  62231. /**
  62232. * The amount of seperation of rgb channels (default: 30)
  62233. */
  62234. aberrationAmount: number;
  62235. /**
  62236. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62237. */
  62238. radialIntensity: number;
  62239. /**
  62240. * 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))
  62241. */
  62242. direction: Vector2;
  62243. /**
  62244. * 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))
  62245. */
  62246. centerPosition: Vector2;
  62247. /**
  62248. * Creates a new instance ChromaticAberrationPostProcess
  62249. * @param name The name of the effect.
  62250. * @param screenWidth The width of the screen to apply the effect on.
  62251. * @param screenHeight The height of the screen to apply the effect on.
  62252. * @param options The required width/height ratio to downsize to before computing the render pass.
  62253. * @param camera The camera to apply the render pass to.
  62254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62255. * @param engine The engine which the post process will be applied. (default: current engine)
  62256. * @param reusable If the post process can be reused on the same frame. (default: false)
  62257. * @param textureType Type of textures used when performing the post process. (default: 0)
  62258. * @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)
  62259. */
  62260. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62261. }
  62262. }
  62263. declare module BABYLON {
  62264. /** @hidden */
  62265. export var circleOfConfusionPixelShader: {
  62266. name: string;
  62267. shader: string;
  62268. };
  62269. }
  62270. declare module BABYLON {
  62271. /**
  62272. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62273. */
  62274. export class CircleOfConfusionPostProcess extends PostProcess {
  62275. /**
  62276. * 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.
  62277. */
  62278. lensSize: number;
  62279. /**
  62280. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62281. */
  62282. fStop: number;
  62283. /**
  62284. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62285. */
  62286. focusDistance: number;
  62287. /**
  62288. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62289. */
  62290. focalLength: number;
  62291. private _depthTexture;
  62292. /**
  62293. * Creates a new instance CircleOfConfusionPostProcess
  62294. * @param name The name of the effect.
  62295. * @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.
  62296. * @param options The required width/height ratio to downsize to before computing the render pass.
  62297. * @param camera The camera to apply the render pass to.
  62298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62299. * @param engine The engine which the post process will be applied. (default: current engine)
  62300. * @param reusable If the post process can be reused on the same frame. (default: false)
  62301. * @param textureType Type of textures used when performing the post process. (default: 0)
  62302. * @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)
  62303. */
  62304. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62305. /**
  62306. * 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.
  62307. */
  62308. set depthTexture(value: RenderTargetTexture);
  62309. }
  62310. }
  62311. declare module BABYLON {
  62312. /** @hidden */
  62313. export var colorCorrectionPixelShader: {
  62314. name: string;
  62315. shader: string;
  62316. };
  62317. }
  62318. declare module BABYLON {
  62319. /**
  62320. *
  62321. * This post-process allows the modification of rendered colors by using
  62322. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62323. *
  62324. * The object needs to be provided an url to a texture containing the color
  62325. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62326. * Use an image editing software to tweak the LUT to match your needs.
  62327. *
  62328. * For an example of a color LUT, see here:
  62329. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62330. * For explanations on color grading, see here:
  62331. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62332. *
  62333. */
  62334. export class ColorCorrectionPostProcess extends PostProcess {
  62335. private _colorTableTexture;
  62336. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62337. }
  62338. }
  62339. declare module BABYLON {
  62340. /** @hidden */
  62341. export var convolutionPixelShader: {
  62342. name: string;
  62343. shader: string;
  62344. };
  62345. }
  62346. declare module BABYLON {
  62347. /**
  62348. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62349. * input texture to perform effects such as edge detection or sharpening
  62350. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62351. */
  62352. export class ConvolutionPostProcess extends PostProcess {
  62353. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62354. kernel: number[];
  62355. /**
  62356. * Creates a new instance ConvolutionPostProcess
  62357. * @param name The name of the effect.
  62358. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62359. * @param options The required width/height ratio to downsize to before computing the render pass.
  62360. * @param camera The camera to apply the render pass to.
  62361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62362. * @param engine The engine which the post process will be applied. (default: current engine)
  62363. * @param reusable If the post process can be reused on the same frame. (default: false)
  62364. * @param textureType Type of textures used when performing the post process. (default: 0)
  62365. */
  62366. constructor(name: string,
  62367. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62368. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62369. /**
  62370. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62371. */
  62372. static EdgeDetect0Kernel: number[];
  62373. /**
  62374. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62375. */
  62376. static EdgeDetect1Kernel: number[];
  62377. /**
  62378. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62379. */
  62380. static EdgeDetect2Kernel: number[];
  62381. /**
  62382. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62383. */
  62384. static SharpenKernel: number[];
  62385. /**
  62386. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62387. */
  62388. static EmbossKernel: number[];
  62389. /**
  62390. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62391. */
  62392. static GaussianKernel: number[];
  62393. }
  62394. }
  62395. declare module BABYLON {
  62396. /**
  62397. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62398. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62399. * based on samples that have a large difference in distance than the center pixel.
  62400. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62401. */
  62402. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62403. direction: Vector2;
  62404. /**
  62405. * Creates a new instance CircleOfConfusionPostProcess
  62406. * @param name The name of the effect.
  62407. * @param scene The scene the effect belongs to.
  62408. * @param direction The direction the blur should be applied.
  62409. * @param kernel The size of the kernel used to blur.
  62410. * @param options The required width/height ratio to downsize to before computing the render pass.
  62411. * @param camera The camera to apply the render pass to.
  62412. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62413. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62415. * @param engine The engine which the post process will be applied. (default: current engine)
  62416. * @param reusable If the post process can be reused on the same frame. (default: false)
  62417. * @param textureType Type of textures used when performing the post process. (default: 0)
  62418. * @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)
  62419. */
  62420. 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);
  62421. }
  62422. }
  62423. declare module BABYLON {
  62424. /** @hidden */
  62425. export var depthOfFieldMergePixelShader: {
  62426. name: string;
  62427. shader: string;
  62428. };
  62429. }
  62430. declare module BABYLON {
  62431. /**
  62432. * Options to be set when merging outputs from the default pipeline.
  62433. */
  62434. export class DepthOfFieldMergePostProcessOptions {
  62435. /**
  62436. * The original image to merge on top of
  62437. */
  62438. originalFromInput: PostProcess;
  62439. /**
  62440. * Parameters to perform the merge of the depth of field effect
  62441. */
  62442. depthOfField?: {
  62443. circleOfConfusion: PostProcess;
  62444. blurSteps: Array<PostProcess>;
  62445. };
  62446. /**
  62447. * Parameters to perform the merge of bloom effect
  62448. */
  62449. bloom?: {
  62450. blurred: PostProcess;
  62451. weight: number;
  62452. };
  62453. }
  62454. /**
  62455. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62456. */
  62457. export class DepthOfFieldMergePostProcess extends PostProcess {
  62458. private blurSteps;
  62459. /**
  62460. * Creates a new instance of DepthOfFieldMergePostProcess
  62461. * @param name The name of the effect.
  62462. * @param originalFromInput Post process which's input will be used for the merge.
  62463. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62464. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62465. * @param options The required width/height ratio to downsize to before computing the render pass.
  62466. * @param camera The camera to apply the render pass to.
  62467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62468. * @param engine The engine which the post process will be applied. (default: current engine)
  62469. * @param reusable If the post process can be reused on the same frame. (default: false)
  62470. * @param textureType Type of textures used when performing the post process. (default: 0)
  62471. * @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)
  62472. */
  62473. 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);
  62474. /**
  62475. * Updates the effect with the current post process compile time values and recompiles the shader.
  62476. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62477. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62478. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62479. * @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
  62480. * @param onCompiled Called when the shader has been compiled.
  62481. * @param onError Called if there is an error when compiling a shader.
  62482. */
  62483. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62484. }
  62485. }
  62486. declare module BABYLON {
  62487. /**
  62488. * Specifies the level of max blur that should be applied when using the depth of field effect
  62489. */
  62490. export enum DepthOfFieldEffectBlurLevel {
  62491. /**
  62492. * Subtle blur
  62493. */
  62494. Low = 0,
  62495. /**
  62496. * Medium blur
  62497. */
  62498. Medium = 1,
  62499. /**
  62500. * Large blur
  62501. */
  62502. High = 2
  62503. }
  62504. /**
  62505. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62506. */
  62507. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62508. private _circleOfConfusion;
  62509. /**
  62510. * @hidden Internal, blurs from high to low
  62511. */
  62512. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62513. private _depthOfFieldBlurY;
  62514. private _dofMerge;
  62515. /**
  62516. * @hidden Internal post processes in depth of field effect
  62517. */
  62518. _effects: Array<PostProcess>;
  62519. /**
  62520. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62521. */
  62522. set focalLength(value: number);
  62523. get focalLength(): number;
  62524. /**
  62525. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62526. */
  62527. set fStop(value: number);
  62528. get fStop(): number;
  62529. /**
  62530. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62531. */
  62532. set focusDistance(value: number);
  62533. get focusDistance(): number;
  62534. /**
  62535. * 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.
  62536. */
  62537. set lensSize(value: number);
  62538. get lensSize(): number;
  62539. /**
  62540. * Creates a new instance DepthOfFieldEffect
  62541. * @param scene The scene the effect belongs to.
  62542. * @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.
  62543. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62544. * @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)
  62545. */
  62546. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62547. /**
  62548. * Get the current class name of the current effet
  62549. * @returns "DepthOfFieldEffect"
  62550. */
  62551. getClassName(): string;
  62552. /**
  62553. * 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.
  62554. */
  62555. set depthTexture(value: RenderTargetTexture);
  62556. /**
  62557. * Disposes each of the internal effects for a given camera.
  62558. * @param camera The camera to dispose the effect on.
  62559. */
  62560. disposeEffects(camera: Camera): void;
  62561. /**
  62562. * @hidden Internal
  62563. */
  62564. _updateEffects(): void;
  62565. /**
  62566. * Internal
  62567. * @returns if all the contained post processes are ready.
  62568. * @hidden
  62569. */
  62570. _isReady(): boolean;
  62571. }
  62572. }
  62573. declare module BABYLON {
  62574. /** @hidden */
  62575. export var displayPassPixelShader: {
  62576. name: string;
  62577. shader: string;
  62578. };
  62579. }
  62580. declare module BABYLON {
  62581. /**
  62582. * DisplayPassPostProcess which produces an output the same as it's input
  62583. */
  62584. export class DisplayPassPostProcess extends PostProcess {
  62585. /**
  62586. * Creates the DisplayPassPostProcess
  62587. * @param name The name of the effect.
  62588. * @param options The required width/height ratio to downsize to before computing the render pass.
  62589. * @param camera The camera to apply the render pass to.
  62590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62591. * @param engine The engine which the post process will be applied. (default: current engine)
  62592. * @param reusable If the post process can be reused on the same frame. (default: false)
  62593. */
  62594. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62595. }
  62596. }
  62597. declare module BABYLON {
  62598. /** @hidden */
  62599. export var filterPixelShader: {
  62600. name: string;
  62601. shader: string;
  62602. };
  62603. }
  62604. declare module BABYLON {
  62605. /**
  62606. * Applies a kernel filter to the image
  62607. */
  62608. export class FilterPostProcess extends PostProcess {
  62609. /** The matrix to be applied to the image */
  62610. kernelMatrix: Matrix;
  62611. /**
  62612. *
  62613. * @param name The name of the effect.
  62614. * @param kernelMatrix The matrix to be applied to the image
  62615. * @param options The required width/height ratio to downsize to before computing the render pass.
  62616. * @param camera The camera to apply the render pass to.
  62617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62618. * @param engine The engine which the post process will be applied. (default: current engine)
  62619. * @param reusable If the post process can be reused on the same frame. (default: false)
  62620. */
  62621. constructor(name: string,
  62622. /** The matrix to be applied to the image */
  62623. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62624. }
  62625. }
  62626. declare module BABYLON {
  62627. /** @hidden */
  62628. export var fxaaPixelShader: {
  62629. name: string;
  62630. shader: string;
  62631. };
  62632. }
  62633. declare module BABYLON {
  62634. /** @hidden */
  62635. export var fxaaVertexShader: {
  62636. name: string;
  62637. shader: string;
  62638. };
  62639. }
  62640. declare module BABYLON {
  62641. /**
  62642. * Fxaa post process
  62643. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62644. */
  62645. export class FxaaPostProcess extends PostProcess {
  62646. /** @hidden */
  62647. texelWidth: number;
  62648. /** @hidden */
  62649. texelHeight: number;
  62650. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62651. private _getDefines;
  62652. }
  62653. }
  62654. declare module BABYLON {
  62655. /** @hidden */
  62656. export var grainPixelShader: {
  62657. name: string;
  62658. shader: string;
  62659. };
  62660. }
  62661. declare module BABYLON {
  62662. /**
  62663. * The GrainPostProcess adds noise to the image at mid luminance levels
  62664. */
  62665. export class GrainPostProcess extends PostProcess {
  62666. /**
  62667. * The intensity of the grain added (default: 30)
  62668. */
  62669. intensity: number;
  62670. /**
  62671. * If the grain should be randomized on every frame
  62672. */
  62673. animated: boolean;
  62674. /**
  62675. * Creates a new instance of @see GrainPostProcess
  62676. * @param name The name of the effect.
  62677. * @param options The required width/height ratio to downsize to before computing the render pass.
  62678. * @param camera The camera to apply the render pass to.
  62679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62680. * @param engine The engine which the post process will be applied. (default: current engine)
  62681. * @param reusable If the post process can be reused on the same frame. (default: false)
  62682. * @param textureType Type of textures used when performing the post process. (default: 0)
  62683. * @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)
  62684. */
  62685. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62686. }
  62687. }
  62688. declare module BABYLON {
  62689. /** @hidden */
  62690. export var highlightsPixelShader: {
  62691. name: string;
  62692. shader: string;
  62693. };
  62694. }
  62695. declare module BABYLON {
  62696. /**
  62697. * Extracts highlights from the image
  62698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62699. */
  62700. export class HighlightsPostProcess extends PostProcess {
  62701. /**
  62702. * Extracts highlights from the image
  62703. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62704. * @param name The name of the effect.
  62705. * @param options The required width/height ratio to downsize to before computing the render pass.
  62706. * @param camera The camera to apply the render pass to.
  62707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62708. * @param engine The engine which the post process will be applied. (default: current engine)
  62709. * @param reusable If the post process can be reused on the same frame. (default: false)
  62710. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62711. */
  62712. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62713. }
  62714. }
  62715. declare module BABYLON {
  62716. /** @hidden */
  62717. export var mrtFragmentDeclaration: {
  62718. name: string;
  62719. shader: string;
  62720. };
  62721. }
  62722. declare module BABYLON {
  62723. /** @hidden */
  62724. export var geometryPixelShader: {
  62725. name: string;
  62726. shader: string;
  62727. };
  62728. }
  62729. declare module BABYLON {
  62730. /** @hidden */
  62731. export var geometryVertexShader: {
  62732. name: string;
  62733. shader: string;
  62734. };
  62735. }
  62736. declare module BABYLON {
  62737. /** @hidden */
  62738. interface ISavedTransformationMatrix {
  62739. world: Matrix;
  62740. viewProjection: Matrix;
  62741. }
  62742. /**
  62743. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62744. */
  62745. export class GeometryBufferRenderer {
  62746. /**
  62747. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62748. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62749. */
  62750. static readonly POSITION_TEXTURE_TYPE: number;
  62751. /**
  62752. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62753. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62754. */
  62755. static readonly VELOCITY_TEXTURE_TYPE: number;
  62756. /**
  62757. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62758. * in order to compute objects velocities when enableVelocity is set to "true"
  62759. * @hidden
  62760. */
  62761. _previousTransformationMatrices: {
  62762. [index: number]: ISavedTransformationMatrix;
  62763. };
  62764. /**
  62765. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62766. * in order to compute objects velocities when enableVelocity is set to "true"
  62767. * @hidden
  62768. */
  62769. _previousBonesTransformationMatrices: {
  62770. [index: number]: Float32Array;
  62771. };
  62772. /**
  62773. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62774. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62775. */
  62776. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62777. private _scene;
  62778. private _multiRenderTarget;
  62779. private _ratio;
  62780. private _enablePosition;
  62781. private _enableVelocity;
  62782. private _positionIndex;
  62783. private _velocityIndex;
  62784. protected _effect: Effect;
  62785. protected _cachedDefines: string;
  62786. /**
  62787. * Set the render list (meshes to be rendered) used in the G buffer.
  62788. */
  62789. set renderList(meshes: Mesh[]);
  62790. /**
  62791. * Gets wether or not G buffer are supported by the running hardware.
  62792. * This requires draw buffer supports
  62793. */
  62794. get isSupported(): boolean;
  62795. /**
  62796. * Returns the index of the given texture type in the G-Buffer textures array
  62797. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62798. * @returns the index of the given texture type in the G-Buffer textures array
  62799. */
  62800. getTextureIndex(textureType: number): number;
  62801. /**
  62802. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62803. */
  62804. get enablePosition(): boolean;
  62805. /**
  62806. * Sets whether or not objects positions are enabled for the G buffer.
  62807. */
  62808. set enablePosition(enable: boolean);
  62809. /**
  62810. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62811. */
  62812. get enableVelocity(): boolean;
  62813. /**
  62814. * Sets wether or not objects velocities are enabled for the G buffer.
  62815. */
  62816. set enableVelocity(enable: boolean);
  62817. /**
  62818. * Gets the scene associated with the buffer.
  62819. */
  62820. get scene(): Scene;
  62821. /**
  62822. * Gets the ratio used by the buffer during its creation.
  62823. * How big is the buffer related to the main canvas.
  62824. */
  62825. get ratio(): number;
  62826. /** @hidden */
  62827. static _SceneComponentInitialization: (scene: Scene) => void;
  62828. /**
  62829. * Creates a new G Buffer for the scene
  62830. * @param scene The scene the buffer belongs to
  62831. * @param ratio How big is the buffer related to the main canvas.
  62832. */
  62833. constructor(scene: Scene, ratio?: number);
  62834. /**
  62835. * Checks wether everything is ready to render a submesh to the G buffer.
  62836. * @param subMesh the submesh to check readiness for
  62837. * @param useInstances is the mesh drawn using instance or not
  62838. * @returns true if ready otherwise false
  62839. */
  62840. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62841. /**
  62842. * Gets the current underlying G Buffer.
  62843. * @returns the buffer
  62844. */
  62845. getGBuffer(): MultiRenderTarget;
  62846. /**
  62847. * Gets the number of samples used to render the buffer (anti aliasing).
  62848. */
  62849. get samples(): number;
  62850. /**
  62851. * Sets the number of samples used to render the buffer (anti aliasing).
  62852. */
  62853. set samples(value: number);
  62854. /**
  62855. * Disposes the renderer and frees up associated resources.
  62856. */
  62857. dispose(): void;
  62858. protected _createRenderTargets(): void;
  62859. private _copyBonesTransformationMatrices;
  62860. }
  62861. }
  62862. declare module BABYLON {
  62863. interface Scene {
  62864. /** @hidden (Backing field) */
  62865. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62866. /**
  62867. * Gets or Sets the current geometry buffer associated to the scene.
  62868. */
  62869. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62870. /**
  62871. * Enables a GeometryBufferRender and associates it with the scene
  62872. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62873. * @returns the GeometryBufferRenderer
  62874. */
  62875. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62876. /**
  62877. * Disables the GeometryBufferRender associated with the scene
  62878. */
  62879. disableGeometryBufferRenderer(): void;
  62880. }
  62881. /**
  62882. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62883. * in several rendering techniques.
  62884. */
  62885. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62886. /**
  62887. * The component name helpful to identify the component in the list of scene components.
  62888. */
  62889. readonly name: string;
  62890. /**
  62891. * The scene the component belongs to.
  62892. */
  62893. scene: Scene;
  62894. /**
  62895. * Creates a new instance of the component for the given scene
  62896. * @param scene Defines the scene to register the component in
  62897. */
  62898. constructor(scene: Scene);
  62899. /**
  62900. * Registers the component in a given scene
  62901. */
  62902. register(): void;
  62903. /**
  62904. * Rebuilds the elements related to this component in case of
  62905. * context lost for instance.
  62906. */
  62907. rebuild(): void;
  62908. /**
  62909. * Disposes the component and the associated ressources
  62910. */
  62911. dispose(): void;
  62912. private _gatherRenderTargets;
  62913. }
  62914. }
  62915. declare module BABYLON {
  62916. /** @hidden */
  62917. export var motionBlurPixelShader: {
  62918. name: string;
  62919. shader: string;
  62920. };
  62921. }
  62922. declare module BABYLON {
  62923. /**
  62924. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62925. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62926. * As an example, all you have to do is to create the post-process:
  62927. * var mb = new BABYLON.MotionBlurPostProcess(
  62928. * 'mb', // The name of the effect.
  62929. * scene, // The scene containing the objects to blur according to their velocity.
  62930. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62931. * camera // The camera to apply the render pass to.
  62932. * );
  62933. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62934. */
  62935. export class MotionBlurPostProcess extends PostProcess {
  62936. /**
  62937. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62938. */
  62939. motionStrength: number;
  62940. /**
  62941. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62942. */
  62943. get motionBlurSamples(): number;
  62944. /**
  62945. * Sets the number of iterations to be used for motion blur quality
  62946. */
  62947. set motionBlurSamples(samples: number);
  62948. private _motionBlurSamples;
  62949. private _geometryBufferRenderer;
  62950. /**
  62951. * Creates a new instance MotionBlurPostProcess
  62952. * @param name The name of the effect.
  62953. * @param scene The scene containing the objects to blur according to their velocity.
  62954. * @param options The required width/height ratio to downsize to before computing the render pass.
  62955. * @param camera The camera to apply the render pass to.
  62956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62957. * @param engine The engine which the post process will be applied. (default: current engine)
  62958. * @param reusable If the post process can be reused on the same frame. (default: false)
  62959. * @param textureType Type of textures used when performing the post process. (default: 0)
  62960. * @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)
  62961. */
  62962. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62963. /**
  62964. * Excludes the given skinned mesh from computing bones velocities.
  62965. * 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.
  62966. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62967. */
  62968. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62969. /**
  62970. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62971. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62972. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62973. */
  62974. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62975. /**
  62976. * Disposes the post process.
  62977. * @param camera The camera to dispose the post process on.
  62978. */
  62979. dispose(camera?: Camera): void;
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /** @hidden */
  62984. export var refractionPixelShader: {
  62985. name: string;
  62986. shader: string;
  62987. };
  62988. }
  62989. declare module BABYLON {
  62990. /**
  62991. * Post process which applies a refractin texture
  62992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62993. */
  62994. export class RefractionPostProcess extends PostProcess {
  62995. /** the base color of the refraction (used to taint the rendering) */
  62996. color: Color3;
  62997. /** simulated refraction depth */
  62998. depth: number;
  62999. /** the coefficient of the base color (0 to remove base color tainting) */
  63000. colorLevel: number;
  63001. private _refTexture;
  63002. private _ownRefractionTexture;
  63003. /**
  63004. * Gets or sets the refraction texture
  63005. * Please note that you are responsible for disposing the texture if you set it manually
  63006. */
  63007. get refractionTexture(): Texture;
  63008. set refractionTexture(value: Texture);
  63009. /**
  63010. * Initializes the RefractionPostProcess
  63011. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63012. * @param name The name of the effect.
  63013. * @param refractionTextureUrl Url of the refraction texture to use
  63014. * @param color the base color of the refraction (used to taint the rendering)
  63015. * @param depth simulated refraction depth
  63016. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63017. * @param camera The camera to apply the render pass to.
  63018. * @param options The required width/height ratio to downsize to before computing the render pass.
  63019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63020. * @param engine The engine which the post process will be applied. (default: current engine)
  63021. * @param reusable If the post process can be reused on the same frame. (default: false)
  63022. */
  63023. constructor(name: string, refractionTextureUrl: string,
  63024. /** the base color of the refraction (used to taint the rendering) */
  63025. color: Color3,
  63026. /** simulated refraction depth */
  63027. depth: number,
  63028. /** the coefficient of the base color (0 to remove base color tainting) */
  63029. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63030. /**
  63031. * Disposes of the post process
  63032. * @param camera Camera to dispose post process on
  63033. */
  63034. dispose(camera: Camera): void;
  63035. }
  63036. }
  63037. declare module BABYLON {
  63038. /** @hidden */
  63039. export var sharpenPixelShader: {
  63040. name: string;
  63041. shader: string;
  63042. };
  63043. }
  63044. declare module BABYLON {
  63045. /**
  63046. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63047. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63048. */
  63049. export class SharpenPostProcess extends PostProcess {
  63050. /**
  63051. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63052. */
  63053. colorAmount: number;
  63054. /**
  63055. * How much sharpness should be applied (default: 0.3)
  63056. */
  63057. edgeAmount: number;
  63058. /**
  63059. * Creates a new instance ConvolutionPostProcess
  63060. * @param name The name of the effect.
  63061. * @param options The required width/height ratio to downsize to before computing the render pass.
  63062. * @param camera The camera to apply the render pass to.
  63063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63064. * @param engine The engine which the post process will be applied. (default: current engine)
  63065. * @param reusable If the post process can be reused on the same frame. (default: false)
  63066. * @param textureType Type of textures used when performing the post process. (default: 0)
  63067. * @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)
  63068. */
  63069. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63070. }
  63071. }
  63072. declare module BABYLON {
  63073. /**
  63074. * PostProcessRenderPipeline
  63075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63076. */
  63077. export class PostProcessRenderPipeline {
  63078. private engine;
  63079. private _renderEffects;
  63080. private _renderEffectsForIsolatedPass;
  63081. /**
  63082. * List of inspectable custom properties (used by the Inspector)
  63083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63084. */
  63085. inspectableCustomProperties: IInspectable[];
  63086. /**
  63087. * @hidden
  63088. */
  63089. protected _cameras: Camera[];
  63090. /** @hidden */
  63091. _name: string;
  63092. /**
  63093. * Gets pipeline name
  63094. */
  63095. get name(): string;
  63096. /** Gets the list of attached cameras */
  63097. get cameras(): Camera[];
  63098. /**
  63099. * Initializes a PostProcessRenderPipeline
  63100. * @param engine engine to add the pipeline to
  63101. * @param name name of the pipeline
  63102. */
  63103. constructor(engine: Engine, name: string);
  63104. /**
  63105. * Gets the class name
  63106. * @returns "PostProcessRenderPipeline"
  63107. */
  63108. getClassName(): string;
  63109. /**
  63110. * If all the render effects in the pipeline are supported
  63111. */
  63112. get isSupported(): boolean;
  63113. /**
  63114. * Adds an effect to the pipeline
  63115. * @param renderEffect the effect to add
  63116. */
  63117. addEffect(renderEffect: PostProcessRenderEffect): void;
  63118. /** @hidden */
  63119. _rebuild(): void;
  63120. /** @hidden */
  63121. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63122. /** @hidden */
  63123. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63124. /** @hidden */
  63125. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63126. /** @hidden */
  63127. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63128. /** @hidden */
  63129. _attachCameras(cameras: Camera, unique: boolean): void;
  63130. /** @hidden */
  63131. _attachCameras(cameras: Camera[], unique: boolean): void;
  63132. /** @hidden */
  63133. _detachCameras(cameras: Camera): void;
  63134. /** @hidden */
  63135. _detachCameras(cameras: Nullable<Camera[]>): void;
  63136. /** @hidden */
  63137. _update(): void;
  63138. /** @hidden */
  63139. _reset(): void;
  63140. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63141. /**
  63142. * Disposes of the pipeline
  63143. */
  63144. dispose(): void;
  63145. }
  63146. }
  63147. declare module BABYLON {
  63148. /**
  63149. * PostProcessRenderPipelineManager class
  63150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63151. */
  63152. export class PostProcessRenderPipelineManager {
  63153. private _renderPipelines;
  63154. /**
  63155. * Initializes a PostProcessRenderPipelineManager
  63156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63157. */
  63158. constructor();
  63159. /**
  63160. * Gets the list of supported render pipelines
  63161. */
  63162. get supportedPipelines(): PostProcessRenderPipeline[];
  63163. /**
  63164. * Adds a pipeline to the manager
  63165. * @param renderPipeline The pipeline to add
  63166. */
  63167. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63168. /**
  63169. * Attaches a camera to the pipeline
  63170. * @param renderPipelineName The name of the pipeline to attach to
  63171. * @param cameras the camera to attach
  63172. * @param unique if the camera can be attached multiple times to the pipeline
  63173. */
  63174. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63175. /**
  63176. * Detaches a camera from the pipeline
  63177. * @param renderPipelineName The name of the pipeline to detach from
  63178. * @param cameras the camera to detach
  63179. */
  63180. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63181. /**
  63182. * Enables an effect by name on a pipeline
  63183. * @param renderPipelineName the name of the pipeline to enable the effect in
  63184. * @param renderEffectName the name of the effect to enable
  63185. * @param cameras the cameras that the effect should be enabled on
  63186. */
  63187. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63188. /**
  63189. * Disables an effect by name on a pipeline
  63190. * @param renderPipelineName the name of the pipeline to disable the effect in
  63191. * @param renderEffectName the name of the effect to disable
  63192. * @param cameras the cameras that the effect should be disabled on
  63193. */
  63194. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63195. /**
  63196. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63197. */
  63198. update(): void;
  63199. /** @hidden */
  63200. _rebuild(): void;
  63201. /**
  63202. * Disposes of the manager and pipelines
  63203. */
  63204. dispose(): void;
  63205. }
  63206. }
  63207. declare module BABYLON {
  63208. interface Scene {
  63209. /** @hidden (Backing field) */
  63210. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63211. /**
  63212. * Gets the postprocess render pipeline manager
  63213. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63214. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63215. */
  63216. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63217. }
  63218. /**
  63219. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63220. */
  63221. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63222. /**
  63223. * The component name helpfull to identify the component in the list of scene components.
  63224. */
  63225. readonly name: string;
  63226. /**
  63227. * The scene the component belongs to.
  63228. */
  63229. scene: Scene;
  63230. /**
  63231. * Creates a new instance of the component for the given scene
  63232. * @param scene Defines the scene to register the component in
  63233. */
  63234. constructor(scene: Scene);
  63235. /**
  63236. * Registers the component in a given scene
  63237. */
  63238. register(): void;
  63239. /**
  63240. * Rebuilds the elements related to this component in case of
  63241. * context lost for instance.
  63242. */
  63243. rebuild(): void;
  63244. /**
  63245. * Disposes the component and the associated ressources
  63246. */
  63247. dispose(): void;
  63248. private _gatherRenderTargets;
  63249. }
  63250. }
  63251. declare module BABYLON {
  63252. /**
  63253. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63254. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63255. */
  63256. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63257. private _scene;
  63258. private _camerasToBeAttached;
  63259. /**
  63260. * ID of the sharpen post process,
  63261. */
  63262. private readonly SharpenPostProcessId;
  63263. /**
  63264. * @ignore
  63265. * ID of the image processing post process;
  63266. */
  63267. readonly ImageProcessingPostProcessId: string;
  63268. /**
  63269. * @ignore
  63270. * ID of the Fast Approximate Anti-Aliasing post process;
  63271. */
  63272. readonly FxaaPostProcessId: string;
  63273. /**
  63274. * ID of the chromatic aberration post process,
  63275. */
  63276. private readonly ChromaticAberrationPostProcessId;
  63277. /**
  63278. * ID of the grain post process
  63279. */
  63280. private readonly GrainPostProcessId;
  63281. /**
  63282. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63283. */
  63284. sharpen: SharpenPostProcess;
  63285. private _sharpenEffect;
  63286. private bloom;
  63287. /**
  63288. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63289. */
  63290. depthOfField: DepthOfFieldEffect;
  63291. /**
  63292. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63293. */
  63294. fxaa: FxaaPostProcess;
  63295. /**
  63296. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63297. */
  63298. imageProcessing: ImageProcessingPostProcess;
  63299. /**
  63300. * Chromatic aberration post process which will shift rgb colors in the image
  63301. */
  63302. chromaticAberration: ChromaticAberrationPostProcess;
  63303. private _chromaticAberrationEffect;
  63304. /**
  63305. * Grain post process which add noise to the image
  63306. */
  63307. grain: GrainPostProcess;
  63308. private _grainEffect;
  63309. /**
  63310. * Glow post process which adds a glow to emissive areas of the image
  63311. */
  63312. private _glowLayer;
  63313. /**
  63314. * Animations which can be used to tweak settings over a period of time
  63315. */
  63316. animations: Animation[];
  63317. private _imageProcessingConfigurationObserver;
  63318. private _sharpenEnabled;
  63319. private _bloomEnabled;
  63320. private _depthOfFieldEnabled;
  63321. private _depthOfFieldBlurLevel;
  63322. private _fxaaEnabled;
  63323. private _imageProcessingEnabled;
  63324. private _defaultPipelineTextureType;
  63325. private _bloomScale;
  63326. private _chromaticAberrationEnabled;
  63327. private _grainEnabled;
  63328. private _buildAllowed;
  63329. /**
  63330. * Gets active scene
  63331. */
  63332. get scene(): Scene;
  63333. /**
  63334. * Enable or disable the sharpen process from the pipeline
  63335. */
  63336. set sharpenEnabled(enabled: boolean);
  63337. get sharpenEnabled(): boolean;
  63338. private _resizeObserver;
  63339. private _hardwareScaleLevel;
  63340. private _bloomKernel;
  63341. /**
  63342. * Specifies the size of the bloom blur kernel, relative to the final output size
  63343. */
  63344. get bloomKernel(): number;
  63345. set bloomKernel(value: number);
  63346. /**
  63347. * Specifies the weight of the bloom in the final rendering
  63348. */
  63349. private _bloomWeight;
  63350. /**
  63351. * Specifies the luma threshold for the area that will be blurred by the bloom
  63352. */
  63353. private _bloomThreshold;
  63354. private _hdr;
  63355. /**
  63356. * The strength of the bloom.
  63357. */
  63358. set bloomWeight(value: number);
  63359. get bloomWeight(): number;
  63360. /**
  63361. * The strength of the bloom.
  63362. */
  63363. set bloomThreshold(value: number);
  63364. get bloomThreshold(): number;
  63365. /**
  63366. * The scale of the bloom, lower value will provide better performance.
  63367. */
  63368. set bloomScale(value: number);
  63369. get bloomScale(): number;
  63370. /**
  63371. * Enable or disable the bloom from the pipeline
  63372. */
  63373. set bloomEnabled(enabled: boolean);
  63374. get bloomEnabled(): boolean;
  63375. private _rebuildBloom;
  63376. /**
  63377. * If the depth of field is enabled.
  63378. */
  63379. get depthOfFieldEnabled(): boolean;
  63380. set depthOfFieldEnabled(enabled: boolean);
  63381. /**
  63382. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63383. */
  63384. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  63385. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  63386. /**
  63387. * If the anti aliasing is enabled.
  63388. */
  63389. set fxaaEnabled(enabled: boolean);
  63390. get fxaaEnabled(): boolean;
  63391. private _samples;
  63392. /**
  63393. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63394. */
  63395. set samples(sampleCount: number);
  63396. get samples(): number;
  63397. /**
  63398. * If image processing is enabled.
  63399. */
  63400. set imageProcessingEnabled(enabled: boolean);
  63401. get imageProcessingEnabled(): boolean;
  63402. /**
  63403. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63404. */
  63405. set glowLayerEnabled(enabled: boolean);
  63406. get glowLayerEnabled(): boolean;
  63407. /**
  63408. * Gets the glow layer (or null if not defined)
  63409. */
  63410. get glowLayer(): Nullable<GlowLayer>;
  63411. /**
  63412. * Enable or disable the chromaticAberration process from the pipeline
  63413. */
  63414. set chromaticAberrationEnabled(enabled: boolean);
  63415. get chromaticAberrationEnabled(): boolean;
  63416. /**
  63417. * Enable or disable the grain process from the pipeline
  63418. */
  63419. set grainEnabled(enabled: boolean);
  63420. get grainEnabled(): boolean;
  63421. /**
  63422. * @constructor
  63423. * @param name - The rendering pipeline name (default: "")
  63424. * @param hdr - If high dynamic range textures should be used (default: true)
  63425. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63426. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63427. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63428. */
  63429. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63430. /**
  63431. * Get the class name
  63432. * @returns "DefaultRenderingPipeline"
  63433. */
  63434. getClassName(): string;
  63435. /**
  63436. * Force the compilation of the entire pipeline.
  63437. */
  63438. prepare(): void;
  63439. private _hasCleared;
  63440. private _prevPostProcess;
  63441. private _prevPrevPostProcess;
  63442. private _setAutoClearAndTextureSharing;
  63443. private _depthOfFieldSceneObserver;
  63444. private _buildPipeline;
  63445. private _disposePostProcesses;
  63446. /**
  63447. * Adds a camera to the pipeline
  63448. * @param camera the camera to be added
  63449. */
  63450. addCamera(camera: Camera): void;
  63451. /**
  63452. * Removes a camera from the pipeline
  63453. * @param camera the camera to remove
  63454. */
  63455. removeCamera(camera: Camera): void;
  63456. /**
  63457. * Dispose of the pipeline and stop all post processes
  63458. */
  63459. dispose(): void;
  63460. /**
  63461. * Serialize the rendering pipeline (Used when exporting)
  63462. * @returns the serialized object
  63463. */
  63464. serialize(): any;
  63465. /**
  63466. * Parse the serialized pipeline
  63467. * @param source Source pipeline.
  63468. * @param scene The scene to load the pipeline to.
  63469. * @param rootUrl The URL of the serialized pipeline.
  63470. * @returns An instantiated pipeline from the serialized object.
  63471. */
  63472. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63473. }
  63474. }
  63475. declare module BABYLON {
  63476. /** @hidden */
  63477. export var lensHighlightsPixelShader: {
  63478. name: string;
  63479. shader: string;
  63480. };
  63481. }
  63482. declare module BABYLON {
  63483. /** @hidden */
  63484. export var depthOfFieldPixelShader: {
  63485. name: string;
  63486. shader: string;
  63487. };
  63488. }
  63489. declare module BABYLON {
  63490. /**
  63491. * BABYLON.JS Chromatic Aberration GLSL Shader
  63492. * Author: Olivier Guyot
  63493. * Separates very slightly R, G and B colors on the edges of the screen
  63494. * Inspired by Francois Tarlier & Martins Upitis
  63495. */
  63496. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63497. /**
  63498. * @ignore
  63499. * The chromatic aberration PostProcess id in the pipeline
  63500. */
  63501. LensChromaticAberrationEffect: string;
  63502. /**
  63503. * @ignore
  63504. * The highlights enhancing PostProcess id in the pipeline
  63505. */
  63506. HighlightsEnhancingEffect: string;
  63507. /**
  63508. * @ignore
  63509. * The depth-of-field PostProcess id in the pipeline
  63510. */
  63511. LensDepthOfFieldEffect: string;
  63512. private _scene;
  63513. private _depthTexture;
  63514. private _grainTexture;
  63515. private _chromaticAberrationPostProcess;
  63516. private _highlightsPostProcess;
  63517. private _depthOfFieldPostProcess;
  63518. private _edgeBlur;
  63519. private _grainAmount;
  63520. private _chromaticAberration;
  63521. private _distortion;
  63522. private _highlightsGain;
  63523. private _highlightsThreshold;
  63524. private _dofDistance;
  63525. private _dofAperture;
  63526. private _dofDarken;
  63527. private _dofPentagon;
  63528. private _blurNoise;
  63529. /**
  63530. * @constructor
  63531. *
  63532. * Effect parameters are as follow:
  63533. * {
  63534. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63535. * edge_blur: number; // from 0 to x (1 for realism)
  63536. * distortion: number; // from 0 to x (1 for realism)
  63537. * grain_amount: number; // from 0 to 1
  63538. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63539. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63540. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63541. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63542. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63543. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63544. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63545. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63546. * }
  63547. * Note: if an effect parameter is unset, effect is disabled
  63548. *
  63549. * @param name The rendering pipeline name
  63550. * @param parameters - An object containing all parameters (see above)
  63551. * @param scene The scene linked to this pipeline
  63552. * @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)
  63553. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63554. */
  63555. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63556. /**
  63557. * Get the class name
  63558. * @returns "LensRenderingPipeline"
  63559. */
  63560. getClassName(): string;
  63561. /**
  63562. * Gets associated scene
  63563. */
  63564. get scene(): Scene;
  63565. /**
  63566. * Gets or sets the edge blur
  63567. */
  63568. get edgeBlur(): number;
  63569. set edgeBlur(value: number);
  63570. /**
  63571. * Gets or sets the grain amount
  63572. */
  63573. get grainAmount(): number;
  63574. set grainAmount(value: number);
  63575. /**
  63576. * Gets or sets the chromatic aberration amount
  63577. */
  63578. get chromaticAberration(): number;
  63579. set chromaticAberration(value: number);
  63580. /**
  63581. * Gets or sets the depth of field aperture
  63582. */
  63583. get dofAperture(): number;
  63584. set dofAperture(value: number);
  63585. /**
  63586. * Gets or sets the edge distortion
  63587. */
  63588. get edgeDistortion(): number;
  63589. set edgeDistortion(value: number);
  63590. /**
  63591. * Gets or sets the depth of field distortion
  63592. */
  63593. get dofDistortion(): number;
  63594. set dofDistortion(value: number);
  63595. /**
  63596. * Gets or sets the darken out of focus amount
  63597. */
  63598. get darkenOutOfFocus(): number;
  63599. set darkenOutOfFocus(value: number);
  63600. /**
  63601. * Gets or sets a boolean indicating if blur noise is enabled
  63602. */
  63603. get blurNoise(): boolean;
  63604. set blurNoise(value: boolean);
  63605. /**
  63606. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63607. */
  63608. get pentagonBokeh(): boolean;
  63609. set pentagonBokeh(value: boolean);
  63610. /**
  63611. * Gets or sets the highlight grain amount
  63612. */
  63613. get highlightsGain(): number;
  63614. set highlightsGain(value: number);
  63615. /**
  63616. * Gets or sets the highlight threshold
  63617. */
  63618. get highlightsThreshold(): number;
  63619. set highlightsThreshold(value: number);
  63620. /**
  63621. * Sets the amount of blur at the edges
  63622. * @param amount blur amount
  63623. */
  63624. setEdgeBlur(amount: number): void;
  63625. /**
  63626. * Sets edge blur to 0
  63627. */
  63628. disableEdgeBlur(): void;
  63629. /**
  63630. * Sets the amout of grain
  63631. * @param amount Amount of grain
  63632. */
  63633. setGrainAmount(amount: number): void;
  63634. /**
  63635. * Set grain amount to 0
  63636. */
  63637. disableGrain(): void;
  63638. /**
  63639. * Sets the chromatic aberration amount
  63640. * @param amount amount of chromatic aberration
  63641. */
  63642. setChromaticAberration(amount: number): void;
  63643. /**
  63644. * Sets chromatic aberration amount to 0
  63645. */
  63646. disableChromaticAberration(): void;
  63647. /**
  63648. * Sets the EdgeDistortion amount
  63649. * @param amount amount of EdgeDistortion
  63650. */
  63651. setEdgeDistortion(amount: number): void;
  63652. /**
  63653. * Sets edge distortion to 0
  63654. */
  63655. disableEdgeDistortion(): void;
  63656. /**
  63657. * Sets the FocusDistance amount
  63658. * @param amount amount of FocusDistance
  63659. */
  63660. setFocusDistance(amount: number): void;
  63661. /**
  63662. * Disables depth of field
  63663. */
  63664. disableDepthOfField(): void;
  63665. /**
  63666. * Sets the Aperture amount
  63667. * @param amount amount of Aperture
  63668. */
  63669. setAperture(amount: number): void;
  63670. /**
  63671. * Sets the DarkenOutOfFocus amount
  63672. * @param amount amount of DarkenOutOfFocus
  63673. */
  63674. setDarkenOutOfFocus(amount: number): void;
  63675. private _pentagonBokehIsEnabled;
  63676. /**
  63677. * Creates a pentagon bokeh effect
  63678. */
  63679. enablePentagonBokeh(): void;
  63680. /**
  63681. * Disables the pentagon bokeh effect
  63682. */
  63683. disablePentagonBokeh(): void;
  63684. /**
  63685. * Enables noise blur
  63686. */
  63687. enableNoiseBlur(): void;
  63688. /**
  63689. * Disables noise blur
  63690. */
  63691. disableNoiseBlur(): void;
  63692. /**
  63693. * Sets the HighlightsGain amount
  63694. * @param amount amount of HighlightsGain
  63695. */
  63696. setHighlightsGain(amount: number): void;
  63697. /**
  63698. * Sets the HighlightsThreshold amount
  63699. * @param amount amount of HighlightsThreshold
  63700. */
  63701. setHighlightsThreshold(amount: number): void;
  63702. /**
  63703. * Disables highlights
  63704. */
  63705. disableHighlights(): void;
  63706. /**
  63707. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63708. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63709. */
  63710. dispose(disableDepthRender?: boolean): void;
  63711. private _createChromaticAberrationPostProcess;
  63712. private _createHighlightsPostProcess;
  63713. private _createDepthOfFieldPostProcess;
  63714. private _createGrainTexture;
  63715. }
  63716. }
  63717. declare module BABYLON {
  63718. /** @hidden */
  63719. export var ssao2PixelShader: {
  63720. name: string;
  63721. shader: string;
  63722. };
  63723. }
  63724. declare module BABYLON {
  63725. /** @hidden */
  63726. export var ssaoCombinePixelShader: {
  63727. name: string;
  63728. shader: string;
  63729. };
  63730. }
  63731. declare module BABYLON {
  63732. /**
  63733. * Render pipeline to produce ssao effect
  63734. */
  63735. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63736. /**
  63737. * @ignore
  63738. * The PassPostProcess id in the pipeline that contains the original scene color
  63739. */
  63740. SSAOOriginalSceneColorEffect: string;
  63741. /**
  63742. * @ignore
  63743. * The SSAO PostProcess id in the pipeline
  63744. */
  63745. SSAORenderEffect: string;
  63746. /**
  63747. * @ignore
  63748. * The horizontal blur PostProcess id in the pipeline
  63749. */
  63750. SSAOBlurHRenderEffect: string;
  63751. /**
  63752. * @ignore
  63753. * The vertical blur PostProcess id in the pipeline
  63754. */
  63755. SSAOBlurVRenderEffect: string;
  63756. /**
  63757. * @ignore
  63758. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63759. */
  63760. SSAOCombineRenderEffect: string;
  63761. /**
  63762. * The output strength of the SSAO post-process. Default value is 1.0.
  63763. */
  63764. totalStrength: number;
  63765. /**
  63766. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63767. */
  63768. maxZ: number;
  63769. /**
  63770. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63771. */
  63772. minZAspect: number;
  63773. private _samples;
  63774. /**
  63775. * Number of samples used for the SSAO calculations. Default value is 8
  63776. */
  63777. set samples(n: number);
  63778. get samples(): number;
  63779. private _textureSamples;
  63780. /**
  63781. * Number of samples to use for antialiasing
  63782. */
  63783. set textureSamples(n: number);
  63784. get textureSamples(): number;
  63785. /**
  63786. * Ratio object used for SSAO ratio and blur ratio
  63787. */
  63788. private _ratio;
  63789. /**
  63790. * Dynamically generated sphere sampler.
  63791. */
  63792. private _sampleSphere;
  63793. /**
  63794. * Blur filter offsets
  63795. */
  63796. private _samplerOffsets;
  63797. private _expensiveBlur;
  63798. /**
  63799. * If bilateral blur should be used
  63800. */
  63801. set expensiveBlur(b: boolean);
  63802. get expensiveBlur(): boolean;
  63803. /**
  63804. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63805. */
  63806. radius: number;
  63807. /**
  63808. * The base color of the SSAO post-process
  63809. * The final result is "base + ssao" between [0, 1]
  63810. */
  63811. base: number;
  63812. /**
  63813. * Support test.
  63814. */
  63815. static get IsSupported(): boolean;
  63816. private _scene;
  63817. private _depthTexture;
  63818. private _normalTexture;
  63819. private _randomTexture;
  63820. private _originalColorPostProcess;
  63821. private _ssaoPostProcess;
  63822. private _blurHPostProcess;
  63823. private _blurVPostProcess;
  63824. private _ssaoCombinePostProcess;
  63825. /**
  63826. * Gets active scene
  63827. */
  63828. get scene(): Scene;
  63829. /**
  63830. * @constructor
  63831. * @param name The rendering pipeline name
  63832. * @param scene The scene linked to this pipeline
  63833. * @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 }
  63834. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63835. */
  63836. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63837. /**
  63838. * Get the class name
  63839. * @returns "SSAO2RenderingPipeline"
  63840. */
  63841. getClassName(): string;
  63842. /**
  63843. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63844. */
  63845. dispose(disableGeometryBufferRenderer?: boolean): void;
  63846. private _createBlurPostProcess;
  63847. /** @hidden */
  63848. _rebuild(): void;
  63849. private _bits;
  63850. private _radicalInverse_VdC;
  63851. private _hammersley;
  63852. private _hemisphereSample_uniform;
  63853. private _generateHemisphere;
  63854. private _createSSAOPostProcess;
  63855. private _createSSAOCombinePostProcess;
  63856. private _createRandomTexture;
  63857. /**
  63858. * Serialize the rendering pipeline (Used when exporting)
  63859. * @returns the serialized object
  63860. */
  63861. serialize(): any;
  63862. /**
  63863. * Parse the serialized pipeline
  63864. * @param source Source pipeline.
  63865. * @param scene The scene to load the pipeline to.
  63866. * @param rootUrl The URL of the serialized pipeline.
  63867. * @returns An instantiated pipeline from the serialized object.
  63868. */
  63869. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63870. }
  63871. }
  63872. declare module BABYLON {
  63873. /** @hidden */
  63874. export var ssaoPixelShader: {
  63875. name: string;
  63876. shader: string;
  63877. };
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Render pipeline to produce ssao effect
  63882. */
  63883. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63884. /**
  63885. * @ignore
  63886. * The PassPostProcess id in the pipeline that contains the original scene color
  63887. */
  63888. SSAOOriginalSceneColorEffect: string;
  63889. /**
  63890. * @ignore
  63891. * The SSAO PostProcess id in the pipeline
  63892. */
  63893. SSAORenderEffect: string;
  63894. /**
  63895. * @ignore
  63896. * The horizontal blur PostProcess id in the pipeline
  63897. */
  63898. SSAOBlurHRenderEffect: string;
  63899. /**
  63900. * @ignore
  63901. * The vertical blur PostProcess id in the pipeline
  63902. */
  63903. SSAOBlurVRenderEffect: string;
  63904. /**
  63905. * @ignore
  63906. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63907. */
  63908. SSAOCombineRenderEffect: string;
  63909. /**
  63910. * The output strength of the SSAO post-process. Default value is 1.0.
  63911. */
  63912. totalStrength: number;
  63913. /**
  63914. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63915. */
  63916. radius: number;
  63917. /**
  63918. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63919. * Must not be equal to fallOff and superior to fallOff.
  63920. * Default value is 0.0075
  63921. */
  63922. area: number;
  63923. /**
  63924. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63925. * Must not be equal to area and inferior to area.
  63926. * Default value is 0.000001
  63927. */
  63928. fallOff: number;
  63929. /**
  63930. * The base color of the SSAO post-process
  63931. * The final result is "base + ssao" between [0, 1]
  63932. */
  63933. base: number;
  63934. private _scene;
  63935. private _depthTexture;
  63936. private _randomTexture;
  63937. private _originalColorPostProcess;
  63938. private _ssaoPostProcess;
  63939. private _blurHPostProcess;
  63940. private _blurVPostProcess;
  63941. private _ssaoCombinePostProcess;
  63942. private _firstUpdate;
  63943. /**
  63944. * Gets active scene
  63945. */
  63946. get scene(): Scene;
  63947. /**
  63948. * @constructor
  63949. * @param name - The rendering pipeline name
  63950. * @param scene - The scene linked to this pipeline
  63951. * @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 }
  63952. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63953. */
  63954. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63955. /**
  63956. * Get the class name
  63957. * @returns "SSAORenderingPipeline"
  63958. */
  63959. getClassName(): string;
  63960. /**
  63961. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63962. */
  63963. dispose(disableDepthRender?: boolean): void;
  63964. private _createBlurPostProcess;
  63965. /** @hidden */
  63966. _rebuild(): void;
  63967. private _createSSAOPostProcess;
  63968. private _createSSAOCombinePostProcess;
  63969. private _createRandomTexture;
  63970. }
  63971. }
  63972. declare module BABYLON {
  63973. /** @hidden */
  63974. export var standardPixelShader: {
  63975. name: string;
  63976. shader: string;
  63977. };
  63978. }
  63979. declare module BABYLON {
  63980. /**
  63981. * Standard rendering pipeline
  63982. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63983. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63984. */
  63985. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63986. /**
  63987. * Public members
  63988. */
  63989. /**
  63990. * Post-process which contains the original scene color before the pipeline applies all the effects
  63991. */
  63992. originalPostProcess: Nullable<PostProcess>;
  63993. /**
  63994. * Post-process used to down scale an image x4
  63995. */
  63996. downSampleX4PostProcess: Nullable<PostProcess>;
  63997. /**
  63998. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63999. */
  64000. brightPassPostProcess: Nullable<PostProcess>;
  64001. /**
  64002. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64003. */
  64004. blurHPostProcesses: PostProcess[];
  64005. /**
  64006. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64007. */
  64008. blurVPostProcesses: PostProcess[];
  64009. /**
  64010. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64011. */
  64012. textureAdderPostProcess: Nullable<PostProcess>;
  64013. /**
  64014. * Post-process used to create volumetric lighting effect
  64015. */
  64016. volumetricLightPostProcess: Nullable<PostProcess>;
  64017. /**
  64018. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64019. */
  64020. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64021. /**
  64022. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64023. */
  64024. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64025. /**
  64026. * Post-process used to merge the volumetric light effect and the real scene color
  64027. */
  64028. volumetricLightMergePostProces: Nullable<PostProcess>;
  64029. /**
  64030. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64031. */
  64032. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64033. /**
  64034. * Base post-process used to calculate the average luminance of the final image for HDR
  64035. */
  64036. luminancePostProcess: Nullable<PostProcess>;
  64037. /**
  64038. * Post-processes used to create down sample post-processes in order to get
  64039. * the average luminance of the final image for HDR
  64040. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64041. */
  64042. luminanceDownSamplePostProcesses: PostProcess[];
  64043. /**
  64044. * Post-process used to create a HDR effect (light adaptation)
  64045. */
  64046. hdrPostProcess: Nullable<PostProcess>;
  64047. /**
  64048. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64049. */
  64050. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64051. /**
  64052. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64053. */
  64054. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64055. /**
  64056. * Post-process used to merge the final HDR post-process and the real scene color
  64057. */
  64058. hdrFinalPostProcess: Nullable<PostProcess>;
  64059. /**
  64060. * Post-process used to create a lens flare effect
  64061. */
  64062. lensFlarePostProcess: Nullable<PostProcess>;
  64063. /**
  64064. * Post-process that merges the result of the lens flare post-process and the real scene color
  64065. */
  64066. lensFlareComposePostProcess: Nullable<PostProcess>;
  64067. /**
  64068. * Post-process used to create a motion blur effect
  64069. */
  64070. motionBlurPostProcess: Nullable<PostProcess>;
  64071. /**
  64072. * Post-process used to create a depth of field effect
  64073. */
  64074. depthOfFieldPostProcess: Nullable<PostProcess>;
  64075. /**
  64076. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64077. */
  64078. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64079. /**
  64080. * Represents the brightness threshold in order to configure the illuminated surfaces
  64081. */
  64082. brightThreshold: number;
  64083. /**
  64084. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64085. */
  64086. blurWidth: number;
  64087. /**
  64088. * Sets if the blur for highlighted surfaces must be only horizontal
  64089. */
  64090. horizontalBlur: boolean;
  64091. /**
  64092. * Gets the overall exposure used by the pipeline
  64093. */
  64094. get exposure(): number;
  64095. /**
  64096. * Sets the overall exposure used by the pipeline
  64097. */
  64098. set exposure(value: number);
  64099. /**
  64100. * Texture used typically to simulate "dirty" on camera lens
  64101. */
  64102. lensTexture: Nullable<Texture>;
  64103. /**
  64104. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64105. */
  64106. volumetricLightCoefficient: number;
  64107. /**
  64108. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64109. */
  64110. volumetricLightPower: number;
  64111. /**
  64112. * Used the set the blur intensity to smooth the volumetric lights
  64113. */
  64114. volumetricLightBlurScale: number;
  64115. /**
  64116. * Light (spot or directional) used to generate the volumetric lights rays
  64117. * The source light must have a shadow generate so the pipeline can get its
  64118. * depth map
  64119. */
  64120. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64121. /**
  64122. * For eye adaptation, represents the minimum luminance the eye can see
  64123. */
  64124. hdrMinimumLuminance: number;
  64125. /**
  64126. * For eye adaptation, represents the decrease luminance speed
  64127. */
  64128. hdrDecreaseRate: number;
  64129. /**
  64130. * For eye adaptation, represents the increase luminance speed
  64131. */
  64132. hdrIncreaseRate: number;
  64133. /**
  64134. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64135. */
  64136. get hdrAutoExposure(): boolean;
  64137. /**
  64138. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64139. */
  64140. set hdrAutoExposure(value: boolean);
  64141. /**
  64142. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64143. */
  64144. lensColorTexture: Nullable<Texture>;
  64145. /**
  64146. * The overall strengh for the lens flare effect
  64147. */
  64148. lensFlareStrength: number;
  64149. /**
  64150. * Dispersion coefficient for lens flare ghosts
  64151. */
  64152. lensFlareGhostDispersal: number;
  64153. /**
  64154. * Main lens flare halo width
  64155. */
  64156. lensFlareHaloWidth: number;
  64157. /**
  64158. * Based on the lens distortion effect, defines how much the lens flare result
  64159. * is distorted
  64160. */
  64161. lensFlareDistortionStrength: number;
  64162. /**
  64163. * Configures the blur intensity used for for lens flare (halo)
  64164. */
  64165. lensFlareBlurWidth: number;
  64166. /**
  64167. * Lens star texture must be used to simulate rays on the flares and is available
  64168. * in the documentation
  64169. */
  64170. lensStarTexture: Nullable<Texture>;
  64171. /**
  64172. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64173. * flare effect by taking account of the dirt texture
  64174. */
  64175. lensFlareDirtTexture: Nullable<Texture>;
  64176. /**
  64177. * Represents the focal length for the depth of field effect
  64178. */
  64179. depthOfFieldDistance: number;
  64180. /**
  64181. * Represents the blur intensity for the blurred part of the depth of field effect
  64182. */
  64183. depthOfFieldBlurWidth: number;
  64184. /**
  64185. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64186. */
  64187. get motionStrength(): number;
  64188. /**
  64189. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64190. */
  64191. set motionStrength(strength: number);
  64192. /**
  64193. * Gets wether or not the motion blur post-process is object based or screen based.
  64194. */
  64195. get objectBasedMotionBlur(): boolean;
  64196. /**
  64197. * Sets wether or not the motion blur post-process should be object based or screen based
  64198. */
  64199. set objectBasedMotionBlur(value: boolean);
  64200. /**
  64201. * List of animations for the pipeline (IAnimatable implementation)
  64202. */
  64203. animations: Animation[];
  64204. /**
  64205. * Private members
  64206. */
  64207. private _scene;
  64208. private _currentDepthOfFieldSource;
  64209. private _basePostProcess;
  64210. private _fixedExposure;
  64211. private _currentExposure;
  64212. private _hdrAutoExposure;
  64213. private _hdrCurrentLuminance;
  64214. private _motionStrength;
  64215. private _isObjectBasedMotionBlur;
  64216. private _floatTextureType;
  64217. private _camerasToBeAttached;
  64218. private _ratio;
  64219. private _bloomEnabled;
  64220. private _depthOfFieldEnabled;
  64221. private _vlsEnabled;
  64222. private _lensFlareEnabled;
  64223. private _hdrEnabled;
  64224. private _motionBlurEnabled;
  64225. private _fxaaEnabled;
  64226. private _motionBlurSamples;
  64227. private _volumetricLightStepsCount;
  64228. private _samples;
  64229. /**
  64230. * @ignore
  64231. * Specifies if the bloom pipeline is enabled
  64232. */
  64233. get BloomEnabled(): boolean;
  64234. set BloomEnabled(enabled: boolean);
  64235. /**
  64236. * @ignore
  64237. * Specifies if the depth of field pipeline is enabed
  64238. */
  64239. get DepthOfFieldEnabled(): boolean;
  64240. set DepthOfFieldEnabled(enabled: boolean);
  64241. /**
  64242. * @ignore
  64243. * Specifies if the lens flare pipeline is enabed
  64244. */
  64245. get LensFlareEnabled(): boolean;
  64246. set LensFlareEnabled(enabled: boolean);
  64247. /**
  64248. * @ignore
  64249. * Specifies if the HDR pipeline is enabled
  64250. */
  64251. get HDREnabled(): boolean;
  64252. set HDREnabled(enabled: boolean);
  64253. /**
  64254. * @ignore
  64255. * Specifies if the volumetric lights scattering effect is enabled
  64256. */
  64257. get VLSEnabled(): boolean;
  64258. set VLSEnabled(enabled: boolean);
  64259. /**
  64260. * @ignore
  64261. * Specifies if the motion blur effect is enabled
  64262. */
  64263. get MotionBlurEnabled(): boolean;
  64264. set MotionBlurEnabled(enabled: boolean);
  64265. /**
  64266. * Specifies if anti-aliasing is enabled
  64267. */
  64268. get fxaaEnabled(): boolean;
  64269. set fxaaEnabled(enabled: boolean);
  64270. /**
  64271. * Specifies the number of steps used to calculate the volumetric lights
  64272. * Typically in interval [50, 200]
  64273. */
  64274. get volumetricLightStepsCount(): number;
  64275. set volumetricLightStepsCount(count: number);
  64276. /**
  64277. * Specifies the number of samples used for the motion blur effect
  64278. * Typically in interval [16, 64]
  64279. */
  64280. get motionBlurSamples(): number;
  64281. set motionBlurSamples(samples: number);
  64282. /**
  64283. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64284. */
  64285. get samples(): number;
  64286. set samples(sampleCount: number);
  64287. /**
  64288. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64289. * @constructor
  64290. * @param name The rendering pipeline name
  64291. * @param scene The scene linked to this pipeline
  64292. * @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)
  64293. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64294. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64295. */
  64296. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64297. private _buildPipeline;
  64298. private _createDownSampleX4PostProcess;
  64299. private _createBrightPassPostProcess;
  64300. private _createBlurPostProcesses;
  64301. private _createTextureAdderPostProcess;
  64302. private _createVolumetricLightPostProcess;
  64303. private _createLuminancePostProcesses;
  64304. private _createHdrPostProcess;
  64305. private _createLensFlarePostProcess;
  64306. private _createDepthOfFieldPostProcess;
  64307. private _createMotionBlurPostProcess;
  64308. private _getDepthTexture;
  64309. private _disposePostProcesses;
  64310. /**
  64311. * Dispose of the pipeline and stop all post processes
  64312. */
  64313. dispose(): void;
  64314. /**
  64315. * Serialize the rendering pipeline (Used when exporting)
  64316. * @returns the serialized object
  64317. */
  64318. serialize(): any;
  64319. /**
  64320. * Parse the serialized pipeline
  64321. * @param source Source pipeline.
  64322. * @param scene The scene to load the pipeline to.
  64323. * @param rootUrl The URL of the serialized pipeline.
  64324. * @returns An instantiated pipeline from the serialized object.
  64325. */
  64326. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64327. /**
  64328. * Luminance steps
  64329. */
  64330. static LuminanceSteps: number;
  64331. }
  64332. }
  64333. declare module BABYLON {
  64334. /** @hidden */
  64335. export var tonemapPixelShader: {
  64336. name: string;
  64337. shader: string;
  64338. };
  64339. }
  64340. declare module BABYLON {
  64341. /** Defines operator used for tonemapping */
  64342. export enum TonemappingOperator {
  64343. /** Hable */
  64344. Hable = 0,
  64345. /** Reinhard */
  64346. Reinhard = 1,
  64347. /** HejiDawson */
  64348. HejiDawson = 2,
  64349. /** Photographic */
  64350. Photographic = 3
  64351. }
  64352. /**
  64353. * Defines a post process to apply tone mapping
  64354. */
  64355. export class TonemapPostProcess extends PostProcess {
  64356. private _operator;
  64357. /** Defines the required exposure adjustement */
  64358. exposureAdjustment: number;
  64359. /**
  64360. * Creates a new TonemapPostProcess
  64361. * @param name defines the name of the postprocess
  64362. * @param _operator defines the operator to use
  64363. * @param exposureAdjustment defines the required exposure adjustement
  64364. * @param camera defines the camera to use (can be null)
  64365. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64366. * @param engine defines the hosting engine (can be ignore if camera is set)
  64367. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64368. */
  64369. constructor(name: string, _operator: TonemappingOperator,
  64370. /** Defines the required exposure adjustement */
  64371. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64372. }
  64373. }
  64374. declare module BABYLON {
  64375. /** @hidden */
  64376. export var depthVertexShader: {
  64377. name: string;
  64378. shader: string;
  64379. };
  64380. }
  64381. declare module BABYLON {
  64382. /** @hidden */
  64383. export var volumetricLightScatteringPixelShader: {
  64384. name: string;
  64385. shader: string;
  64386. };
  64387. }
  64388. declare module BABYLON {
  64389. /** @hidden */
  64390. export var volumetricLightScatteringPassVertexShader: {
  64391. name: string;
  64392. shader: string;
  64393. };
  64394. }
  64395. declare module BABYLON {
  64396. /** @hidden */
  64397. export var volumetricLightScatteringPassPixelShader: {
  64398. name: string;
  64399. shader: string;
  64400. };
  64401. }
  64402. declare module BABYLON {
  64403. /**
  64404. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64405. */
  64406. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64407. private _volumetricLightScatteringPass;
  64408. private _volumetricLightScatteringRTT;
  64409. private _viewPort;
  64410. private _screenCoordinates;
  64411. private _cachedDefines;
  64412. /**
  64413. * If not undefined, the mesh position is computed from the attached node position
  64414. */
  64415. attachedNode: {
  64416. position: Vector3;
  64417. };
  64418. /**
  64419. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64420. */
  64421. customMeshPosition: Vector3;
  64422. /**
  64423. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64424. */
  64425. useCustomMeshPosition: boolean;
  64426. /**
  64427. * If the post-process should inverse the light scattering direction
  64428. */
  64429. invert: boolean;
  64430. /**
  64431. * The internal mesh used by the post-process
  64432. */
  64433. mesh: Mesh;
  64434. /**
  64435. * @hidden
  64436. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64437. */
  64438. get useDiffuseColor(): boolean;
  64439. set useDiffuseColor(useDiffuseColor: boolean);
  64440. /**
  64441. * Array containing the excluded meshes not rendered in the internal pass
  64442. */
  64443. excludedMeshes: AbstractMesh[];
  64444. /**
  64445. * Controls the overall intensity of the post-process
  64446. */
  64447. exposure: number;
  64448. /**
  64449. * Dissipates each sample's contribution in range [0, 1]
  64450. */
  64451. decay: number;
  64452. /**
  64453. * Controls the overall intensity of each sample
  64454. */
  64455. weight: number;
  64456. /**
  64457. * Controls the density of each sample
  64458. */
  64459. density: number;
  64460. /**
  64461. * @constructor
  64462. * @param name The post-process name
  64463. * @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)
  64464. * @param camera The camera that the post-process will be attached to
  64465. * @param mesh The mesh used to create the light scattering
  64466. * @param samples The post-process quality, default 100
  64467. * @param samplingModeThe post-process filtering mode
  64468. * @param engine The babylon engine
  64469. * @param reusable If the post-process is reusable
  64470. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64471. */
  64472. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64473. /**
  64474. * Returns the string "VolumetricLightScatteringPostProcess"
  64475. * @returns "VolumetricLightScatteringPostProcess"
  64476. */
  64477. getClassName(): string;
  64478. private _isReady;
  64479. /**
  64480. * Sets the new light position for light scattering effect
  64481. * @param position The new custom light position
  64482. */
  64483. setCustomMeshPosition(position: Vector3): void;
  64484. /**
  64485. * Returns the light position for light scattering effect
  64486. * @return Vector3 The custom light position
  64487. */
  64488. getCustomMeshPosition(): Vector3;
  64489. /**
  64490. * Disposes the internal assets and detaches the post-process from the camera
  64491. */
  64492. dispose(camera: Camera): void;
  64493. /**
  64494. * Returns the render target texture used by the post-process
  64495. * @return the render target texture used by the post-process
  64496. */
  64497. getPass(): RenderTargetTexture;
  64498. private _meshExcluded;
  64499. private _createPass;
  64500. private _updateMeshScreenCoordinates;
  64501. /**
  64502. * Creates a default mesh for the Volumeric Light Scattering post-process
  64503. * @param name The mesh name
  64504. * @param scene The scene where to create the mesh
  64505. * @return the default mesh
  64506. */
  64507. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64508. }
  64509. }
  64510. declare module BABYLON {
  64511. interface Scene {
  64512. /** @hidden (Backing field) */
  64513. _boundingBoxRenderer: BoundingBoxRenderer;
  64514. /** @hidden (Backing field) */
  64515. _forceShowBoundingBoxes: boolean;
  64516. /**
  64517. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64518. */
  64519. forceShowBoundingBoxes: boolean;
  64520. /**
  64521. * Gets the bounding box renderer associated with the scene
  64522. * @returns a BoundingBoxRenderer
  64523. */
  64524. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64525. }
  64526. interface AbstractMesh {
  64527. /** @hidden (Backing field) */
  64528. _showBoundingBox: boolean;
  64529. /**
  64530. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64531. */
  64532. showBoundingBox: boolean;
  64533. }
  64534. /**
  64535. * Component responsible of rendering the bounding box of the meshes in a scene.
  64536. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64537. */
  64538. export class BoundingBoxRenderer implements ISceneComponent {
  64539. /**
  64540. * The component name helpfull to identify the component in the list of scene components.
  64541. */
  64542. readonly name: string;
  64543. /**
  64544. * The scene the component belongs to.
  64545. */
  64546. scene: Scene;
  64547. /**
  64548. * Color of the bounding box lines placed in front of an object
  64549. */
  64550. frontColor: Color3;
  64551. /**
  64552. * Color of the bounding box lines placed behind an object
  64553. */
  64554. backColor: Color3;
  64555. /**
  64556. * Defines if the renderer should show the back lines or not
  64557. */
  64558. showBackLines: boolean;
  64559. /**
  64560. * @hidden
  64561. */
  64562. renderList: SmartArray<BoundingBox>;
  64563. private _colorShader;
  64564. private _vertexBuffers;
  64565. private _indexBuffer;
  64566. private _fillIndexBuffer;
  64567. private _fillIndexData;
  64568. /**
  64569. * Instantiates a new bounding box renderer in a scene.
  64570. * @param scene the scene the renderer renders in
  64571. */
  64572. constructor(scene: Scene);
  64573. /**
  64574. * Registers the component in a given scene
  64575. */
  64576. register(): void;
  64577. private _evaluateSubMesh;
  64578. private _activeMesh;
  64579. private _prepareRessources;
  64580. private _createIndexBuffer;
  64581. /**
  64582. * Rebuilds the elements related to this component in case of
  64583. * context lost for instance.
  64584. */
  64585. rebuild(): void;
  64586. /**
  64587. * @hidden
  64588. */
  64589. reset(): void;
  64590. /**
  64591. * Render the bounding boxes of a specific rendering group
  64592. * @param renderingGroupId defines the rendering group to render
  64593. */
  64594. render(renderingGroupId: number): void;
  64595. /**
  64596. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64597. * @param mesh Define the mesh to render the occlusion bounding box for
  64598. */
  64599. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64600. /**
  64601. * Dispose and release the resources attached to this renderer.
  64602. */
  64603. dispose(): void;
  64604. }
  64605. }
  64606. declare module BABYLON {
  64607. /** @hidden */
  64608. export var depthPixelShader: {
  64609. name: string;
  64610. shader: string;
  64611. };
  64612. }
  64613. declare module BABYLON {
  64614. /**
  64615. * This represents a depth renderer in Babylon.
  64616. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64617. */
  64618. export class DepthRenderer {
  64619. private _scene;
  64620. private _depthMap;
  64621. private _effect;
  64622. private readonly _storeNonLinearDepth;
  64623. private readonly _clearColor;
  64624. /** Get if the depth renderer is using packed depth or not */
  64625. readonly isPacked: boolean;
  64626. private _cachedDefines;
  64627. private _camera;
  64628. /**
  64629. * Specifiess that the depth renderer will only be used within
  64630. * the camera it is created for.
  64631. * This can help forcing its rendering during the camera processing.
  64632. */
  64633. useOnlyInActiveCamera: boolean;
  64634. /** @hidden */
  64635. static _SceneComponentInitialization: (scene: Scene) => void;
  64636. /**
  64637. * Instantiates a depth renderer
  64638. * @param scene The scene the renderer belongs to
  64639. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64640. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64641. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64642. */
  64643. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64644. /**
  64645. * Creates the depth rendering effect and checks if the effect is ready.
  64646. * @param subMesh The submesh to be used to render the depth map of
  64647. * @param useInstances If multiple world instances should be used
  64648. * @returns if the depth renderer is ready to render the depth map
  64649. */
  64650. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64651. /**
  64652. * Gets the texture which the depth map will be written to.
  64653. * @returns The depth map texture
  64654. */
  64655. getDepthMap(): RenderTargetTexture;
  64656. /**
  64657. * Disposes of the depth renderer.
  64658. */
  64659. dispose(): void;
  64660. }
  64661. }
  64662. declare module BABYLON {
  64663. interface Scene {
  64664. /** @hidden (Backing field) */
  64665. _depthRenderer: {
  64666. [id: string]: DepthRenderer;
  64667. };
  64668. /**
  64669. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64670. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64671. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64672. * @returns the created depth renderer
  64673. */
  64674. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64675. /**
  64676. * Disables a depth renderer for a given camera
  64677. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64678. */
  64679. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64680. }
  64681. /**
  64682. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64683. * in several rendering techniques.
  64684. */
  64685. export class DepthRendererSceneComponent implements ISceneComponent {
  64686. /**
  64687. * The component name helpfull to identify the component in the list of scene components.
  64688. */
  64689. readonly name: string;
  64690. /**
  64691. * The scene the component belongs to.
  64692. */
  64693. scene: Scene;
  64694. /**
  64695. * Creates a new instance of the component for the given scene
  64696. * @param scene Defines the scene to register the component in
  64697. */
  64698. constructor(scene: Scene);
  64699. /**
  64700. * Registers the component in a given scene
  64701. */
  64702. register(): void;
  64703. /**
  64704. * Rebuilds the elements related to this component in case of
  64705. * context lost for instance.
  64706. */
  64707. rebuild(): void;
  64708. /**
  64709. * Disposes the component and the associated ressources
  64710. */
  64711. dispose(): void;
  64712. private _gatherRenderTargets;
  64713. private _gatherActiveCameraRenderTargets;
  64714. }
  64715. }
  64716. declare module BABYLON {
  64717. /** @hidden */
  64718. export var outlinePixelShader: {
  64719. name: string;
  64720. shader: string;
  64721. };
  64722. }
  64723. declare module BABYLON {
  64724. /** @hidden */
  64725. export var outlineVertexShader: {
  64726. name: string;
  64727. shader: string;
  64728. };
  64729. }
  64730. declare module BABYLON {
  64731. interface Scene {
  64732. /** @hidden */
  64733. _outlineRenderer: OutlineRenderer;
  64734. /**
  64735. * Gets the outline renderer associated with the scene
  64736. * @returns a OutlineRenderer
  64737. */
  64738. getOutlineRenderer(): OutlineRenderer;
  64739. }
  64740. interface AbstractMesh {
  64741. /** @hidden (Backing field) */
  64742. _renderOutline: boolean;
  64743. /**
  64744. * Gets or sets a boolean indicating if the outline must be rendered as well
  64745. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64746. */
  64747. renderOutline: boolean;
  64748. /** @hidden (Backing field) */
  64749. _renderOverlay: boolean;
  64750. /**
  64751. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64752. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64753. */
  64754. renderOverlay: boolean;
  64755. }
  64756. /**
  64757. * This class is responsible to draw bothe outline/overlay of meshes.
  64758. * It should not be used directly but through the available method on mesh.
  64759. */
  64760. export class OutlineRenderer implements ISceneComponent {
  64761. /**
  64762. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64763. */
  64764. private static _StencilReference;
  64765. /**
  64766. * The name of the component. Each component must have a unique name.
  64767. */
  64768. name: string;
  64769. /**
  64770. * The scene the component belongs to.
  64771. */
  64772. scene: Scene;
  64773. /**
  64774. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64775. */
  64776. zOffset: number;
  64777. private _engine;
  64778. private _effect;
  64779. private _cachedDefines;
  64780. private _savedDepthWrite;
  64781. /**
  64782. * Instantiates a new outline renderer. (There could be only one per scene).
  64783. * @param scene Defines the scene it belongs to
  64784. */
  64785. constructor(scene: Scene);
  64786. /**
  64787. * Register the component to one instance of a scene.
  64788. */
  64789. register(): void;
  64790. /**
  64791. * Rebuilds the elements related to this component in case of
  64792. * context lost for instance.
  64793. */
  64794. rebuild(): void;
  64795. /**
  64796. * Disposes the component and the associated ressources.
  64797. */
  64798. dispose(): void;
  64799. /**
  64800. * Renders the outline in the canvas.
  64801. * @param subMesh Defines the sumesh to render
  64802. * @param batch Defines the batch of meshes in case of instances
  64803. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64804. */
  64805. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64806. /**
  64807. * Returns whether or not the outline renderer is ready for a given submesh.
  64808. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64809. * @param subMesh Defines the submesh to check readyness for
  64810. * @param useInstances Defines wheter wee are trying to render instances or not
  64811. * @returns true if ready otherwise false
  64812. */
  64813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64814. private _beforeRenderingMesh;
  64815. private _afterRenderingMesh;
  64816. }
  64817. }
  64818. declare module BABYLON {
  64819. /**
  64820. * Defines the basic options interface of a Sprite Frame Source Size.
  64821. */
  64822. export interface ISpriteJSONSpriteSourceSize {
  64823. /**
  64824. * number of the original width of the Frame
  64825. */
  64826. w: number;
  64827. /**
  64828. * number of the original height of the Frame
  64829. */
  64830. h: number;
  64831. }
  64832. /**
  64833. * Defines the basic options interface of a Sprite Frame Data.
  64834. */
  64835. export interface ISpriteJSONSpriteFrameData {
  64836. /**
  64837. * number of the x offset of the Frame
  64838. */
  64839. x: number;
  64840. /**
  64841. * number of the y offset of the Frame
  64842. */
  64843. y: number;
  64844. /**
  64845. * number of the width of the Frame
  64846. */
  64847. w: number;
  64848. /**
  64849. * number of the height of the Frame
  64850. */
  64851. h: number;
  64852. }
  64853. /**
  64854. * Defines the basic options interface of a JSON Sprite.
  64855. */
  64856. export interface ISpriteJSONSprite {
  64857. /**
  64858. * string name of the Frame
  64859. */
  64860. filename: string;
  64861. /**
  64862. * ISpriteJSONSpriteFrame basic object of the frame data
  64863. */
  64864. frame: ISpriteJSONSpriteFrameData;
  64865. /**
  64866. * boolean to flag is the frame was rotated.
  64867. */
  64868. rotated: boolean;
  64869. /**
  64870. * boolean to flag is the frame was trimmed.
  64871. */
  64872. trimmed: boolean;
  64873. /**
  64874. * ISpriteJSONSpriteFrame basic object of the source data
  64875. */
  64876. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64877. /**
  64878. * ISpriteJSONSpriteFrame basic object of the source data
  64879. */
  64880. sourceSize: ISpriteJSONSpriteSourceSize;
  64881. }
  64882. /**
  64883. * Defines the basic options interface of a JSON atlas.
  64884. */
  64885. export interface ISpriteJSONAtlas {
  64886. /**
  64887. * Array of objects that contain the frame data.
  64888. */
  64889. frames: Array<ISpriteJSONSprite>;
  64890. /**
  64891. * object basic object containing the sprite meta data.
  64892. */
  64893. meta?: object;
  64894. }
  64895. }
  64896. declare module BABYLON {
  64897. /** @hidden */
  64898. export var spriteMapPixelShader: {
  64899. name: string;
  64900. shader: string;
  64901. };
  64902. }
  64903. declare module BABYLON {
  64904. /** @hidden */
  64905. export var spriteMapVertexShader: {
  64906. name: string;
  64907. shader: string;
  64908. };
  64909. }
  64910. declare module BABYLON {
  64911. /**
  64912. * Defines the basic options interface of a SpriteMap
  64913. */
  64914. export interface ISpriteMapOptions {
  64915. /**
  64916. * Vector2 of the number of cells in the grid.
  64917. */
  64918. stageSize?: Vector2;
  64919. /**
  64920. * Vector2 of the size of the output plane in World Units.
  64921. */
  64922. outputSize?: Vector2;
  64923. /**
  64924. * Vector3 of the position of the output plane in World Units.
  64925. */
  64926. outputPosition?: Vector3;
  64927. /**
  64928. * Vector3 of the rotation of the output plane.
  64929. */
  64930. outputRotation?: Vector3;
  64931. /**
  64932. * number of layers that the system will reserve in resources.
  64933. */
  64934. layerCount?: number;
  64935. /**
  64936. * number of max animation frames a single cell will reserve in resources.
  64937. */
  64938. maxAnimationFrames?: number;
  64939. /**
  64940. * number cell index of the base tile when the system compiles.
  64941. */
  64942. baseTile?: number;
  64943. /**
  64944. * boolean flip the sprite after its been repositioned by the framing data.
  64945. */
  64946. flipU?: boolean;
  64947. /**
  64948. * Vector3 scalar of the global RGB values of the SpriteMap.
  64949. */
  64950. colorMultiply?: Vector3;
  64951. }
  64952. /**
  64953. * Defines the IDisposable interface in order to be cleanable from resources.
  64954. */
  64955. export interface ISpriteMap extends IDisposable {
  64956. /**
  64957. * String name of the SpriteMap.
  64958. */
  64959. name: string;
  64960. /**
  64961. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  64962. */
  64963. atlasJSON: ISpriteJSONAtlas;
  64964. /**
  64965. * Texture of the SpriteMap.
  64966. */
  64967. spriteSheet: Texture;
  64968. /**
  64969. * The parameters to initialize the SpriteMap with.
  64970. */
  64971. options: ISpriteMapOptions;
  64972. }
  64973. /**
  64974. * Class used to manage a grid restricted sprite deployment on an Output plane.
  64975. */
  64976. export class SpriteMap implements ISpriteMap {
  64977. /** The Name of the spriteMap */
  64978. name: string;
  64979. /** The JSON file with the frame and meta data */
  64980. atlasJSON: ISpriteJSONAtlas;
  64981. /** The systems Sprite Sheet Texture */
  64982. spriteSheet: Texture;
  64983. /** Arguments passed with the Constructor */
  64984. options: ISpriteMapOptions;
  64985. /** Public Sprite Storage array, parsed from atlasJSON */
  64986. sprites: Array<ISpriteJSONSprite>;
  64987. /** Returns the Number of Sprites in the System */
  64988. get spriteCount(): number;
  64989. /** Returns the Position of Output Plane*/
  64990. get position(): Vector3;
  64991. /** Returns the Position of Output Plane*/
  64992. set position(v: Vector3);
  64993. /** Returns the Rotation of Output Plane*/
  64994. get rotation(): Vector3;
  64995. /** Returns the Rotation of Output Plane*/
  64996. set rotation(v: Vector3);
  64997. /** Sets the AnimationMap*/
  64998. get animationMap(): RawTexture;
  64999. /** Sets the AnimationMap*/
  65000. set animationMap(v: RawTexture);
  65001. /** Scene that the SpriteMap was created in */
  65002. private _scene;
  65003. /** Texture Buffer of Float32 that holds tile frame data*/
  65004. private _frameMap;
  65005. /** Texture Buffers of Float32 that holds tileMap data*/
  65006. private _tileMaps;
  65007. /** Texture Buffer of Float32 that holds Animation Data*/
  65008. private _animationMap;
  65009. /** Custom ShaderMaterial Central to the System*/
  65010. private _material;
  65011. /** Custom ShaderMaterial Central to the System*/
  65012. private _output;
  65013. /** Systems Time Ticker*/
  65014. private _time;
  65015. /**
  65016. * Creates a new SpriteMap
  65017. * @param name defines the SpriteMaps Name
  65018. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  65019. * @param spriteSheet is the Texture that the Sprites are on.
  65020. * @param options a basic deployment configuration
  65021. * @param scene The Scene that the map is deployed on
  65022. */
  65023. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  65024. /**
  65025. * Returns tileID location
  65026. * @returns Vector2 the cell position ID
  65027. */
  65028. getTileID(): Vector2;
  65029. /**
  65030. * Gets the UV location of the mouse over the SpriteMap.
  65031. * @returns Vector2 the UV position of the mouse interaction
  65032. */
  65033. getMousePosition(): Vector2;
  65034. /**
  65035. * Creates the "frame" texture Buffer
  65036. * -------------------------------------
  65037. * Structure of frames
  65038. * "filename": "Falling-Water-2.png",
  65039. * "frame": {"x":69,"y":103,"w":24,"h":32},
  65040. * "rotated": true,
  65041. * "trimmed": true,
  65042. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  65043. * "sourceSize": {"w":32,"h":32}
  65044. * @returns RawTexture of the frameMap
  65045. */
  65046. private _createFrameBuffer;
  65047. /**
  65048. * Creates the tileMap texture Buffer
  65049. * @param buffer normally and array of numbers, or a false to generate from scratch
  65050. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  65051. * @returns RawTexture of the tileMap
  65052. */
  65053. private _createTileBuffer;
  65054. /**
  65055. * Modifies the data of the tileMaps
  65056. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  65057. * @param pos is the iVector2 Coordinates of the Tile
  65058. * @param tile The SpriteIndex of the new Tile
  65059. */
  65060. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  65061. /**
  65062. * Creates the animationMap texture Buffer
  65063. * @param buffer normally and array of numbers, or a false to generate from scratch
  65064. * @returns RawTexture of the animationMap
  65065. */
  65066. private _createTileAnimationBuffer;
  65067. /**
  65068. * Modifies the data of the animationMap
  65069. * @param cellID is the Index of the Sprite
  65070. * @param _frame is the target Animation frame
  65071. * @param toCell is the Target Index of the next frame of the animation
  65072. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  65073. * @param speed is a global scalar of the time variable on the map.
  65074. */
  65075. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  65076. /**
  65077. * Exports the .tilemaps file
  65078. */
  65079. saveTileMaps(): void;
  65080. /**
  65081. * Imports the .tilemaps file
  65082. * @param url of the .tilemaps file
  65083. */
  65084. loadTileMaps(url: string): void;
  65085. /**
  65086. * Release associated resources
  65087. */
  65088. dispose(): void;
  65089. }
  65090. }
  65091. declare module BABYLON {
  65092. /**
  65093. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65094. * @see http://doc.babylonjs.com/babylon101/sprites
  65095. */
  65096. export class SpritePackedManager extends SpriteManager {
  65097. /** defines the packed manager's name */
  65098. name: string;
  65099. /**
  65100. * Creates a new sprite manager from a packed sprite sheet
  65101. * @param name defines the manager's name
  65102. * @param imgUrl defines the sprite sheet url
  65103. * @param capacity defines the maximum allowed number of sprites
  65104. * @param scene defines the hosting scene
  65105. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65106. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65107. * @param samplingMode defines the smapling mode to use with spritesheet
  65108. * @param fromPacked set to true; do not alter
  65109. */
  65110. constructor(
  65111. /** defines the packed manager's name */
  65112. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65113. }
  65114. }
  65115. declare module BABYLON {
  65116. /**
  65117. * Defines the list of states available for a task inside a AssetsManager
  65118. */
  65119. export enum AssetTaskState {
  65120. /**
  65121. * Initialization
  65122. */
  65123. INIT = 0,
  65124. /**
  65125. * Running
  65126. */
  65127. RUNNING = 1,
  65128. /**
  65129. * Done
  65130. */
  65131. DONE = 2,
  65132. /**
  65133. * Error
  65134. */
  65135. ERROR = 3
  65136. }
  65137. /**
  65138. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65139. */
  65140. export abstract class AbstractAssetTask {
  65141. /**
  65142. * Task name
  65143. */ name: string;
  65144. /**
  65145. * Callback called when the task is successful
  65146. */
  65147. onSuccess: (task: any) => void;
  65148. /**
  65149. * Callback called when the task is not successful
  65150. */
  65151. onError: (task: any, message?: string, exception?: any) => void;
  65152. /**
  65153. * Creates a new AssetsManager
  65154. * @param name defines the name of the task
  65155. */
  65156. constructor(
  65157. /**
  65158. * Task name
  65159. */ name: string);
  65160. private _isCompleted;
  65161. private _taskState;
  65162. private _errorObject;
  65163. /**
  65164. * Get if the task is completed
  65165. */
  65166. get isCompleted(): boolean;
  65167. /**
  65168. * Gets the current state of the task
  65169. */
  65170. get taskState(): AssetTaskState;
  65171. /**
  65172. * Gets the current error object (if task is in error)
  65173. */
  65174. get errorObject(): {
  65175. message?: string;
  65176. exception?: any;
  65177. };
  65178. /**
  65179. * Internal only
  65180. * @hidden
  65181. */
  65182. _setErrorObject(message?: string, exception?: any): void;
  65183. /**
  65184. * Execute the current task
  65185. * @param scene defines the scene where you want your assets to be loaded
  65186. * @param onSuccess is a callback called when the task is successfully executed
  65187. * @param onError is a callback called if an error occurs
  65188. */
  65189. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65190. /**
  65191. * Execute the current task
  65192. * @param scene defines the scene where you want your assets to be loaded
  65193. * @param onSuccess is a callback called when the task is successfully executed
  65194. * @param onError is a callback called if an error occurs
  65195. */
  65196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65197. /**
  65198. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65199. * This can be used with failed tasks that have the reason for failure fixed.
  65200. */
  65201. reset(): void;
  65202. private onErrorCallback;
  65203. private onDoneCallback;
  65204. }
  65205. /**
  65206. * Define the interface used by progress events raised during assets loading
  65207. */
  65208. export interface IAssetsProgressEvent {
  65209. /**
  65210. * Defines the number of remaining tasks to process
  65211. */
  65212. remainingCount: number;
  65213. /**
  65214. * Defines the total number of tasks
  65215. */
  65216. totalCount: number;
  65217. /**
  65218. * Defines the task that was just processed
  65219. */
  65220. task: AbstractAssetTask;
  65221. }
  65222. /**
  65223. * Class used to share progress information about assets loading
  65224. */
  65225. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65226. /**
  65227. * Defines the number of remaining tasks to process
  65228. */
  65229. remainingCount: number;
  65230. /**
  65231. * Defines the total number of tasks
  65232. */
  65233. totalCount: number;
  65234. /**
  65235. * Defines the task that was just processed
  65236. */
  65237. task: AbstractAssetTask;
  65238. /**
  65239. * Creates a AssetsProgressEvent
  65240. * @param remainingCount defines the number of remaining tasks to process
  65241. * @param totalCount defines the total number of tasks
  65242. * @param task defines the task that was just processed
  65243. */
  65244. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65245. }
  65246. /**
  65247. * Define a task used by AssetsManager to load meshes
  65248. */
  65249. export class MeshAssetTask extends AbstractAssetTask {
  65250. /**
  65251. * Defines the name of the task
  65252. */
  65253. name: string;
  65254. /**
  65255. * Defines the list of mesh's names you want to load
  65256. */
  65257. meshesNames: any;
  65258. /**
  65259. * Defines the root url to use as a base to load your meshes and associated resources
  65260. */
  65261. rootUrl: string;
  65262. /**
  65263. * Defines the filename of the scene to load from
  65264. */
  65265. sceneFilename: string;
  65266. /**
  65267. * Gets the list of loaded meshes
  65268. */
  65269. loadedMeshes: Array<AbstractMesh>;
  65270. /**
  65271. * Gets the list of loaded particle systems
  65272. */
  65273. loadedParticleSystems: Array<IParticleSystem>;
  65274. /**
  65275. * Gets the list of loaded skeletons
  65276. */
  65277. loadedSkeletons: Array<Skeleton>;
  65278. /**
  65279. * Gets the list of loaded animation groups
  65280. */
  65281. loadedAnimationGroups: Array<AnimationGroup>;
  65282. /**
  65283. * Callback called when the task is successful
  65284. */
  65285. onSuccess: (task: MeshAssetTask) => void;
  65286. /**
  65287. * Callback called when the task is successful
  65288. */
  65289. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65290. /**
  65291. * Creates a new MeshAssetTask
  65292. * @param name defines the name of the task
  65293. * @param meshesNames defines the list of mesh's names you want to load
  65294. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65295. * @param sceneFilename defines the filename of the scene to load from
  65296. */
  65297. constructor(
  65298. /**
  65299. * Defines the name of the task
  65300. */
  65301. name: string,
  65302. /**
  65303. * Defines the list of mesh's names you want to load
  65304. */
  65305. meshesNames: any,
  65306. /**
  65307. * Defines the root url to use as a base to load your meshes and associated resources
  65308. */
  65309. rootUrl: string,
  65310. /**
  65311. * Defines the filename of the scene to load from
  65312. */
  65313. sceneFilename: string);
  65314. /**
  65315. * Execute the current task
  65316. * @param scene defines the scene where you want your assets to be loaded
  65317. * @param onSuccess is a callback called when the task is successfully executed
  65318. * @param onError is a callback called if an error occurs
  65319. */
  65320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65321. }
  65322. /**
  65323. * Define a task used by AssetsManager to load text content
  65324. */
  65325. export class TextFileAssetTask extends AbstractAssetTask {
  65326. /**
  65327. * Defines the name of the task
  65328. */
  65329. name: string;
  65330. /**
  65331. * Defines the location of the file to load
  65332. */
  65333. url: string;
  65334. /**
  65335. * Gets the loaded text string
  65336. */
  65337. text: string;
  65338. /**
  65339. * Callback called when the task is successful
  65340. */
  65341. onSuccess: (task: TextFileAssetTask) => void;
  65342. /**
  65343. * Callback called when the task is successful
  65344. */
  65345. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65346. /**
  65347. * Creates a new TextFileAssetTask object
  65348. * @param name defines the name of the task
  65349. * @param url defines the location of the file to load
  65350. */
  65351. constructor(
  65352. /**
  65353. * Defines the name of the task
  65354. */
  65355. name: string,
  65356. /**
  65357. * Defines the location of the file to load
  65358. */
  65359. url: string);
  65360. /**
  65361. * Execute the current task
  65362. * @param scene defines the scene where you want your assets to be loaded
  65363. * @param onSuccess is a callback called when the task is successfully executed
  65364. * @param onError is a callback called if an error occurs
  65365. */
  65366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65367. }
  65368. /**
  65369. * Define a task used by AssetsManager to load binary data
  65370. */
  65371. export class BinaryFileAssetTask extends AbstractAssetTask {
  65372. /**
  65373. * Defines the name of the task
  65374. */
  65375. name: string;
  65376. /**
  65377. * Defines the location of the file to load
  65378. */
  65379. url: string;
  65380. /**
  65381. * Gets the lodaded data (as an array buffer)
  65382. */
  65383. data: ArrayBuffer;
  65384. /**
  65385. * Callback called when the task is successful
  65386. */
  65387. onSuccess: (task: BinaryFileAssetTask) => void;
  65388. /**
  65389. * Callback called when the task is successful
  65390. */
  65391. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65392. /**
  65393. * Creates a new BinaryFileAssetTask object
  65394. * @param name defines the name of the new task
  65395. * @param url defines the location of the file to load
  65396. */
  65397. constructor(
  65398. /**
  65399. * Defines the name of the task
  65400. */
  65401. name: string,
  65402. /**
  65403. * Defines the location of the file to load
  65404. */
  65405. url: string);
  65406. /**
  65407. * Execute the current task
  65408. * @param scene defines the scene where you want your assets to be loaded
  65409. * @param onSuccess is a callback called when the task is successfully executed
  65410. * @param onError is a callback called if an error occurs
  65411. */
  65412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65413. }
  65414. /**
  65415. * Define a task used by AssetsManager to load images
  65416. */
  65417. export class ImageAssetTask extends AbstractAssetTask {
  65418. /**
  65419. * Defines the name of the task
  65420. */
  65421. name: string;
  65422. /**
  65423. * Defines the location of the image to load
  65424. */
  65425. url: string;
  65426. /**
  65427. * Gets the loaded images
  65428. */
  65429. image: HTMLImageElement;
  65430. /**
  65431. * Callback called when the task is successful
  65432. */
  65433. onSuccess: (task: ImageAssetTask) => void;
  65434. /**
  65435. * Callback called when the task is successful
  65436. */
  65437. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65438. /**
  65439. * Creates a new ImageAssetTask
  65440. * @param name defines the name of the task
  65441. * @param url defines the location of the image to load
  65442. */
  65443. constructor(
  65444. /**
  65445. * Defines the name of the task
  65446. */
  65447. name: string,
  65448. /**
  65449. * Defines the location of the image to load
  65450. */
  65451. url: string);
  65452. /**
  65453. * Execute the current task
  65454. * @param scene defines the scene where you want your assets to be loaded
  65455. * @param onSuccess is a callback called when the task is successfully executed
  65456. * @param onError is a callback called if an error occurs
  65457. */
  65458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65459. }
  65460. /**
  65461. * Defines the interface used by texture loading tasks
  65462. */
  65463. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65464. /**
  65465. * Gets the loaded texture
  65466. */
  65467. texture: TEX;
  65468. }
  65469. /**
  65470. * Define a task used by AssetsManager to load 2D textures
  65471. */
  65472. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65473. /**
  65474. * Defines the name of the task
  65475. */
  65476. name: string;
  65477. /**
  65478. * Defines the location of the file to load
  65479. */
  65480. url: string;
  65481. /**
  65482. * Defines if mipmap should not be generated (default is false)
  65483. */
  65484. noMipmap?: boolean | undefined;
  65485. /**
  65486. * Defines if texture must be inverted on Y axis (default is false)
  65487. */
  65488. invertY?: boolean | undefined;
  65489. /**
  65490. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65491. */
  65492. samplingMode: number;
  65493. /**
  65494. * Gets the loaded texture
  65495. */
  65496. texture: Texture;
  65497. /**
  65498. * Callback called when the task is successful
  65499. */
  65500. onSuccess: (task: TextureAssetTask) => void;
  65501. /**
  65502. * Callback called when the task is successful
  65503. */
  65504. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65505. /**
  65506. * Creates a new TextureAssetTask object
  65507. * @param name defines the name of the task
  65508. * @param url defines the location of the file to load
  65509. * @param noMipmap defines if mipmap should not be generated (default is false)
  65510. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65511. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65512. */
  65513. constructor(
  65514. /**
  65515. * Defines the name of the task
  65516. */
  65517. name: string,
  65518. /**
  65519. * Defines the location of the file to load
  65520. */
  65521. url: string,
  65522. /**
  65523. * Defines if mipmap should not be generated (default is false)
  65524. */
  65525. noMipmap?: boolean | undefined,
  65526. /**
  65527. * Defines if texture must be inverted on Y axis (default is false)
  65528. */
  65529. invertY?: boolean | undefined,
  65530. /**
  65531. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65532. */
  65533. samplingMode?: number);
  65534. /**
  65535. * Execute the current task
  65536. * @param scene defines the scene where you want your assets to be loaded
  65537. * @param onSuccess is a callback called when the task is successfully executed
  65538. * @param onError is a callback called if an error occurs
  65539. */
  65540. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65541. }
  65542. /**
  65543. * Define a task used by AssetsManager to load cube textures
  65544. */
  65545. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65546. /**
  65547. * Defines the name of the task
  65548. */
  65549. name: string;
  65550. /**
  65551. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65552. */
  65553. url: string;
  65554. /**
  65555. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65556. */
  65557. extensions?: string[] | undefined;
  65558. /**
  65559. * Defines if mipmaps should not be generated (default is false)
  65560. */
  65561. noMipmap?: boolean | undefined;
  65562. /**
  65563. * Defines the explicit list of files (undefined by default)
  65564. */
  65565. files?: string[] | undefined;
  65566. /**
  65567. * Gets the loaded texture
  65568. */
  65569. texture: CubeTexture;
  65570. /**
  65571. * Callback called when the task is successful
  65572. */
  65573. onSuccess: (task: CubeTextureAssetTask) => void;
  65574. /**
  65575. * Callback called when the task is successful
  65576. */
  65577. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65578. /**
  65579. * Creates a new CubeTextureAssetTask
  65580. * @param name defines the name of the task
  65581. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65582. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65583. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65584. * @param files defines the explicit list of files (undefined by default)
  65585. */
  65586. constructor(
  65587. /**
  65588. * Defines the name of the task
  65589. */
  65590. name: string,
  65591. /**
  65592. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65593. */
  65594. url: string,
  65595. /**
  65596. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65597. */
  65598. extensions?: string[] | undefined,
  65599. /**
  65600. * Defines if mipmaps should not be generated (default is false)
  65601. */
  65602. noMipmap?: boolean | undefined,
  65603. /**
  65604. * Defines the explicit list of files (undefined by default)
  65605. */
  65606. files?: string[] | undefined);
  65607. /**
  65608. * Execute the current task
  65609. * @param scene defines the scene where you want your assets to be loaded
  65610. * @param onSuccess is a callback called when the task is successfully executed
  65611. * @param onError is a callback called if an error occurs
  65612. */
  65613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65614. }
  65615. /**
  65616. * Define a task used by AssetsManager to load HDR cube textures
  65617. */
  65618. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65619. /**
  65620. * Defines the name of the task
  65621. */
  65622. name: string;
  65623. /**
  65624. * Defines the location of the file to load
  65625. */
  65626. url: string;
  65627. /**
  65628. * Defines the desired size (the more it increases the longer the generation will be)
  65629. */
  65630. size: number;
  65631. /**
  65632. * Defines if mipmaps should not be generated (default is false)
  65633. */
  65634. noMipmap: boolean;
  65635. /**
  65636. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65637. */
  65638. generateHarmonics: boolean;
  65639. /**
  65640. * 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)
  65641. */
  65642. gammaSpace: boolean;
  65643. /**
  65644. * Internal Use Only
  65645. */
  65646. reserved: boolean;
  65647. /**
  65648. * Gets the loaded texture
  65649. */
  65650. texture: HDRCubeTexture;
  65651. /**
  65652. * Callback called when the task is successful
  65653. */
  65654. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65655. /**
  65656. * Callback called when the task is successful
  65657. */
  65658. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65659. /**
  65660. * Creates a new HDRCubeTextureAssetTask object
  65661. * @param name defines the name of the task
  65662. * @param url defines the location of the file to load
  65663. * @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.
  65664. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65665. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65666. * @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)
  65667. * @param reserved Internal use only
  65668. */
  65669. constructor(
  65670. /**
  65671. * Defines the name of the task
  65672. */
  65673. name: string,
  65674. /**
  65675. * Defines the location of the file to load
  65676. */
  65677. url: string,
  65678. /**
  65679. * Defines the desired size (the more it increases the longer the generation will be)
  65680. */
  65681. size: number,
  65682. /**
  65683. * Defines if mipmaps should not be generated (default is false)
  65684. */
  65685. noMipmap?: boolean,
  65686. /**
  65687. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65688. */
  65689. generateHarmonics?: boolean,
  65690. /**
  65691. * 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)
  65692. */
  65693. gammaSpace?: boolean,
  65694. /**
  65695. * Internal Use Only
  65696. */
  65697. reserved?: boolean);
  65698. /**
  65699. * Execute the current task
  65700. * @param scene defines the scene where you want your assets to be loaded
  65701. * @param onSuccess is a callback called when the task is successfully executed
  65702. * @param onError is a callback called if an error occurs
  65703. */
  65704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65705. }
  65706. /**
  65707. * Define a task used by AssetsManager to load Equirectangular cube textures
  65708. */
  65709. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65710. /**
  65711. * Defines the name of the task
  65712. */
  65713. name: string;
  65714. /**
  65715. * Defines the location of the file to load
  65716. */
  65717. url: string;
  65718. /**
  65719. * Defines the desired size (the more it increases the longer the generation will be)
  65720. */
  65721. size: number;
  65722. /**
  65723. * Defines if mipmaps should not be generated (default is false)
  65724. */
  65725. noMipmap: boolean;
  65726. /**
  65727. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65728. * but the standard material would require them in Gamma space) (default is true)
  65729. */
  65730. gammaSpace: boolean;
  65731. /**
  65732. * Gets the loaded texture
  65733. */
  65734. texture: EquiRectangularCubeTexture;
  65735. /**
  65736. * Callback called when the task is successful
  65737. */
  65738. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65739. /**
  65740. * Callback called when the task is successful
  65741. */
  65742. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65743. /**
  65744. * Creates a new EquiRectangularCubeTextureAssetTask object
  65745. * @param name defines the name of the task
  65746. * @param url defines the location of the file to load
  65747. * @param size defines the desired size (the more it increases the longer the generation will be)
  65748. * If the size is omitted this implies you are using a preprocessed cubemap.
  65749. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65750. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65751. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65752. * (default is true)
  65753. */
  65754. constructor(
  65755. /**
  65756. * Defines the name of the task
  65757. */
  65758. name: string,
  65759. /**
  65760. * Defines the location of the file to load
  65761. */
  65762. url: string,
  65763. /**
  65764. * Defines the desired size (the more it increases the longer the generation will be)
  65765. */
  65766. size: number,
  65767. /**
  65768. * Defines if mipmaps should not be generated (default is false)
  65769. */
  65770. noMipmap?: boolean,
  65771. /**
  65772. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65773. * but the standard material would require them in Gamma space) (default is true)
  65774. */
  65775. gammaSpace?: boolean);
  65776. /**
  65777. * Execute the current task
  65778. * @param scene defines the scene where you want your assets to be loaded
  65779. * @param onSuccess is a callback called when the task is successfully executed
  65780. * @param onError is a callback called if an error occurs
  65781. */
  65782. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65783. }
  65784. /**
  65785. * This class can be used to easily import assets into a scene
  65786. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65787. */
  65788. export class AssetsManager {
  65789. private _scene;
  65790. private _isLoading;
  65791. protected _tasks: AbstractAssetTask[];
  65792. protected _waitingTasksCount: number;
  65793. protected _totalTasksCount: number;
  65794. /**
  65795. * Callback called when all tasks are processed
  65796. */
  65797. onFinish: (tasks: AbstractAssetTask[]) => void;
  65798. /**
  65799. * Callback called when a task is successful
  65800. */
  65801. onTaskSuccess: (task: AbstractAssetTask) => void;
  65802. /**
  65803. * Callback called when a task had an error
  65804. */
  65805. onTaskError: (task: AbstractAssetTask) => void;
  65806. /**
  65807. * Callback called when a task is done (whatever the result is)
  65808. */
  65809. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65810. /**
  65811. * Observable called when all tasks are processed
  65812. */
  65813. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65814. /**
  65815. * Observable called when a task had an error
  65816. */
  65817. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65818. /**
  65819. * Observable called when all tasks were executed
  65820. */
  65821. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65822. /**
  65823. * Observable called when a task is done (whatever the result is)
  65824. */
  65825. onProgressObservable: Observable<IAssetsProgressEvent>;
  65826. /**
  65827. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65828. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65829. */
  65830. useDefaultLoadingScreen: boolean;
  65831. /**
  65832. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65833. * when all assets have been downloaded.
  65834. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65835. */
  65836. autoHideLoadingUI: boolean;
  65837. /**
  65838. * Creates a new AssetsManager
  65839. * @param scene defines the scene to work on
  65840. */
  65841. constructor(scene: Scene);
  65842. /**
  65843. * Add a MeshAssetTask to the list of active tasks
  65844. * @param taskName defines the name of the new task
  65845. * @param meshesNames defines the name of meshes to load
  65846. * @param rootUrl defines the root url to use to locate files
  65847. * @param sceneFilename defines the filename of the scene file
  65848. * @returns a new MeshAssetTask object
  65849. */
  65850. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65851. /**
  65852. * Add a TextFileAssetTask to the list of active tasks
  65853. * @param taskName defines the name of the new task
  65854. * @param url defines the url of the file to load
  65855. * @returns a new TextFileAssetTask object
  65856. */
  65857. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65858. /**
  65859. * Add a BinaryFileAssetTask to the list of active tasks
  65860. * @param taskName defines the name of the new task
  65861. * @param url defines the url of the file to load
  65862. * @returns a new BinaryFileAssetTask object
  65863. */
  65864. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65865. /**
  65866. * Add a ImageAssetTask to the list of active tasks
  65867. * @param taskName defines the name of the new task
  65868. * @param url defines the url of the file to load
  65869. * @returns a new ImageAssetTask object
  65870. */
  65871. addImageTask(taskName: string, url: string): ImageAssetTask;
  65872. /**
  65873. * Add a TextureAssetTask to the list of active tasks
  65874. * @param taskName defines the name of the new task
  65875. * @param url defines the url of the file to load
  65876. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65877. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65878. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65879. * @returns a new TextureAssetTask object
  65880. */
  65881. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65882. /**
  65883. * Add a CubeTextureAssetTask to the list of active tasks
  65884. * @param taskName defines the name of the new task
  65885. * @param url defines the url of the file to load
  65886. * @param extensions defines the extension to use to load the cube map (can be null)
  65887. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65888. * @param files defines the list of files to load (can be null)
  65889. * @returns a new CubeTextureAssetTask object
  65890. */
  65891. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65892. /**
  65893. *
  65894. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65895. * @param taskName defines the name of the new task
  65896. * @param url defines the url of the file to load
  65897. * @param size defines the size you want for the cubemap (can be null)
  65898. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65899. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65900. * @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)
  65901. * @param reserved Internal use only
  65902. * @returns a new HDRCubeTextureAssetTask object
  65903. */
  65904. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65905. /**
  65906. *
  65907. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65908. * @param taskName defines the name of the new task
  65909. * @param url defines the url of the file to load
  65910. * @param size defines the size you want for the cubemap (can be null)
  65911. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65912. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65913. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65914. * @returns a new EquiRectangularCubeTextureAssetTask object
  65915. */
  65916. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65917. /**
  65918. * Remove a task from the assets manager.
  65919. * @param task the task to remove
  65920. */
  65921. removeTask(task: AbstractAssetTask): void;
  65922. private _decreaseWaitingTasksCount;
  65923. private _runTask;
  65924. /**
  65925. * Reset the AssetsManager and remove all tasks
  65926. * @return the current instance of the AssetsManager
  65927. */
  65928. reset(): AssetsManager;
  65929. /**
  65930. * Start the loading process
  65931. * @return the current instance of the AssetsManager
  65932. */
  65933. load(): AssetsManager;
  65934. /**
  65935. * Start the loading process as an async operation
  65936. * @return a promise returning the list of failed tasks
  65937. */
  65938. loadAsync(): Promise<void>;
  65939. }
  65940. }
  65941. declare module BABYLON {
  65942. /**
  65943. * Wrapper class for promise with external resolve and reject.
  65944. */
  65945. export class Deferred<T> {
  65946. /**
  65947. * The promise associated with this deferred object.
  65948. */
  65949. readonly promise: Promise<T>;
  65950. private _resolve;
  65951. private _reject;
  65952. /**
  65953. * The resolve method of the promise associated with this deferred object.
  65954. */
  65955. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  65956. /**
  65957. * The reject method of the promise associated with this deferred object.
  65958. */
  65959. get reject(): (reason?: any) => void;
  65960. /**
  65961. * Constructor for this deferred object.
  65962. */
  65963. constructor();
  65964. }
  65965. }
  65966. declare module BABYLON {
  65967. /**
  65968. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65969. */
  65970. export class MeshExploder {
  65971. private _centerMesh;
  65972. private _meshes;
  65973. private _meshesOrigins;
  65974. private _toCenterVectors;
  65975. private _scaledDirection;
  65976. private _newPosition;
  65977. private _centerPosition;
  65978. /**
  65979. * Explodes meshes from a center mesh.
  65980. * @param meshes The meshes to explode.
  65981. * @param centerMesh The mesh to be center of explosion.
  65982. */
  65983. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65984. private _setCenterMesh;
  65985. /**
  65986. * Get class name
  65987. * @returns "MeshExploder"
  65988. */
  65989. getClassName(): string;
  65990. /**
  65991. * "Exploded meshes"
  65992. * @returns Array of meshes with the centerMesh at index 0.
  65993. */
  65994. getMeshes(): Array<Mesh>;
  65995. /**
  65996. * Explodes meshes giving a specific direction
  65997. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65998. */
  65999. explode(direction?: number): void;
  66000. }
  66001. }
  66002. declare module BABYLON {
  66003. /**
  66004. * Class used to help managing file picking and drag'n'drop
  66005. */
  66006. export class FilesInput {
  66007. /**
  66008. * List of files ready to be loaded
  66009. */
  66010. static get FilesToLoad(): {
  66011. [key: string]: File;
  66012. };
  66013. /**
  66014. * Callback called when a file is processed
  66015. */
  66016. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66017. private _engine;
  66018. private _currentScene;
  66019. private _sceneLoadedCallback;
  66020. private _progressCallback;
  66021. private _additionalRenderLoopLogicCallback;
  66022. private _textureLoadingCallback;
  66023. private _startingProcessingFilesCallback;
  66024. private _onReloadCallback;
  66025. private _errorCallback;
  66026. private _elementToMonitor;
  66027. private _sceneFileToLoad;
  66028. private _filesToLoad;
  66029. /**
  66030. * Creates a new FilesInput
  66031. * @param engine defines the rendering engine
  66032. * @param scene defines the hosting scene
  66033. * @param sceneLoadedCallback callback called when scene is loaded
  66034. * @param progressCallback callback called to track progress
  66035. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66036. * @param textureLoadingCallback callback called when a texture is loading
  66037. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66038. * @param onReloadCallback callback called when a reload is requested
  66039. * @param errorCallback callback call if an error occurs
  66040. */
  66041. 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);
  66042. private _dragEnterHandler;
  66043. private _dragOverHandler;
  66044. private _dropHandler;
  66045. /**
  66046. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66047. * @param elementToMonitor defines the DOM element to track
  66048. */
  66049. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66050. /**
  66051. * Release all associated resources
  66052. */
  66053. dispose(): void;
  66054. private renderFunction;
  66055. private drag;
  66056. private drop;
  66057. private _traverseFolder;
  66058. private _processFiles;
  66059. /**
  66060. * Load files from a drop event
  66061. * @param event defines the drop event to use as source
  66062. */
  66063. loadFiles(event: any): void;
  66064. private _processReload;
  66065. /**
  66066. * Reload the current scene from the loaded files
  66067. */
  66068. reload(): void;
  66069. }
  66070. }
  66071. declare module BABYLON {
  66072. /**
  66073. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66074. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66075. */
  66076. export class SceneOptimization {
  66077. /**
  66078. * Defines the priority of this optimization (0 by default which means first in the list)
  66079. */
  66080. priority: number;
  66081. /**
  66082. * Gets a string describing the action executed by the current optimization
  66083. * @returns description string
  66084. */
  66085. getDescription(): string;
  66086. /**
  66087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66088. * @param scene defines the current scene where to apply this optimization
  66089. * @param optimizer defines the current optimizer
  66090. * @returns true if everything that can be done was applied
  66091. */
  66092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66093. /**
  66094. * Creates the SceneOptimization object
  66095. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66096. * @param desc defines the description associated with the optimization
  66097. */
  66098. constructor(
  66099. /**
  66100. * Defines the priority of this optimization (0 by default which means first in the list)
  66101. */
  66102. priority?: number);
  66103. }
  66104. /**
  66105. * Defines an optimization used to reduce the size of render target textures
  66106. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66107. */
  66108. export class TextureOptimization extends SceneOptimization {
  66109. /**
  66110. * Defines the priority of this optimization (0 by default which means first in the list)
  66111. */
  66112. priority: number;
  66113. /**
  66114. * 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
  66115. */
  66116. maximumSize: number;
  66117. /**
  66118. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66119. */
  66120. step: number;
  66121. /**
  66122. * Gets a string describing the action executed by the current optimization
  66123. * @returns description string
  66124. */
  66125. getDescription(): string;
  66126. /**
  66127. * Creates the TextureOptimization object
  66128. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66129. * @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
  66130. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66131. */
  66132. constructor(
  66133. /**
  66134. * Defines the priority of this optimization (0 by default which means first in the list)
  66135. */
  66136. priority?: number,
  66137. /**
  66138. * 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
  66139. */
  66140. maximumSize?: number,
  66141. /**
  66142. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66143. */
  66144. step?: number);
  66145. /**
  66146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66147. * @param scene defines the current scene where to apply this optimization
  66148. * @param optimizer defines the current optimizer
  66149. * @returns true if everything that can be done was applied
  66150. */
  66151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66152. }
  66153. /**
  66154. * Defines an optimization used to increase or decrease the rendering resolution
  66155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66156. */
  66157. export class HardwareScalingOptimization extends SceneOptimization {
  66158. /**
  66159. * Defines the priority of this optimization (0 by default which means first in the list)
  66160. */
  66161. priority: number;
  66162. /**
  66163. * Defines the maximum scale to use (2 by default)
  66164. */
  66165. maximumScale: number;
  66166. /**
  66167. * Defines the step to use between two passes (0.5 by default)
  66168. */
  66169. step: number;
  66170. private _currentScale;
  66171. private _directionOffset;
  66172. /**
  66173. * Gets a string describing the action executed by the current optimization
  66174. * @return description string
  66175. */
  66176. getDescription(): string;
  66177. /**
  66178. * Creates the HardwareScalingOptimization object
  66179. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66180. * @param maximumScale defines the maximum scale to use (2 by default)
  66181. * @param step defines the step to use between two passes (0.5 by default)
  66182. */
  66183. constructor(
  66184. /**
  66185. * Defines the priority of this optimization (0 by default which means first in the list)
  66186. */
  66187. priority?: number,
  66188. /**
  66189. * Defines the maximum scale to use (2 by default)
  66190. */
  66191. maximumScale?: number,
  66192. /**
  66193. * Defines the step to use between two passes (0.5 by default)
  66194. */
  66195. step?: number);
  66196. /**
  66197. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66198. * @param scene defines the current scene where to apply this optimization
  66199. * @param optimizer defines the current optimizer
  66200. * @returns true if everything that can be done was applied
  66201. */
  66202. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66203. }
  66204. /**
  66205. * Defines an optimization used to remove shadows
  66206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66207. */
  66208. export class ShadowsOptimization extends SceneOptimization {
  66209. /**
  66210. * Gets a string describing the action executed by the current optimization
  66211. * @return description string
  66212. */
  66213. getDescription(): string;
  66214. /**
  66215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66216. * @param scene defines the current scene where to apply this optimization
  66217. * @param optimizer defines the current optimizer
  66218. * @returns true if everything that can be done was applied
  66219. */
  66220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66221. }
  66222. /**
  66223. * Defines an optimization used to turn post-processes off
  66224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66225. */
  66226. export class PostProcessesOptimization extends SceneOptimization {
  66227. /**
  66228. * Gets a string describing the action executed by the current optimization
  66229. * @return description string
  66230. */
  66231. getDescription(): string;
  66232. /**
  66233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66234. * @param scene defines the current scene where to apply this optimization
  66235. * @param optimizer defines the current optimizer
  66236. * @returns true if everything that can be done was applied
  66237. */
  66238. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66239. }
  66240. /**
  66241. * Defines an optimization used to turn lens flares off
  66242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66243. */
  66244. export class LensFlaresOptimization extends SceneOptimization {
  66245. /**
  66246. * Gets a string describing the action executed by the current optimization
  66247. * @return description string
  66248. */
  66249. getDescription(): string;
  66250. /**
  66251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66252. * @param scene defines the current scene where to apply this optimization
  66253. * @param optimizer defines the current optimizer
  66254. * @returns true if everything that can be done was applied
  66255. */
  66256. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66257. }
  66258. /**
  66259. * Defines an optimization based on user defined callback.
  66260. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66261. */
  66262. export class CustomOptimization extends SceneOptimization {
  66263. /**
  66264. * Callback called to apply the custom optimization.
  66265. */
  66266. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66267. /**
  66268. * Callback called to get custom description
  66269. */
  66270. onGetDescription: () => string;
  66271. /**
  66272. * Gets a string describing the action executed by the current optimization
  66273. * @returns description string
  66274. */
  66275. getDescription(): string;
  66276. /**
  66277. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66278. * @param scene defines the current scene where to apply this optimization
  66279. * @param optimizer defines the current optimizer
  66280. * @returns true if everything that can be done was applied
  66281. */
  66282. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66283. }
  66284. /**
  66285. * Defines an optimization used to turn particles off
  66286. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66287. */
  66288. export class ParticlesOptimization extends SceneOptimization {
  66289. /**
  66290. * Gets a string describing the action executed by the current optimization
  66291. * @return description string
  66292. */
  66293. getDescription(): string;
  66294. /**
  66295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66296. * @param scene defines the current scene where to apply this optimization
  66297. * @param optimizer defines the current optimizer
  66298. * @returns true if everything that can be done was applied
  66299. */
  66300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66301. }
  66302. /**
  66303. * Defines an optimization used to turn render targets off
  66304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66305. */
  66306. export class RenderTargetsOptimization extends SceneOptimization {
  66307. /**
  66308. * Gets a string describing the action executed by the current optimization
  66309. * @return description string
  66310. */
  66311. getDescription(): string;
  66312. /**
  66313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66314. * @param scene defines the current scene where to apply this optimization
  66315. * @param optimizer defines the current optimizer
  66316. * @returns true if everything that can be done was applied
  66317. */
  66318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66319. }
  66320. /**
  66321. * Defines an optimization used to merge meshes with compatible materials
  66322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66323. */
  66324. export class MergeMeshesOptimization extends SceneOptimization {
  66325. private static _UpdateSelectionTree;
  66326. /**
  66327. * Gets or sets a boolean which defines if optimization octree has to be updated
  66328. */
  66329. static get UpdateSelectionTree(): boolean;
  66330. /**
  66331. * Gets or sets a boolean which defines if optimization octree has to be updated
  66332. */
  66333. static set UpdateSelectionTree(value: boolean);
  66334. /**
  66335. * Gets a string describing the action executed by the current optimization
  66336. * @return description string
  66337. */
  66338. getDescription(): string;
  66339. private _canBeMerged;
  66340. /**
  66341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66342. * @param scene defines the current scene where to apply this optimization
  66343. * @param optimizer defines the current optimizer
  66344. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66345. * @returns true if everything that can be done was applied
  66346. */
  66347. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66348. }
  66349. /**
  66350. * Defines a list of options used by SceneOptimizer
  66351. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66352. */
  66353. export class SceneOptimizerOptions {
  66354. /**
  66355. * Defines the target frame rate to reach (60 by default)
  66356. */
  66357. targetFrameRate: number;
  66358. /**
  66359. * Defines the interval between two checkes (2000ms by default)
  66360. */
  66361. trackerDuration: number;
  66362. /**
  66363. * Gets the list of optimizations to apply
  66364. */
  66365. optimizations: SceneOptimization[];
  66366. /**
  66367. * Creates a new list of options used by SceneOptimizer
  66368. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66369. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66370. */
  66371. constructor(
  66372. /**
  66373. * Defines the target frame rate to reach (60 by default)
  66374. */
  66375. targetFrameRate?: number,
  66376. /**
  66377. * Defines the interval between two checkes (2000ms by default)
  66378. */
  66379. trackerDuration?: number);
  66380. /**
  66381. * Add a new optimization
  66382. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66383. * @returns the current SceneOptimizerOptions
  66384. */
  66385. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66386. /**
  66387. * Add a new custom optimization
  66388. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66389. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66390. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66391. * @returns the current SceneOptimizerOptions
  66392. */
  66393. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66394. /**
  66395. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66396. * @param targetFrameRate defines the target frame rate (60 by default)
  66397. * @returns a SceneOptimizerOptions object
  66398. */
  66399. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66400. /**
  66401. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66402. * @param targetFrameRate defines the target frame rate (60 by default)
  66403. * @returns a SceneOptimizerOptions object
  66404. */
  66405. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66406. /**
  66407. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66408. * @param targetFrameRate defines the target frame rate (60 by default)
  66409. * @returns a SceneOptimizerOptions object
  66410. */
  66411. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66412. }
  66413. /**
  66414. * Class used to run optimizations in order to reach a target frame rate
  66415. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66416. */
  66417. export class SceneOptimizer implements IDisposable {
  66418. private _isRunning;
  66419. private _options;
  66420. private _scene;
  66421. private _currentPriorityLevel;
  66422. private _targetFrameRate;
  66423. private _trackerDuration;
  66424. private _currentFrameRate;
  66425. private _sceneDisposeObserver;
  66426. private _improvementMode;
  66427. /**
  66428. * Defines an observable called when the optimizer reaches the target frame rate
  66429. */
  66430. onSuccessObservable: Observable<SceneOptimizer>;
  66431. /**
  66432. * Defines an observable called when the optimizer enables an optimization
  66433. */
  66434. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66435. /**
  66436. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66437. */
  66438. onFailureObservable: Observable<SceneOptimizer>;
  66439. /**
  66440. * Gets a boolean indicating if the optimizer is in improvement mode
  66441. */
  66442. get isInImprovementMode(): boolean;
  66443. /**
  66444. * Gets the current priority level (0 at start)
  66445. */
  66446. get currentPriorityLevel(): number;
  66447. /**
  66448. * Gets the current frame rate checked by the SceneOptimizer
  66449. */
  66450. get currentFrameRate(): number;
  66451. /**
  66452. * Gets or sets the current target frame rate (60 by default)
  66453. */
  66454. get targetFrameRate(): number;
  66455. /**
  66456. * Gets or sets the current target frame rate (60 by default)
  66457. */
  66458. set targetFrameRate(value: number);
  66459. /**
  66460. * Gets or sets the current interval between two checks (every 2000ms by default)
  66461. */
  66462. get trackerDuration(): number;
  66463. /**
  66464. * Gets or sets the current interval between two checks (every 2000ms by default)
  66465. */
  66466. set trackerDuration(value: number);
  66467. /**
  66468. * Gets the list of active optimizations
  66469. */
  66470. get optimizations(): SceneOptimization[];
  66471. /**
  66472. * Creates a new SceneOptimizer
  66473. * @param scene defines the scene to work on
  66474. * @param options defines the options to use with the SceneOptimizer
  66475. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66476. * @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)
  66477. */
  66478. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66479. /**
  66480. * Stops the current optimizer
  66481. */
  66482. stop(): void;
  66483. /**
  66484. * Reset the optimizer to initial step (current priority level = 0)
  66485. */
  66486. reset(): void;
  66487. /**
  66488. * Start the optimizer. By default it will try to reach a specific framerate
  66489. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66490. */
  66491. start(): void;
  66492. private _checkCurrentState;
  66493. /**
  66494. * Release all resources
  66495. */
  66496. dispose(): void;
  66497. /**
  66498. * Helper function to create a SceneOptimizer with one single line of code
  66499. * @param scene defines the scene to work on
  66500. * @param options defines the options to use with the SceneOptimizer
  66501. * @param onSuccess defines a callback to call on success
  66502. * @param onFailure defines a callback to call on failure
  66503. * @returns the new SceneOptimizer object
  66504. */
  66505. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66506. }
  66507. }
  66508. declare module BABYLON {
  66509. /**
  66510. * Class used to serialize a scene into a string
  66511. */
  66512. export class SceneSerializer {
  66513. /**
  66514. * Clear cache used by a previous serialization
  66515. */
  66516. static ClearCache(): void;
  66517. /**
  66518. * Serialize a scene into a JSON compatible object
  66519. * @param scene defines the scene to serialize
  66520. * @returns a JSON compatible object
  66521. */
  66522. static Serialize(scene: Scene): any;
  66523. /**
  66524. * Serialize a mesh into a JSON compatible object
  66525. * @param toSerialize defines the mesh to serialize
  66526. * @param withParents defines if parents must be serialized as well
  66527. * @param withChildren defines if children must be serialized as well
  66528. * @returns a JSON compatible object
  66529. */
  66530. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66531. }
  66532. }
  66533. declare module BABYLON {
  66534. /**
  66535. * Class used to host texture specific utilities
  66536. */
  66537. export class TextureTools {
  66538. /**
  66539. * Uses the GPU to create a copy texture rescaled at a given size
  66540. * @param texture Texture to copy from
  66541. * @param width defines the desired width
  66542. * @param height defines the desired height
  66543. * @param useBilinearMode defines if bilinear mode has to be used
  66544. * @return the generated texture
  66545. */
  66546. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66547. }
  66548. }
  66549. declare module BABYLON {
  66550. /**
  66551. * This represents the different options available for the video capture.
  66552. */
  66553. export interface VideoRecorderOptions {
  66554. /** Defines the mime type of the video. */
  66555. mimeType: string;
  66556. /** Defines the FPS the video should be recorded at. */
  66557. fps: number;
  66558. /** Defines the chunk size for the recording data. */
  66559. recordChunckSize: number;
  66560. /** The audio tracks to attach to the recording. */
  66561. audioTracks?: MediaStreamTrack[];
  66562. }
  66563. /**
  66564. * This can help with recording videos from BabylonJS.
  66565. * This is based on the available WebRTC functionalities of the browser.
  66566. *
  66567. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66568. */
  66569. export class VideoRecorder {
  66570. private static readonly _defaultOptions;
  66571. /**
  66572. * Returns whether or not the VideoRecorder is available in your browser.
  66573. * @param engine Defines the Babylon Engine.
  66574. * @returns true if supported otherwise false.
  66575. */
  66576. static IsSupported(engine: Engine): boolean;
  66577. private readonly _options;
  66578. private _canvas;
  66579. private _mediaRecorder;
  66580. private _recordedChunks;
  66581. private _fileName;
  66582. private _resolve;
  66583. private _reject;
  66584. /**
  66585. * True when a recording is already in progress.
  66586. */
  66587. get isRecording(): boolean;
  66588. /**
  66589. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66590. * @param engine Defines the BabylonJS Engine you wish to record.
  66591. * @param options Defines options that can be used to customize the capture.
  66592. */
  66593. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66594. /**
  66595. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66596. */
  66597. stopRecording(): void;
  66598. /**
  66599. * Starts recording the canvas for a max duration specified in parameters.
  66600. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66601. * If null no automatic download will start and you can rely on the promise to get the data back.
  66602. * @param maxDuration Defines the maximum recording time in seconds.
  66603. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66604. * @return A promise callback at the end of the recording with the video data in Blob.
  66605. */
  66606. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66607. /**
  66608. * Releases internal resources used during the recording.
  66609. */
  66610. dispose(): void;
  66611. private _handleDataAvailable;
  66612. private _handleError;
  66613. private _handleStop;
  66614. }
  66615. }
  66616. declare module BABYLON {
  66617. /**
  66618. * Class containing a set of static utilities functions for screenshots
  66619. */
  66620. export class ScreenshotTools {
  66621. /**
  66622. * Captures a screenshot of the current rendering
  66623. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66624. * @param engine defines the rendering engine
  66625. * @param camera defines the source camera
  66626. * @param size This parameter can be set to a single number or to an object with the
  66627. * following (optional) properties: precision, width, height. If a single number is passed,
  66628. * it will be used for both width and height. If an object is passed, the screenshot size
  66629. * will be derived from the parameters. The precision property is a multiplier allowing
  66630. * rendering at a higher or lower resolution
  66631. * @param successCallback defines the callback receives a single parameter which contains the
  66632. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66633. * src parameter of an <img> to display it
  66634. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66635. * Check your browser for supported MIME types
  66636. */
  66637. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66638. /**
  66639. * Captures a screenshot of the current rendering
  66640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66641. * @param engine defines the rendering engine
  66642. * @param camera defines the source camera
  66643. * @param size This parameter can be set to a single number or to an object with the
  66644. * following (optional) properties: precision, width, height. If a single number is passed,
  66645. * it will be used for both width and height. If an object is passed, the screenshot size
  66646. * will be derived from the parameters. The precision property is a multiplier allowing
  66647. * rendering at a higher or lower resolution
  66648. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66649. * Check your browser for supported MIME types
  66650. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66651. * to the src parameter of an <img> to display it
  66652. */
  66653. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66654. /**
  66655. * Generates an image screenshot from the specified camera.
  66656. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66657. * @param engine The engine to use for rendering
  66658. * @param camera The camera to use for rendering
  66659. * @param size This parameter can be set to a single number or to an object with the
  66660. * following (optional) properties: precision, width, height. If a single number is passed,
  66661. * it will be used for both width and height. If an object is passed, the screenshot size
  66662. * will be derived from the parameters. The precision property is a multiplier allowing
  66663. * rendering at a higher or lower resolution
  66664. * @param successCallback The callback receives a single parameter which contains the
  66665. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66666. * src parameter of an <img> to display it
  66667. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66668. * Check your browser for supported MIME types
  66669. * @param samples Texture samples (default: 1)
  66670. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66671. * @param fileName A name for for the downloaded file.
  66672. */
  66673. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66674. /**
  66675. * Generates an image screenshot from the specified camera.
  66676. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66677. * @param engine The engine to use for rendering
  66678. * @param camera The camera to use for rendering
  66679. * @param size This parameter can be set to a single number or to an object with the
  66680. * following (optional) properties: precision, width, height. If a single number is passed,
  66681. * it will be used for both width and height. If an object is passed, the screenshot size
  66682. * will be derived from the parameters. The precision property is a multiplier allowing
  66683. * rendering at a higher or lower resolution
  66684. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66685. * Check your browser for supported MIME types
  66686. * @param samples Texture samples (default: 1)
  66687. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66688. * @param fileName A name for for the downloaded file.
  66689. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66690. * to the src parameter of an <img> to display it
  66691. */
  66692. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66693. /**
  66694. * Gets height and width for screenshot size
  66695. * @private
  66696. */
  66697. private static _getScreenshotSize;
  66698. }
  66699. }
  66700. declare module BABYLON {
  66701. /**
  66702. * Interface for a data buffer
  66703. */
  66704. export interface IDataBuffer {
  66705. /**
  66706. * Reads bytes from the data buffer.
  66707. * @param byteOffset The byte offset to read
  66708. * @param byteLength The byte length to read
  66709. * @returns A promise that resolves when the bytes are read
  66710. */
  66711. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66712. /**
  66713. * The byte length of the buffer.
  66714. */
  66715. readonly byteLength: number;
  66716. }
  66717. /**
  66718. * Utility class for reading from a data buffer
  66719. */
  66720. export class DataReader {
  66721. /**
  66722. * The data buffer associated with this data reader.
  66723. */
  66724. readonly buffer: IDataBuffer;
  66725. /**
  66726. * The current byte offset from the beginning of the data buffer.
  66727. */
  66728. byteOffset: number;
  66729. private _dataView;
  66730. private _dataByteOffset;
  66731. /**
  66732. * Constructor
  66733. * @param buffer The buffer to read
  66734. */
  66735. constructor(buffer: IDataBuffer);
  66736. /**
  66737. * Loads the given byte length.
  66738. * @param byteLength The byte length to load
  66739. * @returns A promise that resolves when the load is complete
  66740. */
  66741. loadAsync(byteLength: number): Promise<void>;
  66742. /**
  66743. * Read a unsigned 32-bit integer from the currently loaded data range.
  66744. * @returns The 32-bit integer read
  66745. */
  66746. readUint32(): number;
  66747. /**
  66748. * Read a byte array from the currently loaded data range.
  66749. * @param byteLength The byte length to read
  66750. * @returns The byte array read
  66751. */
  66752. readUint8Array(byteLength: number): Uint8Array;
  66753. /**
  66754. * Read a string from the currently loaded data range.
  66755. * @param byteLength The byte length to read
  66756. * @returns The string read
  66757. */
  66758. readString(byteLength: number): string;
  66759. /**
  66760. * Skips the given byte length the currently loaded data range.
  66761. * @param byteLength The byte length to skip
  66762. */
  66763. skipBytes(byteLength: number): void;
  66764. }
  66765. }
  66766. declare module BABYLON {
  66767. /**
  66768. * A cursor which tracks a point on a path
  66769. */
  66770. export class PathCursor {
  66771. private path;
  66772. /**
  66773. * Stores path cursor callbacks for when an onchange event is triggered
  66774. */
  66775. private _onchange;
  66776. /**
  66777. * The value of the path cursor
  66778. */
  66779. value: number;
  66780. /**
  66781. * The animation array of the path cursor
  66782. */
  66783. animations: Animation[];
  66784. /**
  66785. * Initializes the path cursor
  66786. * @param path The path to track
  66787. */
  66788. constructor(path: Path2);
  66789. /**
  66790. * Gets the cursor point on the path
  66791. * @returns A point on the path cursor at the cursor location
  66792. */
  66793. getPoint(): Vector3;
  66794. /**
  66795. * Moves the cursor ahead by the step amount
  66796. * @param step The amount to move the cursor forward
  66797. * @returns This path cursor
  66798. */
  66799. moveAhead(step?: number): PathCursor;
  66800. /**
  66801. * Moves the cursor behind by the step amount
  66802. * @param step The amount to move the cursor back
  66803. * @returns This path cursor
  66804. */
  66805. moveBack(step?: number): PathCursor;
  66806. /**
  66807. * Moves the cursor by the step amount
  66808. * If the step amount is greater than one, an exception is thrown
  66809. * @param step The amount to move the cursor
  66810. * @returns This path cursor
  66811. */
  66812. move(step: number): PathCursor;
  66813. /**
  66814. * Ensures that the value is limited between zero and one
  66815. * @returns This path cursor
  66816. */
  66817. private ensureLimits;
  66818. /**
  66819. * Runs onchange callbacks on change (used by the animation engine)
  66820. * @returns This path cursor
  66821. */
  66822. private raiseOnChange;
  66823. /**
  66824. * Executes a function on change
  66825. * @param f A path cursor onchange callback
  66826. * @returns This path cursor
  66827. */
  66828. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66829. }
  66830. }
  66831. declare module BABYLON {
  66832. /** @hidden */
  66833. export var blurPixelShader: {
  66834. name: string;
  66835. shader: string;
  66836. };
  66837. }
  66838. declare module BABYLON {
  66839. /** @hidden */
  66840. export var pointCloudVertexDeclaration: {
  66841. name: string;
  66842. shader: string;
  66843. };
  66844. }
  66845. // Mixins
  66846. interface Window {
  66847. mozIndexedDB: IDBFactory;
  66848. webkitIndexedDB: IDBFactory;
  66849. msIndexedDB: IDBFactory;
  66850. webkitURL: typeof URL;
  66851. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66852. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66853. WebGLRenderingContext: WebGLRenderingContext;
  66854. MSGesture: MSGesture;
  66855. CANNON: any;
  66856. AudioContext: AudioContext;
  66857. webkitAudioContext: AudioContext;
  66858. PointerEvent: any;
  66859. Math: Math;
  66860. Uint8Array: Uint8ArrayConstructor;
  66861. Float32Array: Float32ArrayConstructor;
  66862. mozURL: typeof URL;
  66863. msURL: typeof URL;
  66864. VRFrameData: any; // WebVR, from specs 1.1
  66865. DracoDecoderModule: any;
  66866. setImmediate(handler: (...args: any[]) => void): number;
  66867. }
  66868. interface HTMLCanvasElement {
  66869. requestPointerLock(): void;
  66870. msRequestPointerLock?(): void;
  66871. mozRequestPointerLock?(): void;
  66872. webkitRequestPointerLock?(): void;
  66873. /** Track wether a record is in progress */
  66874. isRecording: boolean;
  66875. /** Capture Stream method defined by some browsers */
  66876. captureStream(fps?: number): MediaStream;
  66877. }
  66878. interface CanvasRenderingContext2D {
  66879. msImageSmoothingEnabled: boolean;
  66880. }
  66881. interface MouseEvent {
  66882. mozMovementX: number;
  66883. mozMovementY: number;
  66884. webkitMovementX: number;
  66885. webkitMovementY: number;
  66886. msMovementX: number;
  66887. msMovementY: number;
  66888. }
  66889. interface Navigator {
  66890. mozGetVRDevices: (any: any) => any;
  66891. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66892. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66893. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66894. webkitGetGamepads(): Gamepad[];
  66895. msGetGamepads(): Gamepad[];
  66896. webkitGamepads(): Gamepad[];
  66897. }
  66898. interface HTMLVideoElement {
  66899. mozSrcObject: any;
  66900. }
  66901. interface Math {
  66902. fround(x: number): number;
  66903. imul(a: number, b: number): number;
  66904. }
  66905. interface WebGLRenderingContext {
  66906. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  66907. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  66908. vertexAttribDivisor(index: number, divisor: number): void;
  66909. createVertexArray(): any;
  66910. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  66911. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  66912. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  66913. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  66914. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  66915. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  66916. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  66917. // Queries
  66918. createQuery(): WebGLQuery;
  66919. deleteQuery(query: WebGLQuery): void;
  66920. beginQuery(target: number, query: WebGLQuery): void;
  66921. endQuery(target: number): void;
  66922. getQueryParameter(query: WebGLQuery, pname: number): any;
  66923. getQuery(target: number, pname: number): any;
  66924. MAX_SAMPLES: number;
  66925. RGBA8: number;
  66926. READ_FRAMEBUFFER: number;
  66927. DRAW_FRAMEBUFFER: number;
  66928. UNIFORM_BUFFER: number;
  66929. HALF_FLOAT_OES: number;
  66930. RGBA16F: number;
  66931. RGBA32F: number;
  66932. R32F: number;
  66933. RG32F: number;
  66934. RGB32F: number;
  66935. R16F: number;
  66936. RG16F: number;
  66937. RGB16F: number;
  66938. RED: number;
  66939. RG: number;
  66940. R8: number;
  66941. RG8: number;
  66942. UNSIGNED_INT_24_8: number;
  66943. DEPTH24_STENCIL8: number;
  66944. MIN: number;
  66945. MAX: number;
  66946. /* Multiple Render Targets */
  66947. drawBuffers(buffers: number[]): void;
  66948. readBuffer(src: number): void;
  66949. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  66950. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  66951. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  66952. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  66953. // Occlusion Query
  66954. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  66955. ANY_SAMPLES_PASSED: number;
  66956. QUERY_RESULT_AVAILABLE: number;
  66957. QUERY_RESULT: number;
  66958. }
  66959. interface WebGLProgram {
  66960. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  66961. }
  66962. interface EXT_disjoint_timer_query {
  66963. QUERY_COUNTER_BITS_EXT: number;
  66964. TIME_ELAPSED_EXT: number;
  66965. TIMESTAMP_EXT: number;
  66966. GPU_DISJOINT_EXT: number;
  66967. QUERY_RESULT_EXT: number;
  66968. QUERY_RESULT_AVAILABLE_EXT: number;
  66969. queryCounterEXT(query: WebGLQuery, target: number): void;
  66970. createQueryEXT(): WebGLQuery;
  66971. beginQueryEXT(target: number, query: WebGLQuery): void;
  66972. endQueryEXT(target: number): void;
  66973. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  66974. deleteQueryEXT(query: WebGLQuery): void;
  66975. }
  66976. interface WebGLUniformLocation {
  66977. _currentState: any;
  66978. }
  66979. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  66980. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  66981. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  66982. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  66983. interface WebGLRenderingContext {
  66984. readonly RASTERIZER_DISCARD: number;
  66985. readonly DEPTH_COMPONENT24: number;
  66986. readonly TEXTURE_3D: number;
  66987. readonly TEXTURE_2D_ARRAY: number;
  66988. readonly TEXTURE_COMPARE_FUNC: number;
  66989. readonly TEXTURE_COMPARE_MODE: number;
  66990. readonly COMPARE_REF_TO_TEXTURE: number;
  66991. readonly TEXTURE_WRAP_R: number;
  66992. readonly HALF_FLOAT: number;
  66993. readonly RGB8: number;
  66994. readonly RED_INTEGER: number;
  66995. readonly RG_INTEGER: number;
  66996. readonly RGB_INTEGER: number;
  66997. readonly RGBA_INTEGER: number;
  66998. readonly R8_SNORM: number;
  66999. readonly RG8_SNORM: number;
  67000. readonly RGB8_SNORM: number;
  67001. readonly RGBA8_SNORM: number;
  67002. readonly R8I: number;
  67003. readonly RG8I: number;
  67004. readonly RGB8I: number;
  67005. readonly RGBA8I: number;
  67006. readonly R8UI: number;
  67007. readonly RG8UI: number;
  67008. readonly RGB8UI: number;
  67009. readonly RGBA8UI: number;
  67010. readonly R16I: number;
  67011. readonly RG16I: number;
  67012. readonly RGB16I: number;
  67013. readonly RGBA16I: number;
  67014. readonly R16UI: number;
  67015. readonly RG16UI: number;
  67016. readonly RGB16UI: number;
  67017. readonly RGBA16UI: number;
  67018. readonly R32I: number;
  67019. readonly RG32I: number;
  67020. readonly RGB32I: number;
  67021. readonly RGBA32I: number;
  67022. readonly R32UI: number;
  67023. readonly RG32UI: number;
  67024. readonly RGB32UI: number;
  67025. readonly RGBA32UI: number;
  67026. readonly RGB10_A2UI: number;
  67027. readonly R11F_G11F_B10F: number;
  67028. readonly RGB9_E5: number;
  67029. readonly RGB10_A2: number;
  67030. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  67031. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  67032. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  67033. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67034. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  67035. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  67036. 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;
  67037. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  67038. readonly TRANSFORM_FEEDBACK: number;
  67039. readonly INTERLEAVED_ATTRIBS: number;
  67040. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  67041. createTransformFeedback(): WebGLTransformFeedback;
  67042. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  67043. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  67044. beginTransformFeedback(primitiveMode: number): void;
  67045. endTransformFeedback(): void;
  67046. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  67047. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67048. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67049. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67050. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  67051. }
  67052. interface ImageBitmap {
  67053. readonly width: number;
  67054. readonly height: number;
  67055. close(): void;
  67056. }
  67057. interface WebGLQuery extends WebGLObject {
  67058. }
  67059. declare var WebGLQuery: {
  67060. prototype: WebGLQuery;
  67061. new(): WebGLQuery;
  67062. };
  67063. interface WebGLSampler extends WebGLObject {
  67064. }
  67065. declare var WebGLSampler: {
  67066. prototype: WebGLSampler;
  67067. new(): WebGLSampler;
  67068. };
  67069. interface WebGLSync extends WebGLObject {
  67070. }
  67071. declare var WebGLSync: {
  67072. prototype: WebGLSync;
  67073. new(): WebGLSync;
  67074. };
  67075. interface WebGLTransformFeedback extends WebGLObject {
  67076. }
  67077. declare var WebGLTransformFeedback: {
  67078. prototype: WebGLTransformFeedback;
  67079. new(): WebGLTransformFeedback;
  67080. };
  67081. interface WebGLVertexArrayObject extends WebGLObject {
  67082. }
  67083. declare var WebGLVertexArrayObject: {
  67084. prototype: WebGLVertexArrayObject;
  67085. new(): WebGLVertexArrayObject;
  67086. };
  67087. // Type definitions for WebVR API
  67088. // Project: https://w3c.github.io/webvr/
  67089. // Definitions by: six a <https://github.com/lostfictions>
  67090. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67091. interface VRDisplay extends EventTarget {
  67092. /**
  67093. * Dictionary of capabilities describing the VRDisplay.
  67094. */
  67095. readonly capabilities: VRDisplayCapabilities;
  67096. /**
  67097. * z-depth defining the far plane of the eye view frustum
  67098. * enables mapping of values in the render target depth
  67099. * attachment to scene coordinates. Initially set to 10000.0.
  67100. */
  67101. depthFar: number;
  67102. /**
  67103. * z-depth defining the near plane of the eye view frustum
  67104. * enables mapping of values in the render target depth
  67105. * attachment to scene coordinates. Initially set to 0.01.
  67106. */
  67107. depthNear: number;
  67108. /**
  67109. * An identifier for this distinct VRDisplay. Used as an
  67110. * association point in the Gamepad API.
  67111. */
  67112. readonly displayId: number;
  67113. /**
  67114. * A display name, a user-readable name identifying it.
  67115. */
  67116. readonly displayName: string;
  67117. readonly isConnected: boolean;
  67118. readonly isPresenting: boolean;
  67119. /**
  67120. * If this VRDisplay supports room-scale experiences, the optional
  67121. * stage attribute contains details on the room-scale parameters.
  67122. */
  67123. readonly stageParameters: VRStageParameters | null;
  67124. /**
  67125. * Passing the value returned by `requestAnimationFrame` to
  67126. * `cancelAnimationFrame` will unregister the callback.
  67127. * @param handle Define the hanle of the request to cancel
  67128. */
  67129. cancelAnimationFrame(handle: number): void;
  67130. /**
  67131. * Stops presenting to the VRDisplay.
  67132. * @returns a promise to know when it stopped
  67133. */
  67134. exitPresent(): Promise<void>;
  67135. /**
  67136. * Return the current VREyeParameters for the given eye.
  67137. * @param whichEye Define the eye we want the parameter for
  67138. * @returns the eye parameters
  67139. */
  67140. getEyeParameters(whichEye: string): VREyeParameters;
  67141. /**
  67142. * Populates the passed VRFrameData with the information required to render
  67143. * the current frame.
  67144. * @param frameData Define the data structure to populate
  67145. * @returns true if ok otherwise false
  67146. */
  67147. getFrameData(frameData: VRFrameData): boolean;
  67148. /**
  67149. * Get the layers currently being presented.
  67150. * @returns the list of VR layers
  67151. */
  67152. getLayers(): VRLayer[];
  67153. /**
  67154. * Return a VRPose containing the future predicted pose of the VRDisplay
  67155. * when the current frame will be presented. The value returned will not
  67156. * change until JavaScript has returned control to the browser.
  67157. *
  67158. * The VRPose will contain the position, orientation, velocity,
  67159. * and acceleration of each of these properties.
  67160. * @returns the pose object
  67161. */
  67162. getPose(): VRPose;
  67163. /**
  67164. * Return the current instantaneous pose of the VRDisplay, with no
  67165. * prediction applied.
  67166. * @returns the current instantaneous pose
  67167. */
  67168. getImmediatePose(): VRPose;
  67169. /**
  67170. * The callback passed to `requestAnimationFrame` will be called
  67171. * any time a new frame should be rendered. When the VRDisplay is
  67172. * presenting the callback will be called at the native refresh
  67173. * rate of the HMD. When not presenting this function acts
  67174. * identically to how window.requestAnimationFrame acts. Content should
  67175. * make no assumptions of frame rate or vsync behavior as the HMD runs
  67176. * asynchronously from other displays and at differing refresh rates.
  67177. * @param callback Define the eaction to run next frame
  67178. * @returns the request handle it
  67179. */
  67180. requestAnimationFrame(callback: FrameRequestCallback): number;
  67181. /**
  67182. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  67183. * Repeat calls while already presenting will update the VRLayers being displayed.
  67184. * @param layers Define the list of layer to present
  67185. * @returns a promise to know when the request has been fulfilled
  67186. */
  67187. requestPresent(layers: VRLayer[]): Promise<void>;
  67188. /**
  67189. * Reset the pose for this display, treating its current position and
  67190. * orientation as the "origin/zero" values. VRPose.position,
  67191. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  67192. * updated when calling resetPose(). This should be called in only
  67193. * sitting-space experiences.
  67194. */
  67195. resetPose(): void;
  67196. /**
  67197. * The VRLayer provided to the VRDisplay will be captured and presented
  67198. * in the HMD. Calling this function has the same effect on the source
  67199. * canvas as any other operation that uses its source image, and canvases
  67200. * created without preserveDrawingBuffer set to true will be cleared.
  67201. * @param pose Define the pose to submit
  67202. */
  67203. submitFrame(pose?: VRPose): void;
  67204. }
  67205. declare var VRDisplay: {
  67206. prototype: VRDisplay;
  67207. new(): VRDisplay;
  67208. };
  67209. interface VRLayer {
  67210. leftBounds?: number[] | Float32Array | null;
  67211. rightBounds?: number[] | Float32Array | null;
  67212. source?: HTMLCanvasElement | null;
  67213. }
  67214. interface VRDisplayCapabilities {
  67215. readonly canPresent: boolean;
  67216. readonly hasExternalDisplay: boolean;
  67217. readonly hasOrientation: boolean;
  67218. readonly hasPosition: boolean;
  67219. readonly maxLayers: number;
  67220. }
  67221. interface VREyeParameters {
  67222. /** @deprecated */
  67223. readonly fieldOfView: VRFieldOfView;
  67224. readonly offset: Float32Array;
  67225. readonly renderHeight: number;
  67226. readonly renderWidth: number;
  67227. }
  67228. interface VRFieldOfView {
  67229. readonly downDegrees: number;
  67230. readonly leftDegrees: number;
  67231. readonly rightDegrees: number;
  67232. readonly upDegrees: number;
  67233. }
  67234. interface VRFrameData {
  67235. readonly leftProjectionMatrix: Float32Array;
  67236. readonly leftViewMatrix: Float32Array;
  67237. readonly pose: VRPose;
  67238. readonly rightProjectionMatrix: Float32Array;
  67239. readonly rightViewMatrix: Float32Array;
  67240. readonly timestamp: number;
  67241. }
  67242. interface VRPose {
  67243. readonly angularAcceleration: Float32Array | null;
  67244. readonly angularVelocity: Float32Array | null;
  67245. readonly linearAcceleration: Float32Array | null;
  67246. readonly linearVelocity: Float32Array | null;
  67247. readonly orientation: Float32Array | null;
  67248. readonly position: Float32Array | null;
  67249. readonly timestamp: number;
  67250. }
  67251. interface VRStageParameters {
  67252. sittingToStandingTransform?: Float32Array;
  67253. sizeX?: number;
  67254. sizeY?: number;
  67255. }
  67256. interface Navigator {
  67257. getVRDisplays(): Promise<VRDisplay[]>;
  67258. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  67259. }
  67260. interface Window {
  67261. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  67262. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  67263. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  67264. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67265. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  67266. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  67267. }
  67268. interface Gamepad {
  67269. readonly displayId: number;
  67270. }
  67271. type XRSessionMode =
  67272. | "inline"
  67273. | "immersive-vr"
  67274. | "immersive-ar";
  67275. type XRReferenceSpaceType =
  67276. | "viewer"
  67277. | "local"
  67278. | "local-floor"
  67279. | "bounded-floor"
  67280. | "unbounded";
  67281. type XREnvironmentBlendMode =
  67282. | "opaque"
  67283. | "additive"
  67284. | "alpha-blend";
  67285. type XRVisibilityState =
  67286. | "visible"
  67287. | "visible-blurred"
  67288. | "hidden";
  67289. type XRHandedness =
  67290. | "none"
  67291. | "left"
  67292. | "right";
  67293. type XRTargetRayMode =
  67294. | "gaze"
  67295. | "tracked-pointer"
  67296. | "screen";
  67297. type XREye =
  67298. | "none"
  67299. | "left"
  67300. | "right";
  67301. interface XRSpace extends EventTarget {
  67302. }
  67303. interface XRRenderState {
  67304. depthNear?: number;
  67305. depthFar?: number;
  67306. inlineVerticalFieldOfView?: number;
  67307. baseLayer?: XRWebGLLayer;
  67308. }
  67309. interface XRInputSource {
  67310. handedness: XRHandedness;
  67311. targetRayMode: XRTargetRayMode;
  67312. targetRaySpace: XRSpace;
  67313. gripSpace: XRSpace | undefined;
  67314. gamepad: Gamepad | undefined;
  67315. profiles: Array<string>;
  67316. }
  67317. interface XRSession extends XRAnchorCreator {
  67318. addEventListener: Function;
  67319. removeEventListener: Function;
  67320. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  67321. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  67322. requestAnimationFrame: Function;
  67323. end(): Promise<void>;
  67324. renderState: XRRenderState;
  67325. inputSources: Array<XRInputSource>;
  67326. // AR hit test
  67327. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  67328. updateWorldTrackingState(options: {
  67329. planeDetectionState?: { enabled: boolean; }
  67330. }): void;
  67331. }
  67332. interface XRReferenceSpace extends XRSpace {
  67333. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  67334. onreset: any;
  67335. }
  67336. type XRPlaneSet = Set<XRPlane>;
  67337. type XRAnchorSet = Set<XRAnchor>;
  67338. interface XRFrame {
  67339. session: XRSession;
  67340. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  67341. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  67342. // Anchors
  67343. trackedAnchors?: XRAnchorSet;
  67344. // Planes
  67345. worldInformation: {
  67346. detectedPlanes?: XRPlaneSet;
  67347. };
  67348. }
  67349. interface XRViewerPose extends XRPose {
  67350. views: Array<XRView>;
  67351. }
  67352. interface XRPose {
  67353. transform: XRRigidTransform;
  67354. emulatedPosition: boolean;
  67355. }
  67356. interface XRWebGLLayerOptions {
  67357. antialias?: boolean;
  67358. depth?: boolean;
  67359. stencil?: boolean;
  67360. alpha?: boolean;
  67361. multiview?: boolean;
  67362. framebufferScaleFactor?: number;
  67363. }
  67364. declare var XRWebGLLayer: {
  67365. prototype: XRWebGLLayer;
  67366. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  67367. };
  67368. interface XRWebGLLayer {
  67369. framebuffer: WebGLFramebuffer;
  67370. framebufferWidth: number;
  67371. framebufferHeight: number;
  67372. getViewport: Function;
  67373. }
  67374. declare class XRRigidTransform {
  67375. constructor(matrix: Float32Array);
  67376. position: DOMPointReadOnly;
  67377. orientation: DOMPointReadOnly;
  67378. matrix: Float32Array;
  67379. inverse: XRRigidTransform;
  67380. }
  67381. interface XRView {
  67382. eye: XREye;
  67383. projectionMatrix: Float32Array;
  67384. transform: XRRigidTransform;
  67385. }
  67386. interface XRInputSourceChangeEvent {
  67387. session: XRSession;
  67388. removed: Array<XRInputSource>;
  67389. added: Array<XRInputSource>;
  67390. }
  67391. interface XRInputSourceEvent extends Event {
  67392. readonly frame: XRFrame;
  67393. readonly inputSource: XRInputSource;
  67394. }
  67395. // Experimental(er) features
  67396. declare class XRRay {
  67397. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  67398. origin: DOMPointReadOnly;
  67399. direction: DOMPointReadOnly;
  67400. matrix: Float32Array;
  67401. }
  67402. interface XRHitResult {
  67403. hitMatrix: Float32Array;
  67404. }
  67405. interface XRAnchor {
  67406. // remove?
  67407. id?: string;
  67408. anchorSpace: XRSpace;
  67409. lastChangedTime: number;
  67410. detach(): void;
  67411. }
  67412. interface XRPlane extends XRAnchorCreator {
  67413. orientation: "Horizontal" | "Vertical";
  67414. planeSpace: XRSpace;
  67415. polygon: Array<DOMPointReadOnly>;
  67416. lastChangedTime: number;
  67417. }
  67418. interface XRAnchorCreator {
  67419. // AR Anchors
  67420. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  67421. }