babylon.d.ts 2.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Scalar computation library
  496. */
  497. export class Scalar {
  498. /**
  499. * Two pi constants convenient for computation.
  500. */
  501. static TwoPi: number;
  502. /**
  503. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  504. * @param a number
  505. * @param b number
  506. * @param epsilon (default = 1.401298E-45)
  507. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  508. */
  509. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  510. /**
  511. * Returns a string : the upper case translation of the number i to hexadecimal.
  512. * @param i number
  513. * @returns the upper case translation of the number i to hexadecimal.
  514. */
  515. static ToHex(i: number): string;
  516. /**
  517. * Returns -1 if value is negative and +1 is value is positive.
  518. * @param value the value
  519. * @returns the value itself if it's equal to zero.
  520. */
  521. static Sign(value: number): number;
  522. /**
  523. * Returns the value itself if it's between min and max.
  524. * Returns min if the value is lower than min.
  525. * Returns max if the value is greater than max.
  526. * @param value the value to clmap
  527. * @param min the min value to clamp to (default: 0)
  528. * @param max the max value to clamp to (default: 1)
  529. * @returns the clamped value
  530. */
  531. static Clamp(value: number, min?: number, max?: number): number;
  532. /**
  533. * the log2 of value.
  534. * @param value the value to compute log2 of
  535. * @returns the log2 of value.
  536. */
  537. static Log2(value: number): number;
  538. /**
  539. * Loops the value, so that it is never larger than length and never smaller than 0.
  540. *
  541. * This is similar to the modulo operator but it works with floating point numbers.
  542. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  543. * With t = 5 and length = 2.5, the result would be 0.0.
  544. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  545. * @param value the value
  546. * @param length the length
  547. * @returns the looped value
  548. */
  549. static Repeat(value: number, length: number): number;
  550. /**
  551. * Normalize the value between 0.0 and 1.0 using min and max values
  552. * @param value value to normalize
  553. * @param min max to normalize between
  554. * @param max min to normalize between
  555. * @returns the normalized value
  556. */
  557. static Normalize(value: number, min: number, max: number): number;
  558. /**
  559. * Denormalize the value from 0.0 and 1.0 using min and max values
  560. * @param normalized value to denormalize
  561. * @param min max to denormalize between
  562. * @param max min to denormalize between
  563. * @returns the denormalized value
  564. */
  565. static Denormalize(normalized: number, min: number, max: number): number;
  566. /**
  567. * Calculates the shortest difference between two given angles given in degrees.
  568. * @param current current angle in degrees
  569. * @param target target angle in degrees
  570. * @returns the delta
  571. */
  572. static DeltaAngle(current: number, target: number): number;
  573. /**
  574. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  575. * @param tx value
  576. * @param length length
  577. * @returns The returned value will move back and forth between 0 and length
  578. */
  579. static PingPong(tx: number, length: number): number;
  580. /**
  581. * Interpolates between min and max with smoothing at the limits.
  582. *
  583. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  584. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  585. * @param from from
  586. * @param to to
  587. * @param tx value
  588. * @returns the smooth stepped value
  589. */
  590. static SmoothStep(from: number, to: number, tx: number): number;
  591. /**
  592. * Moves a value current towards target.
  593. *
  594. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  595. * Negative values of maxDelta pushes the value away from target.
  596. * @param current current value
  597. * @param target target value
  598. * @param maxDelta max distance to move
  599. * @returns resulting value
  600. */
  601. static MoveTowards(current: number, target: number, maxDelta: number): number;
  602. /**
  603. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  604. *
  605. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  606. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  607. * @param current current value
  608. * @param target target value
  609. * @param maxDelta max distance to move
  610. * @returns resulting angle
  611. */
  612. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  613. /**
  614. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  615. * @param start start value
  616. * @param end target value
  617. * @param amount amount to lerp between
  618. * @returns the lerped value
  619. */
  620. static Lerp(start: number, end: number, amount: number): number;
  621. /**
  622. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  623. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  624. * @param start start value
  625. * @param end target value
  626. * @param amount amount to lerp between
  627. * @returns the lerped value
  628. */
  629. static LerpAngle(start: number, end: number, amount: number): number;
  630. /**
  631. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  632. * @param a start value
  633. * @param b target value
  634. * @param value value between a and b
  635. * @returns the inverseLerp value
  636. */
  637. static InverseLerp(a: number, b: number, value: number): number;
  638. /**
  639. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  640. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  641. * @param value1 spline value
  642. * @param tangent1 spline value
  643. * @param value2 spline value
  644. * @param tangent2 spline value
  645. * @param amount input value
  646. * @returns hermite result
  647. */
  648. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  649. /**
  650. * Returns a random float number between and min and max values
  651. * @param min min value of random
  652. * @param max max value of random
  653. * @returns random value
  654. */
  655. static RandomRange(min: number, max: number): number;
  656. /**
  657. * This function returns percentage of a number in a given range.
  658. *
  659. * RangeToPercent(40,20,60) will return 0.5 (50%)
  660. * RangeToPercent(34,0,100) will return 0.34 (34%)
  661. * @param number to convert to percentage
  662. * @param min min range
  663. * @param max max range
  664. * @returns the percentage
  665. */
  666. static RangeToPercent(number: number, min: number, max: number): number;
  667. /**
  668. * This function returns number that corresponds to the percentage in a given range.
  669. *
  670. * PercentToRange(0.34,0,100) will return 34.
  671. * @param percent to convert to number
  672. * @param min min range
  673. * @param max max range
  674. * @returns the number
  675. */
  676. static PercentToRange(percent: number, min: number, max: number): number;
  677. /**
  678. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  679. * @param angle The angle to normalize in radian.
  680. * @return The converted angle.
  681. */
  682. static NormalizeRadians(angle: number): number;
  683. }
  684. }
  685. declare module BABYLON {
  686. /**
  687. * Constant used to convert a value to gamma space
  688. * @ignorenaming
  689. */
  690. export const ToGammaSpace: number;
  691. /**
  692. * Constant used to convert a value to linear space
  693. * @ignorenaming
  694. */
  695. export const ToLinearSpace = 2.2;
  696. /**
  697. * Constant used to define the minimal number value in Babylon.js
  698. * @ignorenaming
  699. */
  700. let Epsilon: number;
  701. }
  702. declare module BABYLON {
  703. /**
  704. * Class used to represent a viewport on screen
  705. */
  706. export class Viewport {
  707. /** viewport left coordinate */
  708. x: number;
  709. /** viewport top coordinate */
  710. y: number;
  711. /**viewport width */
  712. width: number;
  713. /** viewport height */
  714. height: number;
  715. /**
  716. * Creates a Viewport object located at (x, y) and sized (width, height)
  717. * @param x defines viewport left coordinate
  718. * @param y defines viewport top coordinate
  719. * @param width defines the viewport width
  720. * @param height defines the viewport height
  721. */
  722. constructor(
  723. /** viewport left coordinate */
  724. x: number,
  725. /** viewport top coordinate */
  726. y: number,
  727. /**viewport width */
  728. width: number,
  729. /** viewport height */
  730. height: number);
  731. /**
  732. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  733. * @param renderWidth defines the rendering width
  734. * @param renderHeight defines the rendering height
  735. * @returns a new Viewport
  736. */
  737. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  738. /**
  739. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  740. * @param renderWidth defines the rendering width
  741. * @param renderHeight defines the rendering height
  742. * @param ref defines the target viewport
  743. * @returns the current viewport
  744. */
  745. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  746. /**
  747. * Returns a new Viewport copied from the current one
  748. * @returns a new Viewport
  749. */
  750. clone(): Viewport;
  751. }
  752. }
  753. declare module BABYLON {
  754. /**
  755. * Class containing a set of static utilities functions for arrays.
  756. */
  757. export class ArrayTools {
  758. /**
  759. * Returns an array of the given size filled with element built from the given constructor and the paramters
  760. * @param size the number of element to construct and put in the array
  761. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  762. * @returns a new array filled with new objects
  763. */
  764. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  765. }
  766. }
  767. declare module BABYLON {
  768. /**
  769. * @hidden
  770. */
  771. export interface IColor4Like {
  772. r: float;
  773. g: float;
  774. b: float;
  775. a: float;
  776. }
  777. /**
  778. * @hidden
  779. */
  780. export interface IColor3Like {
  781. r: float;
  782. g: float;
  783. b: float;
  784. }
  785. /**
  786. * @hidden
  787. */
  788. export interface IVector4Like {
  789. x: float;
  790. y: float;
  791. z: float;
  792. w: float;
  793. }
  794. /**
  795. * @hidden
  796. */
  797. export interface IVector3Like {
  798. x: float;
  799. y: float;
  800. z: float;
  801. }
  802. /**
  803. * @hidden
  804. */
  805. export interface IVector2Like {
  806. x: float;
  807. y: float;
  808. }
  809. /**
  810. * @hidden
  811. */
  812. export interface IMatrixLike {
  813. toArray(): DeepImmutable<Float32Array>;
  814. updateFlag: int;
  815. }
  816. /**
  817. * @hidden
  818. */
  819. export interface IViewportLike {
  820. x: float;
  821. y: float;
  822. width: float;
  823. height: float;
  824. }
  825. /**
  826. * @hidden
  827. */
  828. export interface IPlaneLike {
  829. normal: IVector3Like;
  830. d: float;
  831. normalize(): void;
  832. }
  833. }
  834. declare module BABYLON {
  835. /**
  836. * Class representing a vector containing 2 coordinates
  837. */
  838. export class Vector2 {
  839. /** defines the first coordinate */
  840. x: number;
  841. /** defines the second coordinate */
  842. y: number;
  843. /**
  844. * Creates a new Vector2 from the given x and y coordinates
  845. * @param x defines the first coordinate
  846. * @param y defines the second coordinate
  847. */
  848. constructor(
  849. /** defines the first coordinate */
  850. x?: number,
  851. /** defines the second coordinate */
  852. y?: number);
  853. /**
  854. * Gets a string with the Vector2 coordinates
  855. * @returns a string with the Vector2 coordinates
  856. */
  857. toString(): string;
  858. /**
  859. * Gets class name
  860. * @returns the string "Vector2"
  861. */
  862. getClassName(): string;
  863. /**
  864. * Gets current vector hash code
  865. * @returns the Vector2 hash code as a number
  866. */
  867. getHashCode(): number;
  868. /**
  869. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  870. * @param array defines the source array
  871. * @param index defines the offset in source array
  872. * @returns the current Vector2
  873. */
  874. toArray(array: FloatArray, index?: number): Vector2;
  875. /**
  876. * Copy the current vector to an array
  877. * @returns a new array with 2 elements: the Vector2 coordinates.
  878. */
  879. asArray(): number[];
  880. /**
  881. * Sets the Vector2 coordinates with the given Vector2 coordinates
  882. * @param source defines the source Vector2
  883. * @returns the current updated Vector2
  884. */
  885. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  886. /**
  887. * Sets the Vector2 coordinates with the given floats
  888. * @param x defines the first coordinate
  889. * @param y defines the second coordinate
  890. * @returns the current updated Vector2
  891. */
  892. copyFromFloats(x: number, y: number): Vector2;
  893. /**
  894. * Sets the Vector2 coordinates with the given floats
  895. * @param x defines the first coordinate
  896. * @param y defines the second coordinate
  897. * @returns the current updated Vector2
  898. */
  899. set(x: number, y: number): Vector2;
  900. /**
  901. * Add another vector with the current one
  902. * @param otherVector defines the other vector
  903. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  904. */
  905. add(otherVector: DeepImmutable<Vector2>): Vector2;
  906. /**
  907. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  908. * @param otherVector defines the other vector
  909. * @param result defines the target vector
  910. * @returns the unmodified current Vector2
  911. */
  912. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  913. /**
  914. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  915. * @param otherVector defines the other vector
  916. * @returns the current updated Vector2
  917. */
  918. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  921. * @param otherVector defines the other vector
  922. * @returns a new Vector2
  923. */
  924. addVector3(otherVector: Vector3): Vector2;
  925. /**
  926. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  927. * @param otherVector defines the other vector
  928. * @returns a new Vector2
  929. */
  930. subtract(otherVector: Vector2): Vector2;
  931. /**
  932. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  933. * @param otherVector defines the other vector
  934. * @param result defines the target vector
  935. * @returns the unmodified current Vector2
  936. */
  937. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  938. /**
  939. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  940. * @param otherVector defines the other vector
  941. * @returns the current updated Vector2
  942. */
  943. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  944. /**
  945. * Multiplies in place the current Vector2 coordinates by the given ones
  946. * @param otherVector defines the other vector
  947. * @returns the current updated Vector2
  948. */
  949. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  950. /**
  951. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  952. * @param otherVector defines the other vector
  953. * @returns a new Vector2
  954. */
  955. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  956. /**
  957. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  958. * @param otherVector defines the other vector
  959. * @param result defines the target vector
  960. * @returns the unmodified current Vector2
  961. */
  962. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  963. /**
  964. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  965. * @param x defines the first coordinate
  966. * @param y defines the second coordinate
  967. * @returns a new Vector2
  968. */
  969. multiplyByFloats(x: number, y: number): Vector2;
  970. /**
  971. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  972. * @param otherVector defines the other vector
  973. * @returns a new Vector2
  974. */
  975. divide(otherVector: Vector2): Vector2;
  976. /**
  977. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  978. * @param otherVector defines the other vector
  979. * @param result defines the target vector
  980. * @returns the unmodified current Vector2
  981. */
  982. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  983. /**
  984. * Divides the current Vector2 coordinates by the given ones
  985. * @param otherVector defines the other vector
  986. * @returns the current updated Vector2
  987. */
  988. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  989. /**
  990. * Gets a new Vector2 with current Vector2 negated coordinates
  991. * @returns a new Vector2
  992. */
  993. negate(): Vector2;
  994. /**
  995. * Multiply the Vector2 coordinates by scale
  996. * @param scale defines the scaling factor
  997. * @returns the current updated Vector2
  998. */
  999. scaleInPlace(scale: number): Vector2;
  1000. /**
  1001. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1002. * @param scale defines the scaling factor
  1003. * @returns a new Vector2
  1004. */
  1005. scale(scale: number): Vector2;
  1006. /**
  1007. * Scale the current Vector2 values by a factor to a given Vector2
  1008. * @param scale defines the scale factor
  1009. * @param result defines the Vector2 object where to store the result
  1010. * @returns the unmodified current Vector2
  1011. */
  1012. scaleToRef(scale: number, result: Vector2): Vector2;
  1013. /**
  1014. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1015. * @param scale defines the scale factor
  1016. * @param result defines the Vector2 object where to store the result
  1017. * @returns the unmodified current Vector2
  1018. */
  1019. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1020. /**
  1021. * Gets a boolean if two vectors are equals
  1022. * @param otherVector defines the other vector
  1023. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1024. */
  1025. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1026. /**
  1027. * Gets a boolean if two vectors are equals (using an epsilon value)
  1028. * @param otherVector defines the other vector
  1029. * @param epsilon defines the minimal distance to consider equality
  1030. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1031. */
  1032. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. floor(): Vector2;
  1038. /**
  1039. * Gets a new Vector2 from current Vector2 floored values
  1040. * @returns a new Vector2
  1041. */
  1042. fract(): Vector2;
  1043. /**
  1044. * Gets the length of the vector
  1045. * @returns the vector length (float)
  1046. */
  1047. length(): number;
  1048. /**
  1049. * Gets the vector squared length
  1050. * @returns the vector squared length (float)
  1051. */
  1052. lengthSquared(): number;
  1053. /**
  1054. * Normalize the vector
  1055. * @returns the current updated Vector2
  1056. */
  1057. normalize(): Vector2;
  1058. /**
  1059. * Gets a new Vector2 copied from the Vector2
  1060. * @returns a new Vector2
  1061. */
  1062. clone(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(0, 0)
  1065. * @returns a new Vector2
  1066. */
  1067. static Zero(): Vector2;
  1068. /**
  1069. * Gets a new Vector2(1, 1)
  1070. * @returns a new Vector2
  1071. */
  1072. static One(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 set from the given index element of the given array
  1075. * @param array defines the data source
  1076. * @param offset defines the offset in the data source
  1077. * @returns a new Vector2
  1078. */
  1079. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1080. /**
  1081. * Sets "result" from the given index element of the given array
  1082. * @param array defines the data source
  1083. * @param offset defines the offset in the data source
  1084. * @param result defines the target vector
  1085. */
  1086. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1087. /**
  1088. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1089. * @param value1 defines 1st point of control
  1090. * @param value2 defines 2nd point of control
  1091. * @param value3 defines 3rd point of control
  1092. * @param value4 defines 4th point of control
  1093. * @param amount defines the interpolation factor
  1094. * @returns a new Vector2
  1095. */
  1096. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1097. /**
  1098. * 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".
  1099. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1100. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1101. * @param value defines the value to clamp
  1102. * @param min defines the lower limit
  1103. * @param max defines the upper limit
  1104. * @returns a new Vector2
  1105. */
  1106. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1107. /**
  1108. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1109. * @param value1 defines the 1st control point
  1110. * @param tangent1 defines the outgoing tangent
  1111. * @param value2 defines the 2nd control point
  1112. * @param tangent2 defines the incoming tangent
  1113. * @param amount defines the interpolation factor
  1114. * @returns a new Vector2
  1115. */
  1116. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1117. /**
  1118. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1119. * @param start defines the start vector
  1120. * @param end defines the end vector
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * Gets the dot product of the vector "left" and the vector "right"
  1127. * @param left defines first vector
  1128. * @param right defines second vector
  1129. * @returns the dot product (float)
  1130. */
  1131. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1132. /**
  1133. * Returns a new Vector2 equal to the normalized given vector
  1134. * @param vector defines the vector to normalize
  1135. * @returns a new Vector2
  1136. */
  1137. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1138. /**
  1139. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1140. * @param left defines 1st vector
  1141. * @param right defines 2nd vector
  1142. * @returns a new Vector2
  1143. */
  1144. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1145. /**
  1146. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1147. * @param left defines 1st vector
  1148. * @param right defines 2nd vector
  1149. * @returns a new Vector2
  1150. */
  1151. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1152. /**
  1153. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1154. * @param vector defines the vector to transform
  1155. * @param transformation defines the matrix to apply
  1156. * @returns a new Vector2
  1157. */
  1158. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1159. /**
  1160. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1161. * @param vector defines the vector to transform
  1162. * @param transformation defines the matrix to apply
  1163. * @param result defines the target vector
  1164. */
  1165. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1166. /**
  1167. * Determines if a given vector is included in a triangle
  1168. * @param p defines the vector to test
  1169. * @param p0 defines 1st triangle point
  1170. * @param p1 defines 2nd triangle point
  1171. * @param p2 defines 3rd triangle point
  1172. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1173. */
  1174. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1175. /**
  1176. * Gets the distance between the vectors "value1" and "value2"
  1177. * @param value1 defines first vector
  1178. * @param value2 defines second vector
  1179. * @returns the distance between vectors
  1180. */
  1181. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1182. /**
  1183. * Returns the squared distance between the vectors "value1" and "value2"
  1184. * @param value1 defines first vector
  1185. * @param value2 defines second vector
  1186. * @returns the squared distance between vectors
  1187. */
  1188. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1189. /**
  1190. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1191. * @param value1 defines first vector
  1192. * @param value2 defines second vector
  1193. * @returns a new Vector2
  1194. */
  1195. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1196. /**
  1197. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1198. * @param p defines the middle point
  1199. * @param segA defines one point of the segment
  1200. * @param segB defines the other point of the segment
  1201. * @returns the shortest distance
  1202. */
  1203. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1204. }
  1205. /**
  1206. * Classed used to store (x,y,z) vector representation
  1207. * A Vector3 is the main object used in 3D geometry
  1208. * It can represent etiher the coordinates of a point the space, either a direction
  1209. * Reminder: js uses a left handed forward facing system
  1210. */
  1211. export class Vector3 {
  1212. /**
  1213. * Defines the first coordinates (on X axis)
  1214. */
  1215. x: number;
  1216. /**
  1217. * Defines the second coordinates (on Y axis)
  1218. */
  1219. y: number;
  1220. /**
  1221. * Defines the third coordinates (on Z axis)
  1222. */
  1223. z: number;
  1224. private static _UpReadOnly;
  1225. private static _ZeroReadOnly;
  1226. /**
  1227. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1228. * @param x defines the first coordinates (on X axis)
  1229. * @param y defines the second coordinates (on Y axis)
  1230. * @param z defines the third coordinates (on Z axis)
  1231. */
  1232. constructor(
  1233. /**
  1234. * Defines the first coordinates (on X axis)
  1235. */
  1236. x?: number,
  1237. /**
  1238. * Defines the second coordinates (on Y axis)
  1239. */
  1240. y?: number,
  1241. /**
  1242. * Defines the third coordinates (on Z axis)
  1243. */
  1244. z?: number);
  1245. /**
  1246. * Creates a string representation of the Vector3
  1247. * @returns a string with the Vector3 coordinates.
  1248. */
  1249. toString(): string;
  1250. /**
  1251. * Gets the class name
  1252. * @returns the string "Vector3"
  1253. */
  1254. getClassName(): string;
  1255. /**
  1256. * Creates the Vector3 hash code
  1257. * @returns a number which tends to be unique between Vector3 instances
  1258. */
  1259. getHashCode(): number;
  1260. /**
  1261. * Creates an array containing three elements : the coordinates of the Vector3
  1262. * @returns a new array of numbers
  1263. */
  1264. asArray(): number[];
  1265. /**
  1266. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1267. * @param array defines the destination array
  1268. * @param index defines the offset in the destination array
  1269. * @returns the current Vector3
  1270. */
  1271. toArray(array: FloatArray, index?: number): Vector3;
  1272. /**
  1273. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1274. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1275. */
  1276. toQuaternion(): Quaternion;
  1277. /**
  1278. * Adds the given vector to the current Vector3
  1279. * @param otherVector defines the second operand
  1280. * @returns the current updated Vector3
  1281. */
  1282. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1283. /**
  1284. * Adds the given coordinates to the current Vector3
  1285. * @param x defines the x coordinate of the operand
  1286. * @param y defines the y coordinate of the operand
  1287. * @param z defines the z coordinate of the operand
  1288. * @returns the current updated Vector3
  1289. */
  1290. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1291. /**
  1292. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1293. * @param otherVector defines the second operand
  1294. * @returns the resulting Vector3
  1295. */
  1296. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1297. /**
  1298. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1299. * @param otherVector defines the second operand
  1300. * @param result defines the Vector3 object where to store the result
  1301. * @returns the current Vector3
  1302. */
  1303. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1304. /**
  1305. * Subtract the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the current updated Vector3
  1308. */
  1309. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1312. * @param otherVector defines the second operand
  1313. * @returns the resulting Vector3
  1314. */
  1315. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1316. /**
  1317. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1318. * @param otherVector defines the second operand
  1319. * @param result defines the Vector3 object where to store the result
  1320. * @returns the current Vector3
  1321. */
  1322. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1323. /**
  1324. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1325. * @param x defines the x coordinate of the operand
  1326. * @param y defines the y coordinate of the operand
  1327. * @param z defines the z coordinate of the operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1331. /**
  1332. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1333. * @param x defines the x coordinate of the operand
  1334. * @param y defines the y coordinate of the operand
  1335. * @param z defines the z coordinate of the operand
  1336. * @param result defines the Vector3 object where to store the result
  1337. * @returns the current Vector3
  1338. */
  1339. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1340. /**
  1341. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1342. * @returns a new Vector3
  1343. */
  1344. negate(): Vector3;
  1345. /**
  1346. * Multiplies the Vector3 coordinates by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns the current updated Vector3
  1349. */
  1350. scaleInPlace(scale: number): Vector3;
  1351. /**
  1352. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1353. * @param scale defines the multiplier factor
  1354. * @returns a new Vector3
  1355. */
  1356. scale(scale: number): Vector3;
  1357. /**
  1358. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1359. * @param scale defines the multiplier factor
  1360. * @param result defines the Vector3 object where to store the result
  1361. * @returns the current Vector3
  1362. */
  1363. scaleToRef(scale: number, result: Vector3): Vector3;
  1364. /**
  1365. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1366. * @param scale defines the scale factor
  1367. * @param result defines the Vector3 object where to store the result
  1368. * @returns the unmodified current Vector3
  1369. */
  1370. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1373. * @param otherVector defines the second operand
  1374. * @returns true if both vectors are equals
  1375. */
  1376. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1377. /**
  1378. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1379. * @param otherVector defines the second operand
  1380. * @param epsilon defines the minimal distance to define values as equals
  1381. * @returns true if both vectors are distant less than epsilon
  1382. */
  1383. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1384. /**
  1385. * Returns true if the current Vector3 coordinates equals the given floats
  1386. * @param x defines the x coordinate of the operand
  1387. * @param y defines the y coordinate of the operand
  1388. * @param z defines the z coordinate of the operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equalsToFloats(x: number, y: number, z: number): boolean;
  1392. /**
  1393. * Multiplies the current Vector3 coordinates by the given ones
  1394. * @param otherVector defines the second operand
  1395. * @returns the current updated Vector3
  1396. */
  1397. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1400. * @param otherVector defines the second operand
  1401. * @returns the new Vector3
  1402. */
  1403. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1404. /**
  1405. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1406. * @param otherVector defines the second operand
  1407. * @param result defines the Vector3 object where to store the result
  1408. * @returns the current Vector3
  1409. */
  1410. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1411. /**
  1412. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1413. * @param x defines the x coordinate of the operand
  1414. * @param y defines the y coordinate of the operand
  1415. * @param z defines the z coordinate of the operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1419. /**
  1420. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1421. * @param otherVector defines the second operand
  1422. * @returns the new Vector3
  1423. */
  1424. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1425. /**
  1426. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1427. * @param otherVector defines the second operand
  1428. * @param result defines the Vector3 object where to store the result
  1429. * @returns the current Vector3
  1430. */
  1431. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1432. /**
  1433. * Divides the current Vector3 coordinates by the given ones.
  1434. * @param otherVector defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. divideInPlace(otherVector: Vector3): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1446. * @param other defines the second operand
  1447. * @returns the current updated Vector3
  1448. */
  1449. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1450. /**
  1451. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1452. * @param x defines the x coordinate of the operand
  1453. * @param y defines the y coordinate of the operand
  1454. * @param z defines the z coordinate of the operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1460. * @param x defines the x coordinate of the operand
  1461. * @param y defines the y coordinate of the operand
  1462. * @param z defines the z coordinate of the operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1466. /**
  1467. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1468. * Check if is non uniform within a certain amount of decimal places to account for this
  1469. * @param epsilon the amount the values can differ
  1470. * @returns if the the vector is non uniform to a certain number of decimal places
  1471. */
  1472. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1473. /**
  1474. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1475. */
  1476. readonly isNonUniform: boolean;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. floor(): Vector3;
  1482. /**
  1483. * Gets a new Vector3 from current Vector3 floored values
  1484. * @returns a new Vector3
  1485. */
  1486. fract(): Vector3;
  1487. /**
  1488. * Gets the length of the Vector3
  1489. * @returns the length of the Vector3
  1490. */
  1491. length(): number;
  1492. /**
  1493. * Gets the squared length of the Vector3
  1494. * @returns squared length of the Vector3
  1495. */
  1496. lengthSquared(): number;
  1497. /**
  1498. * Normalize the current Vector3.
  1499. * Please note that this is an in place operation.
  1500. * @returns the current updated Vector3
  1501. */
  1502. normalize(): Vector3;
  1503. /**
  1504. * Reorders the x y z properties of the vector in place
  1505. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1506. * @returns the current updated vector
  1507. */
  1508. reorderInPlace(order: string): this;
  1509. /**
  1510. * Rotates the vector around 0,0,0 by a quaternion
  1511. * @param quaternion the rotation quaternion
  1512. * @param result vector to store the result
  1513. * @returns the resulting vector
  1514. */
  1515. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1516. /**
  1517. * Rotates a vector around a given point
  1518. * @param quaternion the rotation quaternion
  1519. * @param point the point to rotate around
  1520. * @param result vector to store the result
  1521. * @returns the resulting vector
  1522. */
  1523. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1524. /**
  1525. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1526. * The cross product is then orthogonal to both current and "other"
  1527. * @param other defines the right operand
  1528. * @returns the cross product
  1529. */
  1530. cross(other: Vector3): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 with the given input length.
  1533. * Please note that this is an in place operation.
  1534. * @param len the length of the vector
  1535. * @returns the current updated Vector3
  1536. */
  1537. normalizeFromLength(len: number): Vector3;
  1538. /**
  1539. * Normalize the current Vector3 to a new vector
  1540. * @returns the new Vector3
  1541. */
  1542. normalizeToNew(): Vector3;
  1543. /**
  1544. * Normalize the current Vector3 to the reference
  1545. * @param reference define the Vector3 to update
  1546. * @returns the updated Vector3
  1547. */
  1548. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Creates a new Vector3 copied from the current Vector3
  1551. * @returns the new Vector3
  1552. */
  1553. clone(): Vector3;
  1554. /**
  1555. * Copies the given vector coordinates to the current Vector3 ones
  1556. * @param source defines the source Vector3
  1557. * @returns the current updated Vector3
  1558. */
  1559. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1560. /**
  1561. * Copies the given floats to the current Vector3 coordinates
  1562. * @param x defines the x coordinate of the operand
  1563. * @param y defines the y coordinate of the operand
  1564. * @param z defines the z coordinate of the operand
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFromFloats(x: number, y: number, z: number): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. set(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given float to the current Vector3 coordinates
  1578. * @param v defines the x, y and z coordinates of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. setAll(v: number): Vector3;
  1582. /**
  1583. * Get the clip factor between two vectors
  1584. * @param vector0 defines the first operand
  1585. * @param vector1 defines the second operand
  1586. * @param axis defines the axis to use
  1587. * @param size defines the size along the axis
  1588. * @returns the clip factor
  1589. */
  1590. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1591. /**
  1592. * Get angle between two vectors
  1593. * @param vector0 angle between vector0 and vector1
  1594. * @param vector1 angle between vector0 and vector1
  1595. * @param normal direction of the normal
  1596. * @return the angle between vector0 and vector1
  1597. */
  1598. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1599. /**
  1600. * Returns a new Vector3 set from the index "offset" of the given array
  1601. * @param array defines the source array
  1602. * @param offset defines the offset in the source array
  1603. * @returns the new Vector3
  1604. */
  1605. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1606. /**
  1607. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1608. * This function is deprecated. Use FromArray instead
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1614. /**
  1615. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1616. * @param array defines the source array
  1617. * @param offset defines the offset in the source array
  1618. * @param result defines the Vector3 where to store the result
  1619. */
  1620. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1621. /**
  1622. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1623. * This function is deprecated. Use FromArrayToRef instead.
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the given floats.
  1631. * @param x defines the x coordinate of the source
  1632. * @param y defines the y coordinate of the source
  1633. * @param z defines the z coordinate of the source
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1637. /**
  1638. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1639. * @returns a new empty Vector3
  1640. */
  1641. static Zero(): Vector3;
  1642. /**
  1643. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1644. * @returns a new unit Vector3
  1645. */
  1646. static One(): Vector3;
  1647. /**
  1648. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1649. * @returns a new up Vector3
  1650. */
  1651. static Up(): Vector3;
  1652. /**
  1653. * Gets a up Vector3 that must not be updated
  1654. */
  1655. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1656. /**
  1657. * Gets a zero Vector3 that must not be updated
  1658. */
  1659. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1660. /**
  1661. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1662. * @returns a new down Vector3
  1663. */
  1664. static Down(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1667. * @returns a new forward Vector3
  1668. */
  1669. static Forward(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1672. * @returns a new forward Vector3
  1673. */
  1674. static Backward(): Vector3;
  1675. /**
  1676. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1677. * @returns a new right Vector3
  1678. */
  1679. static Right(): Vector3;
  1680. /**
  1681. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1682. * @returns a new left Vector3
  1683. */
  1684. static Left(): Vector3;
  1685. /**
  1686. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1687. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1688. * @param vector defines the Vector3 to transform
  1689. * @param transformation defines the transformation matrix
  1690. * @returns the transformed Vector3
  1691. */
  1692. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1693. /**
  1694. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @param result defines the Vector3 where to store the result
  1699. */
  1700. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1703. * This method computes tranformed coordinates only, not transformed direction vectors
  1704. * @param x define the x coordinate of the source vector
  1705. * @param y define the y coordinate of the source vector
  1706. * @param z define the z coordinate of the source vector
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param vector defines the Vector3 to transform
  1715. * @param transformation defines the transformation matrix
  1716. * @returns the new Vector3
  1717. */
  1718. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1719. /**
  1720. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @param result defines the Vector3 where to store the result
  1725. */
  1726. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param x define the x coordinate of the source vector
  1731. * @param y define the y coordinate of the source vector
  1732. * @param z define the z coordinate of the source vector
  1733. * @param transformation defines the transformation matrix
  1734. * @param result defines the Vector3 where to store the result
  1735. */
  1736. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1737. /**
  1738. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1739. * @param value1 defines the first control point
  1740. * @param value2 defines the second control point
  1741. * @param value3 defines the third control point
  1742. * @param value4 defines the fourth control point
  1743. * @param amount defines the amount on the spline to use
  1744. * @returns the new Vector3
  1745. */
  1746. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1747. /**
  1748. * 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"
  1749. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1750. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1751. * @param value defines the current value
  1752. * @param min defines the lower range value
  1753. * @param max defines the upper range value
  1754. * @returns the new Vector3
  1755. */
  1756. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1757. /**
  1758. * 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"
  1759. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1760. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1761. * @param value defines the current value
  1762. * @param min defines the lower range value
  1763. * @param max defines the upper range value
  1764. * @param result defines the Vector3 where to store the result
  1765. */
  1766. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1767. /**
  1768. * Checks if a given vector is inside a specific range
  1769. * @param v defines the vector to test
  1770. * @param min defines the minimum range
  1771. * @param max defines the maximum range
  1772. */
  1773. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1774. /**
  1775. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1776. * @param value1 defines the first control point
  1777. * @param tangent1 defines the first tangent vector
  1778. * @param value2 defines the second control point
  1779. * @param tangent2 defines the second tangent vector
  1780. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1781. * @returns the new Vector3
  1782. */
  1783. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1784. /**
  1785. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1786. * @param start defines the start value
  1787. * @param end defines the end value
  1788. * @param amount max defines amount between both (between 0 and 1)
  1789. * @returns the new Vector3
  1790. */
  1791. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1794. * @param start defines the start value
  1795. * @param end defines the end value
  1796. * @param amount max defines amount between both (between 0 and 1)
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1800. /**
  1801. * Returns the dot product (float) between the vectors "left" and "right"
  1802. * @param left defines the left operand
  1803. * @param right defines the right operand
  1804. * @returns the dot product
  1805. */
  1806. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1807. /**
  1808. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1809. * The cross product is then orthogonal to both "left" and "right"
  1810. * @param left defines the left operand
  1811. * @param right defines the right operand
  1812. * @returns the cross product
  1813. */
  1814. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1815. /**
  1816. * Sets the given vector "result" with the cross product of "left" and "right"
  1817. * The cross product is then orthogonal to both "left" and "right"
  1818. * @param left defines the left operand
  1819. * @param right defines the right operand
  1820. * @param result defines the Vector3 where to store the result
  1821. */
  1822. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1823. /**
  1824. * Returns a new Vector3 as the normalization of the given vector
  1825. * @param vector defines the Vector3 to normalize
  1826. * @returns the new Vector3
  1827. */
  1828. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Sets the given vector "result" with the normalization of the given first vector
  1831. * @param vector defines the Vector3 to normalize
  1832. * @param result defines the Vector3 where to store the result
  1833. */
  1834. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1835. /**
  1836. * Project a Vector3 onto screen space
  1837. * @param vector defines the Vector3 to project
  1838. * @param world defines the world matrix to use
  1839. * @param transform defines the transform (view x projection) matrix to use
  1840. * @param viewport defines the screen viewport to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1844. /** @hidden */
  1845. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1846. /**
  1847. * Unproject from screen space to object space
  1848. * @param source defines the screen space Vector3 to use
  1849. * @param viewportWidth defines the current width of the viewport
  1850. * @param viewportHeight defines the current height of the viewport
  1851. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1852. * @param transform defines the transform (view x projection) matrix to use
  1853. * @returns the new Vector3
  1854. */
  1855. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param source defines the screen space Vector3 to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @returns the new Vector3
  1865. */
  1866. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1867. /**
  1868. * Unproject from screen space to object space
  1869. * @param source defines the screen space Vector3 to use
  1870. * @param viewportWidth defines the current width of the viewport
  1871. * @param viewportHeight defines the current height of the viewport
  1872. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1873. * @param view defines the view matrix to use
  1874. * @param projection defines the projection matrix to use
  1875. * @param result defines the Vector3 where to store the result
  1876. */
  1877. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1878. /**
  1879. * Unproject from screen space to object space
  1880. * @param sourceX defines the screen space x coordinate to use
  1881. * @param sourceY defines the screen space y coordinate to use
  1882. * @param sourceZ defines the screen space z coordinate to use
  1883. * @param viewportWidth defines the current width of the viewport
  1884. * @param viewportHeight defines the current height of the viewport
  1885. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1886. * @param view defines the view matrix to use
  1887. * @param projection defines the projection matrix to use
  1888. * @param result defines the Vector3 where to store the result
  1889. */
  1890. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1891. /**
  1892. * Gets the minimal coordinate values between two Vector3
  1893. * @param left defines the first operand
  1894. * @param right defines the second operand
  1895. * @returns the new Vector3
  1896. */
  1897. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1898. /**
  1899. * Gets the maximal coordinate values between two Vector3
  1900. * @param left defines the first operand
  1901. * @param right defines the second operand
  1902. * @returns the new Vector3
  1903. */
  1904. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1905. /**
  1906. * Returns the distance between the vectors "value1" and "value2"
  1907. * @param value1 defines the first operand
  1908. * @param value2 defines the second operand
  1909. * @returns the distance
  1910. */
  1911. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1912. /**
  1913. * Returns the squared distance between the vectors "value1" and "value2"
  1914. * @param value1 defines the first operand
  1915. * @param value2 defines the second operand
  1916. * @returns the squared distance
  1917. */
  1918. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1919. /**
  1920. * Returns a new Vector3 located at the center between "value1" and "value2"
  1921. * @param value1 defines the first operand
  1922. * @param value2 defines the second operand
  1923. * @returns the new Vector3
  1924. */
  1925. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1926. /**
  1927. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1928. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1929. * to something in order to rotate it from its local system to the given target system
  1930. * Note: axis1, axis2 and axis3 are normalized during this operation
  1931. * @param axis1 defines the first axis
  1932. * @param axis2 defines the second axis
  1933. * @param axis3 defines the third axis
  1934. * @returns a new Vector3
  1935. */
  1936. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1937. /**
  1938. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1939. * @param axis1 defines the first axis
  1940. * @param axis2 defines the second axis
  1941. * @param axis3 defines the third axis
  1942. * @param ref defines the Vector3 where to store the result
  1943. */
  1944. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1945. }
  1946. /**
  1947. * Vector4 class created for EulerAngle class conversion to Quaternion
  1948. */
  1949. export class Vector4 {
  1950. /** x value of the vector */
  1951. x: number;
  1952. /** y value of the vector */
  1953. y: number;
  1954. /** z value of the vector */
  1955. z: number;
  1956. /** w value of the vector */
  1957. w: number;
  1958. /**
  1959. * Creates a Vector4 object from the given floats.
  1960. * @param x x value of the vector
  1961. * @param y y value of the vector
  1962. * @param z z value of the vector
  1963. * @param w w value of the vector
  1964. */
  1965. constructor(
  1966. /** x value of the vector */
  1967. x: number,
  1968. /** y value of the vector */
  1969. y: number,
  1970. /** z value of the vector */
  1971. z: number,
  1972. /** w value of the vector */
  1973. w: number);
  1974. /**
  1975. * Returns the string with the Vector4 coordinates.
  1976. * @returns a string containing all the vector values
  1977. */
  1978. toString(): string;
  1979. /**
  1980. * Returns the string "Vector4".
  1981. * @returns "Vector4"
  1982. */
  1983. getClassName(): string;
  1984. /**
  1985. * Returns the Vector4 hash code.
  1986. * @returns a unique hash code
  1987. */
  1988. getHashCode(): number;
  1989. /**
  1990. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1991. * @returns the resulting array
  1992. */
  1993. asArray(): number[];
  1994. /**
  1995. * Populates the given array from the given index with the Vector4 coordinates.
  1996. * @param array array to populate
  1997. * @param index index of the array to start at (default: 0)
  1998. * @returns the Vector4.
  1999. */
  2000. toArray(array: FloatArray, index?: number): Vector4;
  2001. /**
  2002. * Adds the given vector to the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the updated Vector4.
  2005. */
  2006. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2009. * @param otherVector the vector to add
  2010. * @returns the resulting vector
  2011. */
  2012. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2013. /**
  2014. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2015. * @param otherVector the vector to add
  2016. * @param result the vector to store the result
  2017. * @returns the current Vector4.
  2018. */
  2019. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2020. /**
  2021. * Subtract in place the given vector from the current Vector4.
  2022. * @param otherVector the vector to subtract
  2023. * @returns the updated Vector4.
  2024. */
  2025. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2026. /**
  2027. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2028. * @param otherVector the vector to add
  2029. * @returns the new vector with the result
  2030. */
  2031. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2032. /**
  2033. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2034. * @param otherVector the vector to subtract
  2035. * @param result the vector to store the result
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2041. */
  2042. /**
  2043. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2044. * @param x value to subtract
  2045. * @param y value to subtract
  2046. * @param z value to subtract
  2047. * @param w value to subtract
  2048. * @returns new vector containing the result
  2049. */
  2050. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2051. /**
  2052. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2053. * @param x value to subtract
  2054. * @param y value to subtract
  2055. * @param z value to subtract
  2056. * @param w value to subtract
  2057. * @param result the vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2061. /**
  2062. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2063. * @returns a new vector with the negated values
  2064. */
  2065. negate(): Vector4;
  2066. /**
  2067. * Multiplies the current Vector4 coordinates by scale (float).
  2068. * @param scale the number to scale with
  2069. * @returns the updated Vector4.
  2070. */
  2071. scaleInPlace(scale: number): Vector4;
  2072. /**
  2073. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2074. * @param scale the number to scale with
  2075. * @returns a new vector with the result
  2076. */
  2077. scale(scale: number): Vector4;
  2078. /**
  2079. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2080. * @param scale the number to scale with
  2081. * @param result a vector to store the result in
  2082. * @returns the current Vector4.
  2083. */
  2084. scaleToRef(scale: number, result: Vector4): Vector4;
  2085. /**
  2086. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2087. * @param scale defines the scale factor
  2088. * @param result defines the Vector4 object where to store the result
  2089. * @returns the unmodified current Vector4
  2090. */
  2091. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2092. /**
  2093. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2094. * @param otherVector the vector to compare against
  2095. * @returns true if they are equal
  2096. */
  2097. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2098. /**
  2099. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2100. * @param otherVector vector to compare against
  2101. * @param epsilon (Default: very small number)
  2102. * @returns true if they are equal
  2103. */
  2104. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2105. /**
  2106. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2107. * @param x x value to compare against
  2108. * @param y y value to compare against
  2109. * @param z z value to compare against
  2110. * @param w w value to compare against
  2111. * @returns true if equal
  2112. */
  2113. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2114. /**
  2115. * Multiplies in place the current Vector4 by the given one.
  2116. * @param otherVector vector to multiple with
  2117. * @returns the updated Vector4.
  2118. */
  2119. multiplyInPlace(otherVector: Vector4): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2122. * @param otherVector vector to multiple with
  2123. * @returns resulting new vector
  2124. */
  2125. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2128. * @param otherVector vector to multiple with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2135. * @param x x value multiply with
  2136. * @param y y value multiply with
  2137. * @param z z value multiply with
  2138. * @param w w value multiply with
  2139. * @returns resulting new vector
  2140. */
  2141. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2142. /**
  2143. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2144. * @param otherVector vector to devide with
  2145. * @returns resulting new vector
  2146. */
  2147. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2150. * @param otherVector vector to devide with
  2151. * @param result vector to store the result
  2152. * @returns the current Vector4.
  2153. */
  2154. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2155. /**
  2156. * Divides the current Vector3 coordinates by the given ones.
  2157. * @param otherVector vector to devide with
  2158. * @returns the updated Vector3.
  2159. */
  2160. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2161. /**
  2162. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2163. * @param other defines the second operand
  2164. * @returns the current updated Vector4
  2165. */
  2166. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2167. /**
  2168. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2169. * @param other defines the second operand
  2170. * @returns the current updated Vector4
  2171. */
  2172. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2173. /**
  2174. * Gets a new Vector4 from current Vector4 floored values
  2175. * @returns a new Vector4
  2176. */
  2177. floor(): Vector4;
  2178. /**
  2179. * Gets a new Vector4 from current Vector3 floored values
  2180. * @returns a new Vector4
  2181. */
  2182. fract(): Vector4;
  2183. /**
  2184. * Returns the Vector4 length (float).
  2185. * @returns the length
  2186. */
  2187. length(): number;
  2188. /**
  2189. * Returns the Vector4 squared length (float).
  2190. * @returns the length squared
  2191. */
  2192. lengthSquared(): number;
  2193. /**
  2194. * Normalizes in place the Vector4.
  2195. * @returns the updated Vector4.
  2196. */
  2197. normalize(): Vector4;
  2198. /**
  2199. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2200. * @returns this converted to a new vector3
  2201. */
  2202. toVector3(): Vector3;
  2203. /**
  2204. * Returns a new Vector4 copied from the current one.
  2205. * @returns the new cloned vector
  2206. */
  2207. clone(): Vector4;
  2208. /**
  2209. * Updates the current Vector4 with the given one coordinates.
  2210. * @param source the source vector to copy from
  2211. * @returns the updated Vector4.
  2212. */
  2213. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2214. /**
  2215. * Updates the current Vector4 coordinates with the given floats.
  2216. * @param x float to copy from
  2217. * @param y float to copy from
  2218. * @param z float to copy from
  2219. * @param w float to copy from
  2220. * @returns the updated Vector4.
  2221. */
  2222. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2223. /**
  2224. * Updates the current Vector4 coordinates with the given floats.
  2225. * @param x float to set from
  2226. * @param y float to set from
  2227. * @param z float to set from
  2228. * @param w float to set from
  2229. * @returns the updated Vector4.
  2230. */
  2231. set(x: number, y: number, z: number, w: number): Vector4;
  2232. /**
  2233. * Copies the given float to the current Vector3 coordinates
  2234. * @param v defines the x, y, z and w coordinates of the operand
  2235. * @returns the current updated Vector3
  2236. */
  2237. setAll(v: number): Vector4;
  2238. /**
  2239. * Returns a new Vector4 set from the starting index of the given array.
  2240. * @param array the array to pull values from
  2241. * @param offset the offset into the array to start at
  2242. * @returns the new vector
  2243. */
  2244. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2245. /**
  2246. * Updates the given vector "result" from the starting index of the given array.
  2247. * @param array the array to pull values from
  2248. * @param offset the offset into the array to start at
  2249. * @param result the vector to store the result in
  2250. */
  2251. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2252. /**
  2253. * Updates the given vector "result" from the starting index of the given Float32Array.
  2254. * @param array the array to pull values from
  2255. * @param offset the offset into the array to start at
  2256. * @param result the vector to store the result in
  2257. */
  2258. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2259. /**
  2260. * Updates the given vector "result" coordinates from the given floats.
  2261. * @param x float to set from
  2262. * @param y float to set from
  2263. * @param z float to set from
  2264. * @param w float to set from
  2265. * @param result the vector to the floats in
  2266. */
  2267. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2268. /**
  2269. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2270. * @returns the new vector
  2271. */
  2272. static Zero(): Vector4;
  2273. /**
  2274. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2275. * @returns the new vector
  2276. */
  2277. static One(): Vector4;
  2278. /**
  2279. * Returns a new normalized Vector4 from the given one.
  2280. * @param vector the vector to normalize
  2281. * @returns the vector
  2282. */
  2283. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2284. /**
  2285. * Updates the given vector "result" from the normalization of the given one.
  2286. * @param vector the vector to normalize
  2287. * @param result the vector to store the result in
  2288. */
  2289. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2290. /**
  2291. * Returns a vector with the minimum values from the left and right vectors
  2292. * @param left left vector to minimize
  2293. * @param right right vector to minimize
  2294. * @returns a new vector with the minimum of the left and right vector values
  2295. */
  2296. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2297. /**
  2298. * Returns a vector with the maximum values from the left and right vectors
  2299. * @param left left vector to maximize
  2300. * @param right right vector to maximize
  2301. * @returns a new vector with the maximum of the left and right vector values
  2302. */
  2303. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2304. /**
  2305. * Returns the distance (float) between the vectors "value1" and "value2".
  2306. * @param value1 value to calulate the distance between
  2307. * @param value2 value to calulate the distance between
  2308. * @return the distance between the two vectors
  2309. */
  2310. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2311. /**
  2312. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2313. * @param value1 value to calulate the distance between
  2314. * @param value2 value to calulate the distance between
  2315. * @return the distance between the two vectors squared
  2316. */
  2317. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2318. /**
  2319. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2320. * @param value1 value to calulate the center between
  2321. * @param value2 value to calulate the center between
  2322. * @return the center between the two vectors
  2323. */
  2324. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2325. /**
  2326. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2327. * This methods computes transformed normalized direction vectors only.
  2328. * @param vector the vector to transform
  2329. * @param transformation the transformation matrix to apply
  2330. * @returns the new vector
  2331. */
  2332. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2333. /**
  2334. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2335. * This methods computes transformed normalized direction vectors only.
  2336. * @param vector the vector to transform
  2337. * @param transformation the transformation matrix to apply
  2338. * @param result the vector to store the result in
  2339. */
  2340. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2341. /**
  2342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2343. * This methods computes transformed normalized direction vectors only.
  2344. * @param x value to transform
  2345. * @param y value to transform
  2346. * @param z value to transform
  2347. * @param w value to transform
  2348. * @param transformation the transformation matrix to apply
  2349. * @param result the vector to store the results in
  2350. */
  2351. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2352. /**
  2353. * Creates a new Vector4 from a Vector3
  2354. * @param source defines the source data
  2355. * @param w defines the 4th component (default is 0)
  2356. * @returns a new Vector4
  2357. */
  2358. static FromVector3(source: Vector3, w?: number): Vector4;
  2359. }
  2360. /**
  2361. * Class used to store quaternion data
  2362. * @see https://en.wikipedia.org/wiki/Quaternion
  2363. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2364. */
  2365. export class Quaternion {
  2366. /** defines the first component (0 by default) */
  2367. x: number;
  2368. /** defines the second component (0 by default) */
  2369. y: number;
  2370. /** defines the third component (0 by default) */
  2371. z: number;
  2372. /** defines the fourth component (1.0 by default) */
  2373. w: number;
  2374. /**
  2375. * Creates a new Quaternion from the given floats
  2376. * @param x defines the first component (0 by default)
  2377. * @param y defines the second component (0 by default)
  2378. * @param z defines the third component (0 by default)
  2379. * @param w defines the fourth component (1.0 by default)
  2380. */
  2381. constructor(
  2382. /** defines the first component (0 by default) */
  2383. x?: number,
  2384. /** defines the second component (0 by default) */
  2385. y?: number,
  2386. /** defines the third component (0 by default) */
  2387. z?: number,
  2388. /** defines the fourth component (1.0 by default) */
  2389. w?: number);
  2390. /**
  2391. * Gets a string representation for the current quaternion
  2392. * @returns a string with the Quaternion coordinates
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * Gets the class name of the quaternion
  2397. * @returns the string "Quaternion"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Gets a hash code for this quaternion
  2402. * @returns the quaternion hash code
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Copy the quaternion to an array
  2407. * @returns a new array populated with 4 elements from the quaternion coordinates
  2408. */
  2409. asArray(): number[];
  2410. /**
  2411. * Check if two quaternions are equals
  2412. * @param otherQuaternion defines the second operand
  2413. * @return true if the current quaternion and the given one coordinates are strictly equals
  2414. */
  2415. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2416. /**
  2417. * Clone the current quaternion
  2418. * @returns a new quaternion copied from the current one
  2419. */
  2420. clone(): Quaternion;
  2421. /**
  2422. * Copy a quaternion to the current one
  2423. * @param other defines the other quaternion
  2424. * @returns the updated current quaternion
  2425. */
  2426. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2427. /**
  2428. * Updates the current quaternion with the given float coordinates
  2429. * @param x defines the x coordinate
  2430. * @param y defines the y coordinate
  2431. * @param z defines the z coordinate
  2432. * @param w defines the w coordinate
  2433. * @returns the updated current quaternion
  2434. */
  2435. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2436. /**
  2437. * Updates the current quaternion from the given float coordinates
  2438. * @param x defines the x coordinate
  2439. * @param y defines the y coordinate
  2440. * @param z defines the z coordinate
  2441. * @param w defines the w coordinate
  2442. * @returns the updated current quaternion
  2443. */
  2444. set(x: number, y: number, z: number, w: number): Quaternion;
  2445. /**
  2446. * Adds two quaternions
  2447. * @param other defines the second operand
  2448. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2449. */
  2450. add(other: DeepImmutable<Quaternion>): Quaternion;
  2451. /**
  2452. * Add a quaternion to the current one
  2453. * @param other defines the quaternion to add
  2454. * @returns the current quaternion
  2455. */
  2456. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2457. /**
  2458. * Subtract two quaternions
  2459. * @param other defines the second operand
  2460. * @returns a new quaternion as the subtraction result of the given one from the current one
  2461. */
  2462. subtract(other: Quaternion): Quaternion;
  2463. /**
  2464. * Multiplies the current quaternion by a scale factor
  2465. * @param value defines the scale factor
  2466. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2467. */
  2468. scale(value: number): Quaternion;
  2469. /**
  2470. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2471. * @param scale defines the scale factor
  2472. * @param result defines the Quaternion object where to store the result
  2473. * @returns the unmodified current quaternion
  2474. */
  2475. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2476. /**
  2477. * Multiplies in place the current quaternion by a scale factor
  2478. * @param value defines the scale factor
  2479. * @returns the current modified quaternion
  2480. */
  2481. scaleInPlace(value: number): Quaternion;
  2482. /**
  2483. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2484. * @param scale defines the scale factor
  2485. * @param result defines the Quaternion object where to store the result
  2486. * @returns the unmodified current quaternion
  2487. */
  2488. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2489. /**
  2490. * Multiplies two quaternions
  2491. * @param q1 defines the second operand
  2492. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2493. */
  2494. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2495. /**
  2496. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2497. * @param q1 defines the second operand
  2498. * @param result defines the target quaternion
  2499. * @returns the current quaternion
  2500. */
  2501. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2502. /**
  2503. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2504. * @param q1 defines the second operand
  2505. * @returns the currentupdated quaternion
  2506. */
  2507. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2508. /**
  2509. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2510. * @param ref defines the target quaternion
  2511. * @returns the current quaternion
  2512. */
  2513. conjugateToRef(ref: Quaternion): Quaternion;
  2514. /**
  2515. * Conjugates in place (1-q) the current quaternion
  2516. * @returns the current updated quaternion
  2517. */
  2518. conjugateInPlace(): Quaternion;
  2519. /**
  2520. * Conjugates in place (1-q) the current quaternion
  2521. * @returns a new quaternion
  2522. */
  2523. conjugate(): Quaternion;
  2524. /**
  2525. * Gets length of current quaternion
  2526. * @returns the quaternion length (float)
  2527. */
  2528. length(): number;
  2529. /**
  2530. * Normalize in place the current quaternion
  2531. * @returns the current updated quaternion
  2532. */
  2533. normalize(): Quaternion;
  2534. /**
  2535. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2536. * @param order is a reserved parameter and is ignore for now
  2537. * @returns a new Vector3 containing the Euler angles
  2538. */
  2539. toEulerAngles(order?: string): Vector3;
  2540. /**
  2541. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2542. * @param result defines the vector which will be filled with the Euler angles
  2543. * @param order is a reserved parameter and is ignore for now
  2544. * @returns the current unchanged quaternion
  2545. */
  2546. toEulerAnglesToRef(result: Vector3): Quaternion;
  2547. /**
  2548. * Updates the given rotation matrix with the current quaternion values
  2549. * @param result defines the target matrix
  2550. * @returns the current unchanged quaternion
  2551. */
  2552. toRotationMatrix(result: Matrix): Quaternion;
  2553. /**
  2554. * Updates the current quaternion from the given rotation matrix values
  2555. * @param matrix defines the source matrix
  2556. * @returns the current updated quaternion
  2557. */
  2558. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2559. /**
  2560. * Creates a new quaternion from a rotation matrix
  2561. * @param matrix defines the source matrix
  2562. * @returns a new quaternion created from the given rotation matrix values
  2563. */
  2564. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2565. /**
  2566. * Updates the given quaternion with the given rotation matrix values
  2567. * @param matrix defines the source matrix
  2568. * @param result defines the target quaternion
  2569. */
  2570. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2571. /**
  2572. * Returns the dot product (float) between the quaternions "left" and "right"
  2573. * @param left defines the left operand
  2574. * @param right defines the right operand
  2575. * @returns the dot product
  2576. */
  2577. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2578. /**
  2579. * Checks if the two quaternions are close to each other
  2580. * @param quat0 defines the first quaternion to check
  2581. * @param quat1 defines the second quaternion to check
  2582. * @returns true if the two quaternions are close to each other
  2583. */
  2584. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2585. /**
  2586. * Creates an empty quaternion
  2587. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2588. */
  2589. static Zero(): Quaternion;
  2590. /**
  2591. * Inverse a given quaternion
  2592. * @param q defines the source quaternion
  2593. * @returns a new quaternion as the inverted current quaternion
  2594. */
  2595. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Inverse a given quaternion
  2598. * @param q defines the source quaternion
  2599. * @param result the quaternion the result will be stored in
  2600. * @returns the result quaternion
  2601. */
  2602. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2603. /**
  2604. * Creates an identity quaternion
  2605. * @returns the identity quaternion
  2606. */
  2607. static Identity(): Quaternion;
  2608. /**
  2609. * Gets a boolean indicating if the given quaternion is identity
  2610. * @param quaternion defines the quaternion to check
  2611. * @returns true if the quaternion is identity
  2612. */
  2613. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2614. /**
  2615. * Creates a quaternion from a rotation around an axis
  2616. * @param axis defines the axis to use
  2617. * @param angle defines the angle to use
  2618. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2619. */
  2620. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2621. /**
  2622. * Creates a rotation around an axis and stores it into the given quaternion
  2623. * @param axis defines the axis to use
  2624. * @param angle defines the angle to use
  2625. * @param result defines the target quaternion
  2626. * @returns the target quaternion
  2627. */
  2628. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2629. /**
  2630. * Creates a new quaternion from data stored into an array
  2631. * @param array defines the data source
  2632. * @param offset defines the offset in the source array where the data starts
  2633. * @returns a new quaternion
  2634. */
  2635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2636. /**
  2637. * Create a quaternion from Euler rotation angles
  2638. * @param x Pitch
  2639. * @param y Yaw
  2640. * @param z Roll
  2641. * @returns the new Quaternion
  2642. */
  2643. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2644. /**
  2645. * Updates a quaternion from Euler rotation angles
  2646. * @param x Pitch
  2647. * @param y Yaw
  2648. * @param z Roll
  2649. * @param result the quaternion to store the result
  2650. * @returns the updated quaternion
  2651. */
  2652. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2653. /**
  2654. * Create a quaternion from Euler rotation vector
  2655. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2656. * @returns the new Quaternion
  2657. */
  2658. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2659. /**
  2660. * Updates a quaternion from Euler rotation vector
  2661. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2662. * @param result the quaternion to store the result
  2663. * @returns the updated quaternion
  2664. */
  2665. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2666. /**
  2667. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2668. * @param yaw defines the rotation around Y axis
  2669. * @param pitch defines the rotation around X axis
  2670. * @param roll defines the rotation around Z axis
  2671. * @returns the new quaternion
  2672. */
  2673. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2674. /**
  2675. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2676. * @param yaw defines the rotation around Y axis
  2677. * @param pitch defines the rotation around X axis
  2678. * @param roll defines the rotation around Z axis
  2679. * @param result defines the target quaternion
  2680. */
  2681. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2682. /**
  2683. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2684. * @param alpha defines the rotation around first axis
  2685. * @param beta defines the rotation around second axis
  2686. * @param gamma defines the rotation around third axis
  2687. * @returns the new quaternion
  2688. */
  2689. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2690. /**
  2691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2692. * @param alpha defines the rotation around first axis
  2693. * @param beta defines the rotation around second axis
  2694. * @param gamma defines the rotation around third axis
  2695. * @param result defines the target quaternion
  2696. */
  2697. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2698. /**
  2699. * 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)
  2700. * @param axis1 defines the first axis
  2701. * @param axis2 defines the second axis
  2702. * @param axis3 defines the third axis
  2703. * @returns the new quaternion
  2704. */
  2705. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2706. /**
  2707. * 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
  2708. * @param axis1 defines the first axis
  2709. * @param axis2 defines the second axis
  2710. * @param axis3 defines the third axis
  2711. * @param ref defines the target quaternion
  2712. */
  2713. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2714. /**
  2715. * Interpolates between two quaternions
  2716. * @param left defines first quaternion
  2717. * @param right defines second quaternion
  2718. * @param amount defines the gradient to use
  2719. * @returns the new interpolated quaternion
  2720. */
  2721. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2722. /**
  2723. * Interpolates between two quaternions and stores it into a target quaternion
  2724. * @param left defines first quaternion
  2725. * @param right defines second quaternion
  2726. * @param amount defines the gradient to use
  2727. * @param result defines the target quaternion
  2728. */
  2729. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2730. /**
  2731. * Interpolate between two quaternions using Hermite interpolation
  2732. * @param value1 defines first quaternion
  2733. * @param tangent1 defines the incoming tangent
  2734. * @param value2 defines second quaternion
  2735. * @param tangent2 defines the outgoing tangent
  2736. * @param amount defines the target quaternion
  2737. * @returns the new interpolated quaternion
  2738. */
  2739. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2740. }
  2741. /**
  2742. * Class used to store matrix data (4x4)
  2743. */
  2744. export class Matrix {
  2745. private static _updateFlagSeed;
  2746. private static _identityReadOnly;
  2747. private _isIdentity;
  2748. private _isIdentityDirty;
  2749. private _isIdentity3x2;
  2750. private _isIdentity3x2Dirty;
  2751. /**
  2752. * Gets the update flag of the matrix which is an unique number for the matrix.
  2753. * It will be incremented every time the matrix data change.
  2754. * You can use it to speed the comparison between two versions of the same matrix.
  2755. */
  2756. updateFlag: number;
  2757. private readonly _m;
  2758. /**
  2759. * Gets the internal data of the matrix
  2760. */
  2761. readonly m: DeepImmutable<Float32Array>;
  2762. /** @hidden */
  2763. _markAsUpdated(): void;
  2764. /** @hidden */
  2765. private _updateIdentityStatus;
  2766. /**
  2767. * Creates an empty matrix (filled with zeros)
  2768. */
  2769. constructor();
  2770. /**
  2771. * Check if the current matrix is identity
  2772. * @returns true is the matrix is the identity matrix
  2773. */
  2774. isIdentity(): boolean;
  2775. /**
  2776. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2777. * @returns true is the matrix is the identity matrix
  2778. */
  2779. isIdentityAs3x2(): boolean;
  2780. /**
  2781. * Gets the determinant of the matrix
  2782. * @returns the matrix determinant
  2783. */
  2784. determinant(): number;
  2785. /**
  2786. * Returns the matrix as a Float32Array
  2787. * @returns the matrix underlying array
  2788. */
  2789. toArray(): DeepImmutable<Float32Array>;
  2790. /**
  2791. * Returns the matrix as a Float32Array
  2792. * @returns the matrix underlying array.
  2793. */
  2794. asArray(): DeepImmutable<Float32Array>;
  2795. /**
  2796. * Inverts the current matrix in place
  2797. * @returns the current inverted matrix
  2798. */
  2799. invert(): Matrix;
  2800. /**
  2801. * Sets all the matrix elements to zero
  2802. * @returns the current matrix
  2803. */
  2804. reset(): Matrix;
  2805. /**
  2806. * Adds the current matrix with a second one
  2807. * @param other defines the matrix to add
  2808. * @returns a new matrix as the addition of the current matrix and the given one
  2809. */
  2810. add(other: DeepImmutable<Matrix>): Matrix;
  2811. /**
  2812. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2813. * @param other defines the matrix to add
  2814. * @param result defines the target matrix
  2815. * @returns the current matrix
  2816. */
  2817. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2818. /**
  2819. * Adds in place the given matrix to the current matrix
  2820. * @param other defines the second operand
  2821. * @returns the current updated matrix
  2822. */
  2823. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2824. /**
  2825. * Sets the given matrix to the current inverted Matrix
  2826. * @param other defines the target matrix
  2827. * @returns the unmodified current matrix
  2828. */
  2829. invertToRef(other: Matrix): Matrix;
  2830. /**
  2831. * add a value at the specified position in the current Matrix
  2832. * @param index the index of the value within the matrix. between 0 and 15.
  2833. * @param value the value to be added
  2834. * @returns the current updated matrix
  2835. */
  2836. addAtIndex(index: number, value: number): Matrix;
  2837. /**
  2838. * mutiply the specified position in the current Matrix by a value
  2839. * @param index the index of the value within the matrix. between 0 and 15.
  2840. * @param value the value to be added
  2841. * @returns the current updated matrix
  2842. */
  2843. multiplyAtIndex(index: number, value: number): Matrix;
  2844. /**
  2845. * Inserts the translation vector (using 3 floats) in the current matrix
  2846. * @param x defines the 1st component of the translation
  2847. * @param y defines the 2nd component of the translation
  2848. * @param z defines the 3rd component of the translation
  2849. * @returns the current updated matrix
  2850. */
  2851. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2852. /**
  2853. * Adds the translation vector (using 3 floats) in the current matrix
  2854. * @param x defines the 1st component of the translation
  2855. * @param y defines the 2nd component of the translation
  2856. * @param z defines the 3rd component of the translation
  2857. * @returns the current updated matrix
  2858. */
  2859. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2860. /**
  2861. * Inserts the translation vector in the current matrix
  2862. * @param vector3 defines the translation to insert
  2863. * @returns the current updated matrix
  2864. */
  2865. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2866. /**
  2867. * Gets the translation value of the current matrix
  2868. * @returns a new Vector3 as the extracted translation from the matrix
  2869. */
  2870. getTranslation(): Vector3;
  2871. /**
  2872. * Fill a Vector3 with the extracted translation from the matrix
  2873. * @param result defines the Vector3 where to store the translation
  2874. * @returns the current matrix
  2875. */
  2876. getTranslationToRef(result: Vector3): Matrix;
  2877. /**
  2878. * Remove rotation and scaling part from the matrix
  2879. * @returns the updated matrix
  2880. */
  2881. removeRotationAndScaling(): Matrix;
  2882. /**
  2883. * Multiply two matrices
  2884. * @param other defines the second operand
  2885. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2886. */
  2887. multiply(other: DeepImmutable<Matrix>): Matrix;
  2888. /**
  2889. * Copy the current matrix from the given one
  2890. * @param other defines the source matrix
  2891. * @returns the current updated matrix
  2892. */
  2893. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2894. /**
  2895. * Populates the given array from the starting index with the current matrix values
  2896. * @param array defines the target array
  2897. * @param offset defines the offset in the target array where to start storing values
  2898. * @returns the current matrix
  2899. */
  2900. copyToArray(array: Float32Array, offset?: number): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2903. * @param other defines the second operand
  2904. * @param result defines the matrix where to store the multiplication
  2905. * @returns the current matrix
  2906. */
  2907. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2910. * @param other defines the second operand
  2911. * @param result defines the array where to store the multiplication
  2912. * @param offset defines the offset in the target array where to start storing values
  2913. * @returns the current matrix
  2914. */
  2915. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2916. /**
  2917. * Check equality between this matrix and a second one
  2918. * @param value defines the second matrix to compare
  2919. * @returns true is the current matrix and the given one values are strictly equal
  2920. */
  2921. equals(value: DeepImmutable<Matrix>): boolean;
  2922. /**
  2923. * Clone the current matrix
  2924. * @returns a new matrix from the current matrix
  2925. */
  2926. clone(): Matrix;
  2927. /**
  2928. * Returns the name of the current matrix class
  2929. * @returns the string "Matrix"
  2930. */
  2931. getClassName(): string;
  2932. /**
  2933. * Gets the hash code of the current matrix
  2934. * @returns the hash code
  2935. */
  2936. getHashCode(): number;
  2937. /**
  2938. * Decomposes the current Matrix into a translation, rotation and scaling components
  2939. * @param scale defines the scale vector3 given as a reference to update
  2940. * @param rotation defines the rotation quaternion given as a reference to update
  2941. * @param translation defines the translation vector3 given as a reference to update
  2942. * @returns true if operation was successful
  2943. */
  2944. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2945. /**
  2946. * Gets specific row of the matrix
  2947. * @param index defines the number of the row to get
  2948. * @returns the index-th row of the current matrix as a new Vector4
  2949. */
  2950. getRow(index: number): Nullable<Vector4>;
  2951. /**
  2952. * Sets the index-th row of the current matrix to the vector4 values
  2953. * @param index defines the number of the row to set
  2954. * @param row defines the target vector4
  2955. * @returns the updated current matrix
  2956. */
  2957. setRow(index: number, row: Vector4): Matrix;
  2958. /**
  2959. * Compute the transpose of the matrix
  2960. * @returns the new transposed matrix
  2961. */
  2962. transpose(): Matrix;
  2963. /**
  2964. * Compute the transpose of the matrix and store it in a given matrix
  2965. * @param result defines the target matrix
  2966. * @returns the current matrix
  2967. */
  2968. transposeToRef(result: Matrix): Matrix;
  2969. /**
  2970. * Sets the index-th row of the current matrix with the given 4 x float values
  2971. * @param index defines the row index
  2972. * @param x defines the x component to set
  2973. * @param y defines the y component to set
  2974. * @param z defines the z component to set
  2975. * @param w defines the w component to set
  2976. * @returns the updated current matrix
  2977. */
  2978. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2979. /**
  2980. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2981. * @param scale defines the scale factor
  2982. * @returns a new matrix
  2983. */
  2984. scale(scale: number): Matrix;
  2985. /**
  2986. * Scale the current matrix values by a factor to a given result matrix
  2987. * @param scale defines the scale factor
  2988. * @param result defines the matrix to store the result
  2989. * @returns the current matrix
  2990. */
  2991. scaleToRef(scale: number, result: Matrix): Matrix;
  2992. /**
  2993. * Scale the current matrix values by a factor and add the result to a given matrix
  2994. * @param scale defines the scale factor
  2995. * @param result defines the Matrix to store the result
  2996. * @returns the current matrix
  2997. */
  2998. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  2999. /**
  3000. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3001. * @param ref matrix to store the result
  3002. */
  3003. toNormalMatrix(ref: Matrix): void;
  3004. /**
  3005. * Gets only rotation part of the current matrix
  3006. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3007. */
  3008. getRotationMatrix(): Matrix;
  3009. /**
  3010. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3011. * @param result defines the target matrix to store data to
  3012. * @returns the current matrix
  3013. */
  3014. getRotationMatrixToRef(result: Matrix): Matrix;
  3015. /**
  3016. * Toggles model matrix from being right handed to left handed in place and vice versa
  3017. */
  3018. toggleModelMatrixHandInPlace(): void;
  3019. /**
  3020. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3021. */
  3022. toggleProjectionMatrixHandInPlace(): void;
  3023. /**
  3024. * Creates a matrix from an array
  3025. * @param array defines the source array
  3026. * @param offset defines an offset in the source array
  3027. * @returns a new Matrix set from the starting index of the given array
  3028. */
  3029. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3030. /**
  3031. * Copy the content of an array into a given matrix
  3032. * @param array defines the source array
  3033. * @param offset defines an offset in the source array
  3034. * @param result defines the target matrix
  3035. */
  3036. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3037. /**
  3038. * Stores an array into a matrix after having multiplied each component by a given factor
  3039. * @param array defines the source array
  3040. * @param offset defines the offset in the source array
  3041. * @param scale defines the scaling factor
  3042. * @param result defines the target matrix
  3043. */
  3044. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3045. /**
  3046. * Gets an identity matrix that must not be updated
  3047. */
  3048. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3049. /**
  3050. * Stores a list of values (16) inside a given matrix
  3051. * @param initialM11 defines 1st value of 1st row
  3052. * @param initialM12 defines 2nd value of 1st row
  3053. * @param initialM13 defines 3rd value of 1st row
  3054. * @param initialM14 defines 4th value of 1st row
  3055. * @param initialM21 defines 1st value of 2nd row
  3056. * @param initialM22 defines 2nd value of 2nd row
  3057. * @param initialM23 defines 3rd value of 2nd row
  3058. * @param initialM24 defines 4th value of 2nd row
  3059. * @param initialM31 defines 1st value of 3rd row
  3060. * @param initialM32 defines 2nd value of 3rd row
  3061. * @param initialM33 defines 3rd value of 3rd row
  3062. * @param initialM34 defines 4th value of 3rd row
  3063. * @param initialM41 defines 1st value of 4th row
  3064. * @param initialM42 defines 2nd value of 4th row
  3065. * @param initialM43 defines 3rd value of 4th row
  3066. * @param initialM44 defines 4th value of 4th row
  3067. * @param result defines the target matrix
  3068. */
  3069. 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;
  3070. /**
  3071. * Creates new matrix from a list of values (16)
  3072. * @param initialM11 defines 1st value of 1st row
  3073. * @param initialM12 defines 2nd value of 1st row
  3074. * @param initialM13 defines 3rd value of 1st row
  3075. * @param initialM14 defines 4th value of 1st row
  3076. * @param initialM21 defines 1st value of 2nd row
  3077. * @param initialM22 defines 2nd value of 2nd row
  3078. * @param initialM23 defines 3rd value of 2nd row
  3079. * @param initialM24 defines 4th value of 2nd row
  3080. * @param initialM31 defines 1st value of 3rd row
  3081. * @param initialM32 defines 2nd value of 3rd row
  3082. * @param initialM33 defines 3rd value of 3rd row
  3083. * @param initialM34 defines 4th value of 3rd row
  3084. * @param initialM41 defines 1st value of 4th row
  3085. * @param initialM42 defines 2nd value of 4th row
  3086. * @param initialM43 defines 3rd value of 4th row
  3087. * @param initialM44 defines 4th value of 4th row
  3088. * @returns the new matrix
  3089. */
  3090. 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;
  3091. /**
  3092. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3093. * @param scale defines the scale vector3
  3094. * @param rotation defines the rotation quaternion
  3095. * @param translation defines the translation vector3
  3096. * @returns a new matrix
  3097. */
  3098. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3099. /**
  3100. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3101. * @param scale defines the scale vector3
  3102. * @param rotation defines the rotation quaternion
  3103. * @param translation defines the translation vector3
  3104. * @param result defines the target matrix
  3105. */
  3106. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3107. /**
  3108. * Creates a new identity matrix
  3109. * @returns a new identity matrix
  3110. */
  3111. static Identity(): Matrix;
  3112. /**
  3113. * Creates a new identity matrix and stores the result in a given matrix
  3114. * @param result defines the target matrix
  3115. */
  3116. static IdentityToRef(result: Matrix): void;
  3117. /**
  3118. * Creates a new zero matrix
  3119. * @returns a new zero matrix
  3120. */
  3121. static Zero(): Matrix;
  3122. /**
  3123. * Creates a new rotation matrix for "angle" radians around the X axis
  3124. * @param angle defines the angle (in radians) to use
  3125. * @return the new matrix
  3126. */
  3127. static RotationX(angle: number): Matrix;
  3128. /**
  3129. * Creates a new matrix as the invert of a given matrix
  3130. * @param source defines the source matrix
  3131. * @returns the new matrix
  3132. */
  3133. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3134. /**
  3135. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3136. * @param angle defines the angle (in radians) to use
  3137. * @param result defines the target matrix
  3138. */
  3139. static RotationXToRef(angle: number, result: Matrix): void;
  3140. /**
  3141. * Creates a new rotation matrix for "angle" radians around the Y axis
  3142. * @param angle defines the angle (in radians) to use
  3143. * @return the new matrix
  3144. */
  3145. static RotationY(angle: number): Matrix;
  3146. /**
  3147. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3148. * @param angle defines the angle (in radians) to use
  3149. * @param result defines the target matrix
  3150. */
  3151. static RotationYToRef(angle: number, result: Matrix): void;
  3152. /**
  3153. * Creates a new rotation matrix for "angle" radians around the Z axis
  3154. * @param angle defines the angle (in radians) to use
  3155. * @return the new matrix
  3156. */
  3157. static RotationZ(angle: number): Matrix;
  3158. /**
  3159. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3160. * @param angle defines the angle (in radians) to use
  3161. * @param result defines the target matrix
  3162. */
  3163. static RotationZToRef(angle: number, result: Matrix): void;
  3164. /**
  3165. * Creates a new rotation matrix for "angle" radians around the given axis
  3166. * @param axis defines the axis to use
  3167. * @param angle defines the angle (in radians) to use
  3168. * @return the new matrix
  3169. */
  3170. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3171. /**
  3172. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3173. * @param axis defines the axis to use
  3174. * @param angle defines the angle (in radians) to use
  3175. * @param result defines the target matrix
  3176. */
  3177. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3178. /**
  3179. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3180. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3181. * @param from defines the vector to align
  3182. * @param to defines the vector to align to
  3183. * @param result defines the target matrix
  3184. */
  3185. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3186. /**
  3187. * Creates a rotation matrix
  3188. * @param yaw defines the yaw angle in radians (Y axis)
  3189. * @param pitch defines the pitch angle in radians (X axis)
  3190. * @param roll defines the roll angle in radians (X axis)
  3191. * @returns the new rotation matrix
  3192. */
  3193. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3194. /**
  3195. * Creates a rotation matrix and stores it in a given matrix
  3196. * @param yaw defines the yaw angle in radians (Y axis)
  3197. * @param pitch defines the pitch angle in radians (X axis)
  3198. * @param roll defines the roll angle in radians (X axis)
  3199. * @param result defines the target matrix
  3200. */
  3201. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3202. /**
  3203. * Creates a scaling matrix
  3204. * @param x defines the scale factor on X axis
  3205. * @param y defines the scale factor on Y axis
  3206. * @param z defines the scale factor on Z axis
  3207. * @returns the new matrix
  3208. */
  3209. static Scaling(x: number, y: number, z: number): Matrix;
  3210. /**
  3211. * Creates a scaling matrix and stores it in a given matrix
  3212. * @param x defines the scale factor on X axis
  3213. * @param y defines the scale factor on Y axis
  3214. * @param z defines the scale factor on Z axis
  3215. * @param result defines the target matrix
  3216. */
  3217. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3218. /**
  3219. * Creates a translation matrix
  3220. * @param x defines the translation on X axis
  3221. * @param y defines the translation on Y axis
  3222. * @param z defines the translationon Z axis
  3223. * @returns the new matrix
  3224. */
  3225. static Translation(x: number, y: number, z: number): Matrix;
  3226. /**
  3227. * Creates a translation matrix and stores it in a given matrix
  3228. * @param x defines the translation on X axis
  3229. * @param y defines the translation on Y axis
  3230. * @param z defines the translationon Z axis
  3231. * @param result defines the target matrix
  3232. */
  3233. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3234. /**
  3235. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3236. * @param startValue defines the start value
  3237. * @param endValue defines the end value
  3238. * @param gradient defines the gradient factor
  3239. * @returns the new matrix
  3240. */
  3241. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3242. /**
  3243. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3244. * @param startValue defines the start value
  3245. * @param endValue defines the end value
  3246. * @param gradient defines the gradient factor
  3247. * @param result defines the Matrix object where to store data
  3248. */
  3249. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3250. /**
  3251. * Builds a new matrix whose values are computed by:
  3252. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3253. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3254. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3255. * @param startValue defines the first matrix
  3256. * @param endValue defines the second matrix
  3257. * @param gradient defines the gradient between the two matrices
  3258. * @returns the new matrix
  3259. */
  3260. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3261. /**
  3262. * Update a matrix to values which are computed by:
  3263. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3264. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3265. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3266. * @param startValue defines the first matrix
  3267. * @param endValue defines the second matrix
  3268. * @param gradient defines the gradient between the two matrices
  3269. * @param result defines the target matrix
  3270. */
  3271. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3272. /**
  3273. * 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"
  3274. * This function works in left handed mode
  3275. * @param eye defines the final position of the entity
  3276. * @param target defines where the entity should look at
  3277. * @param up defines the up vector for the entity
  3278. * @returns the new matrix
  3279. */
  3280. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3281. /**
  3282. * 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".
  3283. * This function works in left handed mode
  3284. * @param eye defines the final position of the entity
  3285. * @param target defines where the entity should look at
  3286. * @param up defines the up vector for the entity
  3287. * @param result defines the target matrix
  3288. */
  3289. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3290. /**
  3291. * 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"
  3292. * This function works in right handed mode
  3293. * @param eye defines the final position of the entity
  3294. * @param target defines where the entity should look at
  3295. * @param up defines the up vector for the entity
  3296. * @returns the new matrix
  3297. */
  3298. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3299. /**
  3300. * 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".
  3301. * This function works in right handed mode
  3302. * @param eye defines the final position of the entity
  3303. * @param target defines where the entity should look at
  3304. * @param up defines the up vector for the entity
  3305. * @param result defines the target matrix
  3306. */
  3307. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3308. /**
  3309. * Create a left-handed orthographic projection matrix
  3310. * @param width defines the viewport width
  3311. * @param height defines the viewport height
  3312. * @param znear defines the near clip plane
  3313. * @param zfar defines the far clip plane
  3314. * @returns a new matrix as a left-handed orthographic projection matrix
  3315. */
  3316. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3317. /**
  3318. * Store a left-handed orthographic projection to a given matrix
  3319. * @param width defines the viewport width
  3320. * @param height defines the viewport height
  3321. * @param znear defines the near clip plane
  3322. * @param zfar defines the far clip plane
  3323. * @param result defines the target matrix
  3324. */
  3325. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3326. /**
  3327. * Create a left-handed orthographic projection matrix
  3328. * @param left defines the viewport left coordinate
  3329. * @param right defines the viewport right coordinate
  3330. * @param bottom defines the viewport bottom coordinate
  3331. * @param top defines the viewport top coordinate
  3332. * @param znear defines the near clip plane
  3333. * @param zfar defines the far clip plane
  3334. * @returns a new matrix as a left-handed orthographic projection matrix
  3335. */
  3336. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3337. /**
  3338. * Stores a left-handed orthographic projection into a given matrix
  3339. * @param left defines the viewport left coordinate
  3340. * @param right defines the viewport right coordinate
  3341. * @param bottom defines the viewport bottom coordinate
  3342. * @param top defines the viewport top coordinate
  3343. * @param znear defines the near clip plane
  3344. * @param zfar defines the far clip plane
  3345. * @param result defines the target matrix
  3346. */
  3347. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3348. /**
  3349. * Creates a right-handed orthographic projection matrix
  3350. * @param left defines the viewport left coordinate
  3351. * @param right defines the viewport right coordinate
  3352. * @param bottom defines the viewport bottom coordinate
  3353. * @param top defines the viewport top coordinate
  3354. * @param znear defines the near clip plane
  3355. * @param zfar defines the far clip plane
  3356. * @returns a new matrix as a right-handed orthographic projection matrix
  3357. */
  3358. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3359. /**
  3360. * Stores a right-handed orthographic projection into a given matrix
  3361. * @param left defines the viewport left coordinate
  3362. * @param right defines the viewport right coordinate
  3363. * @param bottom defines the viewport bottom coordinate
  3364. * @param top defines the viewport top coordinate
  3365. * @param znear defines the near clip plane
  3366. * @param zfar defines the far clip plane
  3367. * @param result defines the target matrix
  3368. */
  3369. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3370. /**
  3371. * Creates a left-handed perspective projection matrix
  3372. * @param width defines the viewport width
  3373. * @param height defines the viewport height
  3374. * @param znear defines the near clip plane
  3375. * @param zfar defines the far clip plane
  3376. * @returns a new matrix as a left-handed perspective projection matrix
  3377. */
  3378. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3379. /**
  3380. * Creates a left-handed perspective projection matrix
  3381. * @param fov defines the horizontal field of view
  3382. * @param aspect defines the aspect ratio
  3383. * @param znear defines the near clip plane
  3384. * @param zfar defines the far clip plane
  3385. * @returns a new matrix as a left-handed perspective projection matrix
  3386. */
  3387. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3388. /**
  3389. * Stores a left-handed perspective projection into a given matrix
  3390. * @param fov defines the horizontal field of view
  3391. * @param aspect defines the aspect ratio
  3392. * @param znear defines the near clip plane
  3393. * @param zfar defines the far clip plane
  3394. * @param result defines the target matrix
  3395. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3396. */
  3397. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3398. /**
  3399. * Creates a right-handed perspective projection matrix
  3400. * @param fov defines the horizontal field of view
  3401. * @param aspect defines the aspect ratio
  3402. * @param znear defines the near clip plane
  3403. * @param zfar defines the far clip plane
  3404. * @returns a new matrix as a right-handed perspective projection matrix
  3405. */
  3406. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3407. /**
  3408. * Stores a right-handed perspective projection into a given matrix
  3409. * @param fov defines the horizontal field of view
  3410. * @param aspect defines the aspect ratio
  3411. * @param znear defines the near clip plane
  3412. * @param zfar defines the far clip plane
  3413. * @param result defines the target matrix
  3414. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3415. */
  3416. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3417. /**
  3418. * Stores a perspective projection for WebVR info a given matrix
  3419. * @param fov defines the field of view
  3420. * @param znear defines the near clip plane
  3421. * @param zfar defines the far clip plane
  3422. * @param result defines the target matrix
  3423. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3424. */
  3425. static PerspectiveFovWebVRToRef(fov: {
  3426. upDegrees: number;
  3427. downDegrees: number;
  3428. leftDegrees: number;
  3429. rightDegrees: number;
  3430. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3431. /**
  3432. * Computes a complete transformation matrix
  3433. * @param viewport defines the viewport to use
  3434. * @param world defines the world matrix
  3435. * @param view defines the view matrix
  3436. * @param projection defines the projection matrix
  3437. * @param zmin defines the near clip plane
  3438. * @param zmax defines the far clip plane
  3439. * @returns the transformation matrix
  3440. */
  3441. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3442. /**
  3443. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3444. * @param matrix defines the matrix to use
  3445. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3446. */
  3447. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3448. /**
  3449. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3450. * @param matrix defines the matrix to use
  3451. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3452. */
  3453. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3454. /**
  3455. * Compute the transpose of a given matrix
  3456. * @param matrix defines the matrix to transpose
  3457. * @returns the new matrix
  3458. */
  3459. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3460. /**
  3461. * Compute the transpose of a matrix and store it in a target matrix
  3462. * @param matrix defines the matrix to transpose
  3463. * @param result defines the target matrix
  3464. */
  3465. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3466. /**
  3467. * Computes a reflection matrix from a plane
  3468. * @param plane defines the reflection plane
  3469. * @returns a new matrix
  3470. */
  3471. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3472. /**
  3473. * Computes a reflection matrix from a plane
  3474. * @param plane defines the reflection plane
  3475. * @param result defines the target matrix
  3476. */
  3477. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3478. /**
  3479. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3480. * @param xaxis defines the value of the 1st axis
  3481. * @param yaxis defines the value of the 2nd axis
  3482. * @param zaxis defines the value of the 3rd axis
  3483. * @param result defines the target matrix
  3484. */
  3485. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3486. /**
  3487. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3488. * @param quat defines the quaternion to use
  3489. * @param result defines the target matrix
  3490. */
  3491. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3492. }
  3493. /**
  3494. * @hidden
  3495. */
  3496. export class TmpVectors {
  3497. static Vector2: Vector2[];
  3498. static Vector3: Vector3[];
  3499. static Vector4: Vector4[];
  3500. static Quaternion: Quaternion[];
  3501. static Matrix: Matrix[];
  3502. }
  3503. }
  3504. declare module BABYLON {
  3505. /**
  3506. * Class used to hold a RBG color
  3507. */
  3508. export class Color3 {
  3509. /**
  3510. * Defines the red component (between 0 and 1, default is 0)
  3511. */
  3512. r: number;
  3513. /**
  3514. * Defines the green component (between 0 and 1, default is 0)
  3515. */
  3516. g: number;
  3517. /**
  3518. * Defines the blue component (between 0 and 1, default is 0)
  3519. */
  3520. b: number;
  3521. /**
  3522. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3523. * @param r defines the red component (between 0 and 1, default is 0)
  3524. * @param g defines the green component (between 0 and 1, default is 0)
  3525. * @param b defines the blue component (between 0 and 1, default is 0)
  3526. */
  3527. constructor(
  3528. /**
  3529. * Defines the red component (between 0 and 1, default is 0)
  3530. */
  3531. r?: number,
  3532. /**
  3533. * Defines the green component (between 0 and 1, default is 0)
  3534. */
  3535. g?: number,
  3536. /**
  3537. * Defines the blue component (between 0 and 1, default is 0)
  3538. */
  3539. b?: number);
  3540. /**
  3541. * Creates a string with the Color3 current values
  3542. * @returns the string representation of the Color3 object
  3543. */
  3544. toString(): string;
  3545. /**
  3546. * Returns the string "Color3"
  3547. * @returns "Color3"
  3548. */
  3549. getClassName(): string;
  3550. /**
  3551. * Compute the Color3 hash code
  3552. * @returns an unique number that can be used to hash Color3 objects
  3553. */
  3554. getHashCode(): number;
  3555. /**
  3556. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3557. * @param array defines the array where to store the r,g,b components
  3558. * @param index defines an optional index in the target array to define where to start storing values
  3559. * @returns the current Color3 object
  3560. */
  3561. toArray(array: FloatArray, index?: number): Color3;
  3562. /**
  3563. * Returns a new Color4 object from the current Color3 and the given alpha
  3564. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3565. * @returns a new Color4 object
  3566. */
  3567. toColor4(alpha?: number): Color4;
  3568. /**
  3569. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3570. * @returns the new array
  3571. */
  3572. asArray(): number[];
  3573. /**
  3574. * Returns the luminance value
  3575. * @returns a float value
  3576. */
  3577. toLuminance(): number;
  3578. /**
  3579. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3580. * @param otherColor defines the second operand
  3581. * @returns the new Color3 object
  3582. */
  3583. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3584. /**
  3585. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3586. * @param otherColor defines the second operand
  3587. * @param result defines the Color3 object where to store the result
  3588. * @returns the current Color3
  3589. */
  3590. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3591. /**
  3592. * Determines equality between Color3 objects
  3593. * @param otherColor defines the second operand
  3594. * @returns true if the rgb values are equal to the given ones
  3595. */
  3596. equals(otherColor: DeepImmutable<Color3>): boolean;
  3597. /**
  3598. * Determines equality between the current Color3 object and a set of r,b,g values
  3599. * @param r defines the red component to check
  3600. * @param g defines the green component to check
  3601. * @param b defines the blue component to check
  3602. * @returns true if the rgb values are equal to the given ones
  3603. */
  3604. equalsFloats(r: number, g: number, b: number): boolean;
  3605. /**
  3606. * Multiplies in place each rgb value by scale
  3607. * @param scale defines the scaling factor
  3608. * @returns the updated Color3
  3609. */
  3610. scale(scale: number): Color3;
  3611. /**
  3612. * Multiplies the rgb values by scale and stores the result into "result"
  3613. * @param scale defines the scaling factor
  3614. * @param result defines the Color3 object where to store the result
  3615. * @returns the unmodified current Color3
  3616. */
  3617. scaleToRef(scale: number, result: Color3): Color3;
  3618. /**
  3619. * Scale the current Color3 values by a factor and add the result to a given Color3
  3620. * @param scale defines the scale factor
  3621. * @param result defines color to store the result into
  3622. * @returns the unmodified current Color3
  3623. */
  3624. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3625. /**
  3626. * Clamps the rgb values by the min and max values and stores the result into "result"
  3627. * @param min defines minimum clamping value (default is 0)
  3628. * @param max defines maximum clamping value (default is 1)
  3629. * @param result defines color to store the result into
  3630. * @returns the original Color3
  3631. */
  3632. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3633. /**
  3634. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3635. * @param otherColor defines the second operand
  3636. * @returns the new Color3
  3637. */
  3638. add(otherColor: DeepImmutable<Color3>): Color3;
  3639. /**
  3640. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3641. * @param otherColor defines the second operand
  3642. * @param result defines Color3 object to store the result into
  3643. * @returns the unmodified current Color3
  3644. */
  3645. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3646. /**
  3647. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3648. * @param otherColor defines the second operand
  3649. * @returns the new Color3
  3650. */
  3651. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3652. /**
  3653. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3654. * @param otherColor defines the second operand
  3655. * @param result defines Color3 object to store the result into
  3656. * @returns the unmodified current Color3
  3657. */
  3658. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3659. /**
  3660. * Copy the current object
  3661. * @returns a new Color3 copied the current one
  3662. */
  3663. clone(): Color3;
  3664. /**
  3665. * Copies the rgb values from the source in the current Color3
  3666. * @param source defines the source Color3 object
  3667. * @returns the updated Color3 object
  3668. */
  3669. copyFrom(source: DeepImmutable<Color3>): Color3;
  3670. /**
  3671. * Updates the Color3 rgb values from the given floats
  3672. * @param r defines the red component to read from
  3673. * @param g defines the green component to read from
  3674. * @param b defines the blue component to read from
  3675. * @returns the current Color3 object
  3676. */
  3677. copyFromFloats(r: number, g: number, b: number): Color3;
  3678. /**
  3679. * Updates the Color3 rgb values from the given floats
  3680. * @param r defines the red component to read from
  3681. * @param g defines the green component to read from
  3682. * @param b defines the blue component to read from
  3683. * @returns the current Color3 object
  3684. */
  3685. set(r: number, g: number, b: number): Color3;
  3686. /**
  3687. * Compute the Color3 hexadecimal code as a string
  3688. * @returns a string containing the hexadecimal representation of the Color3 object
  3689. */
  3690. toHexString(): string;
  3691. /**
  3692. * Computes a new Color3 converted from the current one to linear space
  3693. * @returns a new Color3 object
  3694. */
  3695. toLinearSpace(): Color3;
  3696. /**
  3697. * Converts current color in rgb space to HSV values
  3698. * @returns a new color3 representing the HSV values
  3699. */
  3700. toHSV(): Color3;
  3701. /**
  3702. * Converts current color in rgb space to HSV values
  3703. * @param result defines the Color3 where to store the HSV values
  3704. */
  3705. toHSVToRef(result: Color3): void;
  3706. /**
  3707. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3708. * @param convertedColor defines the Color3 object where to store the linear space version
  3709. * @returns the unmodified Color3
  3710. */
  3711. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3712. /**
  3713. * Computes a new Color3 converted from the current one to gamma space
  3714. * @returns a new Color3 object
  3715. */
  3716. toGammaSpace(): Color3;
  3717. /**
  3718. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3719. * @param convertedColor defines the Color3 object where to store the gamma space version
  3720. * @returns the unmodified Color3
  3721. */
  3722. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3723. private static _BlackReadOnly;
  3724. /**
  3725. * Convert Hue, saturation and value to a Color3 (RGB)
  3726. * @param hue defines the hue
  3727. * @param saturation defines the saturation
  3728. * @param value defines the value
  3729. * @param result defines the Color3 where to store the RGB values
  3730. */
  3731. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3732. /**
  3733. * Creates a new Color3 from the string containing valid hexadecimal values
  3734. * @param hex defines a string containing valid hexadecimal values
  3735. * @returns a new Color3 object
  3736. */
  3737. static FromHexString(hex: string): Color3;
  3738. /**
  3739. * Creates a new Color3 from the starting index of the given array
  3740. * @param array defines the source array
  3741. * @param offset defines an offset in the source array
  3742. * @returns a new Color3 object
  3743. */
  3744. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3745. /**
  3746. * Creates a new Color3 from integer values (< 256)
  3747. * @param r defines the red component to read from (value between 0 and 255)
  3748. * @param g defines the green component to read from (value between 0 and 255)
  3749. * @param b defines the blue component to read from (value between 0 and 255)
  3750. * @returns a new Color3 object
  3751. */
  3752. static FromInts(r: number, g: number, b: number): Color3;
  3753. /**
  3754. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3755. * @param start defines the start Color3 value
  3756. * @param end defines the end Color3 value
  3757. * @param amount defines the gradient value between start and end
  3758. * @returns a new Color3 object
  3759. */
  3760. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3761. /**
  3762. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3763. * @param left defines the start value
  3764. * @param right defines the end value
  3765. * @param amount defines the gradient factor
  3766. * @param result defines the Color3 object where to store the result
  3767. */
  3768. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3769. /**
  3770. * Returns a Color3 value containing a red color
  3771. * @returns a new Color3 object
  3772. */
  3773. static Red(): Color3;
  3774. /**
  3775. * Returns a Color3 value containing a green color
  3776. * @returns a new Color3 object
  3777. */
  3778. static Green(): Color3;
  3779. /**
  3780. * Returns a Color3 value containing a blue color
  3781. * @returns a new Color3 object
  3782. */
  3783. static Blue(): Color3;
  3784. /**
  3785. * Returns a Color3 value containing a black color
  3786. * @returns a new Color3 object
  3787. */
  3788. static Black(): Color3;
  3789. /**
  3790. * Gets a Color3 value containing a black color that must not be updated
  3791. */
  3792. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3793. /**
  3794. * Returns a Color3 value containing a white color
  3795. * @returns a new Color3 object
  3796. */
  3797. static White(): Color3;
  3798. /**
  3799. * Returns a Color3 value containing a purple color
  3800. * @returns a new Color3 object
  3801. */
  3802. static Purple(): Color3;
  3803. /**
  3804. * Returns a Color3 value containing a magenta color
  3805. * @returns a new Color3 object
  3806. */
  3807. static Magenta(): Color3;
  3808. /**
  3809. * Returns a Color3 value containing a yellow color
  3810. * @returns a new Color3 object
  3811. */
  3812. static Yellow(): Color3;
  3813. /**
  3814. * Returns a Color3 value containing a gray color
  3815. * @returns a new Color3 object
  3816. */
  3817. static Gray(): Color3;
  3818. /**
  3819. * Returns a Color3 value containing a teal color
  3820. * @returns a new Color3 object
  3821. */
  3822. static Teal(): Color3;
  3823. /**
  3824. * Returns a Color3 value containing a random color
  3825. * @returns a new Color3 object
  3826. */
  3827. static Random(): Color3;
  3828. }
  3829. /**
  3830. * Class used to hold a RBGA color
  3831. */
  3832. export class Color4 {
  3833. /**
  3834. * Defines the red component (between 0 and 1, default is 0)
  3835. */
  3836. r: number;
  3837. /**
  3838. * Defines the green component (between 0 and 1, default is 0)
  3839. */
  3840. g: number;
  3841. /**
  3842. * Defines the blue component (between 0 and 1, default is 0)
  3843. */
  3844. b: number;
  3845. /**
  3846. * Defines the alpha component (between 0 and 1, default is 1)
  3847. */
  3848. a: number;
  3849. /**
  3850. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3851. * @param r defines the red component (between 0 and 1, default is 0)
  3852. * @param g defines the green component (between 0 and 1, default is 0)
  3853. * @param b defines the blue component (between 0 and 1, default is 0)
  3854. * @param a defines the alpha component (between 0 and 1, default is 1)
  3855. */
  3856. constructor(
  3857. /**
  3858. * Defines the red component (between 0 and 1, default is 0)
  3859. */
  3860. r?: number,
  3861. /**
  3862. * Defines the green component (between 0 and 1, default is 0)
  3863. */
  3864. g?: number,
  3865. /**
  3866. * Defines the blue component (between 0 and 1, default is 0)
  3867. */
  3868. b?: number,
  3869. /**
  3870. * Defines the alpha component (between 0 and 1, default is 1)
  3871. */
  3872. a?: number);
  3873. /**
  3874. * Adds in place the given Color4 values to the current Color4 object
  3875. * @param right defines the second operand
  3876. * @returns the current updated Color4 object
  3877. */
  3878. addInPlace(right: DeepImmutable<Color4>): Color4;
  3879. /**
  3880. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3881. * @returns the new array
  3882. */
  3883. asArray(): number[];
  3884. /**
  3885. * Stores from the starting index in the given array the Color4 successive values
  3886. * @param array defines the array where to store the r,g,b components
  3887. * @param index defines an optional index in the target array to define where to start storing values
  3888. * @returns the current Color4 object
  3889. */
  3890. toArray(array: number[], index?: number): Color4;
  3891. /**
  3892. * Determines equality between Color4 objects
  3893. * @param otherColor defines the second operand
  3894. * @returns true if the rgba values are equal to the given ones
  3895. */
  3896. equals(otherColor: DeepImmutable<Color4>): boolean;
  3897. /**
  3898. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3899. * @param right defines the second operand
  3900. * @returns a new Color4 object
  3901. */
  3902. add(right: DeepImmutable<Color4>): Color4;
  3903. /**
  3904. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3905. * @param right defines the second operand
  3906. * @returns a new Color4 object
  3907. */
  3908. subtract(right: DeepImmutable<Color4>): Color4;
  3909. /**
  3910. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3911. * @param right defines the second operand
  3912. * @param result defines the Color4 object where to store the result
  3913. * @returns the current Color4 object
  3914. */
  3915. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3916. /**
  3917. * Creates a new Color4 with the current Color4 values multiplied by scale
  3918. * @param scale defines the scaling factor to apply
  3919. * @returns a new Color4 object
  3920. */
  3921. scale(scale: number): Color4;
  3922. /**
  3923. * Multiplies the current Color4 values by scale and stores the result in "result"
  3924. * @param scale defines the scaling factor to apply
  3925. * @param result defines the Color4 object where to store the result
  3926. * @returns the current unmodified Color4
  3927. */
  3928. scaleToRef(scale: number, result: Color4): Color4;
  3929. /**
  3930. * Scale the current Color4 values by a factor and add the result to a given Color4
  3931. * @param scale defines the scale factor
  3932. * @param result defines the Color4 object where to store the result
  3933. * @returns the unmodified current Color4
  3934. */
  3935. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3936. /**
  3937. * Clamps the rgb values by the min and max values and stores the result into "result"
  3938. * @param min defines minimum clamping value (default is 0)
  3939. * @param max defines maximum clamping value (default is 1)
  3940. * @param result defines color to store the result into.
  3941. * @returns the cuurent Color4
  3942. */
  3943. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3944. /**
  3945. * Multipy an Color4 value by another and return a new Color4 object
  3946. * @param color defines the Color4 value to multiply by
  3947. * @returns a new Color4 object
  3948. */
  3949. multiply(color: Color4): Color4;
  3950. /**
  3951. * Multipy a Color4 value by another and push the result in a reference value
  3952. * @param color defines the Color4 value to multiply by
  3953. * @param result defines the Color4 to fill the result in
  3954. * @returns the result Color4
  3955. */
  3956. multiplyToRef(color: Color4, result: Color4): Color4;
  3957. /**
  3958. * Creates a string with the Color4 current values
  3959. * @returns the string representation of the Color4 object
  3960. */
  3961. toString(): string;
  3962. /**
  3963. * Returns the string "Color4"
  3964. * @returns "Color4"
  3965. */
  3966. getClassName(): string;
  3967. /**
  3968. * Compute the Color4 hash code
  3969. * @returns an unique number that can be used to hash Color4 objects
  3970. */
  3971. getHashCode(): number;
  3972. /**
  3973. * Creates a new Color4 copied from the current one
  3974. * @returns a new Color4 object
  3975. */
  3976. clone(): Color4;
  3977. /**
  3978. * Copies the given Color4 values into the current one
  3979. * @param source defines the source Color4 object
  3980. * @returns the current updated Color4 object
  3981. */
  3982. copyFrom(source: Color4): Color4;
  3983. /**
  3984. * Copies the given float values into the current one
  3985. * @param r defines the red component to read from
  3986. * @param g defines the green component to read from
  3987. * @param b defines the blue component to read from
  3988. * @param a defines the alpha component to read from
  3989. * @returns the current updated Color4 object
  3990. */
  3991. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  3992. /**
  3993. * Copies the given float values into the current one
  3994. * @param r defines the red component to read from
  3995. * @param g defines the green component to read from
  3996. * @param b defines the blue component to read from
  3997. * @param a defines the alpha component to read from
  3998. * @returns the current updated Color4 object
  3999. */
  4000. set(r: number, g: number, b: number, a: number): Color4;
  4001. /**
  4002. * Compute the Color4 hexadecimal code as a string
  4003. * @returns a string containing the hexadecimal representation of the Color4 object
  4004. */
  4005. toHexString(): string;
  4006. /**
  4007. * Computes a new Color4 converted from the current one to linear space
  4008. * @returns a new Color4 object
  4009. */
  4010. toLinearSpace(): Color4;
  4011. /**
  4012. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4013. * @param convertedColor defines the Color4 object where to store the linear space version
  4014. * @returns the unmodified Color4
  4015. */
  4016. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4017. /**
  4018. * Computes a new Color4 converted from the current one to gamma space
  4019. * @returns a new Color4 object
  4020. */
  4021. toGammaSpace(): Color4;
  4022. /**
  4023. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4024. * @param convertedColor defines the Color4 object where to store the gamma space version
  4025. * @returns the unmodified Color4
  4026. */
  4027. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4028. /**
  4029. * Creates a new Color4 from the string containing valid hexadecimal values
  4030. * @param hex defines a string containing valid hexadecimal values
  4031. * @returns a new Color4 object
  4032. */
  4033. static FromHexString(hex: string): Color4;
  4034. /**
  4035. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4036. * @param left defines the start value
  4037. * @param right defines the end value
  4038. * @param amount defines the gradient factor
  4039. * @returns a new Color4 object
  4040. */
  4041. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4042. /**
  4043. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4044. * @param left defines the start value
  4045. * @param right defines the end value
  4046. * @param amount defines the gradient factor
  4047. * @param result defines the Color4 object where to store data
  4048. */
  4049. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4050. /**
  4051. * Creates a new Color4 from a Color3 and an alpha value
  4052. * @param color3 defines the source Color3 to read from
  4053. * @param alpha defines the alpha component (1.0 by default)
  4054. * @returns a new Color4 object
  4055. */
  4056. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4057. /**
  4058. * Creates a new Color4 from the starting index element of the given array
  4059. * @param array defines the source array to read from
  4060. * @param offset defines the offset in the source array
  4061. * @returns a new Color4 object
  4062. */
  4063. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4064. /**
  4065. * Creates a new Color3 from integer values (< 256)
  4066. * @param r defines the red component to read from (value between 0 and 255)
  4067. * @param g defines the green component to read from (value between 0 and 255)
  4068. * @param b defines the blue component to read from (value between 0 and 255)
  4069. * @param a defines the alpha component to read from (value between 0 and 255)
  4070. * @returns a new Color3 object
  4071. */
  4072. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4073. /**
  4074. * Check the content of a given array and convert it to an array containing RGBA data
  4075. * If the original array was already containing count * 4 values then it is returned directly
  4076. * @param colors defines the array to check
  4077. * @param count defines the number of RGBA data to expect
  4078. * @returns an array containing count * 4 values (RGBA)
  4079. */
  4080. static CheckColors4(colors: number[], count: number): number[];
  4081. }
  4082. /**
  4083. * @hidden
  4084. */
  4085. export class TmpColors {
  4086. static Color3: Color3[];
  4087. static Color4: Color4[];
  4088. }
  4089. }
  4090. declare module BABYLON {
  4091. /**
  4092. * Class representing spherical harmonics coefficients to the 3rd degree
  4093. */
  4094. export class SphericalHarmonics {
  4095. /**
  4096. * Defines whether or not the harmonics have been prescaled for rendering.
  4097. */
  4098. preScaled: boolean;
  4099. /**
  4100. * The l0,0 coefficients of the spherical harmonics
  4101. */
  4102. l00: Vector3;
  4103. /**
  4104. * The l1,-1 coefficients of the spherical harmonics
  4105. */
  4106. l1_1: Vector3;
  4107. /**
  4108. * The l1,0 coefficients of the spherical harmonics
  4109. */
  4110. l10: Vector3;
  4111. /**
  4112. * The l1,1 coefficients of the spherical harmonics
  4113. */
  4114. l11: Vector3;
  4115. /**
  4116. * The l2,-2 coefficients of the spherical harmonics
  4117. */
  4118. l2_2: Vector3;
  4119. /**
  4120. * The l2,-1 coefficients of the spherical harmonics
  4121. */
  4122. l2_1: Vector3;
  4123. /**
  4124. * The l2,0 coefficients of the spherical harmonics
  4125. */
  4126. l20: Vector3;
  4127. /**
  4128. * The l2,1 coefficients of the spherical harmonics
  4129. */
  4130. l21: Vector3;
  4131. /**
  4132. * The l2,2 coefficients of the spherical harmonics
  4133. */
  4134. l22: Vector3;
  4135. /**
  4136. * Adds a light to the spherical harmonics
  4137. * @param direction the direction of the light
  4138. * @param color the color of the light
  4139. * @param deltaSolidAngle the delta solid angle of the light
  4140. */
  4141. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4142. /**
  4143. * Scales the spherical harmonics by the given amount
  4144. * @param scale the amount to scale
  4145. */
  4146. scaleInPlace(scale: number): void;
  4147. /**
  4148. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4149. *
  4150. * ```
  4151. * E_lm = A_l * L_lm
  4152. * ```
  4153. *
  4154. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4155. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4156. * the scaling factors are given in equation 9.
  4157. */
  4158. convertIncidentRadianceToIrradiance(): void;
  4159. /**
  4160. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4161. *
  4162. * ```
  4163. * L = (1/pi) * E * rho
  4164. * ```
  4165. *
  4166. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4167. */
  4168. convertIrradianceToLambertianRadiance(): void;
  4169. /**
  4170. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4171. * required operations at run time.
  4172. *
  4173. * This is simply done by scaling back the SH with Ylm constants parameter.
  4174. * The trigonometric part being applied by the shader at run time.
  4175. */
  4176. preScaleForRendering(): void;
  4177. /**
  4178. * Constructs a spherical harmonics from an array.
  4179. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4180. * @returns the spherical harmonics
  4181. */
  4182. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4183. /**
  4184. * Gets the spherical harmonics from polynomial
  4185. * @param polynomial the spherical polynomial
  4186. * @returns the spherical harmonics
  4187. */
  4188. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4189. }
  4190. /**
  4191. * Class representing spherical polynomial coefficients to the 3rd degree
  4192. */
  4193. export class SphericalPolynomial {
  4194. private _harmonics;
  4195. /**
  4196. * The spherical harmonics used to create the polynomials.
  4197. */
  4198. readonly preScaledHarmonics: SphericalHarmonics;
  4199. /**
  4200. * The x coefficients of the spherical polynomial
  4201. */
  4202. x: Vector3;
  4203. /**
  4204. * The y coefficients of the spherical polynomial
  4205. */
  4206. y: Vector3;
  4207. /**
  4208. * The z coefficients of the spherical polynomial
  4209. */
  4210. z: Vector3;
  4211. /**
  4212. * The xx coefficients of the spherical polynomial
  4213. */
  4214. xx: Vector3;
  4215. /**
  4216. * The yy coefficients of the spherical polynomial
  4217. */
  4218. yy: Vector3;
  4219. /**
  4220. * The zz coefficients of the spherical polynomial
  4221. */
  4222. zz: Vector3;
  4223. /**
  4224. * The xy coefficients of the spherical polynomial
  4225. */
  4226. xy: Vector3;
  4227. /**
  4228. * The yz coefficients of the spherical polynomial
  4229. */
  4230. yz: Vector3;
  4231. /**
  4232. * The zx coefficients of the spherical polynomial
  4233. */
  4234. zx: Vector3;
  4235. /**
  4236. * Adds an ambient color to the spherical polynomial
  4237. * @param color the color to add
  4238. */
  4239. addAmbient(color: Color3): void;
  4240. /**
  4241. * Scales the spherical polynomial by the given amount
  4242. * @param scale the amount to scale
  4243. */
  4244. scaleInPlace(scale: number): void;
  4245. /**
  4246. * Gets the spherical polynomial from harmonics
  4247. * @param harmonics the spherical harmonics
  4248. * @returns the spherical polynomial
  4249. */
  4250. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4251. /**
  4252. * Constructs a spherical polynomial from an array.
  4253. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4254. * @returns the spherical polynomial
  4255. */
  4256. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4257. }
  4258. }
  4259. declare module BABYLON {
  4260. /**
  4261. * Define options used to create a render target texture
  4262. */
  4263. export class RenderTargetCreationOptions {
  4264. /**
  4265. * Specifies is mipmaps must be generated
  4266. */
  4267. generateMipMaps?: boolean;
  4268. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4269. generateDepthBuffer?: boolean;
  4270. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4271. generateStencilBuffer?: boolean;
  4272. /** Defines texture type (int by default) */
  4273. type?: number;
  4274. /** Defines sampling mode (trilinear by default) */
  4275. samplingMode?: number;
  4276. /** Defines format (RGBA by default) */
  4277. format?: number;
  4278. }
  4279. }
  4280. declare module BABYLON {
  4281. /**
  4282. * @hidden
  4283. **/
  4284. export class _AlphaState {
  4285. private _isAlphaBlendDirty;
  4286. private _isBlendFunctionParametersDirty;
  4287. private _isBlendEquationParametersDirty;
  4288. private _isBlendConstantsDirty;
  4289. private _alphaBlend;
  4290. private _blendFunctionParameters;
  4291. private _blendEquationParameters;
  4292. private _blendConstants;
  4293. /**
  4294. * Initializes the state.
  4295. */
  4296. constructor();
  4297. readonly isDirty: boolean;
  4298. alphaBlend: boolean;
  4299. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  4300. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  4301. setAlphaEquationParameters(rgb: number, alpha: number): void;
  4302. reset(): void;
  4303. apply(gl: WebGLRenderingContext): void;
  4304. }
  4305. }
  4306. declare module BABYLON {
  4307. /**
  4308. * @hidden
  4309. **/
  4310. export class _DepthCullingState {
  4311. private _isDepthTestDirty;
  4312. private _isDepthMaskDirty;
  4313. private _isDepthFuncDirty;
  4314. private _isCullFaceDirty;
  4315. private _isCullDirty;
  4316. private _isZOffsetDirty;
  4317. private _isFrontFaceDirty;
  4318. private _depthTest;
  4319. private _depthMask;
  4320. private _depthFunc;
  4321. private _cull;
  4322. private _cullFace;
  4323. private _zOffset;
  4324. private _frontFace;
  4325. /**
  4326. * Initializes the state.
  4327. */
  4328. constructor();
  4329. readonly isDirty: boolean;
  4330. zOffset: number;
  4331. cullFace: Nullable<number>;
  4332. cull: Nullable<boolean>;
  4333. depthFunc: Nullable<number>;
  4334. depthMask: boolean;
  4335. depthTest: boolean;
  4336. frontFace: Nullable<number>;
  4337. reset(): void;
  4338. apply(gl: WebGLRenderingContext): void;
  4339. }
  4340. }
  4341. declare module BABYLON {
  4342. /** Defines the cross module used constants to avoid circular dependncies */
  4343. export class Constants {
  4344. /** Defines that alpha blending is disabled */
  4345. static readonly ALPHA_DISABLE: number;
  4346. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4347. static readonly ALPHA_ADD: number;
  4348. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4349. static readonly ALPHA_COMBINE: number;
  4350. /** Defines that alpha blending to DEST - SRC * DEST */
  4351. static readonly ALPHA_SUBTRACT: number;
  4352. /** Defines that alpha blending to SRC * DEST */
  4353. static readonly ALPHA_MULTIPLY: number;
  4354. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4355. static readonly ALPHA_MAXIMIZED: number;
  4356. /** Defines that alpha blending to SRC + DEST */
  4357. static readonly ALPHA_ONEONE: number;
  4358. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4359. static readonly ALPHA_PREMULTIPLIED: number;
  4360. /**
  4361. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4362. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4363. */
  4364. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4365. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4366. static readonly ALPHA_INTERPOLATE: number;
  4367. /**
  4368. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4369. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4370. */
  4371. static readonly ALPHA_SCREENMODE: number;
  4372. /**
  4373. * Defines that alpha blending to SRC + DST
  4374. * Alpha will be set to SRC ALPHA + DST ALPHA
  4375. */
  4376. static readonly ALPHA_ONEONE_ONEONE: number;
  4377. /**
  4378. * Defines that alpha blending to SRC * DST ALPHA + DST
  4379. * Alpha will be set to 0
  4380. */
  4381. static readonly ALPHA_ALPHATOCOLOR: number;
  4382. /**
  4383. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4384. */
  4385. static readonly ALPHA_REVERSEONEMINUS: number;
  4386. /**
  4387. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4388. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4389. */
  4390. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4391. /**
  4392. * Defines that alpha blending to SRC + DST
  4393. * Alpha will be set to SRC ALPHA
  4394. */
  4395. static readonly ALPHA_ONEONE_ONEZERO: number;
  4396. /** Defines that alpha blending equation a SUM */
  4397. static readonly ALPHA_EQUATION_ADD: number;
  4398. /** Defines that alpha blending equation a SUBSTRACTION */
  4399. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4400. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4401. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4402. /** Defines that alpha blending equation a MAX operation */
  4403. static readonly ALPHA_EQUATION_MAX: number;
  4404. /** Defines that alpha blending equation a MIN operation */
  4405. static readonly ALPHA_EQUATION_MIN: number;
  4406. /**
  4407. * Defines that alpha blending equation a DARKEN operation:
  4408. * It takes the min of the src and sums the alpha channels.
  4409. */
  4410. static readonly ALPHA_EQUATION_DARKEN: number;
  4411. /** Defines that the ressource is not delayed*/
  4412. static readonly DELAYLOADSTATE_NONE: number;
  4413. /** Defines that the ressource was successfully delay loaded */
  4414. static readonly DELAYLOADSTATE_LOADED: number;
  4415. /** Defines that the ressource is currently delay loading */
  4416. static readonly DELAYLOADSTATE_LOADING: number;
  4417. /** Defines that the ressource is delayed and has not started loading */
  4418. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4419. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4420. static readonly NEVER: number;
  4421. /** 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 */
  4422. static readonly ALWAYS: number;
  4423. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4424. static readonly LESS: number;
  4425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4426. static readonly EQUAL: number;
  4427. /** 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 */
  4428. static readonly LEQUAL: number;
  4429. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4430. static readonly GREATER: number;
  4431. /** 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 */
  4432. static readonly GEQUAL: number;
  4433. /** 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 */
  4434. static readonly NOTEQUAL: number;
  4435. /** Passed to stencilOperation to specify that stencil value must be kept */
  4436. static readonly KEEP: number;
  4437. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4438. static readonly REPLACE: number;
  4439. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4440. static readonly INCR: number;
  4441. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4442. static readonly DECR: number;
  4443. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4444. static readonly INVERT: number;
  4445. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4446. static readonly INCR_WRAP: number;
  4447. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4448. static readonly DECR_WRAP: number;
  4449. /** Texture is not repeating outside of 0..1 UVs */
  4450. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4451. /** Texture is repeating outside of 0..1 UVs */
  4452. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4453. /** Texture is repeating and mirrored */
  4454. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4455. /** ALPHA */
  4456. static readonly TEXTUREFORMAT_ALPHA: number;
  4457. /** LUMINANCE */
  4458. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4459. /** LUMINANCE_ALPHA */
  4460. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4461. /** RGB */
  4462. static readonly TEXTUREFORMAT_RGB: number;
  4463. /** RGBA */
  4464. static readonly TEXTUREFORMAT_RGBA: number;
  4465. /** RED */
  4466. static readonly TEXTUREFORMAT_RED: number;
  4467. /** RED (2nd reference) */
  4468. static readonly TEXTUREFORMAT_R: number;
  4469. /** RG */
  4470. static readonly TEXTUREFORMAT_RG: number;
  4471. /** RED_INTEGER */
  4472. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4473. /** RED_INTEGER (2nd reference) */
  4474. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4475. /** RG_INTEGER */
  4476. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4477. /** RGB_INTEGER */
  4478. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4479. /** RGBA_INTEGER */
  4480. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4481. /** UNSIGNED_BYTE */
  4482. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4483. /** UNSIGNED_BYTE (2nd reference) */
  4484. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4485. /** FLOAT */
  4486. static readonly TEXTURETYPE_FLOAT: number;
  4487. /** HALF_FLOAT */
  4488. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4489. /** BYTE */
  4490. static readonly TEXTURETYPE_BYTE: number;
  4491. /** SHORT */
  4492. static readonly TEXTURETYPE_SHORT: number;
  4493. /** UNSIGNED_SHORT */
  4494. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4495. /** INT */
  4496. static readonly TEXTURETYPE_INT: number;
  4497. /** UNSIGNED_INT */
  4498. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4499. /** UNSIGNED_SHORT_4_4_4_4 */
  4500. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4501. /** UNSIGNED_SHORT_5_5_5_1 */
  4502. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4503. /** UNSIGNED_SHORT_5_6_5 */
  4504. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4505. /** UNSIGNED_INT_2_10_10_10_REV */
  4506. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4507. /** UNSIGNED_INT_24_8 */
  4508. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4509. /** UNSIGNED_INT_10F_11F_11F_REV */
  4510. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4511. /** UNSIGNED_INT_5_9_9_9_REV */
  4512. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4513. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4514. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4515. /** nearest is mag = nearest and min = nearest and mip = linear */
  4516. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4517. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4518. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4519. /** Trilinear is mag = linear and min = linear and mip = linear */
  4520. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4521. /** nearest is mag = nearest and min = nearest and mip = linear */
  4522. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4524. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4525. /** Trilinear is mag = linear and min = linear and mip = linear */
  4526. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4527. /** mag = nearest and min = nearest and mip = nearest */
  4528. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4529. /** mag = nearest and min = linear and mip = nearest */
  4530. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4531. /** mag = nearest and min = linear and mip = linear */
  4532. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4533. /** mag = nearest and min = linear and mip = none */
  4534. static readonly TEXTURE_NEAREST_LINEAR: number;
  4535. /** mag = nearest and min = nearest and mip = none */
  4536. static readonly TEXTURE_NEAREST_NEAREST: number;
  4537. /** mag = linear and min = nearest and mip = nearest */
  4538. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4539. /** mag = linear and min = nearest and mip = linear */
  4540. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4541. /** mag = linear and min = linear and mip = none */
  4542. static readonly TEXTURE_LINEAR_LINEAR: number;
  4543. /** mag = linear and min = nearest and mip = none */
  4544. static readonly TEXTURE_LINEAR_NEAREST: number;
  4545. /** Explicit coordinates mode */
  4546. static readonly TEXTURE_EXPLICIT_MODE: number;
  4547. /** Spherical coordinates mode */
  4548. static readonly TEXTURE_SPHERICAL_MODE: number;
  4549. /** Planar coordinates mode */
  4550. static readonly TEXTURE_PLANAR_MODE: number;
  4551. /** Cubic coordinates mode */
  4552. static readonly TEXTURE_CUBIC_MODE: number;
  4553. /** Projection coordinates mode */
  4554. static readonly TEXTURE_PROJECTION_MODE: number;
  4555. /** Skybox coordinates mode */
  4556. static readonly TEXTURE_SKYBOX_MODE: number;
  4557. /** Inverse Cubic coordinates mode */
  4558. static readonly TEXTURE_INVCUBIC_MODE: number;
  4559. /** Equirectangular coordinates mode */
  4560. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4561. /** Equirectangular Fixed coordinates mode */
  4562. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4563. /** Equirectangular Fixed Mirrored coordinates mode */
  4564. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4565. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4566. static readonly SCALEMODE_FLOOR: number;
  4567. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4568. static readonly SCALEMODE_NEAREST: number;
  4569. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4570. static readonly SCALEMODE_CEILING: number;
  4571. /**
  4572. * The dirty texture flag value
  4573. */
  4574. static readonly MATERIAL_TextureDirtyFlag: number;
  4575. /**
  4576. * The dirty light flag value
  4577. */
  4578. static readonly MATERIAL_LightDirtyFlag: number;
  4579. /**
  4580. * The dirty fresnel flag value
  4581. */
  4582. static readonly MATERIAL_FresnelDirtyFlag: number;
  4583. /**
  4584. * The dirty attribute flag value
  4585. */
  4586. static readonly MATERIAL_AttributesDirtyFlag: number;
  4587. /**
  4588. * The dirty misc flag value
  4589. */
  4590. static readonly MATERIAL_MiscDirtyFlag: number;
  4591. /**
  4592. * The all dirty flag value
  4593. */
  4594. static readonly MATERIAL_AllDirtyFlag: number;
  4595. /**
  4596. * Returns the triangle fill mode
  4597. */
  4598. static readonly MATERIAL_TriangleFillMode: number;
  4599. /**
  4600. * Returns the wireframe mode
  4601. */
  4602. static readonly MATERIAL_WireFrameFillMode: number;
  4603. /**
  4604. * Returns the point fill mode
  4605. */
  4606. static readonly MATERIAL_PointFillMode: number;
  4607. /**
  4608. * Returns the point list draw mode
  4609. */
  4610. static readonly MATERIAL_PointListDrawMode: number;
  4611. /**
  4612. * Returns the line list draw mode
  4613. */
  4614. static readonly MATERIAL_LineListDrawMode: number;
  4615. /**
  4616. * Returns the line loop draw mode
  4617. */
  4618. static readonly MATERIAL_LineLoopDrawMode: number;
  4619. /**
  4620. * Returns the line strip draw mode
  4621. */
  4622. static readonly MATERIAL_LineStripDrawMode: number;
  4623. /**
  4624. * Returns the triangle strip draw mode
  4625. */
  4626. static readonly MATERIAL_TriangleStripDrawMode: number;
  4627. /**
  4628. * Returns the triangle fan draw mode
  4629. */
  4630. static readonly MATERIAL_TriangleFanDrawMode: number;
  4631. /**
  4632. * Stores the clock-wise side orientation
  4633. */
  4634. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4635. /**
  4636. * Stores the counter clock-wise side orientation
  4637. */
  4638. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4639. /**
  4640. * Nothing
  4641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4642. */
  4643. static readonly ACTION_NothingTrigger: number;
  4644. /**
  4645. * On pick
  4646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4647. */
  4648. static readonly ACTION_OnPickTrigger: number;
  4649. /**
  4650. * On left pick
  4651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4652. */
  4653. static readonly ACTION_OnLeftPickTrigger: number;
  4654. /**
  4655. * On right pick
  4656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4657. */
  4658. static readonly ACTION_OnRightPickTrigger: number;
  4659. /**
  4660. * On center pick
  4661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4662. */
  4663. static readonly ACTION_OnCenterPickTrigger: number;
  4664. /**
  4665. * On pick down
  4666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4667. */
  4668. static readonly ACTION_OnPickDownTrigger: number;
  4669. /**
  4670. * On double pick
  4671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4672. */
  4673. static readonly ACTION_OnDoublePickTrigger: number;
  4674. /**
  4675. * On pick up
  4676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4677. */
  4678. static readonly ACTION_OnPickUpTrigger: number;
  4679. /**
  4680. * On pick out.
  4681. * This trigger will only be raised if you also declared a OnPickDown
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_OnPickOutTrigger: number;
  4685. /**
  4686. * On long press
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnLongPressTrigger: number;
  4690. /**
  4691. * On pointer over
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnPointerOverTrigger: number;
  4695. /**
  4696. * On pointer out
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPointerOutTrigger: number;
  4700. /**
  4701. * On every frame
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnEveryFrameTrigger: number;
  4705. /**
  4706. * On intersection enter
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4710. /**
  4711. * On intersection exit
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnIntersectionExitTrigger: number;
  4715. /**
  4716. * On key down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnKeyDownTrigger: number;
  4720. /**
  4721. * On key up
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnKeyUpTrigger: number;
  4725. /**
  4726. * Billboard mode will only apply to Y axis
  4727. */
  4728. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4729. /**
  4730. * Billboard mode will apply to all axes
  4731. */
  4732. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4733. /**
  4734. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4735. */
  4736. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4737. /**
  4738. * Gets or sets base Assets URL
  4739. */
  4740. static PARTICLES_BaseAssetsUrl: string;
  4741. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4742. * Test order :
  4743. * Is the bounding sphere outside the frustum ?
  4744. * If not, are the bounding box vertices outside the frustum ?
  4745. * It not, then the cullable object is in the frustum.
  4746. */
  4747. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4748. /** Culling strategy : Bounding Sphere Only.
  4749. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4750. * It's also less accurate than the standard because some not visible objects can still be selected.
  4751. * Test : is the bounding sphere outside the frustum ?
  4752. * If not, then the cullable object is in the frustum.
  4753. */
  4754. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4755. /** Culling strategy : Optimistic Inclusion.
  4756. * This in an inclusion test first, then the standard exclusion test.
  4757. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4758. * 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.
  4759. * Anyway, it's as accurate as the standard strategy.
  4760. * Test :
  4761. * Is the cullable object bounding sphere center in the frustum ?
  4762. * If not, apply the default culling strategy.
  4763. */
  4764. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4765. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4766. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4767. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4768. * 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.
  4769. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4770. * Test :
  4771. * Is the cullable object bounding sphere center in the frustum ?
  4772. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4773. */
  4774. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4775. /**
  4776. * No logging while loading
  4777. */
  4778. static readonly SCENELOADER_NO_LOGGING: number;
  4779. /**
  4780. * Minimal logging while loading
  4781. */
  4782. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4783. /**
  4784. * Summary logging while loading
  4785. */
  4786. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4787. /**
  4788. * Detailled logging while loading
  4789. */
  4790. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4791. }
  4792. }
  4793. declare module BABYLON {
  4794. /**
  4795. * @hidden
  4796. **/
  4797. export class _StencilState {
  4798. /** 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 */
  4799. static readonly ALWAYS: number;
  4800. /** Passed to stencilOperation to specify that stencil value must be kept */
  4801. static readonly KEEP: number;
  4802. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4803. static readonly REPLACE: number;
  4804. private _isStencilTestDirty;
  4805. private _isStencilMaskDirty;
  4806. private _isStencilFuncDirty;
  4807. private _isStencilOpDirty;
  4808. private _stencilTest;
  4809. private _stencilMask;
  4810. private _stencilFunc;
  4811. private _stencilFuncRef;
  4812. private _stencilFuncMask;
  4813. private _stencilOpStencilFail;
  4814. private _stencilOpDepthFail;
  4815. private _stencilOpStencilDepthPass;
  4816. readonly isDirty: boolean;
  4817. stencilFunc: number;
  4818. stencilFuncRef: number;
  4819. stencilFuncMask: number;
  4820. stencilOpStencilFail: number;
  4821. stencilOpDepthFail: number;
  4822. stencilOpStencilDepthPass: number;
  4823. stencilMask: number;
  4824. stencilTest: boolean;
  4825. constructor();
  4826. reset(): void;
  4827. apply(gl: WebGLRenderingContext): void;
  4828. }
  4829. }
  4830. declare module BABYLON {
  4831. /**
  4832. * @hidden
  4833. **/
  4834. export class _TimeToken {
  4835. _startTimeQuery: Nullable<WebGLQuery>;
  4836. _endTimeQuery: Nullable<WebGLQuery>;
  4837. _timeElapsedQuery: Nullable<WebGLQuery>;
  4838. _timeElapsedQueryEnded: boolean;
  4839. }
  4840. }
  4841. declare module BABYLON {
  4842. /**
  4843. * This represents the required contract to create a new type of texture loader.
  4844. */
  4845. export interface IInternalTextureLoader {
  4846. /**
  4847. * Defines wether the loader supports cascade loading the different faces.
  4848. */
  4849. supportCascades: boolean;
  4850. /**
  4851. * This returns if the loader support the current file information.
  4852. * @param extension defines the file extension of the file being loaded
  4853. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4854. * @param fallback defines the fallback internal texture if any
  4855. * @param isBase64 defines whether the texture is encoded as a base64
  4856. * @param isBuffer defines whether the texture data are stored as a buffer
  4857. * @returns true if the loader can load the specified file
  4858. */
  4859. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4860. /**
  4861. * Transform the url before loading if required.
  4862. * @param rootUrl the url of the texture
  4863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4864. * @returns the transformed texture
  4865. */
  4866. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4867. /**
  4868. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4869. * @param rootUrl the url of the texture
  4870. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4871. * @returns the fallback texture
  4872. */
  4873. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4874. /**
  4875. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4876. * @param data contains the texture data
  4877. * @param texture defines the BabylonJS internal texture
  4878. * @param createPolynomials will be true if polynomials have been requested
  4879. * @param onLoad defines the callback to trigger once the texture is ready
  4880. * @param onError defines the callback to trigger in case of error
  4881. */
  4882. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4883. /**
  4884. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4885. * @param data contains the texture data
  4886. * @param texture defines the BabylonJS internal texture
  4887. * @param callback defines the method to call once ready to upload
  4888. */
  4889. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4890. }
  4891. }
  4892. declare module BABYLON {
  4893. /**
  4894. * Class used to store and describe the pipeline context associated with an effect
  4895. */
  4896. export interface IPipelineContext {
  4897. /**
  4898. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4899. */
  4900. isAsync: boolean;
  4901. /**
  4902. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4903. */
  4904. isReady: boolean;
  4905. /** @hidden */
  4906. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4907. }
  4908. }
  4909. declare module BABYLON {
  4910. /**
  4911. * Class used to store gfx data (like WebGLBuffer)
  4912. */
  4913. export class DataBuffer {
  4914. /**
  4915. * Gets or sets the number of objects referencing this buffer
  4916. */
  4917. references: number;
  4918. /** Gets or sets the size of the underlying buffer */
  4919. capacity: number;
  4920. /**
  4921. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4922. */
  4923. is32Bits: boolean;
  4924. /**
  4925. * Gets the underlying buffer
  4926. */
  4927. readonly underlyingResource: any;
  4928. }
  4929. }
  4930. declare module BABYLON {
  4931. /** @hidden */
  4932. export interface IShaderProcessor {
  4933. attributeProcessor?: (attribute: string) => string;
  4934. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4935. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4936. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4937. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4938. lineProcessor?: (line: string, isFragment: boolean) => string;
  4939. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4940. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4941. }
  4942. }
  4943. declare module BABYLON {
  4944. /** @hidden */
  4945. export interface ProcessingOptions {
  4946. defines: string[];
  4947. indexParameters: any;
  4948. isFragment: boolean;
  4949. shouldUseHighPrecisionShader: boolean;
  4950. supportsUniformBuffers: boolean;
  4951. shadersRepository: string;
  4952. includesShadersStore: {
  4953. [key: string]: string;
  4954. };
  4955. processor?: IShaderProcessor;
  4956. version: string;
  4957. platformName: string;
  4958. lookForClosingBracketForUniformBuffer?: boolean;
  4959. }
  4960. }
  4961. declare module BABYLON {
  4962. /**
  4963. * Helper to manipulate strings
  4964. */
  4965. export class StringTools {
  4966. /**
  4967. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4968. * @param str Source string
  4969. * @param suffix Suffix to search for in the source string
  4970. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4971. */
  4972. static EndsWith(str: string, suffix: string): boolean;
  4973. /**
  4974. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4975. * @param str Source string
  4976. * @param suffix Suffix to search for in the source string
  4977. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4978. */
  4979. static StartsWith(str: string, suffix: string): boolean;
  4980. }
  4981. }
  4982. declare module BABYLON {
  4983. /** @hidden */
  4984. export class ShaderCodeNode {
  4985. line: string;
  4986. children: ShaderCodeNode[];
  4987. additionalDefineKey?: string;
  4988. additionalDefineValue?: string;
  4989. isValid(preprocessors: {
  4990. [key: string]: string;
  4991. }): boolean;
  4992. process(preprocessors: {
  4993. [key: string]: string;
  4994. }, options: ProcessingOptions): string;
  4995. }
  4996. }
  4997. declare module BABYLON {
  4998. /** @hidden */
  4999. export class ShaderCodeCursor {
  5000. private _lines;
  5001. lineIndex: number;
  5002. readonly currentLine: string;
  5003. readonly canRead: boolean;
  5004. lines: string[];
  5005. }
  5006. }
  5007. declare module BABYLON {
  5008. /** @hidden */
  5009. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5010. process(preprocessors: {
  5011. [key: string]: string;
  5012. }, options: ProcessingOptions): string;
  5013. }
  5014. }
  5015. declare module BABYLON {
  5016. /** @hidden */
  5017. export class ShaderDefineExpression {
  5018. isTrue(preprocessors: {
  5019. [key: string]: string;
  5020. }): boolean;
  5021. }
  5022. }
  5023. declare module BABYLON {
  5024. /** @hidden */
  5025. export class ShaderCodeTestNode extends ShaderCodeNode {
  5026. testExpression: ShaderDefineExpression;
  5027. isValid(preprocessors: {
  5028. [key: string]: string;
  5029. }): boolean;
  5030. }
  5031. }
  5032. declare module BABYLON {
  5033. /** @hidden */
  5034. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5035. define: string;
  5036. not: boolean;
  5037. constructor(define: string, not?: boolean);
  5038. isTrue(preprocessors: {
  5039. [key: string]: string;
  5040. }): boolean;
  5041. }
  5042. }
  5043. declare module BABYLON {
  5044. /** @hidden */
  5045. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5046. leftOperand: ShaderDefineExpression;
  5047. rightOperand: ShaderDefineExpression;
  5048. isTrue(preprocessors: {
  5049. [key: string]: string;
  5050. }): boolean;
  5051. }
  5052. }
  5053. declare module BABYLON {
  5054. /** @hidden */
  5055. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5056. leftOperand: ShaderDefineExpression;
  5057. rightOperand: ShaderDefineExpression;
  5058. isTrue(preprocessors: {
  5059. [key: string]: string;
  5060. }): boolean;
  5061. }
  5062. }
  5063. declare module BABYLON {
  5064. /** @hidden */
  5065. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5066. define: string;
  5067. operand: string;
  5068. testValue: string;
  5069. constructor(define: string, operand: string, testValue: string);
  5070. isTrue(preprocessors: {
  5071. [key: string]: string;
  5072. }): boolean;
  5073. }
  5074. }
  5075. declare module BABYLON {
  5076. /**
  5077. * @ignore
  5078. * Application error to support additional information when loading a file
  5079. */
  5080. export class LoadFileError extends Error {
  5081. /** defines the optional web request */
  5082. request?: WebRequest | undefined;
  5083. private static _setPrototypeOf;
  5084. /**
  5085. * Creates a new LoadFileError
  5086. * @param message defines the message of the error
  5087. * @param request defines the optional web request
  5088. */
  5089. constructor(message: string,
  5090. /** defines the optional web request */
  5091. request?: WebRequest | undefined);
  5092. }
  5093. }
  5094. declare module BABYLON {
  5095. /**
  5096. * Class used to enable access to offline support
  5097. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5098. */
  5099. export interface IOfflineProvider {
  5100. /**
  5101. * Gets a boolean indicating if scene must be saved in the database
  5102. */
  5103. enableSceneOffline: boolean;
  5104. /**
  5105. * Gets a boolean indicating if textures must be saved in the database
  5106. */
  5107. enableTexturesOffline: boolean;
  5108. /**
  5109. * Open the offline support and make it available
  5110. * @param successCallback defines the callback to call on success
  5111. * @param errorCallback defines the callback to call on error
  5112. */
  5113. open(successCallback: () => void, errorCallback: () => void): void;
  5114. /**
  5115. * Loads an image from the offline support
  5116. * @param url defines the url to load from
  5117. * @param image defines the target DOM image
  5118. */
  5119. loadImage(url: string, image: HTMLImageElement): void;
  5120. /**
  5121. * Loads a file from offline support
  5122. * @param url defines the URL to load from
  5123. * @param sceneLoaded defines a callback to call on success
  5124. * @param progressCallBack defines a callback to call when progress changed
  5125. * @param errorCallback defines a callback to call on error
  5126. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5127. */
  5128. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5129. }
  5130. }
  5131. declare module BABYLON {
  5132. /**
  5133. * Class used to help managing file picking and drag'n'drop
  5134. * File Storage
  5135. */
  5136. export class FilesInputStore {
  5137. /**
  5138. * List of files ready to be loaded
  5139. */
  5140. static FilesToLoad: {
  5141. [key: string]: File;
  5142. };
  5143. }
  5144. }
  5145. declare module BABYLON {
  5146. /**
  5147. * Class used to define a retry strategy when error happens while loading assets
  5148. */
  5149. export class RetryStrategy {
  5150. /**
  5151. * Function used to defines an exponential back off strategy
  5152. * @param maxRetries defines the maximum number of retries (3 by default)
  5153. * @param baseInterval defines the interval between retries
  5154. * @returns the strategy function to use
  5155. */
  5156. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5157. }
  5158. }
  5159. declare module BABYLON {
  5160. /**
  5161. * @hidden
  5162. */
  5163. export class FileTools {
  5164. /**
  5165. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5166. */
  5167. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5168. /**
  5169. * Gets or sets the base URL to use to load assets
  5170. */
  5171. static BaseUrl: string;
  5172. /**
  5173. * Default behaviour for cors in the application.
  5174. * It can be a string if the expected behavior is identical in the entire app.
  5175. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5176. */
  5177. static CorsBehavior: string | ((url: string | string[]) => string);
  5178. /**
  5179. * Gets or sets a function used to pre-process url before using them to load assets
  5180. */
  5181. static PreprocessUrl: (url: string) => string;
  5182. /**
  5183. * Removes unwanted characters from an url
  5184. * @param url defines the url to clean
  5185. * @returns the cleaned url
  5186. */
  5187. private static _CleanUrl;
  5188. /**
  5189. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5190. * @param url define the url we are trying
  5191. * @param element define the dom element where to configure the cors policy
  5192. */
  5193. static SetCorsBehavior(url: string | string[], element: {
  5194. crossOrigin: string | null;
  5195. }): void;
  5196. /**
  5197. * Loads an image as an HTMLImageElement.
  5198. * @param input url string, ArrayBuffer, or Blob to load
  5199. * @param onLoad callback called when the image successfully loads
  5200. * @param onError callback called when the image fails to load
  5201. * @param offlineProvider offline provider for caching
  5202. * @returns the HTMLImageElement of the loaded image
  5203. */
  5204. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5205. /**
  5206. * Loads a file
  5207. * @param fileToLoad defines the file to load
  5208. * @param callback defines the callback to call when data is loaded
  5209. * @param progressCallBack defines the callback to call during loading process
  5210. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5211. * @returns a file request object
  5212. */
  5213. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5214. /**
  5215. * Loads a file
  5216. * @param url url string, ArrayBuffer, or Blob to load
  5217. * @param onSuccess callback called when the file successfully loads
  5218. * @param onProgress callback called while file is loading (if the server supports this mode)
  5219. * @param offlineProvider defines the offline provider for caching
  5220. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5221. * @param onError callback called when the file fails to load
  5222. * @returns a file request object
  5223. */
  5224. 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;
  5225. /**
  5226. * Checks if the loaded document was accessed via `file:`-Protocol.
  5227. * @returns boolean
  5228. */
  5229. static IsFileURL(): boolean;
  5230. }
  5231. }
  5232. declare module BABYLON {
  5233. /** @hidden */
  5234. export class ShaderProcessor {
  5235. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5236. private static _ProcessPrecision;
  5237. private static _ExtractOperation;
  5238. private static _BuildSubExpression;
  5239. private static _BuildExpression;
  5240. private static _MoveCursorWithinIf;
  5241. private static _MoveCursor;
  5242. private static _EvaluatePreProcessors;
  5243. private static _PreparePreProcessors;
  5244. private static _ProcessShaderConversion;
  5245. private static _ProcessIncludes;
  5246. }
  5247. }
  5248. declare module BABYLON {
  5249. /**
  5250. * Class used to evalaute queries containing `and` and `or` operators
  5251. */
  5252. export class AndOrNotEvaluator {
  5253. /**
  5254. * Evaluate a query
  5255. * @param query defines the query to evaluate
  5256. * @param evaluateCallback defines the callback used to filter result
  5257. * @returns true if the query matches
  5258. */
  5259. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5260. private static _HandleParenthesisContent;
  5261. private static _SimplifyNegation;
  5262. }
  5263. }
  5264. declare module BABYLON {
  5265. /**
  5266. * Class used to store custom tags
  5267. */
  5268. export class Tags {
  5269. /**
  5270. * Adds support for tags on the given object
  5271. * @param obj defines the object to use
  5272. */
  5273. static EnableFor(obj: any): void;
  5274. /**
  5275. * Removes tags support
  5276. * @param obj defines the object to use
  5277. */
  5278. static DisableFor(obj: any): void;
  5279. /**
  5280. * Gets a boolean indicating if the given object has tags
  5281. * @param obj defines the object to use
  5282. * @returns a boolean
  5283. */
  5284. static HasTags(obj: any): boolean;
  5285. /**
  5286. * Gets the tags available on a given object
  5287. * @param obj defines the object to use
  5288. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5289. * @returns the tags
  5290. */
  5291. static GetTags(obj: any, asString?: boolean): any;
  5292. /**
  5293. * Adds tags to an object
  5294. * @param obj defines the object to use
  5295. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5296. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5297. */
  5298. static AddTagsTo(obj: any, tagsString: string): void;
  5299. /**
  5300. * @hidden
  5301. */
  5302. static _AddTagTo(obj: any, tag: string): void;
  5303. /**
  5304. * Removes specific tags from a specific object
  5305. * @param obj defines the object to use
  5306. * @param tagsString defines the tags to remove
  5307. */
  5308. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5309. /**
  5310. * @hidden
  5311. */
  5312. static _RemoveTagFrom(obj: any, tag: string): void;
  5313. /**
  5314. * Defines if tags hosted on an object match a given query
  5315. * @param obj defines the object to use
  5316. * @param tagsQuery defines the tag query
  5317. * @returns a boolean
  5318. */
  5319. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5320. }
  5321. }
  5322. declare module BABYLON {
  5323. /**
  5324. * Defines potential orientation for back face culling
  5325. */
  5326. export enum Orientation {
  5327. /**
  5328. * Clockwise
  5329. */
  5330. CW = 0,
  5331. /** Counter clockwise */
  5332. CCW = 1
  5333. }
  5334. /** Class used to represent a Bezier curve */
  5335. export class BezierCurve {
  5336. /**
  5337. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5338. * @param t defines the time
  5339. * @param x1 defines the left coordinate on X axis
  5340. * @param y1 defines the left coordinate on Y axis
  5341. * @param x2 defines the right coordinate on X axis
  5342. * @param y2 defines the right coordinate on Y axis
  5343. * @returns the interpolated value
  5344. */
  5345. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5346. }
  5347. /**
  5348. * Defines angle representation
  5349. */
  5350. export class Angle {
  5351. private _radians;
  5352. /**
  5353. * Creates an Angle object of "radians" radians (float).
  5354. * @param radians the angle in radians
  5355. */
  5356. constructor(radians: number);
  5357. /**
  5358. * Get value in degrees
  5359. * @returns the Angle value in degrees (float)
  5360. */
  5361. degrees(): number;
  5362. /**
  5363. * Get value in radians
  5364. * @returns the Angle value in radians (float)
  5365. */
  5366. radians(): number;
  5367. /**
  5368. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5369. * @param a defines first vector
  5370. * @param b defines second vector
  5371. * @returns a new Angle
  5372. */
  5373. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5374. /**
  5375. * Gets a new Angle object from the given float in radians
  5376. * @param radians defines the angle value in radians
  5377. * @returns a new Angle
  5378. */
  5379. static FromRadians(radians: number): Angle;
  5380. /**
  5381. * Gets a new Angle object from the given float in degrees
  5382. * @param degrees defines the angle value in degrees
  5383. * @returns a new Angle
  5384. */
  5385. static FromDegrees(degrees: number): Angle;
  5386. }
  5387. /**
  5388. * This represents an arc in a 2d space.
  5389. */
  5390. export class Arc2 {
  5391. /** Defines the start point of the arc */
  5392. startPoint: Vector2;
  5393. /** Defines the mid point of the arc */
  5394. midPoint: Vector2;
  5395. /** Defines the end point of the arc */
  5396. endPoint: Vector2;
  5397. /**
  5398. * Defines the center point of the arc.
  5399. */
  5400. centerPoint: Vector2;
  5401. /**
  5402. * Defines the radius of the arc.
  5403. */
  5404. radius: number;
  5405. /**
  5406. * Defines the angle of the arc (from mid point to end point).
  5407. */
  5408. angle: Angle;
  5409. /**
  5410. * Defines the start angle of the arc (from start point to middle point).
  5411. */
  5412. startAngle: Angle;
  5413. /**
  5414. * Defines the orientation of the arc (clock wise/counter clock wise).
  5415. */
  5416. orientation: Orientation;
  5417. /**
  5418. * Creates an Arc object from the three given points : start, middle and end.
  5419. * @param startPoint Defines the start point of the arc
  5420. * @param midPoint Defines the midlle point of the arc
  5421. * @param endPoint Defines the end point of the arc
  5422. */
  5423. constructor(
  5424. /** Defines the start point of the arc */
  5425. startPoint: Vector2,
  5426. /** Defines the mid point of the arc */
  5427. midPoint: Vector2,
  5428. /** Defines the end point of the arc */
  5429. endPoint: Vector2);
  5430. }
  5431. /**
  5432. * Represents a 2D path made up of multiple 2D points
  5433. */
  5434. export class Path2 {
  5435. private _points;
  5436. private _length;
  5437. /**
  5438. * If the path start and end point are the same
  5439. */
  5440. closed: boolean;
  5441. /**
  5442. * Creates a Path2 object from the starting 2D coordinates x and y.
  5443. * @param x the starting points x value
  5444. * @param y the starting points y value
  5445. */
  5446. constructor(x: number, y: number);
  5447. /**
  5448. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5449. * @param x the added points x value
  5450. * @param y the added points y value
  5451. * @returns the updated Path2.
  5452. */
  5453. addLineTo(x: number, y: number): Path2;
  5454. /**
  5455. * 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.
  5456. * @param midX middle point x value
  5457. * @param midY middle point y value
  5458. * @param endX end point x value
  5459. * @param endY end point y value
  5460. * @param numberOfSegments (default: 36)
  5461. * @returns the updated Path2.
  5462. */
  5463. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5464. /**
  5465. * Closes the Path2.
  5466. * @returns the Path2.
  5467. */
  5468. close(): Path2;
  5469. /**
  5470. * Gets the sum of the distance between each sequential point in the path
  5471. * @returns the Path2 total length (float).
  5472. */
  5473. length(): number;
  5474. /**
  5475. * Gets the points which construct the path
  5476. * @returns the Path2 internal array of points.
  5477. */
  5478. getPoints(): Vector2[];
  5479. /**
  5480. * Retreives the point at the distance aways from the starting point
  5481. * @param normalizedLengthPosition the length along the path to retreive the point from
  5482. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5483. */
  5484. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5485. /**
  5486. * Creates a new path starting from an x and y position
  5487. * @param x starting x value
  5488. * @param y starting y value
  5489. * @returns a new Path2 starting at the coordinates (x, y).
  5490. */
  5491. static StartingAt(x: number, y: number): Path2;
  5492. }
  5493. /**
  5494. * Represents a 3D path made up of multiple 3D points
  5495. */
  5496. export class Path3D {
  5497. /**
  5498. * an array of Vector3, the curve axis of the Path3D
  5499. */
  5500. path: Vector3[];
  5501. private _curve;
  5502. private _distances;
  5503. private _tangents;
  5504. private _normals;
  5505. private _binormals;
  5506. private _raw;
  5507. /**
  5508. * new Path3D(path, normal, raw)
  5509. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5510. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5511. * @param path an array of Vector3, the curve axis of the Path3D
  5512. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5513. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5514. */
  5515. constructor(
  5516. /**
  5517. * an array of Vector3, the curve axis of the Path3D
  5518. */
  5519. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5520. /**
  5521. * Returns the Path3D array of successive Vector3 designing its curve.
  5522. * @returns the Path3D array of successive Vector3 designing its curve.
  5523. */
  5524. getCurve(): Vector3[];
  5525. /**
  5526. * Returns an array populated with tangent vectors on each Path3D curve point.
  5527. * @returns an array populated with tangent vectors on each Path3D curve point.
  5528. */
  5529. getTangents(): Vector3[];
  5530. /**
  5531. * Returns an array populated with normal vectors on each Path3D curve point.
  5532. * @returns an array populated with normal vectors on each Path3D curve point.
  5533. */
  5534. getNormals(): Vector3[];
  5535. /**
  5536. * Returns an array populated with binormal vectors on each Path3D curve point.
  5537. * @returns an array populated with binormal vectors on each Path3D curve point.
  5538. */
  5539. getBinormals(): Vector3[];
  5540. /**
  5541. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5542. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5543. */
  5544. getDistances(): number[];
  5545. /**
  5546. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5547. * @param path path which all values are copied into the curves points
  5548. * @param firstNormal which should be projected onto the curve
  5549. * @returns the same object updated.
  5550. */
  5551. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5552. private _compute;
  5553. private _getFirstNonNullVector;
  5554. private _getLastNonNullVector;
  5555. private _normalVector;
  5556. }
  5557. /**
  5558. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5559. * A Curve3 is designed from a series of successive Vector3.
  5560. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5561. */
  5562. export class Curve3 {
  5563. private _points;
  5564. private _length;
  5565. /**
  5566. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5567. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5568. * @param v1 (Vector3) the control point
  5569. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5570. * @param nbPoints (integer) the wanted number of points in the curve
  5571. * @returns the created Curve3
  5572. */
  5573. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5574. /**
  5575. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5576. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5577. * @param v1 (Vector3) the first control point
  5578. * @param v2 (Vector3) the second control point
  5579. * @param v3 (Vector3) the end point of the Cubic Bezier
  5580. * @param nbPoints (integer) the wanted number of points in the curve
  5581. * @returns the created Curve3
  5582. */
  5583. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5584. /**
  5585. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5586. * @param p1 (Vector3) the origin point of the Hermite Spline
  5587. * @param t1 (Vector3) the tangent vector at the origin point
  5588. * @param p2 (Vector3) the end point of the Hermite Spline
  5589. * @param t2 (Vector3) the tangent vector at the end point
  5590. * @param nbPoints (integer) the wanted number of points in the curve
  5591. * @returns the created Curve3
  5592. */
  5593. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5594. /**
  5595. * Returns a Curve3 object along a CatmullRom Spline curve :
  5596. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5597. * @param nbPoints (integer) the wanted number of points between each curve control points
  5598. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5599. * @returns the created Curve3
  5600. */
  5601. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5602. /**
  5603. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5604. * A Curve3 is designed from a series of successive Vector3.
  5605. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5606. * @param points points which make up the curve
  5607. */
  5608. constructor(points: Vector3[]);
  5609. /**
  5610. * @returns the Curve3 stored array of successive Vector3
  5611. */
  5612. getPoints(): Vector3[];
  5613. /**
  5614. * @returns the computed length (float) of the curve.
  5615. */
  5616. length(): number;
  5617. /**
  5618. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5619. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5620. * curveA and curveB keep unchanged.
  5621. * @param curve the curve to continue from this curve
  5622. * @returns the newly constructed curve
  5623. */
  5624. continue(curve: DeepImmutable<Curve3>): Curve3;
  5625. private _computeLength;
  5626. }
  5627. }
  5628. declare module BABYLON {
  5629. /**
  5630. * This represents the main contract an easing function should follow.
  5631. * Easing functions are used throughout the animation system.
  5632. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5633. */
  5634. export interface IEasingFunction {
  5635. /**
  5636. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5637. * of the easing function.
  5638. * The link below provides some of the most common examples of easing functions.
  5639. * @see https://easings.net/
  5640. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5641. * @returns the corresponding value on the curve defined by the easing function
  5642. */
  5643. ease(gradient: number): number;
  5644. }
  5645. /**
  5646. * Base class used for every default easing function.
  5647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5648. */
  5649. export class EasingFunction implements IEasingFunction {
  5650. /**
  5651. * Interpolation follows the mathematical formula associated with the easing function.
  5652. */
  5653. static readonly EASINGMODE_EASEIN: number;
  5654. /**
  5655. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5656. */
  5657. static readonly EASINGMODE_EASEOUT: number;
  5658. /**
  5659. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5660. */
  5661. static readonly EASINGMODE_EASEINOUT: number;
  5662. private _easingMode;
  5663. /**
  5664. * Sets the easing mode of the current function.
  5665. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5666. */
  5667. setEasingMode(easingMode: number): void;
  5668. /**
  5669. * Gets the current easing mode.
  5670. * @returns the easing mode
  5671. */
  5672. getEasingMode(): number;
  5673. /**
  5674. * @hidden
  5675. */
  5676. easeInCore(gradient: number): number;
  5677. /**
  5678. * Given an input gradient between 0 and 1, this returns the corresponding value
  5679. * of the easing function.
  5680. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5681. * @returns the corresponding value on the curve defined by the easing function
  5682. */
  5683. ease(gradient: number): number;
  5684. }
  5685. /**
  5686. * Easing function with a circle shape (see link below).
  5687. * @see https://easings.net/#easeInCirc
  5688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5689. */
  5690. export class CircleEase extends EasingFunction implements IEasingFunction {
  5691. /** @hidden */
  5692. easeInCore(gradient: number): number;
  5693. }
  5694. /**
  5695. * Easing function with a ease back shape (see link below).
  5696. * @see https://easings.net/#easeInBack
  5697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5698. */
  5699. export class BackEase extends EasingFunction implements IEasingFunction {
  5700. /** Defines the amplitude of the function */
  5701. amplitude: number;
  5702. /**
  5703. * Instantiates a back ease easing
  5704. * @see https://easings.net/#easeInBack
  5705. * @param amplitude Defines the amplitude of the function
  5706. */
  5707. constructor(
  5708. /** Defines the amplitude of the function */
  5709. amplitude?: number);
  5710. /** @hidden */
  5711. easeInCore(gradient: number): number;
  5712. }
  5713. /**
  5714. * Easing function with a bouncing shape (see link below).
  5715. * @see https://easings.net/#easeInBounce
  5716. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5717. */
  5718. export class BounceEase extends EasingFunction implements IEasingFunction {
  5719. /** Defines the number of bounces */
  5720. bounces: number;
  5721. /** Defines the amplitude of the bounce */
  5722. bounciness: number;
  5723. /**
  5724. * Instantiates a bounce easing
  5725. * @see https://easings.net/#easeInBounce
  5726. * @param bounces Defines the number of bounces
  5727. * @param bounciness Defines the amplitude of the bounce
  5728. */
  5729. constructor(
  5730. /** Defines the number of bounces */
  5731. bounces?: number,
  5732. /** Defines the amplitude of the bounce */
  5733. bounciness?: number);
  5734. /** @hidden */
  5735. easeInCore(gradient: number): number;
  5736. }
  5737. /**
  5738. * Easing function with a power of 3 shape (see link below).
  5739. * @see https://easings.net/#easeInCubic
  5740. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5741. */
  5742. export class CubicEase extends EasingFunction implements IEasingFunction {
  5743. /** @hidden */
  5744. easeInCore(gradient: number): number;
  5745. }
  5746. /**
  5747. * Easing function with an elastic shape (see link below).
  5748. * @see https://easings.net/#easeInElastic
  5749. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5750. */
  5751. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5752. /** Defines the number of oscillations*/
  5753. oscillations: number;
  5754. /** Defines the amplitude of the oscillations*/
  5755. springiness: number;
  5756. /**
  5757. * Instantiates an elastic easing function
  5758. * @see https://easings.net/#easeInElastic
  5759. * @param oscillations Defines the number of oscillations
  5760. * @param springiness Defines the amplitude of the oscillations
  5761. */
  5762. constructor(
  5763. /** Defines the number of oscillations*/
  5764. oscillations?: number,
  5765. /** Defines the amplitude of the oscillations*/
  5766. springiness?: number);
  5767. /** @hidden */
  5768. easeInCore(gradient: number): number;
  5769. }
  5770. /**
  5771. * Easing function with an exponential shape (see link below).
  5772. * @see https://easings.net/#easeInExpo
  5773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5774. */
  5775. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5776. /** Defines the exponent of the function */
  5777. exponent: number;
  5778. /**
  5779. * Instantiates an exponential easing function
  5780. * @see https://easings.net/#easeInExpo
  5781. * @param exponent Defines the exponent of the function
  5782. */
  5783. constructor(
  5784. /** Defines the exponent of the function */
  5785. exponent?: number);
  5786. /** @hidden */
  5787. easeInCore(gradient: number): number;
  5788. }
  5789. /**
  5790. * Easing function with a power shape (see link below).
  5791. * @see https://easings.net/#easeInQuad
  5792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5793. */
  5794. export class PowerEase extends EasingFunction implements IEasingFunction {
  5795. /** Defines the power of the function */
  5796. power: number;
  5797. /**
  5798. * Instantiates an power base easing function
  5799. * @see https://easings.net/#easeInQuad
  5800. * @param power Defines the power of the function
  5801. */
  5802. constructor(
  5803. /** Defines the power of the function */
  5804. power?: number);
  5805. /** @hidden */
  5806. easeInCore(gradient: number): number;
  5807. }
  5808. /**
  5809. * Easing function with a power of 2 shape (see link below).
  5810. * @see https://easings.net/#easeInQuad
  5811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5812. */
  5813. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5814. /** @hidden */
  5815. easeInCore(gradient: number): number;
  5816. }
  5817. /**
  5818. * Easing function with a power of 4 shape (see link below).
  5819. * @see https://easings.net/#easeInQuart
  5820. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5821. */
  5822. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5823. /** @hidden */
  5824. easeInCore(gradient: number): number;
  5825. }
  5826. /**
  5827. * Easing function with a power of 5 shape (see link below).
  5828. * @see https://easings.net/#easeInQuint
  5829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5830. */
  5831. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5832. /** @hidden */
  5833. easeInCore(gradient: number): number;
  5834. }
  5835. /**
  5836. * Easing function with a sin shape (see link below).
  5837. * @see https://easings.net/#easeInSine
  5838. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5839. */
  5840. export class SineEase extends EasingFunction implements IEasingFunction {
  5841. /** @hidden */
  5842. easeInCore(gradient: number): number;
  5843. }
  5844. /**
  5845. * Easing function with a bezier shape (see link below).
  5846. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5847. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5848. */
  5849. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5850. /** Defines the x component of the start tangent in the bezier curve */
  5851. x1: number;
  5852. /** Defines the y component of the start tangent in the bezier curve */
  5853. y1: number;
  5854. /** Defines the x component of the end tangent in the bezier curve */
  5855. x2: number;
  5856. /** Defines the y component of the end tangent in the bezier curve */
  5857. y2: number;
  5858. /**
  5859. * Instantiates a bezier function
  5860. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5861. * @param x1 Defines the x component of the start tangent in the bezier curve
  5862. * @param y1 Defines the y component of the start tangent in the bezier curve
  5863. * @param x2 Defines the x component of the end tangent in the bezier curve
  5864. * @param y2 Defines the y component of the end tangent in the bezier curve
  5865. */
  5866. constructor(
  5867. /** Defines the x component of the start tangent in the bezier curve */
  5868. x1?: number,
  5869. /** Defines the y component of the start tangent in the bezier curve */
  5870. y1?: number,
  5871. /** Defines the x component of the end tangent in the bezier curve */
  5872. x2?: number,
  5873. /** Defines the y component of the end tangent in the bezier curve */
  5874. y2?: number);
  5875. /** @hidden */
  5876. easeInCore(gradient: number): number;
  5877. }
  5878. }
  5879. declare module BABYLON {
  5880. /**
  5881. * Defines an interface which represents an animation key frame
  5882. */
  5883. export interface IAnimationKey {
  5884. /**
  5885. * Frame of the key frame
  5886. */
  5887. frame: number;
  5888. /**
  5889. * Value at the specifies key frame
  5890. */
  5891. value: any;
  5892. /**
  5893. * The input tangent for the cubic hermite spline
  5894. */
  5895. inTangent?: any;
  5896. /**
  5897. * The output tangent for the cubic hermite spline
  5898. */
  5899. outTangent?: any;
  5900. /**
  5901. * The animation interpolation type
  5902. */
  5903. interpolation?: AnimationKeyInterpolation;
  5904. }
  5905. /**
  5906. * Enum for the animation key frame interpolation type
  5907. */
  5908. export enum AnimationKeyInterpolation {
  5909. /**
  5910. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5911. */
  5912. STEP = 1
  5913. }
  5914. }
  5915. declare module BABYLON {
  5916. /**
  5917. * Represents the range of an animation
  5918. */
  5919. export class AnimationRange {
  5920. /**The name of the animation range**/
  5921. name: string;
  5922. /**The starting frame of the animation */
  5923. from: number;
  5924. /**The ending frame of the animation*/
  5925. to: number;
  5926. /**
  5927. * Initializes the range of an animation
  5928. * @param name The name of the animation range
  5929. * @param from The starting frame of the animation
  5930. * @param to The ending frame of the animation
  5931. */
  5932. constructor(
  5933. /**The name of the animation range**/
  5934. name: string,
  5935. /**The starting frame of the animation */
  5936. from: number,
  5937. /**The ending frame of the animation*/
  5938. to: number);
  5939. /**
  5940. * Makes a copy of the animation range
  5941. * @returns A copy of the animation range
  5942. */
  5943. clone(): AnimationRange;
  5944. }
  5945. }
  5946. declare module BABYLON {
  5947. /**
  5948. * Composed of a frame, and an action function
  5949. */
  5950. export class AnimationEvent {
  5951. /** The frame for which the event is triggered **/
  5952. frame: number;
  5953. /** The event to perform when triggered **/
  5954. action: (currentFrame: number) => void;
  5955. /** Specifies if the event should be triggered only once**/
  5956. onlyOnce?: boolean | undefined;
  5957. /**
  5958. * Specifies if the animation event is done
  5959. */
  5960. isDone: boolean;
  5961. /**
  5962. * Initializes the animation event
  5963. * @param frame The frame for which the event is triggered
  5964. * @param action The event to perform when triggered
  5965. * @param onlyOnce Specifies if the event should be triggered only once
  5966. */
  5967. constructor(
  5968. /** The frame for which the event is triggered **/
  5969. frame: number,
  5970. /** The event to perform when triggered **/
  5971. action: (currentFrame: number) => void,
  5972. /** Specifies if the event should be triggered only once**/
  5973. onlyOnce?: boolean | undefined);
  5974. /** @hidden */
  5975. _clone(): AnimationEvent;
  5976. }
  5977. }
  5978. declare module BABYLON {
  5979. /**
  5980. * Interface used to define a behavior
  5981. */
  5982. export interface Behavior<T> {
  5983. /** gets or sets behavior's name */
  5984. name: string;
  5985. /**
  5986. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5987. */
  5988. init(): void;
  5989. /**
  5990. * Called when the behavior is attached to a target
  5991. * @param target defines the target where the behavior is attached to
  5992. */
  5993. attach(target: T): void;
  5994. /**
  5995. * Called when the behavior is detached from its target
  5996. */
  5997. detach(): void;
  5998. }
  5999. /**
  6000. * Interface implemented by classes supporting behaviors
  6001. */
  6002. export interface IBehaviorAware<T> {
  6003. /**
  6004. * Attach a behavior
  6005. * @param behavior defines the behavior to attach
  6006. * @returns the current host
  6007. */
  6008. addBehavior(behavior: Behavior<T>): T;
  6009. /**
  6010. * Remove a behavior from the current object
  6011. * @param behavior defines the behavior to detach
  6012. * @returns the current host
  6013. */
  6014. removeBehavior(behavior: Behavior<T>): T;
  6015. /**
  6016. * Gets a behavior using its name to search
  6017. * @param name defines the name to search
  6018. * @returns the behavior or null if not found
  6019. */
  6020. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6021. }
  6022. }
  6023. declare module BABYLON {
  6024. /**
  6025. * Defines an array and its length.
  6026. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6027. */
  6028. export interface ISmartArrayLike<T> {
  6029. /**
  6030. * The data of the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. }
  6038. /**
  6039. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6040. */
  6041. export class SmartArray<T> implements ISmartArrayLike<T> {
  6042. /**
  6043. * The full set of data from the array.
  6044. */
  6045. data: Array<T>;
  6046. /**
  6047. * The active length of the array.
  6048. */
  6049. length: number;
  6050. protected _id: number;
  6051. /**
  6052. * Instantiates a Smart Array.
  6053. * @param capacity defines the default capacity of the array.
  6054. */
  6055. constructor(capacity: number);
  6056. /**
  6057. * Pushes a value at the end of the active data.
  6058. * @param value defines the object to push in the array.
  6059. */
  6060. push(value: T): void;
  6061. /**
  6062. * Iterates over the active data and apply the lambda to them.
  6063. * @param func defines the action to apply on each value.
  6064. */
  6065. forEach(func: (content: T) => void): void;
  6066. /**
  6067. * Sorts the full sets of data.
  6068. * @param compareFn defines the comparison function to apply.
  6069. */
  6070. sort(compareFn: (a: T, b: T) => number): void;
  6071. /**
  6072. * Resets the active data to an empty array.
  6073. */
  6074. reset(): void;
  6075. /**
  6076. * Releases all the data from the array as well as the array.
  6077. */
  6078. dispose(): void;
  6079. /**
  6080. * Concats the active data with a given array.
  6081. * @param array defines the data to concatenate with.
  6082. */
  6083. concat(array: any): void;
  6084. /**
  6085. * Returns the position of a value in the active data.
  6086. * @param value defines the value to find the index for
  6087. * @returns the index if found in the active data otherwise -1
  6088. */
  6089. indexOf(value: T): number;
  6090. /**
  6091. * Returns whether an element is part of the active data.
  6092. * @param value defines the value to look for
  6093. * @returns true if found in the active data otherwise false
  6094. */
  6095. contains(value: T): boolean;
  6096. private static _GlobalId;
  6097. }
  6098. /**
  6099. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6100. * The data in this array can only be present once
  6101. */
  6102. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6103. private _duplicateId;
  6104. /**
  6105. * Pushes a value at the end of the active data.
  6106. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6107. * @param value defines the object to push in the array.
  6108. */
  6109. push(value: T): void;
  6110. /**
  6111. * Pushes a value at the end of the active data.
  6112. * If the data is already present, it won t be added again
  6113. * @param value defines the object to push in the array.
  6114. * @returns true if added false if it was already present
  6115. */
  6116. pushNoDuplicate(value: T): boolean;
  6117. /**
  6118. * Resets the active data to an empty array.
  6119. */
  6120. reset(): void;
  6121. /**
  6122. * Concats the active data with a given array.
  6123. * This ensures no dupplicate will be present in the result.
  6124. * @param array defines the data to concatenate with.
  6125. */
  6126. concatWithNoDuplicate(array: any): void;
  6127. }
  6128. }
  6129. declare module BABYLON {
  6130. /**
  6131. * @ignore
  6132. * This is a list of all the different input types that are available in the application.
  6133. * Fo instance: ArcRotateCameraGamepadInput...
  6134. */
  6135. export var CameraInputTypes: {};
  6136. /**
  6137. * This is the contract to implement in order to create a new input class.
  6138. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6139. */
  6140. export interface ICameraInput<TCamera extends Camera> {
  6141. /**
  6142. * Defines the camera the input is attached to.
  6143. */
  6144. camera: Nullable<TCamera>;
  6145. /**
  6146. * Gets the class name of the current intput.
  6147. * @returns the class name
  6148. */
  6149. getClassName(): string;
  6150. /**
  6151. * Get the friendly name associated with the input class.
  6152. * @returns the input friendly name
  6153. */
  6154. getSimpleName(): string;
  6155. /**
  6156. * Attach the input controls to a specific dom element to get the input from.
  6157. * @param element Defines the element the controls should be listened from
  6158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6159. */
  6160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6161. /**
  6162. * Detach the current controls from the specified dom element.
  6163. * @param element Defines the element to stop listening the inputs from
  6164. */
  6165. detachControl(element: Nullable<HTMLElement>): void;
  6166. /**
  6167. * Update the current camera state depending on the inputs that have been used this frame.
  6168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6169. */
  6170. checkInputs?: () => void;
  6171. }
  6172. /**
  6173. * Represents a map of input types to input instance or input index to input instance.
  6174. */
  6175. export interface CameraInputsMap<TCamera extends Camera> {
  6176. /**
  6177. * Accessor to the input by input type.
  6178. */
  6179. [name: string]: ICameraInput<TCamera>;
  6180. /**
  6181. * Accessor to the input by input index.
  6182. */
  6183. [idx: number]: ICameraInput<TCamera>;
  6184. }
  6185. /**
  6186. * This represents the input manager used within a camera.
  6187. * It helps dealing with all the different kind of input attached to a camera.
  6188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6189. */
  6190. export class CameraInputsManager<TCamera extends Camera> {
  6191. /**
  6192. * Defines the list of inputs attahed to the camera.
  6193. */
  6194. attached: CameraInputsMap<TCamera>;
  6195. /**
  6196. * Defines the dom element the camera is collecting inputs from.
  6197. * This is null if the controls have not been attached.
  6198. */
  6199. attachedElement: Nullable<HTMLElement>;
  6200. /**
  6201. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6202. */
  6203. noPreventDefault: boolean;
  6204. /**
  6205. * Defined the camera the input manager belongs to.
  6206. */
  6207. camera: TCamera;
  6208. /**
  6209. * Update the current camera state depending on the inputs that have been used this frame.
  6210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6211. */
  6212. checkInputs: () => void;
  6213. /**
  6214. * Instantiate a new Camera Input Manager.
  6215. * @param camera Defines the camera the input manager blongs to
  6216. */
  6217. constructor(camera: TCamera);
  6218. /**
  6219. * Add an input method to a camera
  6220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6221. * @param input camera input method
  6222. */
  6223. add(input: ICameraInput<TCamera>): void;
  6224. /**
  6225. * Remove a specific input method from a camera
  6226. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6227. * @param inputToRemove camera input method
  6228. */
  6229. remove(inputToRemove: ICameraInput<TCamera>): void;
  6230. /**
  6231. * Remove a specific input type from a camera
  6232. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6233. * @param inputType the type of the input to remove
  6234. */
  6235. removeByType(inputType: string): void;
  6236. private _addCheckInputs;
  6237. /**
  6238. * Attach the input controls to the currently attached dom element to listen the events from.
  6239. * @param input Defines the input to attach
  6240. */
  6241. attachInput(input: ICameraInput<TCamera>): void;
  6242. /**
  6243. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6244. * @param element Defines the dom element to collect the events from
  6245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6246. */
  6247. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6248. /**
  6249. * Detach the current manager inputs controls from a specific dom element.
  6250. * @param element Defines the dom element to collect the events from
  6251. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6252. */
  6253. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6254. /**
  6255. * Rebuild the dynamic inputCheck function from the current list of
  6256. * defined inputs in the manager.
  6257. */
  6258. rebuildInputCheck(): void;
  6259. /**
  6260. * Remove all attached input methods from a camera
  6261. */
  6262. clear(): void;
  6263. /**
  6264. * Serialize the current input manager attached to a camera.
  6265. * This ensures than once parsed,
  6266. * the input associated to the camera will be identical to the current ones
  6267. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6268. */
  6269. serialize(serializedCamera: any): void;
  6270. /**
  6271. * Parses an input manager serialized JSON to restore the previous list of inputs
  6272. * and states associated to a camera.
  6273. * @param parsedCamera Defines the JSON to parse
  6274. */
  6275. parse(parsedCamera: any): void;
  6276. }
  6277. }
  6278. declare module BABYLON {
  6279. /**
  6280. * Class used to store data that will be store in GPU memory
  6281. */
  6282. export class Buffer {
  6283. private _engine;
  6284. private _buffer;
  6285. /** @hidden */
  6286. _data: Nullable<DataArray>;
  6287. private _updatable;
  6288. private _instanced;
  6289. /**
  6290. * Gets the byte stride.
  6291. */
  6292. readonly byteStride: number;
  6293. /**
  6294. * Constructor
  6295. * @param engine the engine
  6296. * @param data the data to use for this buffer
  6297. * @param updatable whether the data is updatable
  6298. * @param stride the stride (optional)
  6299. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param useBytes set to true if the stride in in bytes (optional)
  6302. */
  6303. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6304. /**
  6305. * Create a new VertexBuffer based on the current buffer
  6306. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6307. * @param offset defines offset in the buffer (0 by default)
  6308. * @param size defines the size in floats of attributes (position is 3 for instance)
  6309. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6310. * @param instanced defines if the vertex buffer contains indexed data
  6311. * @param useBytes defines if the offset and stride are in bytes
  6312. * @returns the new vertex buffer
  6313. */
  6314. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6315. /**
  6316. * Gets a boolean indicating if the Buffer is updatable?
  6317. * @returns true if the buffer is updatable
  6318. */
  6319. isUpdatable(): boolean;
  6320. /**
  6321. * Gets current buffer's data
  6322. * @returns a DataArray or null
  6323. */
  6324. getData(): Nullable<DataArray>;
  6325. /**
  6326. * Gets underlying native buffer
  6327. * @returns underlying native buffer
  6328. */
  6329. getBuffer(): Nullable<DataBuffer>;
  6330. /**
  6331. * Gets the stride in float32 units (i.e. byte stride / 4).
  6332. * May not be an integer if the byte stride is not divisible by 4.
  6333. * DEPRECATED. Use byteStride instead.
  6334. * @returns the stride in float32 units
  6335. */
  6336. getStrideSize(): number;
  6337. /**
  6338. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6339. * @param data defines the data to store
  6340. */
  6341. create(data?: Nullable<DataArray>): void;
  6342. /** @hidden */
  6343. _rebuild(): void;
  6344. /**
  6345. * Update current buffer data
  6346. * @param data defines the data to store
  6347. */
  6348. update(data: DataArray): void;
  6349. /**
  6350. * Updates the data directly.
  6351. * @param data the new data
  6352. * @param offset the new offset
  6353. * @param vertexCount the vertex count (optional)
  6354. * @param useBytes set to true if the offset is in bytes
  6355. */
  6356. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6357. /**
  6358. * Release all resources
  6359. */
  6360. dispose(): void;
  6361. }
  6362. /**
  6363. * Specialized buffer used to store vertex data
  6364. */
  6365. export class VertexBuffer {
  6366. /** @hidden */
  6367. _buffer: Buffer;
  6368. private _kind;
  6369. private _size;
  6370. private _ownsBuffer;
  6371. private _instanced;
  6372. private _instanceDivisor;
  6373. /**
  6374. * The byte type.
  6375. */
  6376. static readonly BYTE: number;
  6377. /**
  6378. * The unsigned byte type.
  6379. */
  6380. static readonly UNSIGNED_BYTE: number;
  6381. /**
  6382. * The short type.
  6383. */
  6384. static readonly SHORT: number;
  6385. /**
  6386. * The unsigned short type.
  6387. */
  6388. static readonly UNSIGNED_SHORT: number;
  6389. /**
  6390. * The integer type.
  6391. */
  6392. static readonly INT: number;
  6393. /**
  6394. * The unsigned integer type.
  6395. */
  6396. static readonly UNSIGNED_INT: number;
  6397. /**
  6398. * The float type.
  6399. */
  6400. static readonly FLOAT: number;
  6401. /**
  6402. * Gets or sets the instance divisor when in instanced mode
  6403. */
  6404. instanceDivisor: number;
  6405. /**
  6406. * Gets the byte stride.
  6407. */
  6408. readonly byteStride: number;
  6409. /**
  6410. * Gets the byte offset.
  6411. */
  6412. readonly byteOffset: number;
  6413. /**
  6414. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6415. */
  6416. readonly normalized: boolean;
  6417. /**
  6418. * Gets the data type of each component in the array.
  6419. */
  6420. readonly type: number;
  6421. /**
  6422. * Constructor
  6423. * @param engine the engine
  6424. * @param data the data to use for this vertex buffer
  6425. * @param kind the vertex buffer kind
  6426. * @param updatable whether the data is updatable
  6427. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6428. * @param stride the stride (optional)
  6429. * @param instanced whether the buffer is instanced (optional)
  6430. * @param offset the offset of the data (optional)
  6431. * @param size the number of components (optional)
  6432. * @param type the type of the component (optional)
  6433. * @param normalized whether the data contains normalized data (optional)
  6434. * @param useBytes set to true if stride and offset are in bytes (optional)
  6435. */
  6436. 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);
  6437. /** @hidden */
  6438. _rebuild(): void;
  6439. /**
  6440. * Returns the kind of the VertexBuffer (string)
  6441. * @returns a string
  6442. */
  6443. getKind(): string;
  6444. /**
  6445. * Gets a boolean indicating if the VertexBuffer is updatable?
  6446. * @returns true if the buffer is updatable
  6447. */
  6448. isUpdatable(): boolean;
  6449. /**
  6450. * Gets current buffer's data
  6451. * @returns a DataArray or null
  6452. */
  6453. getData(): Nullable<DataArray>;
  6454. /**
  6455. * Gets underlying native buffer
  6456. * @returns underlying native buffer
  6457. */
  6458. getBuffer(): Nullable<DataBuffer>;
  6459. /**
  6460. * Gets the stride in float32 units (i.e. byte stride / 4).
  6461. * May not be an integer if the byte stride is not divisible by 4.
  6462. * DEPRECATED. Use byteStride instead.
  6463. * @returns the stride in float32 units
  6464. */
  6465. getStrideSize(): number;
  6466. /**
  6467. * Returns the offset as a multiple of the type byte length.
  6468. * DEPRECATED. Use byteOffset instead.
  6469. * @returns the offset in bytes
  6470. */
  6471. getOffset(): number;
  6472. /**
  6473. * Returns the number of components per vertex attribute (integer)
  6474. * @returns the size in float
  6475. */
  6476. getSize(): number;
  6477. /**
  6478. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6479. * @returns true if this buffer is instanced
  6480. */
  6481. getIsInstanced(): boolean;
  6482. /**
  6483. * Returns the instancing divisor, zero for non-instanced (integer).
  6484. * @returns a number
  6485. */
  6486. getInstanceDivisor(): number;
  6487. /**
  6488. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6489. * @param data defines the data to store
  6490. */
  6491. create(data?: DataArray): void;
  6492. /**
  6493. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6494. * This function will create a new buffer if the current one is not updatable
  6495. * @param data defines the data to store
  6496. */
  6497. update(data: DataArray): void;
  6498. /**
  6499. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6500. * Returns the directly updated WebGLBuffer.
  6501. * @param data the new data
  6502. * @param offset the new offset
  6503. * @param useBytes set to true if the offset is in bytes
  6504. */
  6505. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6506. /**
  6507. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6508. */
  6509. dispose(): void;
  6510. /**
  6511. * Enumerates each value of this vertex buffer as numbers.
  6512. * @param count the number of values to enumerate
  6513. * @param callback the callback function called for each value
  6514. */
  6515. forEach(count: number, callback: (value: number, index: number) => void): void;
  6516. /**
  6517. * Positions
  6518. */
  6519. static readonly PositionKind: string;
  6520. /**
  6521. * Normals
  6522. */
  6523. static readonly NormalKind: string;
  6524. /**
  6525. * Tangents
  6526. */
  6527. static readonly TangentKind: string;
  6528. /**
  6529. * Texture coordinates
  6530. */
  6531. static readonly UVKind: string;
  6532. /**
  6533. * Texture coordinates 2
  6534. */
  6535. static readonly UV2Kind: string;
  6536. /**
  6537. * Texture coordinates 3
  6538. */
  6539. static readonly UV3Kind: string;
  6540. /**
  6541. * Texture coordinates 4
  6542. */
  6543. static readonly UV4Kind: string;
  6544. /**
  6545. * Texture coordinates 5
  6546. */
  6547. static readonly UV5Kind: string;
  6548. /**
  6549. * Texture coordinates 6
  6550. */
  6551. static readonly UV6Kind: string;
  6552. /**
  6553. * Colors
  6554. */
  6555. static readonly ColorKind: string;
  6556. /**
  6557. * Matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesKind: string;
  6560. /**
  6561. * Matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsKind: string;
  6564. /**
  6565. * Additional matrix indices (for bones)
  6566. */
  6567. static readonly MatricesIndicesExtraKind: string;
  6568. /**
  6569. * Additional matrix weights (for bones)
  6570. */
  6571. static readonly MatricesWeightsExtraKind: string;
  6572. /**
  6573. * Deduces the stride given a kind.
  6574. * @param kind The kind string to deduce
  6575. * @returns The deduced stride
  6576. */
  6577. static DeduceStride(kind: string): number;
  6578. /**
  6579. * Gets the byte length of the given type.
  6580. * @param type the type
  6581. * @returns the number of bytes
  6582. */
  6583. static GetTypeByteLength(type: number): number;
  6584. /**
  6585. * Enumerates each value of the given parameters as numbers.
  6586. * @param data the data to enumerate
  6587. * @param byteOffset the byte offset of the data
  6588. * @param byteStride the byte stride of the data
  6589. * @param componentCount the number of components per element
  6590. * @param componentType the type of the component
  6591. * @param count the number of values to enumerate
  6592. * @param normalized whether the data is normalized
  6593. * @param callback the callback function called for each value
  6594. */
  6595. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6596. private static _GetFloatValue;
  6597. }
  6598. }
  6599. declare module BABYLON {
  6600. /**
  6601. * @hidden
  6602. */
  6603. export class IntersectionInfo {
  6604. bu: Nullable<number>;
  6605. bv: Nullable<number>;
  6606. distance: number;
  6607. faceId: number;
  6608. subMeshId: number;
  6609. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6610. }
  6611. }
  6612. declare module BABYLON {
  6613. /**
  6614. * Represens a plane by the equation ax + by + cz + d = 0
  6615. */
  6616. export class Plane {
  6617. private static _TmpMatrix;
  6618. /**
  6619. * Normal of the plane (a,b,c)
  6620. */
  6621. normal: Vector3;
  6622. /**
  6623. * d component of the plane
  6624. */
  6625. d: number;
  6626. /**
  6627. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6628. * @param a a component of the plane
  6629. * @param b b component of the plane
  6630. * @param c c component of the plane
  6631. * @param d d component of the plane
  6632. */
  6633. constructor(a: number, b: number, c: number, d: number);
  6634. /**
  6635. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6636. */
  6637. asArray(): number[];
  6638. /**
  6639. * @returns a new plane copied from the current Plane.
  6640. */
  6641. clone(): Plane;
  6642. /**
  6643. * @returns the string "Plane".
  6644. */
  6645. getClassName(): string;
  6646. /**
  6647. * @returns the Plane hash code.
  6648. */
  6649. getHashCode(): number;
  6650. /**
  6651. * Normalize the current Plane in place.
  6652. * @returns the updated Plane.
  6653. */
  6654. normalize(): Plane;
  6655. /**
  6656. * Applies a transformation the plane and returns the result
  6657. * @param transformation the transformation matrix to be applied to the plane
  6658. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6659. */
  6660. transform(transformation: DeepImmutable<Matrix>): Plane;
  6661. /**
  6662. * Calcualtte the dot product between the point and the plane normal
  6663. * @param point point to calculate the dot product with
  6664. * @returns the dot product (float) of the point coordinates and the plane normal.
  6665. */
  6666. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6667. /**
  6668. * Updates the current Plane from the plane defined by the three given points.
  6669. * @param point1 one of the points used to contruct the plane
  6670. * @param point2 one of the points used to contruct the plane
  6671. * @param point3 one of the points used to contruct the plane
  6672. * @returns the updated Plane.
  6673. */
  6674. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6675. /**
  6676. * Checks if the plane is facing a given direction
  6677. * @param direction the direction to check if the plane is facing
  6678. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6679. * @returns True is the vector "direction" is the same side than the plane normal.
  6680. */
  6681. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6682. /**
  6683. * Calculates the distance to a point
  6684. * @param point point to calculate distance to
  6685. * @returns the signed distance (float) from the given point to the Plane.
  6686. */
  6687. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6688. /**
  6689. * Creates a plane from an array
  6690. * @param array the array to create a plane from
  6691. * @returns a new Plane from the given array.
  6692. */
  6693. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6694. /**
  6695. * Creates a plane from three points
  6696. * @param point1 point used to create the plane
  6697. * @param point2 point used to create the plane
  6698. * @param point3 point used to create the plane
  6699. * @returns a new Plane defined by the three given points.
  6700. */
  6701. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Creates a plane from an origin point and a normal
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @returns a new Plane the normal vector to this plane at the given origin point.
  6707. * Note : the vector "normal" is updated because normalized.
  6708. */
  6709. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6710. /**
  6711. * Calculates the distance from a plane and a point
  6712. * @param origin origin of the plane to be constructed
  6713. * @param normal normal of the plane to be constructed
  6714. * @param point point to calculate distance to
  6715. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6716. */
  6717. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6718. }
  6719. }
  6720. declare module BABYLON {
  6721. /**
  6722. * Class used to store bounding sphere information
  6723. */
  6724. export class BoundingSphere {
  6725. /**
  6726. * Gets the center of the bounding sphere in local space
  6727. */
  6728. readonly center: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in local space
  6731. */
  6732. radius: number;
  6733. /**
  6734. * Gets the center of the bounding sphere in world space
  6735. */
  6736. readonly centerWorld: Vector3;
  6737. /**
  6738. * Radius of the bounding sphere in world space
  6739. */
  6740. radiusWorld: number;
  6741. /**
  6742. * Gets the minimum vector in local space
  6743. */
  6744. readonly minimum: Vector3;
  6745. /**
  6746. * Gets the maximum vector in local space
  6747. */
  6748. readonly maximum: Vector3;
  6749. private _worldMatrix;
  6750. private static readonly TmpVector3;
  6751. /**
  6752. * Creates a new bounding sphere
  6753. * @param min defines the minimum vector (in local space)
  6754. * @param max defines the maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6758. /**
  6759. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6760. * @param min defines the new minimum vector (in local space)
  6761. * @param max defines the new maximum vector (in local space)
  6762. * @param worldMatrix defines the new world matrix
  6763. */
  6764. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Scale the current bounding sphere by applying a scale factor
  6767. * @param factor defines the scale factor to apply
  6768. * @returns the current bounding box
  6769. */
  6770. scale(factor: number): BoundingSphere;
  6771. /**
  6772. * Gets the world matrix of the bounding box
  6773. * @returns a matrix
  6774. */
  6775. getWorldMatrix(): DeepImmutable<Matrix>;
  6776. /** @hidden */
  6777. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6778. /**
  6779. * Tests if the bounding sphere is intersecting the frustum planes
  6780. * @param frustumPlanes defines the frustum planes to test
  6781. * @returns true if there is an intersection
  6782. */
  6783. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6784. /**
  6785. * Tests if the bounding sphere center is in between the frustum planes.
  6786. * Used for optimistic fast inclusion.
  6787. * @param frustumPlanes defines the frustum planes to test
  6788. * @returns true if the sphere center is in between the frustum planes
  6789. */
  6790. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6791. /**
  6792. * Tests if a point is inside the bounding sphere
  6793. * @param point defines the point to test
  6794. * @returns true if the point is inside the bounding sphere
  6795. */
  6796. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6797. /**
  6798. * Checks if two sphere intersct
  6799. * @param sphere0 sphere 0
  6800. * @param sphere1 sphere 1
  6801. * @returns true if the speres intersect
  6802. */
  6803. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6804. }
  6805. }
  6806. declare module BABYLON {
  6807. /**
  6808. * Class used to store bounding box information
  6809. */
  6810. export class BoundingBox implements ICullable {
  6811. /**
  6812. * Gets the 8 vectors representing the bounding box in local space
  6813. */
  6814. readonly vectors: Vector3[];
  6815. /**
  6816. * Gets the center of the bounding box in local space
  6817. */
  6818. readonly center: Vector3;
  6819. /**
  6820. * Gets the center of the bounding box in world space
  6821. */
  6822. readonly centerWorld: Vector3;
  6823. /**
  6824. * Gets the extend size in local space
  6825. */
  6826. readonly extendSize: Vector3;
  6827. /**
  6828. * Gets the extend size in world space
  6829. */
  6830. readonly extendSizeWorld: Vector3;
  6831. /**
  6832. * Gets the OBB (object bounding box) directions
  6833. */
  6834. readonly directions: Vector3[];
  6835. /**
  6836. * Gets the 8 vectors representing the bounding box in world space
  6837. */
  6838. readonly vectorsWorld: Vector3[];
  6839. /**
  6840. * Gets the minimum vector in world space
  6841. */
  6842. readonly minimumWorld: Vector3;
  6843. /**
  6844. * Gets the maximum vector in world space
  6845. */
  6846. readonly maximumWorld: Vector3;
  6847. /**
  6848. * Gets the minimum vector in local space
  6849. */
  6850. readonly minimum: Vector3;
  6851. /**
  6852. * Gets the maximum vector in local space
  6853. */
  6854. readonly maximum: Vector3;
  6855. private _worldMatrix;
  6856. private static readonly TmpVector3;
  6857. /**
  6858. * @hidden
  6859. */
  6860. _tag: number;
  6861. /**
  6862. * Creates a new bounding box
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding box by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingBox;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(world: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding box is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding box is entirely inside the frustum planes
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @returns true if there is an inclusion
  6898. */
  6899. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. /**
  6901. * Tests if a point is inside the bounding box
  6902. * @param point defines the point to test
  6903. * @returns true if the point is inside the bounding box
  6904. */
  6905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6906. /**
  6907. * Tests if the bounding box intersects with a bounding sphere
  6908. * @param sphere defines the sphere to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6912. /**
  6913. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6914. * @param min defines the min vector to use
  6915. * @param max defines the max vector to use
  6916. * @returns true if there is an intersection
  6917. */
  6918. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6919. /**
  6920. * Tests if two bounding boxes are intersections
  6921. * @param box0 defines the first box to test
  6922. * @param box1 defines the second box to test
  6923. * @returns true if there is an intersection
  6924. */
  6925. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6926. /**
  6927. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6928. * @param minPoint defines the minimum vector of the bounding box
  6929. * @param maxPoint defines the maximum vector of the bounding box
  6930. * @param sphereCenter defines the sphere center
  6931. * @param sphereRadius defines the sphere radius
  6932. * @returns true if there is an intersection
  6933. */
  6934. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6935. /**
  6936. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @return true if there is an inclusion
  6940. */
  6941. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6944. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @return true if there is an intersection
  6947. */
  6948. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. }
  6950. }
  6951. declare module BABYLON {
  6952. /** @hidden */
  6953. export class Collider {
  6954. /** Define if a collision was found */
  6955. collisionFound: boolean;
  6956. /**
  6957. * Define last intersection point in local space
  6958. */
  6959. intersectionPoint: Vector3;
  6960. /**
  6961. * Define last collided mesh
  6962. */
  6963. collidedMesh: Nullable<AbstractMesh>;
  6964. private _collisionPoint;
  6965. private _planeIntersectionPoint;
  6966. private _tempVector;
  6967. private _tempVector2;
  6968. private _tempVector3;
  6969. private _tempVector4;
  6970. private _edge;
  6971. private _baseToVertex;
  6972. private _destinationPoint;
  6973. private _slidePlaneNormal;
  6974. private _displacementVector;
  6975. /** @hidden */
  6976. _radius: Vector3;
  6977. /** @hidden */
  6978. _retry: number;
  6979. private _velocity;
  6980. private _basePoint;
  6981. private _epsilon;
  6982. /** @hidden */
  6983. _velocityWorldLength: number;
  6984. /** @hidden */
  6985. _basePointWorld: Vector3;
  6986. private _velocityWorld;
  6987. private _normalizedVelocity;
  6988. /** @hidden */
  6989. _initialVelocity: Vector3;
  6990. /** @hidden */
  6991. _initialPosition: Vector3;
  6992. private _nearestDistance;
  6993. private _collisionMask;
  6994. collisionMask: number;
  6995. /**
  6996. * Gets the plane normal used to compute the sliding response (in local space)
  6997. */
  6998. readonly slidePlaneNormal: Vector3;
  6999. /** @hidden */
  7000. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7001. /** @hidden */
  7002. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7003. /** @hidden */
  7004. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7005. /** @hidden */
  7006. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7007. /** @hidden */
  7008. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7009. /** @hidden */
  7010. _getResponse(pos: Vector3, vel: Vector3): void;
  7011. }
  7012. }
  7013. declare module BABYLON {
  7014. /**
  7015. * Interface for cullable objects
  7016. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7017. */
  7018. export interface ICullable {
  7019. /**
  7020. * Checks if the object or part of the object is in the frustum
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isInFrustum(frustumPlanes: Plane[]): boolean;
  7025. /**
  7026. * Checks if a cullable object (mesh...) is in the camera frustum
  7027. * Unlike isInFrustum this cheks the full bounding box
  7028. * @param frustumPlanes Camera near/planes
  7029. * @returns true if the object is in frustum otherwise false
  7030. */
  7031. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7032. }
  7033. /**
  7034. * Info for a bounding data of a mesh
  7035. */
  7036. export class BoundingInfo implements ICullable {
  7037. /**
  7038. * Bounding box for the mesh
  7039. */
  7040. readonly boundingBox: BoundingBox;
  7041. /**
  7042. * Bounding sphere for the mesh
  7043. */
  7044. readonly boundingSphere: BoundingSphere;
  7045. private _isLocked;
  7046. private static readonly TmpVector3;
  7047. /**
  7048. * Constructs bounding info
  7049. * @param minimum min vector of the bounding box/sphere
  7050. * @param maximum max vector of the bounding box/sphere
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7054. /**
  7055. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7056. * @param min defines the new minimum vector (in local space)
  7057. * @param max defines the new maximum vector (in local space)
  7058. * @param worldMatrix defines the new world matrix
  7059. */
  7060. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7061. /**
  7062. * min vector of the bounding box/sphere
  7063. */
  7064. readonly minimum: Vector3;
  7065. /**
  7066. * max vector of the bounding box/sphere
  7067. */
  7068. readonly maximum: Vector3;
  7069. /**
  7070. * If the info is locked and won't be updated to avoid perf overhead
  7071. */
  7072. isLocked: boolean;
  7073. /**
  7074. * Updates the bounding sphere and box
  7075. * @param world world matrix to be used to update
  7076. */
  7077. update(world: DeepImmutable<Matrix>): void;
  7078. /**
  7079. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7080. * @param center New center of the bounding info
  7081. * @param extend New extend of the bounding info
  7082. * @returns the current bounding info
  7083. */
  7084. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7085. /**
  7086. * Scale the current bounding info by applying a scale factor
  7087. * @param factor defines the scale factor to apply
  7088. * @returns the current bounding info
  7089. */
  7090. scale(factor: number): BoundingInfo;
  7091. /**
  7092. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7093. * @param frustumPlanes defines the frustum to test
  7094. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7095. * @returns true if the bounding info is in the frustum planes
  7096. */
  7097. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7098. /**
  7099. * Gets the world distance between the min and max points of the bounding box
  7100. */
  7101. readonly diagonalLength: number;
  7102. /**
  7103. * Checks if a cullable object (mesh...) is in the camera frustum
  7104. * Unlike isInFrustum this cheks the full bounding box
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. /** @hidden */
  7110. _checkCollision(collider: Collider): boolean;
  7111. /**
  7112. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7113. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7114. * @param point the point to check intersection with
  7115. * @returns if the point intersects
  7116. */
  7117. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7118. /**
  7119. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7120. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7121. * @param boundingInfo the bounding info to check intersection with
  7122. * @param precise if the intersection should be done using OBB
  7123. * @returns if the bounding info intersects
  7124. */
  7125. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7126. }
  7127. }
  7128. declare module BABYLON {
  7129. /**
  7130. * Extracts minimum and maximum values from a list of indexed positions
  7131. * @param positions defines the positions to use
  7132. * @param indices defines the indices to the positions
  7133. * @param indexStart defines the start index
  7134. * @param indexCount defines the end index
  7135. * @param bias defines bias value to add to the result
  7136. * @return minimum and maximum values
  7137. */
  7138. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7139. minimum: Vector3;
  7140. maximum: Vector3;
  7141. };
  7142. /**
  7143. * Extracts minimum and maximum values from a list of positions
  7144. * @param positions defines the positions to use
  7145. * @param start defines the start index in the positions array
  7146. * @param count defines the number of positions to handle
  7147. * @param bias defines bias value to add to the result
  7148. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7149. * @return minimum and maximum values
  7150. */
  7151. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7152. minimum: Vector3;
  7153. maximum: Vector3;
  7154. };
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Uniform buffer objects.
  7159. *
  7160. * Handles blocks of uniform on the GPU.
  7161. *
  7162. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7163. *
  7164. * For more information, please refer to :
  7165. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7166. */
  7167. export class UniformBuffer {
  7168. private _engine;
  7169. private _buffer;
  7170. private _data;
  7171. private _bufferData;
  7172. private _dynamic?;
  7173. private _uniformLocations;
  7174. private _uniformSizes;
  7175. private _uniformLocationPointer;
  7176. private _needSync;
  7177. private _noUBO;
  7178. private _currentEffect;
  7179. private static _MAX_UNIFORM_SIZE;
  7180. private static _tempBuffer;
  7181. /**
  7182. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7183. * This is dynamic to allow compat with webgl 1 and 2.
  7184. * You will need to pass the name of the uniform as well as the value.
  7185. */
  7186. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7187. /**
  7188. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7189. * This is dynamic to allow compat with webgl 1 and 2.
  7190. * You will need to pass the name of the uniform as well as the value.
  7191. */
  7192. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7193. /**
  7194. * Lambda to Update a single float in a uniform buffer.
  7195. * This is dynamic to allow compat with webgl 1 and 2.
  7196. * You will need to pass the name of the uniform as well as the value.
  7197. */
  7198. updateFloat: (name: string, x: number) => void;
  7199. /**
  7200. * Lambda to Update a vec2 of float in a uniform buffer.
  7201. * This is dynamic to allow compat with webgl 1 and 2.
  7202. * You will need to pass the name of the uniform as well as the value.
  7203. */
  7204. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7205. /**
  7206. * Lambda to Update a vec3 of float in a uniform buffer.
  7207. * This is dynamic to allow compat with webgl 1 and 2.
  7208. * You will need to pass the name of the uniform as well as the value.
  7209. */
  7210. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7211. /**
  7212. * Lambda to Update a vec4 of float in a uniform buffer.
  7213. * This is dynamic to allow compat with webgl 1 and 2.
  7214. * You will need to pass the name of the uniform as well as the value.
  7215. */
  7216. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7217. /**
  7218. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7219. * This is dynamic to allow compat with webgl 1 and 2.
  7220. * You will need to pass the name of the uniform as well as the value.
  7221. */
  7222. updateMatrix: (name: string, mat: Matrix) => void;
  7223. /**
  7224. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7225. * This is dynamic to allow compat with webgl 1 and 2.
  7226. * You will need to pass the name of the uniform as well as the value.
  7227. */
  7228. updateVector3: (name: string, vector: Vector3) => void;
  7229. /**
  7230. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7231. * This is dynamic to allow compat with webgl 1 and 2.
  7232. * You will need to pass the name of the uniform as well as the value.
  7233. */
  7234. updateVector4: (name: string, vector: Vector4) => void;
  7235. /**
  7236. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7237. * This is dynamic to allow compat with webgl 1 and 2.
  7238. * You will need to pass the name of the uniform as well as the value.
  7239. */
  7240. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7241. /**
  7242. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7243. * This is dynamic to allow compat with webgl 1 and 2.
  7244. * You will need to pass the name of the uniform as well as the value.
  7245. */
  7246. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7247. /**
  7248. * Instantiates a new Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. * @param engine Define the engine the buffer is associated with
  7257. * @param data Define the data contained in the buffer
  7258. * @param dynamic Define if the buffer is updatable
  7259. */
  7260. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7261. /**
  7262. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7263. * or just falling back on setUniformXXX calls.
  7264. */
  7265. readonly useUbo: boolean;
  7266. /**
  7267. * Indicates if the WebGL underlying uniform buffer is in sync
  7268. * with the javascript cache data.
  7269. */
  7270. readonly isSync: boolean;
  7271. /**
  7272. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7273. * Also, a dynamic UniformBuffer will disable cache verification and always
  7274. * update the underlying WebGL uniform buffer to the GPU.
  7275. * @returns if Dynamic, otherwise false
  7276. */
  7277. isDynamic(): boolean;
  7278. /**
  7279. * The data cache on JS side.
  7280. * @returns the underlying data as a float array
  7281. */
  7282. getData(): Float32Array;
  7283. /**
  7284. * The underlying WebGL Uniform buffer.
  7285. * @returns the webgl buffer
  7286. */
  7287. getBuffer(): Nullable<DataBuffer>;
  7288. /**
  7289. * std140 layout specifies how to align data within an UBO structure.
  7290. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7291. * for specs.
  7292. */
  7293. private _fillAlignment;
  7294. /**
  7295. * Adds an uniform in the buffer.
  7296. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7297. * for the layout to be correct !
  7298. * @param name Name of the uniform, as used in the uniform block in the shader.
  7299. * @param size Data size, or data directly.
  7300. */
  7301. addUniform(name: string, size: number | number[]): void;
  7302. /**
  7303. * Adds a Matrix 4x4 to the uniform buffer.
  7304. * @param name Name of the uniform, as used in the uniform block in the shader.
  7305. * @param mat A 4x4 matrix.
  7306. */
  7307. addMatrix(name: string, mat: Matrix): void;
  7308. /**
  7309. * Adds a vec2 to the uniform buffer.
  7310. * @param name Name of the uniform, as used in the uniform block in the shader.
  7311. * @param x Define the x component value of the vec2
  7312. * @param y Define the y component value of the vec2
  7313. */
  7314. addFloat2(name: string, x: number, y: number): void;
  7315. /**
  7316. * Adds a vec3 to the uniform buffer.
  7317. * @param name Name of the uniform, as used in the uniform block in the shader.
  7318. * @param x Define the x component value of the vec3
  7319. * @param y Define the y component value of the vec3
  7320. * @param z Define the z component value of the vec3
  7321. */
  7322. addFloat3(name: string, x: number, y: number, z: number): void;
  7323. /**
  7324. * Adds a vec3 to the uniform buffer.
  7325. * @param name Name of the uniform, as used in the uniform block in the shader.
  7326. * @param color Define the vec3 from a Color
  7327. */
  7328. addColor3(name: string, color: Color3): void;
  7329. /**
  7330. * Adds a vec4 to the uniform buffer.
  7331. * @param name Name of the uniform, as used in the uniform block in the shader.
  7332. * @param color Define the rgb components from a Color
  7333. * @param alpha Define the a component of the vec4
  7334. */
  7335. addColor4(name: string, color: Color3, alpha: number): void;
  7336. /**
  7337. * Adds a vec3 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. * @param vector Define the vec3 components from a Vector
  7340. */
  7341. addVector3(name: string, vector: Vector3): void;
  7342. /**
  7343. * Adds a Matrix 3x3 to the uniform buffer.
  7344. * @param name Name of the uniform, as used in the uniform block in the shader.
  7345. */
  7346. addMatrix3x3(name: string): void;
  7347. /**
  7348. * Adds a Matrix 2x2 to the uniform buffer.
  7349. * @param name Name of the uniform, as used in the uniform block in the shader.
  7350. */
  7351. addMatrix2x2(name: string): void;
  7352. /**
  7353. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7354. */
  7355. create(): void;
  7356. /** @hidden */
  7357. _rebuild(): void;
  7358. /**
  7359. * Updates the WebGL Uniform Buffer on the GPU.
  7360. * If the `dynamic` flag is set to true, no cache comparison is done.
  7361. * Otherwise, the buffer will be updated only if the cache differs.
  7362. */
  7363. update(): void;
  7364. /**
  7365. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7366. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7367. * @param data Define the flattened data
  7368. * @param size Define the size of the data.
  7369. */
  7370. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7371. private _valueCache;
  7372. private _cacheMatrix;
  7373. private _updateMatrix3x3ForUniform;
  7374. private _updateMatrix3x3ForEffect;
  7375. private _updateMatrix2x2ForEffect;
  7376. private _updateMatrix2x2ForUniform;
  7377. private _updateFloatForEffect;
  7378. private _updateFloatForUniform;
  7379. private _updateFloat2ForEffect;
  7380. private _updateFloat2ForUniform;
  7381. private _updateFloat3ForEffect;
  7382. private _updateFloat3ForUniform;
  7383. private _updateFloat4ForEffect;
  7384. private _updateFloat4ForUniform;
  7385. private _updateMatrixForEffect;
  7386. private _updateMatrixForUniform;
  7387. private _updateVector3ForEffect;
  7388. private _updateVector3ForUniform;
  7389. private _updateVector4ForEffect;
  7390. private _updateVector4ForUniform;
  7391. private _updateColor3ForEffect;
  7392. private _updateColor3ForUniform;
  7393. private _updateColor4ForEffect;
  7394. private _updateColor4ForUniform;
  7395. /**
  7396. * Sets a sampler uniform on the effect.
  7397. * @param name Define the name of the sampler.
  7398. * @param texture Define the texture to set in the sampler
  7399. */
  7400. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7401. /**
  7402. * Directly updates the value of the uniform in the cache AND on the GPU.
  7403. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7404. * @param data Define the flattened data
  7405. */
  7406. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7407. /**
  7408. * Binds this uniform buffer to an effect.
  7409. * @param effect Define the effect to bind the buffer to
  7410. * @param name Name of the uniform block in the shader.
  7411. */
  7412. bindToEffect(effect: Effect, name: string): void;
  7413. /**
  7414. * Disposes the uniform buffer.
  7415. */
  7416. dispose(): void;
  7417. }
  7418. }
  7419. declare module BABYLON {
  7420. /**
  7421. * Enum that determines the text-wrapping mode to use.
  7422. */
  7423. export enum InspectableType {
  7424. /**
  7425. * Checkbox for booleans
  7426. */
  7427. Checkbox = 0,
  7428. /**
  7429. * Sliders for numbers
  7430. */
  7431. Slider = 1,
  7432. /**
  7433. * Vector3
  7434. */
  7435. Vector3 = 2,
  7436. /**
  7437. * Quaternions
  7438. */
  7439. Quaternion = 3,
  7440. /**
  7441. * Color3
  7442. */
  7443. Color3 = 4,
  7444. /**
  7445. * String
  7446. */
  7447. String = 5
  7448. }
  7449. /**
  7450. * Interface used to define custom inspectable properties.
  7451. * This interface is used by the inspector to display custom property grids
  7452. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7453. */
  7454. export interface IInspectable {
  7455. /**
  7456. * Gets the label to display
  7457. */
  7458. label: string;
  7459. /**
  7460. * Gets the name of the property to edit
  7461. */
  7462. propertyName: string;
  7463. /**
  7464. * Gets the type of the editor to use
  7465. */
  7466. type: InspectableType;
  7467. /**
  7468. * Gets the minimum value of the property when using in "slider" mode
  7469. */
  7470. min?: number;
  7471. /**
  7472. * Gets the maximum value of the property when using in "slider" mode
  7473. */
  7474. max?: number;
  7475. /**
  7476. * Gets the setp to use when using in "slider" mode
  7477. */
  7478. step?: number;
  7479. }
  7480. }
  7481. declare module BABYLON {
  7482. /**
  7483. * Class used to provide helper for timing
  7484. */
  7485. export class TimingTools {
  7486. /**
  7487. * Polyfill for setImmediate
  7488. * @param action defines the action to execute after the current execution block
  7489. */
  7490. static SetImmediate(action: () => void): void;
  7491. }
  7492. }
  7493. declare module BABYLON {
  7494. /**
  7495. * Class used to enable instatition of objects by class name
  7496. */
  7497. export class InstantiationTools {
  7498. /**
  7499. * Use this object to register external classes like custom textures or material
  7500. * to allow the laoders to instantiate them
  7501. */
  7502. static RegisteredExternalClasses: {
  7503. [key: string]: Object;
  7504. };
  7505. /**
  7506. * Tries to instantiate a new object from a given class name
  7507. * @param className defines the class name to instantiate
  7508. * @returns the new object or null if the system was not able to do the instantiation
  7509. */
  7510. static Instantiate(className: string): any;
  7511. }
  7512. }
  7513. declare module BABYLON {
  7514. /**
  7515. * Define options used to create a depth texture
  7516. */
  7517. export class DepthTextureCreationOptions {
  7518. /** Specifies whether or not a stencil should be allocated in the texture */
  7519. generateStencil?: boolean;
  7520. /** Specifies whether or not bilinear filtering is enable on the texture */
  7521. bilinearFiltering?: boolean;
  7522. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7523. comparisonFunction?: number;
  7524. /** Specifies if the created texture is a cube texture */
  7525. isCube?: boolean;
  7526. }
  7527. }
  7528. declare module BABYLON {
  7529. interface BaseEngine {
  7530. /**
  7531. * Creates a depth stencil cube texture.
  7532. * This is only available in WebGL 2.
  7533. * @param size The size of face edge in the cube texture.
  7534. * @param options The options defining the cube texture.
  7535. * @returns The cube texture
  7536. */
  7537. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7538. /**
  7539. * Creates a cube texture
  7540. * @param rootUrl defines the url where the files to load is located
  7541. * @param scene defines the current scene
  7542. * @param files defines the list of files to load (1 per face)
  7543. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7544. * @param onLoad defines an optional callback raised when the texture is loaded
  7545. * @param onError defines an optional callback raised if there is an issue to load the texture
  7546. * @param format defines the format of the data
  7547. * @param forcedExtension defines the extension to use to pick the right loader
  7548. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7551. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7552. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7553. * @returns the cube texture as an InternalTexture
  7554. */
  7555. 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;
  7556. /**
  7557. * Creates a cube texture
  7558. * @param rootUrl defines the url where the files to load is located
  7559. * @param scene defines the current scene
  7560. * @param files defines the list of files to load (1 per face)
  7561. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7562. * @param onLoad defines an optional callback raised when the texture is loaded
  7563. * @param onError defines an optional callback raised if there is an issue to load the texture
  7564. * @param format defines the format of the data
  7565. * @param forcedExtension defines the extension to use to pick the right loader
  7566. * @returns the cube texture as an InternalTexture
  7567. */
  7568. 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;
  7569. /**
  7570. * Creates a cube texture
  7571. * @param rootUrl defines the url where the files to load is located
  7572. * @param scene defines the current scene
  7573. * @param files defines the list of files to load (1 per face)
  7574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7575. * @param onLoad defines an optional callback raised when the texture is loaded
  7576. * @param onError defines an optional callback raised if there is an issue to load the texture
  7577. * @param format defines the format of the data
  7578. * @param forcedExtension defines the extension to use to pick the right loader
  7579. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7580. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7581. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7582. * @returns the cube texture as an InternalTexture
  7583. */
  7584. 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;
  7585. /** @hidden */
  7586. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7587. /** @hidden */
  7588. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7589. /** @hidden */
  7590. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7591. /** @hidden */
  7592. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7593. }
  7594. }
  7595. declare module BABYLON {
  7596. /**
  7597. * Class for creating a cube texture
  7598. */
  7599. export class CubeTexture extends BaseTexture {
  7600. private _delayedOnLoad;
  7601. /**
  7602. * The url of the texture
  7603. */
  7604. url: string;
  7605. /**
  7606. * Gets or sets the center of the bounding box associated with the cube texture.
  7607. * It must define where the camera used to render the texture was set
  7608. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7609. */
  7610. boundingBoxPosition: Vector3;
  7611. private _boundingBoxSize;
  7612. /**
  7613. * Gets or sets the size of the bounding box associated with the cube texture
  7614. * When defined, the cubemap will switch to local mode
  7615. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7616. * @example https://www.babylonjs-playground.com/#RNASML
  7617. */
  7618. /**
  7619. * Returns the bounding box size
  7620. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7621. */
  7622. boundingBoxSize: Vector3;
  7623. protected _rotationY: number;
  7624. /**
  7625. * Sets texture matrix rotation angle around Y axis in radians.
  7626. */
  7627. /**
  7628. * Gets texture matrix rotation angle around Y axis radians.
  7629. */
  7630. rotationY: number;
  7631. /**
  7632. * Are mip maps generated for this texture or not.
  7633. */
  7634. readonly noMipmap: boolean;
  7635. private _noMipmap;
  7636. private _files;
  7637. private _extensions;
  7638. private _textureMatrix;
  7639. private _format;
  7640. private _createPolynomials;
  7641. /** @hidden */
  7642. _prefiltered: boolean;
  7643. /**
  7644. * Creates a cube texture from an array of image urls
  7645. * @param files defines an array of image urls
  7646. * @param scene defines the hosting scene
  7647. * @param noMipmap specifies if mip maps are not used
  7648. * @returns a cube texture
  7649. */
  7650. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7651. /**
  7652. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7653. * @param url defines the url of the prefiltered texture
  7654. * @param scene defines the scene the texture is attached to
  7655. * @param forcedExtension defines the extension of the file if different from the url
  7656. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7657. * @return the prefiltered texture
  7658. */
  7659. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7660. /**
  7661. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7662. * as prefiltered data.
  7663. * @param rootUrl defines the url of the texture or the root name of the six images
  7664. * @param scene defines the scene the texture is attached to
  7665. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7666. * @param noMipmap defines if mipmaps should be created or not
  7667. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7668. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7669. * @param onError defines a callback triggered in case of error during load
  7670. * @param format defines the internal format to use for the texture once loaded
  7671. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7672. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7673. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7676. * @return the cube texture
  7677. */
  7678. 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);
  7679. /**
  7680. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7681. */
  7682. readonly isPrefiltered: boolean;
  7683. /**
  7684. * Get the current class name of the texture useful for serialization or dynamic coding.
  7685. * @returns "CubeTexture"
  7686. */
  7687. getClassName(): string;
  7688. /**
  7689. * Update the url (and optional buffer) of this texture if url was null during construction.
  7690. * @param url the url of the texture
  7691. * @param forcedExtension defines the extension to use
  7692. * @param onLoad callback called when the texture is loaded (defaults to null)
  7693. */
  7694. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7695. /**
  7696. * Delays loading of the cube texture
  7697. * @param forcedExtension defines the extension to use
  7698. */
  7699. delayLoad(forcedExtension?: string): void;
  7700. /**
  7701. * Returns the reflection texture matrix
  7702. * @returns the reflection texture matrix
  7703. */
  7704. getReflectionTextureMatrix(): Matrix;
  7705. /**
  7706. * Sets the reflection texture matrix
  7707. * @param value Reflection texture matrix
  7708. */
  7709. setReflectionTextureMatrix(value: Matrix): void;
  7710. /**
  7711. * Parses text to create a cube texture
  7712. * @param parsedTexture define the serialized text to read from
  7713. * @param scene defines the hosting scene
  7714. * @param rootUrl defines the root url of the cube texture
  7715. * @returns a cube texture
  7716. */
  7717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7718. /**
  7719. * Makes a clone, or deep copy, of the cube texture
  7720. * @returns a new cube texture
  7721. */
  7722. clone(): CubeTexture;
  7723. }
  7724. }
  7725. declare module BABYLON {
  7726. /**
  7727. * Manages the defines for the Material
  7728. */
  7729. export class MaterialDefines {
  7730. /** @hidden */
  7731. protected _keys: string[];
  7732. private _isDirty;
  7733. /** @hidden */
  7734. _renderId: number;
  7735. /** @hidden */
  7736. _areLightsDirty: boolean;
  7737. /** @hidden */
  7738. _areLightsDisposed: boolean;
  7739. /** @hidden */
  7740. _areAttributesDirty: boolean;
  7741. /** @hidden */
  7742. _areTexturesDirty: boolean;
  7743. /** @hidden */
  7744. _areFresnelDirty: boolean;
  7745. /** @hidden */
  7746. _areMiscDirty: boolean;
  7747. /** @hidden */
  7748. _areImageProcessingDirty: boolean;
  7749. /** @hidden */
  7750. _normals: boolean;
  7751. /** @hidden */
  7752. _uvs: boolean;
  7753. /** @hidden */
  7754. _needNormals: boolean;
  7755. /** @hidden */
  7756. _needUVs: boolean;
  7757. [id: string]: any;
  7758. /**
  7759. * Specifies if the material needs to be re-calculated
  7760. */
  7761. readonly isDirty: boolean;
  7762. /**
  7763. * Marks the material to indicate that it has been re-calculated
  7764. */
  7765. markAsProcessed(): void;
  7766. /**
  7767. * Marks the material to indicate that it needs to be re-calculated
  7768. */
  7769. markAsUnprocessed(): void;
  7770. /**
  7771. * Marks the material to indicate all of its defines need to be re-calculated
  7772. */
  7773. markAllAsDirty(): void;
  7774. /**
  7775. * Marks the material to indicate that image processing needs to be re-calculated
  7776. */
  7777. markAsImageProcessingDirty(): void;
  7778. /**
  7779. * Marks the material to indicate the lights need to be re-calculated
  7780. * @param disposed Defines whether the light is dirty due to dispose or not
  7781. */
  7782. markAsLightDirty(disposed?: boolean): void;
  7783. /**
  7784. * Marks the attribute state as changed
  7785. */
  7786. markAsAttributesDirty(): void;
  7787. /**
  7788. * Marks the texture state as changed
  7789. */
  7790. markAsTexturesDirty(): void;
  7791. /**
  7792. * Marks the fresnel state as changed
  7793. */
  7794. markAsFresnelDirty(): void;
  7795. /**
  7796. * Marks the misc state as changed
  7797. */
  7798. markAsMiscDirty(): void;
  7799. /**
  7800. * Rebuilds the material defines
  7801. */
  7802. rebuild(): void;
  7803. /**
  7804. * Specifies if two material defines are equal
  7805. * @param other - A material define instance to compare to
  7806. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7807. */
  7808. isEqual(other: MaterialDefines): boolean;
  7809. /**
  7810. * Clones this instance's defines to another instance
  7811. * @param other - material defines to clone values to
  7812. */
  7813. cloneTo(other: MaterialDefines): void;
  7814. /**
  7815. * Resets the material define values
  7816. */
  7817. reset(): void;
  7818. /**
  7819. * Converts the material define values to a string
  7820. * @returns - String of material define information
  7821. */
  7822. toString(): string;
  7823. }
  7824. }
  7825. declare module BABYLON {
  7826. /**
  7827. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7828. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7829. * 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;
  7830. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7831. */
  7832. export class ColorCurves {
  7833. private _dirty;
  7834. private _tempColor;
  7835. private _globalCurve;
  7836. private _highlightsCurve;
  7837. private _midtonesCurve;
  7838. private _shadowsCurve;
  7839. private _positiveCurve;
  7840. private _negativeCurve;
  7841. private _globalHue;
  7842. private _globalDensity;
  7843. private _globalSaturation;
  7844. private _globalExposure;
  7845. /**
  7846. * Gets the global Hue value.
  7847. * 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).
  7848. */
  7849. /**
  7850. * Sets the global Hue value.
  7851. * 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).
  7852. */
  7853. globalHue: number;
  7854. /**
  7855. * Gets the global Density value.
  7856. * 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.
  7857. * Values less than zero provide a filter of opposite hue.
  7858. */
  7859. /**
  7860. * Sets the global Density value.
  7861. * 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.
  7862. * Values less than zero provide a filter of opposite hue.
  7863. */
  7864. globalDensity: number;
  7865. /**
  7866. * Gets the global Saturation value.
  7867. * 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.
  7868. */
  7869. /**
  7870. * Sets the global Saturation value.
  7871. * 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.
  7872. */
  7873. globalSaturation: number;
  7874. /**
  7875. * Gets the global Exposure value.
  7876. * 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.
  7877. */
  7878. /**
  7879. * Sets the global Exposure value.
  7880. * 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.
  7881. */
  7882. globalExposure: number;
  7883. private _highlightsHue;
  7884. private _highlightsDensity;
  7885. private _highlightsSaturation;
  7886. private _highlightsExposure;
  7887. /**
  7888. * Gets the highlights Hue value.
  7889. * 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).
  7890. */
  7891. /**
  7892. * Sets the highlights Hue value.
  7893. * 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).
  7894. */
  7895. highlightsHue: number;
  7896. /**
  7897. * Gets the highlights 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. /**
  7902. * Sets the highlights Density value.
  7903. * 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.
  7904. * Values less than zero provide a filter of opposite hue.
  7905. */
  7906. highlightsDensity: number;
  7907. /**
  7908. * Gets the highlights 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. /**
  7912. * Sets the highlights Saturation value.
  7913. * 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.
  7914. */
  7915. highlightsSaturation: number;
  7916. /**
  7917. * Gets the highlights Exposure value.
  7918. * 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.
  7919. */
  7920. /**
  7921. * Sets the highlights Exposure value.
  7922. * 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.
  7923. */
  7924. highlightsExposure: number;
  7925. private _midtonesHue;
  7926. private _midtonesDensity;
  7927. private _midtonesSaturation;
  7928. private _midtonesExposure;
  7929. /**
  7930. * Gets the midtones Hue value.
  7931. * 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).
  7932. */
  7933. /**
  7934. * Sets the midtones Hue value.
  7935. * 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).
  7936. */
  7937. midtonesHue: number;
  7938. /**
  7939. * Gets the midtones Density value.
  7940. * 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.
  7941. * Values less than zero provide a filter of opposite hue.
  7942. */
  7943. /**
  7944. * Sets the midtones Density value.
  7945. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. midtonesDensity: number;
  7949. /**
  7950. * Gets the midtones Saturation value.
  7951. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7952. */
  7953. /**
  7954. * Sets the midtones 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. midtonesSaturation: number;
  7958. /**
  7959. * Gets the midtones 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. /**
  7963. * Sets the midtones Exposure value.
  7964. * 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.
  7965. */
  7966. midtonesExposure: number;
  7967. private _shadowsHue;
  7968. private _shadowsDensity;
  7969. private _shadowsSaturation;
  7970. private _shadowsExposure;
  7971. /**
  7972. * Gets the shadows Hue value.
  7973. * 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).
  7974. */
  7975. /**
  7976. * Sets the shadows Hue value.
  7977. * 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).
  7978. */
  7979. shadowsHue: number;
  7980. /**
  7981. * Gets the shadows Density value.
  7982. * 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.
  7983. * Values less than zero provide a filter of opposite hue.
  7984. */
  7985. /**
  7986. * Sets the shadows Density value.
  7987. * 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.
  7988. * Values less than zero provide a filter of opposite hue.
  7989. */
  7990. shadowsDensity: number;
  7991. /**
  7992. * Gets the shadows Saturation value.
  7993. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7994. */
  7995. /**
  7996. * Sets the shadows Saturation value.
  7997. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7998. */
  7999. shadowsSaturation: number;
  8000. /**
  8001. * Gets the shadows Exposure value.
  8002. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8003. */
  8004. /**
  8005. * Sets the shadows 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. shadowsExposure: number;
  8009. /**
  8010. * Returns the class name
  8011. * @returns The class name
  8012. */
  8013. getClassName(): string;
  8014. /**
  8015. * Binds the color curves to the shader.
  8016. * @param colorCurves The color curve to bind
  8017. * @param effect The effect to bind to
  8018. * @param positiveUniform The positive uniform shader parameter
  8019. * @param neutralUniform The neutral uniform shader parameter
  8020. * @param negativeUniform The negative uniform shader parameter
  8021. */
  8022. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8023. /**
  8024. * Prepare the list of uniforms associated with the ColorCurves effects.
  8025. * @param uniformsList The list of uniforms used in the effect
  8026. */
  8027. static PrepareUniforms(uniformsList: string[]): void;
  8028. /**
  8029. * Returns color grading data based on a hue, density, saturation and exposure value.
  8030. * @param filterHue The hue of the color filter.
  8031. * @param filterDensity The density of the color filter.
  8032. * @param saturation The saturation.
  8033. * @param exposure The exposure.
  8034. * @param result The result data container.
  8035. */
  8036. private getColorGradingDataToRef;
  8037. /**
  8038. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8039. * @param value The input slider value in range [-100,100].
  8040. * @returns Adjusted value.
  8041. */
  8042. private static applyColorGradingSliderNonlinear;
  8043. /**
  8044. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8045. * @param hue The hue (H) input.
  8046. * @param saturation The saturation (S) input.
  8047. * @param brightness The brightness (B) input.
  8048. * @result An RGBA color represented as Vector4.
  8049. */
  8050. private static fromHSBToRef;
  8051. /**
  8052. * Returns a value clamped between min and max
  8053. * @param value The value to clamp
  8054. * @param min The minimum of value
  8055. * @param max The maximum of value
  8056. * @returns The clamped value.
  8057. */
  8058. private static clamp;
  8059. /**
  8060. * Clones the current color curve instance.
  8061. * @return The cloned curves
  8062. */
  8063. clone(): ColorCurves;
  8064. /**
  8065. * Serializes the current color curve instance to a json representation.
  8066. * @return a JSON representation
  8067. */
  8068. serialize(): any;
  8069. /**
  8070. * Parses the color curve from a json representation.
  8071. * @param source the JSON source to parse
  8072. * @return The parsed curves
  8073. */
  8074. static Parse(source: any): ColorCurves;
  8075. }
  8076. }
  8077. declare module BABYLON {
  8078. /**
  8079. * Interface to follow in your material defines to integrate easily the
  8080. * Image proccessing functions.
  8081. * @hidden
  8082. */
  8083. export interface IImageProcessingConfigurationDefines {
  8084. IMAGEPROCESSING: boolean;
  8085. VIGNETTE: boolean;
  8086. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8087. VIGNETTEBLENDMODEOPAQUE: boolean;
  8088. TONEMAPPING: boolean;
  8089. TONEMAPPING_ACES: boolean;
  8090. CONTRAST: boolean;
  8091. EXPOSURE: boolean;
  8092. COLORCURVES: boolean;
  8093. COLORGRADING: boolean;
  8094. COLORGRADING3D: boolean;
  8095. SAMPLER3DGREENDEPTH: boolean;
  8096. SAMPLER3DBGRMAP: boolean;
  8097. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8098. }
  8099. /**
  8100. * @hidden
  8101. */
  8102. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8103. IMAGEPROCESSING: boolean;
  8104. VIGNETTE: boolean;
  8105. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8106. VIGNETTEBLENDMODEOPAQUE: boolean;
  8107. TONEMAPPING: boolean;
  8108. TONEMAPPING_ACES: boolean;
  8109. CONTRAST: boolean;
  8110. COLORCURVES: boolean;
  8111. COLORGRADING: boolean;
  8112. COLORGRADING3D: boolean;
  8113. SAMPLER3DGREENDEPTH: boolean;
  8114. SAMPLER3DBGRMAP: boolean;
  8115. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8116. EXPOSURE: boolean;
  8117. constructor();
  8118. }
  8119. /**
  8120. * This groups together the common properties used for image processing either in direct forward pass
  8121. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8122. * or not.
  8123. */
  8124. export class ImageProcessingConfiguration {
  8125. /**
  8126. * Default tone mapping applied in BabylonJS.
  8127. */
  8128. static readonly TONEMAPPING_STANDARD: number;
  8129. /**
  8130. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8131. * to other engines rendering to increase portability.
  8132. */
  8133. static readonly TONEMAPPING_ACES: number;
  8134. /**
  8135. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8136. */
  8137. colorCurves: Nullable<ColorCurves>;
  8138. private _colorCurvesEnabled;
  8139. /**
  8140. * Gets wether the color curves effect is enabled.
  8141. */
  8142. /**
  8143. * Sets wether the color curves effect is enabled.
  8144. */
  8145. colorCurvesEnabled: boolean;
  8146. private _colorGradingTexture;
  8147. /**
  8148. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8149. */
  8150. /**
  8151. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8152. */
  8153. colorGradingTexture: Nullable<BaseTexture>;
  8154. private _colorGradingEnabled;
  8155. /**
  8156. * Gets wether the color grading effect is enabled.
  8157. */
  8158. /**
  8159. * Sets wether the color grading effect is enabled.
  8160. */
  8161. colorGradingEnabled: boolean;
  8162. private _colorGradingWithGreenDepth;
  8163. /**
  8164. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8165. */
  8166. /**
  8167. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8168. */
  8169. colorGradingWithGreenDepth: boolean;
  8170. private _colorGradingBGR;
  8171. /**
  8172. * Gets wether the color grading texture contains BGR values.
  8173. */
  8174. /**
  8175. * Sets wether the color grading texture contains BGR values.
  8176. */
  8177. colorGradingBGR: boolean;
  8178. /** @hidden */
  8179. _exposure: number;
  8180. /**
  8181. * Gets the Exposure used in the effect.
  8182. */
  8183. /**
  8184. * Sets the Exposure used in the effect.
  8185. */
  8186. exposure: number;
  8187. private _toneMappingEnabled;
  8188. /**
  8189. * Gets wether the tone mapping effect is enabled.
  8190. */
  8191. /**
  8192. * Sets wether the tone mapping effect is enabled.
  8193. */
  8194. toneMappingEnabled: boolean;
  8195. private _toneMappingType;
  8196. /**
  8197. * Gets the type of tone mapping effect.
  8198. */
  8199. /**
  8200. * Sets the type of tone mapping effect used in BabylonJS.
  8201. */
  8202. toneMappingType: number;
  8203. protected _contrast: number;
  8204. /**
  8205. * Gets the contrast used in the effect.
  8206. */
  8207. /**
  8208. * Sets the contrast used in the effect.
  8209. */
  8210. contrast: number;
  8211. /**
  8212. * Vignette stretch size.
  8213. */
  8214. vignetteStretch: number;
  8215. /**
  8216. * Vignette centre X Offset.
  8217. */
  8218. vignetteCentreX: number;
  8219. /**
  8220. * Vignette centre Y Offset.
  8221. */
  8222. vignetteCentreY: number;
  8223. /**
  8224. * Vignette weight or intensity of the vignette effect.
  8225. */
  8226. vignetteWeight: number;
  8227. /**
  8228. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8229. * if vignetteEnabled is set to true.
  8230. */
  8231. vignetteColor: Color4;
  8232. /**
  8233. * Camera field of view used by the Vignette effect.
  8234. */
  8235. vignetteCameraFov: number;
  8236. private _vignetteBlendMode;
  8237. /**
  8238. * Gets the vignette blend mode allowing different kind of effect.
  8239. */
  8240. /**
  8241. * Sets the vignette blend mode allowing different kind of effect.
  8242. */
  8243. vignetteBlendMode: number;
  8244. private _vignetteEnabled;
  8245. /**
  8246. * Gets wether the vignette effect is enabled.
  8247. */
  8248. /**
  8249. * Sets wether the vignette effect is enabled.
  8250. */
  8251. vignetteEnabled: boolean;
  8252. private _applyByPostProcess;
  8253. /**
  8254. * Gets wether the image processing is applied through a post process or not.
  8255. */
  8256. /**
  8257. * Sets wether the image processing is applied through a post process or not.
  8258. */
  8259. applyByPostProcess: boolean;
  8260. private _isEnabled;
  8261. /**
  8262. * Gets wether the image processing is enabled or not.
  8263. */
  8264. /**
  8265. * Sets wether the image processing is enabled or not.
  8266. */
  8267. isEnabled: boolean;
  8268. /**
  8269. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8270. */
  8271. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8272. /**
  8273. * Method called each time the image processing information changes requires to recompile the effect.
  8274. */
  8275. protected _updateParameters(): void;
  8276. /**
  8277. * Gets the current class name.
  8278. * @return "ImageProcessingConfiguration"
  8279. */
  8280. getClassName(): string;
  8281. /**
  8282. * Prepare the list of uniforms associated with the Image Processing effects.
  8283. * @param uniforms The list of uniforms used in the effect
  8284. * @param defines the list of defines currently in use
  8285. */
  8286. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8287. /**
  8288. * Prepare the list of samplers associated with the Image Processing effects.
  8289. * @param samplersList The list of uniforms used in the effect
  8290. * @param defines the list of defines currently in use
  8291. */
  8292. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8293. /**
  8294. * Prepare the list of defines associated to the shader.
  8295. * @param defines the list of defines to complete
  8296. * @param forPostProcess Define if we are currently in post process mode or not
  8297. */
  8298. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8299. /**
  8300. * Returns true if all the image processing information are ready.
  8301. * @returns True if ready, otherwise, false
  8302. */
  8303. isReady(): boolean;
  8304. /**
  8305. * Binds the image processing to the shader.
  8306. * @param effect The effect to bind to
  8307. * @param aspectRatio Define the current aspect ratio of the effect
  8308. */
  8309. bind(effect: Effect, aspectRatio?: number): void;
  8310. /**
  8311. * Clones the current image processing instance.
  8312. * @return The cloned image processing
  8313. */
  8314. clone(): ImageProcessingConfiguration;
  8315. /**
  8316. * Serializes the current image processing instance to a json representation.
  8317. * @return a JSON representation
  8318. */
  8319. serialize(): any;
  8320. /**
  8321. * Parses the image processing from a json representation.
  8322. * @param source the JSON source to parse
  8323. * @return The parsed image processing
  8324. */
  8325. static Parse(source: any): ImageProcessingConfiguration;
  8326. private static _VIGNETTEMODE_MULTIPLY;
  8327. private static _VIGNETTEMODE_OPAQUE;
  8328. /**
  8329. * Used to apply the vignette as a mix with the pixel color.
  8330. */
  8331. static readonly VIGNETTEMODE_MULTIPLY: number;
  8332. /**
  8333. * Used to apply the vignette as a replacement of the pixel color.
  8334. */
  8335. static readonly VIGNETTEMODE_OPAQUE: number;
  8336. }
  8337. }
  8338. declare module BABYLON {
  8339. /** @hidden */
  8340. export var postprocessVertexShader: {
  8341. name: string;
  8342. shader: string;
  8343. };
  8344. }
  8345. declare module BABYLON {
  8346. /** Defines supported spaces */
  8347. export enum Space {
  8348. /** Local (object) space */
  8349. LOCAL = 0,
  8350. /** World space */
  8351. WORLD = 1,
  8352. /** Bone space */
  8353. BONE = 2
  8354. }
  8355. /** Defines the 3 main axes */
  8356. export class Axis {
  8357. /** X axis */
  8358. static X: Vector3;
  8359. /** Y axis */
  8360. static Y: Vector3;
  8361. /** Z axis */
  8362. static Z: Vector3;
  8363. }
  8364. }
  8365. declare module BABYLON {
  8366. /**
  8367. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8368. * This is the base of the follow, arc rotate cameras and Free camera
  8369. * @see http://doc.babylonjs.com/features/cameras
  8370. */
  8371. export class TargetCamera extends Camera {
  8372. private static _RigCamTransformMatrix;
  8373. private static _TargetTransformMatrix;
  8374. private static _TargetFocalPoint;
  8375. /**
  8376. * Define the current direction the camera is moving to
  8377. */
  8378. cameraDirection: Vector3;
  8379. /**
  8380. * Define the current rotation the camera is rotating to
  8381. */
  8382. cameraRotation: Vector2;
  8383. /**
  8384. * When set, the up vector of the camera will be updated by the rotation of the camera
  8385. */
  8386. updateUpVectorFromRotation: boolean;
  8387. private _tmpQuaternion;
  8388. /**
  8389. * Define the current rotation of the camera
  8390. */
  8391. rotation: Vector3;
  8392. /**
  8393. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8394. */
  8395. rotationQuaternion: Quaternion;
  8396. /**
  8397. * Define the current speed of the camera
  8398. */
  8399. speed: number;
  8400. /**
  8401. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8402. * around all axis.
  8403. */
  8404. noRotationConstraint: boolean;
  8405. /**
  8406. * Define the current target of the camera as an object or a position.
  8407. */
  8408. lockedTarget: any;
  8409. /** @hidden */
  8410. _currentTarget: Vector3;
  8411. /** @hidden */
  8412. _initialFocalDistance: number;
  8413. /** @hidden */
  8414. _viewMatrix: Matrix;
  8415. /** @hidden */
  8416. _camMatrix: Matrix;
  8417. /** @hidden */
  8418. _cameraTransformMatrix: Matrix;
  8419. /** @hidden */
  8420. _cameraRotationMatrix: Matrix;
  8421. /** @hidden */
  8422. _referencePoint: Vector3;
  8423. /** @hidden */
  8424. _transformedReferencePoint: Vector3;
  8425. protected _globalCurrentTarget: Vector3;
  8426. protected _globalCurrentUpVector: Vector3;
  8427. /** @hidden */
  8428. _reset: () => void;
  8429. private _defaultUp;
  8430. /**
  8431. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8432. * This is the base of the follow, arc rotate cameras and Free camera
  8433. * @see http://doc.babylonjs.com/features/cameras
  8434. * @param name Defines the name of the camera in the scene
  8435. * @param position Defines the start position of the camera in the scene
  8436. * @param scene Defines the scene the camera belongs to
  8437. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8438. */
  8439. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8440. /**
  8441. * Gets the position in front of the camera at a given distance.
  8442. * @param distance The distance from the camera we want the position to be
  8443. * @returns the position
  8444. */
  8445. getFrontPosition(distance: number): Vector3;
  8446. /** @hidden */
  8447. _getLockedTargetPosition(): Nullable<Vector3>;
  8448. private _storedPosition;
  8449. private _storedRotation;
  8450. private _storedRotationQuaternion;
  8451. /**
  8452. * Store current camera state of the camera (fov, position, rotation, etc..)
  8453. * @returns the camera
  8454. */
  8455. storeState(): Camera;
  8456. /**
  8457. * Restored camera state. You must call storeState() first
  8458. * @returns whether it was successful or not
  8459. * @hidden
  8460. */
  8461. _restoreStateValues(): boolean;
  8462. /** @hidden */
  8463. _initCache(): void;
  8464. /** @hidden */
  8465. _updateCache(ignoreParentClass?: boolean): void;
  8466. /** @hidden */
  8467. _isSynchronizedViewMatrix(): boolean;
  8468. /** @hidden */
  8469. _computeLocalCameraSpeed(): number;
  8470. /**
  8471. * Defines the target the camera should look at.
  8472. * @param target Defines the new target as a Vector or a mesh
  8473. */
  8474. setTarget(target: Vector3): void;
  8475. /**
  8476. * Return the current target position of the camera. This value is expressed in local space.
  8477. * @returns the target position
  8478. */
  8479. getTarget(): Vector3;
  8480. /** @hidden */
  8481. _decideIfNeedsToMove(): boolean;
  8482. /** @hidden */
  8483. _updatePosition(): void;
  8484. /** @hidden */
  8485. _checkInputs(): void;
  8486. protected _updateCameraRotationMatrix(): void;
  8487. /**
  8488. * 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)
  8489. * @returns the current camera
  8490. */
  8491. private _rotateUpVectorWithCameraRotationMatrix;
  8492. private _cachedRotationZ;
  8493. private _cachedQuaternionRotationZ;
  8494. /** @hidden */
  8495. _getViewMatrix(): Matrix;
  8496. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8497. /**
  8498. * @hidden
  8499. */
  8500. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8501. /**
  8502. * @hidden
  8503. */
  8504. _updateRigCameras(): void;
  8505. private _getRigCamPositionAndTarget;
  8506. /**
  8507. * Gets the current object class name.
  8508. * @return the class name
  8509. */
  8510. getClassName(): string;
  8511. }
  8512. }
  8513. declare module BABYLON {
  8514. /**
  8515. * Gather the list of keyboard event types as constants.
  8516. */
  8517. export class KeyboardEventTypes {
  8518. /**
  8519. * The keydown event is fired when a key becomes active (pressed).
  8520. */
  8521. static readonly KEYDOWN: number;
  8522. /**
  8523. * The keyup event is fired when a key has been released.
  8524. */
  8525. static readonly KEYUP: number;
  8526. }
  8527. /**
  8528. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8529. */
  8530. export class KeyboardInfo {
  8531. /**
  8532. * Defines the type of event (KeyboardEventTypes)
  8533. */
  8534. type: number;
  8535. /**
  8536. * Defines the related dom event
  8537. */
  8538. event: KeyboardEvent;
  8539. /**
  8540. * Instantiates a new keyboard info.
  8541. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8542. * @param type Defines the type of event (KeyboardEventTypes)
  8543. * @param event Defines the related dom event
  8544. */
  8545. constructor(
  8546. /**
  8547. * Defines the type of event (KeyboardEventTypes)
  8548. */
  8549. type: number,
  8550. /**
  8551. * Defines the related dom event
  8552. */
  8553. event: KeyboardEvent);
  8554. }
  8555. /**
  8556. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8557. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8558. */
  8559. export class KeyboardInfoPre extends KeyboardInfo {
  8560. /**
  8561. * Defines the type of event (KeyboardEventTypes)
  8562. */
  8563. type: number;
  8564. /**
  8565. * Defines the related dom event
  8566. */
  8567. event: KeyboardEvent;
  8568. /**
  8569. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8570. */
  8571. skipOnPointerObservable: boolean;
  8572. /**
  8573. * Instantiates a new keyboard pre info.
  8574. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8575. * @param type Defines the type of event (KeyboardEventTypes)
  8576. * @param event Defines the related dom event
  8577. */
  8578. constructor(
  8579. /**
  8580. * Defines the type of event (KeyboardEventTypes)
  8581. */
  8582. type: number,
  8583. /**
  8584. * Defines the related dom event
  8585. */
  8586. event: KeyboardEvent);
  8587. }
  8588. }
  8589. declare module BABYLON {
  8590. /**
  8591. * Manage the keyboard inputs to control the movement of a free camera.
  8592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8593. */
  8594. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8595. /**
  8596. * Defines the camera the input is attached to.
  8597. */
  8598. camera: FreeCamera;
  8599. /**
  8600. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8601. */
  8602. keysUp: number[];
  8603. /**
  8604. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8605. */
  8606. keysDown: number[];
  8607. /**
  8608. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8609. */
  8610. keysLeft: number[];
  8611. /**
  8612. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8613. */
  8614. keysRight: number[];
  8615. private _keys;
  8616. private _onCanvasBlurObserver;
  8617. private _onKeyboardObserver;
  8618. private _engine;
  8619. private _scene;
  8620. /**
  8621. * Attach the input controls to a specific dom element to get the input from.
  8622. * @param element Defines the element the controls should be listened from
  8623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8624. */
  8625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8626. /**
  8627. * Detach the current controls from the specified dom element.
  8628. * @param element Defines the element to stop listening the inputs from
  8629. */
  8630. detachControl(element: Nullable<HTMLElement>): void;
  8631. /**
  8632. * Update the current camera state depending on the inputs that have been used this frame.
  8633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8634. */
  8635. checkInputs(): void;
  8636. /**
  8637. * Gets the class name of the current intput.
  8638. * @returns the class name
  8639. */
  8640. getClassName(): string;
  8641. /** @hidden */
  8642. _onLostFocus(): void;
  8643. /**
  8644. * Get the friendly name associated with the input class.
  8645. * @returns the input friendly name
  8646. */
  8647. getSimpleName(): string;
  8648. }
  8649. }
  8650. declare module BABYLON {
  8651. /**
  8652. * Interface describing all the common properties and methods a shadow light needs to implement.
  8653. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8654. * as well as binding the different shadow properties to the effects.
  8655. */
  8656. export interface IShadowLight extends Light {
  8657. /**
  8658. * The light id in the scene (used in scene.findLighById for instance)
  8659. */
  8660. id: string;
  8661. /**
  8662. * The position the shdow will be casted from.
  8663. */
  8664. position: Vector3;
  8665. /**
  8666. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8667. */
  8668. direction: Vector3;
  8669. /**
  8670. * The transformed position. Position of the light in world space taking parenting in account.
  8671. */
  8672. transformedPosition: Vector3;
  8673. /**
  8674. * The transformed direction. Direction of the light in world space taking parenting in account.
  8675. */
  8676. transformedDirection: Vector3;
  8677. /**
  8678. * The friendly name of the light in the scene.
  8679. */
  8680. name: string;
  8681. /**
  8682. * Defines the shadow projection clipping minimum z value.
  8683. */
  8684. shadowMinZ: number;
  8685. /**
  8686. * Defines the shadow projection clipping maximum z value.
  8687. */
  8688. shadowMaxZ: number;
  8689. /**
  8690. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8691. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8692. */
  8693. computeTransformedInformation(): boolean;
  8694. /**
  8695. * Gets the scene the light belongs to.
  8696. * @returns The scene
  8697. */
  8698. getScene(): Scene;
  8699. /**
  8700. * Callback defining a custom Projection Matrix Builder.
  8701. * This can be used to override the default projection matrix computation.
  8702. */
  8703. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8704. /**
  8705. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8706. * @param matrix The materix to updated with the projection information
  8707. * @param viewMatrix The transform matrix of the light
  8708. * @param renderList The list of mesh to render in the map
  8709. * @returns The current light
  8710. */
  8711. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8712. /**
  8713. * Gets the current depth scale used in ESM.
  8714. * @returns The scale
  8715. */
  8716. getDepthScale(): number;
  8717. /**
  8718. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8719. * @returns true if a cube texture needs to be use
  8720. */
  8721. needCube(): boolean;
  8722. /**
  8723. * Detects if the projection matrix requires to be recomputed this frame.
  8724. * @returns true if it requires to be recomputed otherwise, false.
  8725. */
  8726. needProjectionMatrixCompute(): boolean;
  8727. /**
  8728. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8729. */
  8730. forceProjectionMatrixCompute(): void;
  8731. /**
  8732. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8733. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8734. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8735. */
  8736. getShadowDirection(faceIndex?: number): Vector3;
  8737. /**
  8738. * Gets the minZ used for shadow according to both the scene and the light.
  8739. * @param activeCamera The camera we are returning the min for
  8740. * @returns the depth min z
  8741. */
  8742. getDepthMinZ(activeCamera: Camera): number;
  8743. /**
  8744. * Gets the maxZ used for shadow according to both the scene and the light.
  8745. * @param activeCamera The camera we are returning the max for
  8746. * @returns the depth max z
  8747. */
  8748. getDepthMaxZ(activeCamera: Camera): number;
  8749. }
  8750. /**
  8751. * Base implementation IShadowLight
  8752. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8753. */
  8754. export abstract class ShadowLight extends Light implements IShadowLight {
  8755. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8756. protected _position: Vector3;
  8757. protected _setPosition(value: Vector3): void;
  8758. /**
  8759. * Sets the position the shadow will be casted from. Also use as the light position for both
  8760. * point and spot lights.
  8761. */
  8762. /**
  8763. * Sets the position the shadow will be casted from. Also use as the light position for both
  8764. * point and spot lights.
  8765. */
  8766. position: Vector3;
  8767. protected _direction: Vector3;
  8768. protected _setDirection(value: Vector3): void;
  8769. /**
  8770. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8771. * Also use as the light direction on spot and directional lights.
  8772. */
  8773. /**
  8774. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8775. * Also use as the light direction on spot and directional lights.
  8776. */
  8777. direction: Vector3;
  8778. private _shadowMinZ;
  8779. /**
  8780. * Gets the shadow projection clipping minimum z value.
  8781. */
  8782. /**
  8783. * Sets the shadow projection clipping minimum z value.
  8784. */
  8785. shadowMinZ: number;
  8786. private _shadowMaxZ;
  8787. /**
  8788. * Sets the shadow projection clipping maximum z value.
  8789. */
  8790. /**
  8791. * Gets the shadow projection clipping maximum z value.
  8792. */
  8793. shadowMaxZ: number;
  8794. /**
  8795. * Callback defining a custom Projection Matrix Builder.
  8796. * This can be used to override the default projection matrix computation.
  8797. */
  8798. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8799. /**
  8800. * The transformed position. Position of the light in world space taking parenting in account.
  8801. */
  8802. transformedPosition: Vector3;
  8803. /**
  8804. * The transformed direction. Direction of the light in world space taking parenting in account.
  8805. */
  8806. transformedDirection: Vector3;
  8807. private _needProjectionMatrixCompute;
  8808. /**
  8809. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8810. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8811. */
  8812. computeTransformedInformation(): boolean;
  8813. /**
  8814. * Return the depth scale used for the shadow map.
  8815. * @returns the depth scale.
  8816. */
  8817. getDepthScale(): number;
  8818. /**
  8819. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8820. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8821. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8822. */
  8823. getShadowDirection(faceIndex?: number): Vector3;
  8824. /**
  8825. * Returns the ShadowLight absolute position in the World.
  8826. * @returns the position vector in world space
  8827. */
  8828. getAbsolutePosition(): Vector3;
  8829. /**
  8830. * Sets the ShadowLight direction toward the passed target.
  8831. * @param target The point to target in local space
  8832. * @returns the updated ShadowLight direction
  8833. */
  8834. setDirectionToTarget(target: Vector3): Vector3;
  8835. /**
  8836. * Returns the light rotation in euler definition.
  8837. * @returns the x y z rotation in local space.
  8838. */
  8839. getRotation(): Vector3;
  8840. /**
  8841. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8842. * @returns true if a cube texture needs to be use
  8843. */
  8844. needCube(): boolean;
  8845. /**
  8846. * Detects if the projection matrix requires to be recomputed this frame.
  8847. * @returns true if it requires to be recomputed otherwise, false.
  8848. */
  8849. needProjectionMatrixCompute(): boolean;
  8850. /**
  8851. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8852. */
  8853. forceProjectionMatrixCompute(): void;
  8854. /** @hidden */
  8855. _initCache(): void;
  8856. /** @hidden */
  8857. _isSynchronized(): boolean;
  8858. /**
  8859. * Computes the world matrix of the node
  8860. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8861. * @returns the world matrix
  8862. */
  8863. computeWorldMatrix(force?: boolean): Matrix;
  8864. /**
  8865. * Gets the minZ used for shadow according to both the scene and the light.
  8866. * @param activeCamera The camera we are returning the min for
  8867. * @returns the depth min z
  8868. */
  8869. getDepthMinZ(activeCamera: Camera): number;
  8870. /**
  8871. * Gets the maxZ used for shadow according to both the scene and the light.
  8872. * @param activeCamera The camera we are returning the max for
  8873. * @returns the depth max z
  8874. */
  8875. getDepthMaxZ(activeCamera: Camera): number;
  8876. /**
  8877. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8878. * @param matrix The materix to updated with the projection information
  8879. * @param viewMatrix The transform matrix of the light
  8880. * @param renderList The list of mesh to render in the map
  8881. * @returns The current light
  8882. */
  8883. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8884. }
  8885. }
  8886. declare module BABYLON {
  8887. /**
  8888. * "Static Class" containing the most commonly used helper while dealing with material for
  8889. * rendering purpose.
  8890. *
  8891. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8892. *
  8893. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8894. */
  8895. export class MaterialHelper {
  8896. /**
  8897. * Bind the current view position to an effect.
  8898. * @param effect The effect to be bound
  8899. * @param scene The scene the eyes position is used from
  8900. */
  8901. static BindEyePosition(effect: Effect, scene: Scene): void;
  8902. /**
  8903. * Helps preparing the defines values about the UVs in used in the effect.
  8904. * UVs are shared as much as we can accross channels in the shaders.
  8905. * @param texture The texture we are preparing the UVs for
  8906. * @param defines The defines to update
  8907. * @param key The channel key "diffuse", "specular"... used in the shader
  8908. */
  8909. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8910. /**
  8911. * Binds a texture matrix value to its corrsponding uniform
  8912. * @param texture The texture to bind the matrix for
  8913. * @param uniformBuffer The uniform buffer receivin the data
  8914. * @param key The channel key "diffuse", "specular"... used in the shader
  8915. */
  8916. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8917. /**
  8918. * Gets the current status of the fog (should it be enabled?)
  8919. * @param mesh defines the mesh to evaluate for fog support
  8920. * @param scene defines the hosting scene
  8921. * @returns true if fog must be enabled
  8922. */
  8923. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8924. /**
  8925. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8926. * @param mesh defines the current mesh
  8927. * @param scene defines the current scene
  8928. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8929. * @param pointsCloud defines if point cloud rendering has to be turned on
  8930. * @param fogEnabled defines if fog has to be turned on
  8931. * @param alphaTest defines if alpha testing has to be turned on
  8932. * @param defines defines the current list of defines
  8933. */
  8934. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8935. /**
  8936. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8937. * @param scene defines the current scene
  8938. * @param engine defines the current engine
  8939. * @param defines specifies the list of active defines
  8940. * @param useInstances defines if instances have to be turned on
  8941. * @param useClipPlane defines if clip plane have to be turned on
  8942. */
  8943. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8944. /**
  8945. * Prepares the defines for bones
  8946. * @param mesh The mesh containing the geometry data we will draw
  8947. * @param defines The defines to update
  8948. */
  8949. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8950. /**
  8951. * Prepares the defines for morph targets
  8952. * @param mesh The mesh containing the geometry data we will draw
  8953. * @param defines The defines to update
  8954. */
  8955. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8956. /**
  8957. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8958. * @param mesh The mesh containing the geometry data we will draw
  8959. * @param defines The defines to update
  8960. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8961. * @param useBones Precise whether bones should be used or not (override mesh info)
  8962. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8963. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8964. * @returns false if defines are considered not dirty and have not been checked
  8965. */
  8966. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8967. /**
  8968. * Prepares the defines related to multiview
  8969. * @param scene The scene we are intending to draw
  8970. * @param defines The defines to update
  8971. */
  8972. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8973. /**
  8974. * Prepares the defines related to the light information passed in parameter
  8975. * @param scene The scene we are intending to draw
  8976. * @param mesh The mesh the effect is compiling for
  8977. * @param light The light the effect is compiling for
  8978. * @param lightIndex The index of the light
  8979. * @param defines The defines to update
  8980. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8981. * @param state Defines the current state regarding what is needed (normals, etc...)
  8982. */
  8983. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8984. needNormals: boolean;
  8985. needRebuild: boolean;
  8986. shadowEnabled: boolean;
  8987. specularEnabled: boolean;
  8988. lightmapMode: boolean;
  8989. }): void;
  8990. /**
  8991. * Prepares the defines related to the light information passed in parameter
  8992. * @param scene The scene we are intending to draw
  8993. * @param mesh The mesh the effect is compiling for
  8994. * @param defines The defines to update
  8995. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8996. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8997. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8998. * @returns true if normals will be required for the rest of the effect
  8999. */
  9000. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9001. /**
  9002. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9003. * @param lightIndex defines the light index
  9004. * @param uniformsList The uniform list
  9005. * @param samplersList The sampler list
  9006. * @param projectedLightTexture defines if projected texture must be used
  9007. * @param uniformBuffersList defines an optional list of uniform buffers
  9008. */
  9009. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9010. /**
  9011. * Prepares the uniforms and samplers list to be used in the effect
  9012. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9013. * @param samplersList The sampler list
  9014. * @param defines The defines helping in the list generation
  9015. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9016. */
  9017. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9018. /**
  9019. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9020. * @param defines The defines to update while falling back
  9021. * @param fallbacks The authorized effect fallbacks
  9022. * @param maxSimultaneousLights The maximum number of lights allowed
  9023. * @param rank the current rank of the Effect
  9024. * @returns The newly affected rank
  9025. */
  9026. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9027. private static _TmpMorphInfluencers;
  9028. /**
  9029. * Prepares the list of attributes required for morph targets according to the effect defines.
  9030. * @param attribs The current list of supported attribs
  9031. * @param mesh The mesh to prepare the morph targets attributes for
  9032. * @param influencers The number of influencers
  9033. */
  9034. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9035. /**
  9036. * Prepares the list of attributes required for morph targets according to the effect defines.
  9037. * @param attribs The current list of supported attribs
  9038. * @param mesh The mesh to prepare the morph targets attributes for
  9039. * @param defines The current Defines of the effect
  9040. */
  9041. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9042. /**
  9043. * Prepares the list of attributes required for bones according to the effect defines.
  9044. * @param attribs The current list of supported attribs
  9045. * @param mesh The mesh to prepare the bones attributes for
  9046. * @param defines The current Defines of the effect
  9047. * @param fallbacks The current efffect fallback strategy
  9048. */
  9049. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9050. /**
  9051. * Check and prepare the list of attributes required for instances according to the effect defines.
  9052. * @param attribs The current list of supported attribs
  9053. * @param defines The current MaterialDefines of the effect
  9054. */
  9055. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9056. /**
  9057. * Add the list of attributes required for instances to the attribs array.
  9058. * @param attribs The current list of supported attribs
  9059. */
  9060. static PushAttributesForInstances(attribs: string[]): void;
  9061. /**
  9062. * Binds the light shadow information to the effect for the given mesh.
  9063. * @param light The light containing the generator
  9064. * @param scene The scene the lights belongs to
  9065. * @param mesh The mesh we are binding the information to render
  9066. * @param lightIndex The light index in the effect used to render the mesh
  9067. * @param effect The effect we are binding the data to
  9068. */
  9069. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9070. /**
  9071. * Binds the light information to the effect.
  9072. * @param light The light containing the generator
  9073. * @param effect The effect we are binding the data to
  9074. * @param lightIndex The light index in the effect used to render
  9075. */
  9076. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9077. /**
  9078. * Binds the lights information from the scene to the effect for the given mesh.
  9079. * @param light Light to bind
  9080. * @param lightIndex Light index
  9081. * @param scene The scene where the light belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param useSpecular Defines if specular is supported
  9085. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9086. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9087. */
  9088. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9089. /**
  9090. * Binds the lights information from the scene to the effect for the given mesh.
  9091. * @param scene The scene the lights belongs to
  9092. * @param mesh The mesh we are binding the information to render
  9093. * @param effect The effect we are binding the data to
  9094. * @param defines The generated defines for the effect
  9095. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9096. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9097. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9098. */
  9099. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9100. private static _tempFogColor;
  9101. /**
  9102. * Binds the fog information from the scene to the effect for the given mesh.
  9103. * @param scene The scene the lights belongs to
  9104. * @param mesh The mesh we are binding the information to render
  9105. * @param effect The effect we are binding the data to
  9106. * @param linearSpace Defines if the fog effect is applied in linear space
  9107. */
  9108. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9109. /**
  9110. * Binds the bones information from the mesh to the effect.
  9111. * @param mesh The mesh we are binding the information to render
  9112. * @param effect The effect we are binding the data to
  9113. */
  9114. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9115. /**
  9116. * Binds the morph targets information from the mesh to the effect.
  9117. * @param abstractMesh The mesh we are binding the information to render
  9118. * @param effect The effect we are binding the data to
  9119. */
  9120. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9121. /**
  9122. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9123. * @param defines The generated defines used in the effect
  9124. * @param effect The effect we are binding the data to
  9125. * @param scene The scene we are willing to render with logarithmic scale for
  9126. */
  9127. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9128. /**
  9129. * Binds the clip plane information from the scene to the effect.
  9130. * @param scene The scene the clip plane information are extracted from
  9131. * @param effect The effect we are binding the data to
  9132. */
  9133. static BindClipPlane(effect: Effect, scene: Scene): void;
  9134. }
  9135. }
  9136. declare module BABYLON {
  9137. /** @hidden */
  9138. export var packingFunctions: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module BABYLON {
  9144. /** @hidden */
  9145. export var shadowMapPixelShader: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module BABYLON {
  9151. /** @hidden */
  9152. export var bonesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module BABYLON {
  9158. /** @hidden */
  9159. export var morphTargetsVertexGlobalDeclaration: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module BABYLON {
  9165. /** @hidden */
  9166. export var morphTargetsVertexDeclaration: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module BABYLON {
  9172. /** @hidden */
  9173. export var instancesDeclaration: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module BABYLON {
  9179. /** @hidden */
  9180. export var helperFunctions: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module BABYLON {
  9186. /** @hidden */
  9187. export var morphTargetsVertex: {
  9188. name: string;
  9189. shader: string;
  9190. };
  9191. }
  9192. declare module BABYLON {
  9193. /** @hidden */
  9194. export var instancesVertex: {
  9195. name: string;
  9196. shader: string;
  9197. };
  9198. }
  9199. declare module BABYLON {
  9200. /** @hidden */
  9201. export var bonesVertex: {
  9202. name: string;
  9203. shader: string;
  9204. };
  9205. }
  9206. declare module BABYLON {
  9207. /** @hidden */
  9208. export var shadowMapVertexShader: {
  9209. name: string;
  9210. shader: string;
  9211. };
  9212. }
  9213. declare module BABYLON {
  9214. /** @hidden */
  9215. export var depthBoxBlurPixelShader: {
  9216. name: string;
  9217. shader: string;
  9218. };
  9219. }
  9220. declare module BABYLON {
  9221. /**
  9222. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9223. */
  9224. export interface ICustomShaderOptions {
  9225. /**
  9226. * Gets or sets the custom shader name to use
  9227. */
  9228. shaderName: string;
  9229. /**
  9230. * The list of attribute names used in the shader
  9231. */
  9232. attributes?: string[];
  9233. /**
  9234. * The list of unifrom names used in the shader
  9235. */
  9236. uniforms?: string[];
  9237. /**
  9238. * The list of sampler names used in the shader
  9239. */
  9240. samplers?: string[];
  9241. /**
  9242. * The list of defines used in the shader
  9243. */
  9244. defines?: string[];
  9245. }
  9246. /**
  9247. * Interface to implement to create a shadow generator compatible with BJS.
  9248. */
  9249. export interface IShadowGenerator {
  9250. /**
  9251. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9252. * @returns The render target texture if present otherwise, null
  9253. */
  9254. getShadowMap(): Nullable<RenderTargetTexture>;
  9255. /**
  9256. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9257. * @returns The render target texture if the shadow map is present otherwise, null
  9258. */
  9259. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9260. /**
  9261. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9262. * @param subMesh The submesh we want to render in the shadow map
  9263. * @param useInstances Defines wether will draw in the map using instances
  9264. * @returns true if ready otherwise, false
  9265. */
  9266. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9267. /**
  9268. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9269. * @param defines Defines of the material we want to update
  9270. * @param lightIndex Index of the light in the enabled light list of the material
  9271. */
  9272. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9273. /**
  9274. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9275. * defined in the generator but impacting the effect).
  9276. * It implies the unifroms available on the materials are the standard BJS ones.
  9277. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9278. * @param effect The effect we are binfing the information for
  9279. */
  9280. bindShadowLight(lightIndex: string, effect: Effect): void;
  9281. /**
  9282. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9283. * (eq to shadow prjection matrix * light transform matrix)
  9284. * @returns The transform matrix used to create the shadow map
  9285. */
  9286. getTransformMatrix(): Matrix;
  9287. /**
  9288. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9289. * Cube and 2D textures for instance.
  9290. */
  9291. recreateShadowMap(): void;
  9292. /**
  9293. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9294. * @param onCompiled Callback triggered at the and of the effects compilation
  9295. * @param options Sets of optional options forcing the compilation with different modes
  9296. */
  9297. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9298. useInstances: boolean;
  9299. }>): void;
  9300. /**
  9301. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9302. * @param options Sets of optional options forcing the compilation with different modes
  9303. * @returns A promise that resolves when the compilation completes
  9304. */
  9305. forceCompilationAsync(options?: Partial<{
  9306. useInstances: boolean;
  9307. }>): Promise<void>;
  9308. /**
  9309. * Serializes the shadow generator setup to a json object.
  9310. * @returns The serialized JSON object
  9311. */
  9312. serialize(): any;
  9313. /**
  9314. * Disposes the Shadow map and related Textures and effects.
  9315. */
  9316. dispose(): void;
  9317. }
  9318. /**
  9319. * Default implementation IShadowGenerator.
  9320. * This is the main object responsible of generating shadows in the framework.
  9321. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9322. */
  9323. export class ShadowGenerator implements IShadowGenerator {
  9324. /**
  9325. * Shadow generator mode None: no filtering applied.
  9326. */
  9327. static readonly FILTER_NONE: number;
  9328. /**
  9329. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9330. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9331. */
  9332. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9333. /**
  9334. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9335. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9336. */
  9337. static readonly FILTER_POISSONSAMPLING: number;
  9338. /**
  9339. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9340. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9341. */
  9342. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9343. /**
  9344. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9345. * edge artifacts on steep falloff.
  9346. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9347. */
  9348. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9349. /**
  9350. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9351. * edge artifacts on steep falloff.
  9352. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9353. */
  9354. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9355. /**
  9356. * Shadow generator mode PCF: Percentage Closer Filtering
  9357. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9358. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9359. */
  9360. static readonly FILTER_PCF: number;
  9361. /**
  9362. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9363. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9364. * Contact Hardening
  9365. */
  9366. static readonly FILTER_PCSS: number;
  9367. /**
  9368. * Reserved for PCF and PCSS
  9369. * Highest Quality.
  9370. *
  9371. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9372. *
  9373. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9374. */
  9375. static readonly QUALITY_HIGH: number;
  9376. /**
  9377. * Reserved for PCF and PCSS
  9378. * Good tradeoff for quality/perf cross devices
  9379. *
  9380. * Execute PCF on a 3*3 kernel.
  9381. *
  9382. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9383. */
  9384. static readonly QUALITY_MEDIUM: number;
  9385. /**
  9386. * Reserved for PCF and PCSS
  9387. * The lowest quality but the fastest.
  9388. *
  9389. * Execute PCF on a 1*1 kernel.
  9390. *
  9391. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9392. */
  9393. static readonly QUALITY_LOW: number;
  9394. /** Gets or sets the custom shader name to use */
  9395. customShaderOptions: ICustomShaderOptions;
  9396. /**
  9397. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9398. */
  9399. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9400. /**
  9401. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9402. */
  9403. onAfterShadowMapRenderObservable: Observable<Effect>;
  9404. /**
  9405. * Observable triggered before a mesh is rendered in the shadow map.
  9406. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9407. */
  9408. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9409. /**
  9410. * Observable triggered after a mesh is rendered in the shadow map.
  9411. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9412. */
  9413. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9414. private _bias;
  9415. /**
  9416. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9417. */
  9418. /**
  9419. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9420. */
  9421. bias: number;
  9422. private _normalBias;
  9423. /**
  9424. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9425. */
  9426. /**
  9427. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9428. */
  9429. normalBias: number;
  9430. private _blurBoxOffset;
  9431. /**
  9432. * Gets the blur box offset: offset applied during the blur pass.
  9433. * Only useful if useKernelBlur = false
  9434. */
  9435. /**
  9436. * Sets the blur box offset: offset applied during the blur pass.
  9437. * Only useful if useKernelBlur = false
  9438. */
  9439. blurBoxOffset: number;
  9440. private _blurScale;
  9441. /**
  9442. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9443. * 2 means half of the size.
  9444. */
  9445. /**
  9446. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9447. * 2 means half of the size.
  9448. */
  9449. blurScale: number;
  9450. private _blurKernel;
  9451. /**
  9452. * Gets the blur kernel: kernel size of the blur pass.
  9453. * Only useful if useKernelBlur = true
  9454. */
  9455. /**
  9456. * Sets the blur kernel: kernel size of the blur pass.
  9457. * Only useful if useKernelBlur = true
  9458. */
  9459. blurKernel: number;
  9460. private _useKernelBlur;
  9461. /**
  9462. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9463. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9464. */
  9465. /**
  9466. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9467. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9468. */
  9469. useKernelBlur: boolean;
  9470. private _depthScale;
  9471. /**
  9472. * Gets the depth scale used in ESM mode.
  9473. */
  9474. /**
  9475. * Sets the depth scale used in ESM mode.
  9476. * This can override the scale stored on the light.
  9477. */
  9478. depthScale: number;
  9479. private _filter;
  9480. /**
  9481. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9482. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9483. */
  9484. /**
  9485. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9486. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9487. */
  9488. filter: number;
  9489. /**
  9490. * Gets if the current filter is set to Poisson Sampling.
  9491. */
  9492. /**
  9493. * Sets the current filter to Poisson Sampling.
  9494. */
  9495. usePoissonSampling: boolean;
  9496. /**
  9497. * Gets if the current filter is set to ESM.
  9498. */
  9499. /**
  9500. * Sets the current filter is to ESM.
  9501. */
  9502. useExponentialShadowMap: boolean;
  9503. /**
  9504. * Gets if the current filter is set to filtered ESM.
  9505. */
  9506. /**
  9507. * Gets if the current filter is set to filtered ESM.
  9508. */
  9509. useBlurExponentialShadowMap: boolean;
  9510. /**
  9511. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9512. * exponential to prevent steep falloff artifacts).
  9513. */
  9514. /**
  9515. * Sets the current filter to "close ESM" (using the inverse of the
  9516. * exponential to prevent steep falloff artifacts).
  9517. */
  9518. useCloseExponentialShadowMap: boolean;
  9519. /**
  9520. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9521. * exponential to prevent steep falloff artifacts).
  9522. */
  9523. /**
  9524. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9525. * exponential to prevent steep falloff artifacts).
  9526. */
  9527. useBlurCloseExponentialShadowMap: boolean;
  9528. /**
  9529. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9530. */
  9531. /**
  9532. * Sets the current filter to "PCF" (percentage closer filtering).
  9533. */
  9534. usePercentageCloserFiltering: boolean;
  9535. private _filteringQuality;
  9536. /**
  9537. * Gets the PCF or PCSS Quality.
  9538. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9539. */
  9540. /**
  9541. * Sets the PCF or PCSS Quality.
  9542. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9543. */
  9544. filteringQuality: number;
  9545. /**
  9546. * Gets if the current filter is set to "PCSS" (contact hardening).
  9547. */
  9548. /**
  9549. * Sets the current filter to "PCSS" (contact hardening).
  9550. */
  9551. useContactHardeningShadow: boolean;
  9552. private _contactHardeningLightSizeUVRatio;
  9553. /**
  9554. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9555. * Using a ratio helps keeping shape stability independently of the map size.
  9556. *
  9557. * It does not account for the light projection as it was having too much
  9558. * instability during the light setup or during light position changes.
  9559. *
  9560. * Only valid if useContactHardeningShadow is true.
  9561. */
  9562. /**
  9563. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9564. * Using a ratio helps keeping shape stability independently of the map size.
  9565. *
  9566. * It does not account for the light projection as it was having too much
  9567. * instability during the light setup or during light position changes.
  9568. *
  9569. * Only valid if useContactHardeningShadow is true.
  9570. */
  9571. contactHardeningLightSizeUVRatio: number;
  9572. private _darkness;
  9573. /** Gets or sets the actual darkness of a shadow */
  9574. darkness: number;
  9575. /**
  9576. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9577. * 0 means strongest and 1 would means no shadow.
  9578. * @returns the darkness.
  9579. */
  9580. getDarkness(): number;
  9581. /**
  9582. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9583. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9584. * @returns the shadow generator allowing fluent coding.
  9585. */
  9586. setDarkness(darkness: number): ShadowGenerator;
  9587. private _transparencyShadow;
  9588. /** Gets or sets the ability to have transparent shadow */
  9589. transparencyShadow: boolean;
  9590. /**
  9591. * Sets the ability to have transparent shadow (boolean).
  9592. * @param transparent True if transparent else False
  9593. * @returns the shadow generator allowing fluent coding
  9594. */
  9595. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9596. private _shadowMap;
  9597. private _shadowMap2;
  9598. /**
  9599. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9600. * @returns The render target texture if present otherwise, null
  9601. */
  9602. getShadowMap(): Nullable<RenderTargetTexture>;
  9603. /**
  9604. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9605. * @returns The render target texture if the shadow map is present otherwise, null
  9606. */
  9607. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9608. /**
  9609. * Gets the class name of that object
  9610. * @returns "ShadowGenerator"
  9611. */
  9612. getClassName(): string;
  9613. /**
  9614. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9615. * @param mesh Mesh to add
  9616. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9617. * @returns the Shadow Generator itself
  9618. */
  9619. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9620. /**
  9621. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9622. * @param mesh Mesh to remove
  9623. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9624. * @returns the Shadow Generator itself
  9625. */
  9626. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9627. /**
  9628. * Controls the extent to which the shadows fade out at the edge of the frustum
  9629. * Used only by directionals and spots
  9630. */
  9631. frustumEdgeFalloff: number;
  9632. private _light;
  9633. /**
  9634. * Returns the associated light object.
  9635. * @returns the light generating the shadow
  9636. */
  9637. getLight(): IShadowLight;
  9638. /**
  9639. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9640. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9641. * It might on the other hand introduce peter panning.
  9642. */
  9643. forceBackFacesOnly: boolean;
  9644. private _scene;
  9645. private _lightDirection;
  9646. private _effect;
  9647. private _viewMatrix;
  9648. private _projectionMatrix;
  9649. private _transformMatrix;
  9650. private _cachedPosition;
  9651. private _cachedDirection;
  9652. private _cachedDefines;
  9653. private _currentRenderID;
  9654. private _boxBlurPostprocess;
  9655. private _kernelBlurXPostprocess;
  9656. private _kernelBlurYPostprocess;
  9657. private _blurPostProcesses;
  9658. private _mapSize;
  9659. private _currentFaceIndex;
  9660. private _currentFaceIndexCache;
  9661. private _textureType;
  9662. private _defaultTextureMatrix;
  9663. /** @hidden */
  9664. static _SceneComponentInitialization: (scene: Scene) => void;
  9665. /**
  9666. * Creates a ShadowGenerator object.
  9667. * A ShadowGenerator is the required tool to use the shadows.
  9668. * Each light casting shadows needs to use its own ShadowGenerator.
  9669. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9670. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9671. * @param light The light object generating the shadows.
  9672. * @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.
  9673. */
  9674. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9675. private _initializeGenerator;
  9676. private _initializeShadowMap;
  9677. private _initializeBlurRTTAndPostProcesses;
  9678. private _renderForShadowMap;
  9679. private _renderSubMeshForShadowMap;
  9680. private _applyFilterValues;
  9681. /**
  9682. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9683. * @param onCompiled Callback triggered at the and of the effects compilation
  9684. * @param options Sets of optional options forcing the compilation with different modes
  9685. */
  9686. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9687. useInstances: boolean;
  9688. }>): void;
  9689. /**
  9690. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9691. * @param options Sets of optional options forcing the compilation with different modes
  9692. * @returns A promise that resolves when the compilation completes
  9693. */
  9694. forceCompilationAsync(options?: Partial<{
  9695. useInstances: boolean;
  9696. }>): Promise<void>;
  9697. /**
  9698. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9699. * @param subMesh The submesh we want to render in the shadow map
  9700. * @param useInstances Defines wether will draw in the map using instances
  9701. * @returns true if ready otherwise, false
  9702. */
  9703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9704. /**
  9705. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9706. * @param defines Defines of the material we want to update
  9707. * @param lightIndex Index of the light in the enabled light list of the material
  9708. */
  9709. prepareDefines(defines: any, lightIndex: number): void;
  9710. /**
  9711. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9712. * defined in the generator but impacting the effect).
  9713. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9714. * @param effect The effect we are binfing the information for
  9715. */
  9716. bindShadowLight(lightIndex: string, effect: Effect): void;
  9717. /**
  9718. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9719. * (eq to shadow prjection matrix * light transform matrix)
  9720. * @returns The transform matrix used to create the shadow map
  9721. */
  9722. getTransformMatrix(): Matrix;
  9723. /**
  9724. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9725. * Cube and 2D textures for instance.
  9726. */
  9727. recreateShadowMap(): void;
  9728. private _disposeBlurPostProcesses;
  9729. private _disposeRTTandPostProcesses;
  9730. /**
  9731. * Disposes the ShadowGenerator.
  9732. * Returns nothing.
  9733. */
  9734. dispose(): void;
  9735. /**
  9736. * Serializes the shadow generator setup to a json object.
  9737. * @returns The serialized JSON object
  9738. */
  9739. serialize(): any;
  9740. /**
  9741. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9742. * @param parsedShadowGenerator The JSON object to parse
  9743. * @param scene The scene to create the shadow map for
  9744. * @returns The parsed shadow generator
  9745. */
  9746. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9747. }
  9748. }
  9749. declare module BABYLON {
  9750. /**
  9751. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9752. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9753. * 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.
  9754. */
  9755. export abstract class Light extends Node {
  9756. /**
  9757. * Falloff Default: light is falling off following the material specification:
  9758. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9759. */
  9760. static readonly FALLOFF_DEFAULT: number;
  9761. /**
  9762. * Falloff Physical: light is falling off following the inverse squared distance law.
  9763. */
  9764. static readonly FALLOFF_PHYSICAL: number;
  9765. /**
  9766. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9767. * to enhance interoperability with other engines.
  9768. */
  9769. static readonly FALLOFF_GLTF: number;
  9770. /**
  9771. * Falloff Standard: light is falling off like in the standard material
  9772. * to enhance interoperability with other materials.
  9773. */
  9774. static readonly FALLOFF_STANDARD: number;
  9775. /**
  9776. * If every light affecting the material is in this lightmapMode,
  9777. * material.lightmapTexture adds or multiplies
  9778. * (depends on material.useLightmapAsShadowmap)
  9779. * after every other light calculations.
  9780. */
  9781. static readonly LIGHTMAP_DEFAULT: number;
  9782. /**
  9783. * material.lightmapTexture as only diffuse lighting from this light
  9784. * adds only specular lighting from this light
  9785. * adds dynamic shadows
  9786. */
  9787. static readonly LIGHTMAP_SPECULAR: number;
  9788. /**
  9789. * material.lightmapTexture as only lighting
  9790. * no light calculation from this light
  9791. * only adds dynamic shadows from this light
  9792. */
  9793. static readonly LIGHTMAP_SHADOWSONLY: number;
  9794. /**
  9795. * Each light type uses the default quantity according to its type:
  9796. * point/spot lights use luminous intensity
  9797. * directional lights use illuminance
  9798. */
  9799. static readonly INTENSITYMODE_AUTOMATIC: number;
  9800. /**
  9801. * lumen (lm)
  9802. */
  9803. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9804. /**
  9805. * candela (lm/sr)
  9806. */
  9807. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9808. /**
  9809. * lux (lm/m^2)
  9810. */
  9811. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9812. /**
  9813. * nit (cd/m^2)
  9814. */
  9815. static readonly INTENSITYMODE_LUMINANCE: number;
  9816. /**
  9817. * Light type const id of the point light.
  9818. */
  9819. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9820. /**
  9821. * Light type const id of the directional light.
  9822. */
  9823. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9824. /**
  9825. * Light type const id of the spot light.
  9826. */
  9827. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9828. /**
  9829. * Light type const id of the hemispheric light.
  9830. */
  9831. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9832. /**
  9833. * Diffuse gives the basic color to an object.
  9834. */
  9835. diffuse: Color3;
  9836. /**
  9837. * Specular produces a highlight color on an object.
  9838. * Note: This is note affecting PBR materials.
  9839. */
  9840. specular: Color3;
  9841. /**
  9842. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9843. * falling off base on range or angle.
  9844. * This can be set to any values in Light.FALLOFF_x.
  9845. *
  9846. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9847. * other types of materials.
  9848. */
  9849. falloffType: number;
  9850. /**
  9851. * Strength of the light.
  9852. * Note: By default it is define in the framework own unit.
  9853. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9854. */
  9855. intensity: number;
  9856. private _range;
  9857. protected _inverseSquaredRange: number;
  9858. /**
  9859. * Defines how far from the source the light is impacting in scene units.
  9860. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9861. */
  9862. /**
  9863. * Defines how far from the source the light is impacting in scene units.
  9864. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9865. */
  9866. range: number;
  9867. /**
  9868. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9869. * of light.
  9870. */
  9871. private _photometricScale;
  9872. private _intensityMode;
  9873. /**
  9874. * Gets the photometric scale used to interpret the intensity.
  9875. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9876. */
  9877. /**
  9878. * Sets the photometric scale used to interpret the intensity.
  9879. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9880. */
  9881. intensityMode: number;
  9882. private _radius;
  9883. /**
  9884. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9885. */
  9886. /**
  9887. * sets the light radius used by PBR Materials to simulate soft area lights.
  9888. */
  9889. radius: number;
  9890. private _renderPriority;
  9891. /**
  9892. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9893. * exceeding the number allowed of the materials.
  9894. */
  9895. renderPriority: number;
  9896. private _shadowEnabled;
  9897. /**
  9898. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9899. * the current shadow generator.
  9900. */
  9901. /**
  9902. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9903. * the current shadow generator.
  9904. */
  9905. shadowEnabled: boolean;
  9906. private _includedOnlyMeshes;
  9907. /**
  9908. * Gets the only meshes impacted by this light.
  9909. */
  9910. /**
  9911. * Sets the only meshes impacted by this light.
  9912. */
  9913. includedOnlyMeshes: AbstractMesh[];
  9914. private _excludedMeshes;
  9915. /**
  9916. * Gets the meshes not impacted by this light.
  9917. */
  9918. /**
  9919. * Sets the meshes not impacted by this light.
  9920. */
  9921. excludedMeshes: AbstractMesh[];
  9922. private _excludeWithLayerMask;
  9923. /**
  9924. * Gets the layer id use to find what meshes are not impacted by the light.
  9925. * Inactive if 0
  9926. */
  9927. /**
  9928. * Sets the layer id use to find what meshes are not impacted by the light.
  9929. * Inactive if 0
  9930. */
  9931. excludeWithLayerMask: number;
  9932. private _includeOnlyWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. includeOnlyWithLayerMask: number;
  9942. private _lightmapMode;
  9943. /**
  9944. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9945. */
  9946. /**
  9947. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9948. */
  9949. lightmapMode: number;
  9950. /**
  9951. * Shadow generator associted to the light.
  9952. * @hidden Internal use only.
  9953. */
  9954. _shadowGenerator: Nullable<IShadowGenerator>;
  9955. /**
  9956. * @hidden Internal use only.
  9957. */
  9958. _excludedMeshesIds: string[];
  9959. /**
  9960. * @hidden Internal use only.
  9961. */
  9962. _includedOnlyMeshesIds: string[];
  9963. /**
  9964. * The current light unifom buffer.
  9965. * @hidden Internal use only.
  9966. */
  9967. _uniformBuffer: UniformBuffer;
  9968. /**
  9969. * Creates a Light object in the scene.
  9970. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9971. * @param name The firendly name of the light
  9972. * @param scene The scene the light belongs too
  9973. */
  9974. constructor(name: string, scene: Scene);
  9975. protected abstract _buildUniformLayout(): void;
  9976. /**
  9977. * Sets the passed Effect "effect" with the Light information.
  9978. * @param effect The effect to update
  9979. * @param lightIndex The index of the light in the effect to update
  9980. * @returns The light
  9981. */
  9982. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9983. /**
  9984. * Sets the passed Effect "effect" with the Light information.
  9985. * @param effect The effect to update
  9986. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9987. * @returns The light
  9988. */
  9989. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9990. /**
  9991. * Returns the string "Light".
  9992. * @returns the class name
  9993. */
  9994. getClassName(): string;
  9995. /** @hidden */
  9996. readonly _isLight: boolean;
  9997. /**
  9998. * Converts the light information to a readable string for debug purpose.
  9999. * @param fullDetails Supports for multiple levels of logging within scene loading
  10000. * @returns the human readable light info
  10001. */
  10002. toString(fullDetails?: boolean): string;
  10003. /** @hidden */
  10004. protected _syncParentEnabledState(): void;
  10005. /**
  10006. * Set the enabled state of this node.
  10007. * @param value - the new enabled state
  10008. */
  10009. setEnabled(value: boolean): void;
  10010. /**
  10011. * Returns the Light associated shadow generator if any.
  10012. * @return the associated shadow generator.
  10013. */
  10014. getShadowGenerator(): Nullable<IShadowGenerator>;
  10015. /**
  10016. * Returns a Vector3, the absolute light position in the World.
  10017. * @returns the world space position of the light
  10018. */
  10019. getAbsolutePosition(): Vector3;
  10020. /**
  10021. * Specifies if the light will affect the passed mesh.
  10022. * @param mesh The mesh to test against the light
  10023. * @return true the mesh is affected otherwise, false.
  10024. */
  10025. canAffectMesh(mesh: AbstractMesh): boolean;
  10026. /**
  10027. * Sort function to order lights for rendering.
  10028. * @param a First Light object to compare to second.
  10029. * @param b Second Light object to compare first.
  10030. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10031. */
  10032. static CompareLightsPriority(a: Light, b: Light): number;
  10033. /**
  10034. * Releases resources associated with this node.
  10035. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10036. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10037. */
  10038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10039. /**
  10040. * Returns the light type ID (integer).
  10041. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10042. */
  10043. getTypeID(): number;
  10044. /**
  10045. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10046. * @returns the scaled intensity in intensity mode unit
  10047. */
  10048. getScaledIntensity(): number;
  10049. /**
  10050. * Returns a new Light object, named "name", from the current one.
  10051. * @param name The name of the cloned light
  10052. * @returns the new created light
  10053. */
  10054. clone(name: string): Nullable<Light>;
  10055. /**
  10056. * Serializes the current light into a Serialization object.
  10057. * @returns the serialized object.
  10058. */
  10059. serialize(): any;
  10060. /**
  10061. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10062. * This new light is named "name" and added to the passed scene.
  10063. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10064. * @param name The friendly name of the light
  10065. * @param scene The scene the new light will belong to
  10066. * @returns the constructor function
  10067. */
  10068. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10069. /**
  10070. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10071. * @param parsedLight The JSON representation of the light
  10072. * @param scene The scene to create the parsed light in
  10073. * @returns the created light after parsing
  10074. */
  10075. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10076. private _hookArrayForExcluded;
  10077. private _hookArrayForIncludedOnly;
  10078. private _resyncMeshes;
  10079. /**
  10080. * Forces the meshes to update their light related information in their rendering used effects
  10081. * @hidden Internal Use Only
  10082. */
  10083. _markMeshesAsLightDirty(): void;
  10084. /**
  10085. * Recomputes the cached photometric scale if needed.
  10086. */
  10087. private _computePhotometricScale;
  10088. /**
  10089. * Returns the Photometric Scale according to the light type and intensity mode.
  10090. */
  10091. private _getPhotometricScale;
  10092. /**
  10093. * Reorder the light in the scene according to their defined priority.
  10094. * @hidden Internal Use Only
  10095. */
  10096. _reorderLightsInScene(): void;
  10097. /**
  10098. * Prepares the list of defines specific to the light type.
  10099. * @param defines the list of defines
  10100. * @param lightIndex defines the index of the light for the effect
  10101. */
  10102. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10103. }
  10104. }
  10105. declare module BABYLON {
  10106. /**
  10107. * Interface used to define Action
  10108. */
  10109. export interface IAction {
  10110. /**
  10111. * Trigger for the action
  10112. */
  10113. trigger: number;
  10114. /** Options of the trigger */
  10115. triggerOptions: any;
  10116. /**
  10117. * Gets the trigger parameters
  10118. * @returns the trigger parameters
  10119. */
  10120. getTriggerParameter(): any;
  10121. /**
  10122. * Internal only - executes current action event
  10123. * @hidden
  10124. */
  10125. _executeCurrent(evt?: ActionEvent): void;
  10126. /**
  10127. * Serialize placeholder for child classes
  10128. * @param parent of child
  10129. * @returns the serialized object
  10130. */
  10131. serialize(parent: any): any;
  10132. /**
  10133. * Internal only
  10134. * @hidden
  10135. */
  10136. _prepare(): void;
  10137. /**
  10138. * Internal only - manager for action
  10139. * @hidden
  10140. */
  10141. _actionManager: AbstractActionManager;
  10142. /**
  10143. * Adds action to chain of actions, may be a DoNothingAction
  10144. * @param action defines the next action to execute
  10145. * @returns The action passed in
  10146. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10147. */
  10148. then(action: IAction): IAction;
  10149. }
  10150. /**
  10151. * The action to be carried out following a trigger
  10152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10153. */
  10154. export class Action implements IAction {
  10155. /** the trigger, with or without parameters, for the action */
  10156. triggerOptions: any;
  10157. /**
  10158. * Trigger for the action
  10159. */
  10160. trigger: number;
  10161. /**
  10162. * Internal only - manager for action
  10163. * @hidden
  10164. */
  10165. _actionManager: ActionManager;
  10166. private _nextActiveAction;
  10167. private _child;
  10168. private _condition?;
  10169. private _triggerParameter;
  10170. /**
  10171. * An event triggered prior to action being executed.
  10172. */
  10173. onBeforeExecuteObservable: Observable<Action>;
  10174. /**
  10175. * Creates a new Action
  10176. * @param triggerOptions the trigger, with or without parameters, for the action
  10177. * @param condition an optional determinant of action
  10178. */
  10179. constructor(
  10180. /** the trigger, with or without parameters, for the action */
  10181. triggerOptions: any, condition?: Condition);
  10182. /**
  10183. * Internal only
  10184. * @hidden
  10185. */
  10186. _prepare(): void;
  10187. /**
  10188. * Gets the trigger parameters
  10189. * @returns the trigger parameters
  10190. */
  10191. getTriggerParameter(): any;
  10192. /**
  10193. * Internal only - executes current action event
  10194. * @hidden
  10195. */
  10196. _executeCurrent(evt?: ActionEvent): void;
  10197. /**
  10198. * Execute placeholder for child classes
  10199. * @param evt optional action event
  10200. */
  10201. execute(evt?: ActionEvent): void;
  10202. /**
  10203. * Skips to next active action
  10204. */
  10205. skipToNextActiveAction(): void;
  10206. /**
  10207. * Adds action to chain of actions, may be a DoNothingAction
  10208. * @param action defines the next action to execute
  10209. * @returns The action passed in
  10210. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10211. */
  10212. then(action: Action): Action;
  10213. /**
  10214. * Internal only
  10215. * @hidden
  10216. */
  10217. _getProperty(propertyPath: string): string;
  10218. /**
  10219. * Internal only
  10220. * @hidden
  10221. */
  10222. _getEffectiveTarget(target: any, propertyPath: string): any;
  10223. /**
  10224. * Serialize placeholder for child classes
  10225. * @param parent of child
  10226. * @returns the serialized object
  10227. */
  10228. serialize(parent: any): any;
  10229. /**
  10230. * Internal only called by serialize
  10231. * @hidden
  10232. */
  10233. protected _serialize(serializedAction: any, parent?: any): any;
  10234. /**
  10235. * Internal only
  10236. * @hidden
  10237. */
  10238. static _SerializeValueAsString: (value: any) => string;
  10239. /**
  10240. * Internal only
  10241. * @hidden
  10242. */
  10243. static _GetTargetProperty: (target: Node | Scene) => {
  10244. name: string;
  10245. targetType: string;
  10246. value: string;
  10247. };
  10248. }
  10249. }
  10250. declare module BABYLON {
  10251. /**
  10252. * A Condition applied to an Action
  10253. */
  10254. export class Condition {
  10255. /**
  10256. * Internal only - manager for action
  10257. * @hidden
  10258. */
  10259. _actionManager: ActionManager;
  10260. /**
  10261. * Internal only
  10262. * @hidden
  10263. */
  10264. _evaluationId: number;
  10265. /**
  10266. * Internal only
  10267. * @hidden
  10268. */
  10269. _currentResult: boolean;
  10270. /**
  10271. * Creates a new Condition
  10272. * @param actionManager the manager of the action the condition is applied to
  10273. */
  10274. constructor(actionManager: ActionManager);
  10275. /**
  10276. * Check if the current condition is valid
  10277. * @returns a boolean
  10278. */
  10279. isValid(): boolean;
  10280. /**
  10281. * Internal only
  10282. * @hidden
  10283. */
  10284. _getProperty(propertyPath: string): string;
  10285. /**
  10286. * Internal only
  10287. * @hidden
  10288. */
  10289. _getEffectiveTarget(target: any, propertyPath: string): any;
  10290. /**
  10291. * Serialize placeholder for child classes
  10292. * @returns the serialized object
  10293. */
  10294. serialize(): any;
  10295. /**
  10296. * Internal only
  10297. * @hidden
  10298. */
  10299. protected _serialize(serializedCondition: any): any;
  10300. }
  10301. /**
  10302. * Defines specific conditional operators as extensions of Condition
  10303. */
  10304. export class ValueCondition extends Condition {
  10305. /** path to specify the property of the target the conditional operator uses */
  10306. propertyPath: string;
  10307. /** the value compared by the conditional operator against the current value of the property */
  10308. value: any;
  10309. /** the conditional operator, default ValueCondition.IsEqual */
  10310. operator: number;
  10311. /**
  10312. * Internal only
  10313. * @hidden
  10314. */
  10315. private static _IsEqual;
  10316. /**
  10317. * Internal only
  10318. * @hidden
  10319. */
  10320. private static _IsDifferent;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. private static _IsGreater;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. private static _IsLesser;
  10331. /**
  10332. * returns the number for IsEqual
  10333. */
  10334. static readonly IsEqual: number;
  10335. /**
  10336. * Returns the number for IsDifferent
  10337. */
  10338. static readonly IsDifferent: number;
  10339. /**
  10340. * Returns the number for IsGreater
  10341. */
  10342. static readonly IsGreater: number;
  10343. /**
  10344. * Returns the number for IsLesser
  10345. */
  10346. static readonly IsLesser: number;
  10347. /**
  10348. * Internal only The action manager for the condition
  10349. * @hidden
  10350. */
  10351. _actionManager: ActionManager;
  10352. /**
  10353. * Internal only
  10354. * @hidden
  10355. */
  10356. private _target;
  10357. /**
  10358. * Internal only
  10359. * @hidden
  10360. */
  10361. private _effectiveTarget;
  10362. /**
  10363. * Internal only
  10364. * @hidden
  10365. */
  10366. private _property;
  10367. /**
  10368. * Creates a new ValueCondition
  10369. * @param actionManager manager for the action the condition applies to
  10370. * @param target for the action
  10371. * @param propertyPath path to specify the property of the target the conditional operator uses
  10372. * @param value the value compared by the conditional operator against the current value of the property
  10373. * @param operator the conditional operator, default ValueCondition.IsEqual
  10374. */
  10375. constructor(actionManager: ActionManager, target: any,
  10376. /** path to specify the property of the target the conditional operator uses */
  10377. propertyPath: string,
  10378. /** the value compared by the conditional operator against the current value of the property */
  10379. value: any,
  10380. /** the conditional operator, default ValueCondition.IsEqual */
  10381. operator?: number);
  10382. /**
  10383. * Compares the given value with the property value for the specified conditional operator
  10384. * @returns the result of the comparison
  10385. */
  10386. isValid(): boolean;
  10387. /**
  10388. * Serialize the ValueCondition into a JSON compatible object
  10389. * @returns serialization object
  10390. */
  10391. serialize(): any;
  10392. /**
  10393. * Gets the name of the conditional operator for the ValueCondition
  10394. * @param operator the conditional operator
  10395. * @returns the name
  10396. */
  10397. static GetOperatorName(operator: number): string;
  10398. }
  10399. /**
  10400. * Defines a predicate condition as an extension of Condition
  10401. */
  10402. export class PredicateCondition extends Condition {
  10403. /** defines the predicate function used to validate the condition */
  10404. predicate: () => boolean;
  10405. /**
  10406. * Internal only - manager for action
  10407. * @hidden
  10408. */
  10409. _actionManager: ActionManager;
  10410. /**
  10411. * Creates a new PredicateCondition
  10412. * @param actionManager manager for the action the condition applies to
  10413. * @param predicate defines the predicate function used to validate the condition
  10414. */
  10415. constructor(actionManager: ActionManager,
  10416. /** defines the predicate function used to validate the condition */
  10417. predicate: () => boolean);
  10418. /**
  10419. * @returns the validity of the predicate condition
  10420. */
  10421. isValid(): boolean;
  10422. }
  10423. /**
  10424. * Defines a state condition as an extension of Condition
  10425. */
  10426. export class StateCondition extends Condition {
  10427. /** Value to compare with target state */
  10428. value: string;
  10429. /**
  10430. * Internal only - manager for action
  10431. * @hidden
  10432. */
  10433. _actionManager: ActionManager;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. private _target;
  10439. /**
  10440. * Creates a new StateCondition
  10441. * @param actionManager manager for the action the condition applies to
  10442. * @param target of the condition
  10443. * @param value to compare with target state
  10444. */
  10445. constructor(actionManager: ActionManager, target: any,
  10446. /** Value to compare with target state */
  10447. value: string);
  10448. /**
  10449. * Gets a boolean indicating if the current condition is met
  10450. * @returns the validity of the state
  10451. */
  10452. isValid(): boolean;
  10453. /**
  10454. * Serialize the StateCondition into a JSON compatible object
  10455. * @returns serialization object
  10456. */
  10457. serialize(): any;
  10458. }
  10459. }
  10460. declare module BABYLON {
  10461. /**
  10462. * This defines an action responsible to toggle a boolean once triggered.
  10463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10464. */
  10465. export class SwitchBooleanAction extends Action {
  10466. /**
  10467. * The path to the boolean property in the target object
  10468. */
  10469. propertyPath: string;
  10470. private _target;
  10471. private _effectiveTarget;
  10472. private _property;
  10473. /**
  10474. * Instantiate the action
  10475. * @param triggerOptions defines the trigger options
  10476. * @param target defines the object containing the boolean
  10477. * @param propertyPath defines the path to the boolean property in the target object
  10478. * @param condition defines the trigger related conditions
  10479. */
  10480. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10481. /** @hidden */
  10482. _prepare(): void;
  10483. /**
  10484. * Execute the action toggle the boolean value.
  10485. */
  10486. execute(): void;
  10487. /**
  10488. * Serializes the actions and its related information.
  10489. * @param parent defines the object to serialize in
  10490. * @returns the serialized object
  10491. */
  10492. serialize(parent: any): any;
  10493. }
  10494. /**
  10495. * This defines an action responsible to set a the state field of the target
  10496. * to a desired value once triggered.
  10497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10498. */
  10499. export class SetStateAction extends Action {
  10500. /**
  10501. * The value to store in the state field.
  10502. */
  10503. value: string;
  10504. private _target;
  10505. /**
  10506. * Instantiate the action
  10507. * @param triggerOptions defines the trigger options
  10508. * @param target defines the object containing the state property
  10509. * @param value defines the value to store in the state field
  10510. * @param condition defines the trigger related conditions
  10511. */
  10512. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10513. /**
  10514. * Execute the action and store the value on the target state property.
  10515. */
  10516. execute(): void;
  10517. /**
  10518. * Serializes the actions and its related information.
  10519. * @param parent defines the object to serialize in
  10520. * @returns the serialized object
  10521. */
  10522. serialize(parent: any): any;
  10523. }
  10524. /**
  10525. * This defines an action responsible to set a property of the target
  10526. * to a desired value once triggered.
  10527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10528. */
  10529. export class SetValueAction extends Action {
  10530. /**
  10531. * The path of the property to set in the target.
  10532. */
  10533. propertyPath: string;
  10534. /**
  10535. * The value to set in the property
  10536. */
  10537. value: any;
  10538. private _target;
  10539. private _effectiveTarget;
  10540. private _property;
  10541. /**
  10542. * Instantiate the action
  10543. * @param triggerOptions defines the trigger options
  10544. * @param target defines the object containing the property
  10545. * @param propertyPath defines the path of the property to set in the target
  10546. * @param value defines the value to set in the property
  10547. * @param condition defines the trigger related conditions
  10548. */
  10549. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10550. /** @hidden */
  10551. _prepare(): void;
  10552. /**
  10553. * Execute the action and set the targetted property to the desired value.
  10554. */
  10555. execute(): void;
  10556. /**
  10557. * Serializes the actions and its related information.
  10558. * @param parent defines the object to serialize in
  10559. * @returns the serialized object
  10560. */
  10561. serialize(parent: any): any;
  10562. }
  10563. /**
  10564. * This defines an action responsible to increment the target value
  10565. * to a desired value once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class IncrementValueAction extends Action {
  10569. /**
  10570. * The path of the property to increment in the target.
  10571. */
  10572. propertyPath: string;
  10573. /**
  10574. * The value we should increment the property by.
  10575. */
  10576. value: any;
  10577. private _target;
  10578. private _effectiveTarget;
  10579. private _property;
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param target defines the object containing the property
  10584. * @param propertyPath defines the path of the property to increment in the target
  10585. * @param value defines the value value we should increment the property by
  10586. * @param condition defines the trigger related conditions
  10587. */
  10588. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10589. /** @hidden */
  10590. _prepare(): void;
  10591. /**
  10592. * Execute the action and increment the target of the value amount.
  10593. */
  10594. execute(): void;
  10595. /**
  10596. * Serializes the actions and its related information.
  10597. * @param parent defines the object to serialize in
  10598. * @returns the serialized object
  10599. */
  10600. serialize(parent: any): any;
  10601. }
  10602. /**
  10603. * This defines an action responsible to start an animation once triggered.
  10604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10605. */
  10606. export class PlayAnimationAction extends Action {
  10607. /**
  10608. * Where the animation should start (animation frame)
  10609. */
  10610. from: number;
  10611. /**
  10612. * Where the animation should stop (animation frame)
  10613. */
  10614. to: number;
  10615. /**
  10616. * Define if the animation should loop or stop after the first play.
  10617. */
  10618. loop?: boolean;
  10619. private _target;
  10620. /**
  10621. * Instantiate the action
  10622. * @param triggerOptions defines the trigger options
  10623. * @param target defines the target animation or animation name
  10624. * @param from defines from where the animation should start (animation frame)
  10625. * @param end defines where the animation should stop (animation frame)
  10626. * @param loop defines if the animation should loop or stop after the first play
  10627. * @param condition defines the trigger related conditions
  10628. */
  10629. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10630. /** @hidden */
  10631. _prepare(): void;
  10632. /**
  10633. * Execute the action and play the animation.
  10634. */
  10635. execute(): void;
  10636. /**
  10637. * Serializes the actions and its related information.
  10638. * @param parent defines the object to serialize in
  10639. * @returns the serialized object
  10640. */
  10641. serialize(parent: any): any;
  10642. }
  10643. /**
  10644. * This defines an action responsible to stop an animation once triggered.
  10645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10646. */
  10647. export class StopAnimationAction extends Action {
  10648. private _target;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the target animation or animation name
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action and stop the animation.
  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 that does nothing once triggered.
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10672. */
  10673. export class DoNothingAction extends Action {
  10674. /**
  10675. * Instantiate the action
  10676. * @param triggerOptions defines the trigger options
  10677. * @param condition defines the trigger related conditions
  10678. */
  10679. constructor(triggerOptions?: any, condition?: Condition);
  10680. /**
  10681. * Execute the action and do nothing.
  10682. */
  10683. execute(): void;
  10684. /**
  10685. * Serializes the actions and its related information.
  10686. * @param parent defines the object to serialize in
  10687. * @returns the serialized object
  10688. */
  10689. serialize(parent: any): any;
  10690. }
  10691. /**
  10692. * This defines an action responsible to trigger several actions once triggered.
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10694. */
  10695. export class CombineAction extends Action {
  10696. /**
  10697. * The list of aggregated animations to run.
  10698. */
  10699. children: Action[];
  10700. /**
  10701. * Instantiate the action
  10702. * @param triggerOptions defines the trigger options
  10703. * @param children defines the list of aggregated animations to run
  10704. * @param condition defines the trigger related conditions
  10705. */
  10706. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10707. /** @hidden */
  10708. _prepare(): void;
  10709. /**
  10710. * Execute the action and executes all the aggregated actions.
  10711. */
  10712. execute(evt: ActionEvent): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. /**
  10721. * This defines an action responsible to run code (external event) once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class ExecuteCodeAction extends Action {
  10725. /**
  10726. * The callback function to run.
  10727. */
  10728. func: (evt: ActionEvent) => void;
  10729. /**
  10730. * Instantiate the action
  10731. * @param triggerOptions defines the trigger options
  10732. * @param func defines the callback function to run
  10733. * @param condition defines the trigger related conditions
  10734. */
  10735. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10736. /**
  10737. * Execute the action and run the attached code.
  10738. */
  10739. execute(evt: ActionEvent): void;
  10740. }
  10741. /**
  10742. * This defines an action responsible to set the parent property of the target once triggered.
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10744. */
  10745. export class SetParentAction extends Action {
  10746. private _parent;
  10747. private _target;
  10748. /**
  10749. * Instantiate the action
  10750. * @param triggerOptions defines the trigger options
  10751. * @param target defines the target containing the parent property
  10752. * @param parent defines from where the animation should start (animation frame)
  10753. * @param condition defines the trigger related conditions
  10754. */
  10755. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10756. /** @hidden */
  10757. _prepare(): void;
  10758. /**
  10759. * Execute the action and set the parent property.
  10760. */
  10761. execute(): void;
  10762. /**
  10763. * Serializes the actions and its related information.
  10764. * @param parent defines the object to serialize in
  10765. * @returns the serialized object
  10766. */
  10767. serialize(parent: any): any;
  10768. }
  10769. }
  10770. declare module BABYLON {
  10771. /**
  10772. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10773. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10775. */
  10776. export class ActionManager extends AbstractActionManager {
  10777. /**
  10778. * Nothing
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10780. */
  10781. static readonly NothingTrigger: number;
  10782. /**
  10783. * On pick
  10784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10785. */
  10786. static readonly OnPickTrigger: number;
  10787. /**
  10788. * On left pick
  10789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10790. */
  10791. static readonly OnLeftPickTrigger: number;
  10792. /**
  10793. * On right pick
  10794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10795. */
  10796. static readonly OnRightPickTrigger: number;
  10797. /**
  10798. * On center pick
  10799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10800. */
  10801. static readonly OnCenterPickTrigger: number;
  10802. /**
  10803. * On pick down
  10804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10805. */
  10806. static readonly OnPickDownTrigger: number;
  10807. /**
  10808. * On double pick
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10810. */
  10811. static readonly OnDoublePickTrigger: number;
  10812. /**
  10813. * On pick up
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10815. */
  10816. static readonly OnPickUpTrigger: number;
  10817. /**
  10818. * On pick out.
  10819. * This trigger will only be raised if you also declared a OnPickDown
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10821. */
  10822. static readonly OnPickOutTrigger: number;
  10823. /**
  10824. * On long press
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10826. */
  10827. static readonly OnLongPressTrigger: number;
  10828. /**
  10829. * On pointer over
  10830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10831. */
  10832. static readonly OnPointerOverTrigger: number;
  10833. /**
  10834. * On pointer out
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10836. */
  10837. static readonly OnPointerOutTrigger: number;
  10838. /**
  10839. * On every frame
  10840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10841. */
  10842. static readonly OnEveryFrameTrigger: number;
  10843. /**
  10844. * On intersection enter
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10846. */
  10847. static readonly OnIntersectionEnterTrigger: number;
  10848. /**
  10849. * On intersection exit
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10851. */
  10852. static readonly OnIntersectionExitTrigger: number;
  10853. /**
  10854. * On key down
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnKeyDownTrigger: number;
  10858. /**
  10859. * On key up
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnKeyUpTrigger: number;
  10863. private _scene;
  10864. /**
  10865. * Creates a new action manager
  10866. * @param scene defines the hosting scene
  10867. */
  10868. constructor(scene: Scene);
  10869. /**
  10870. * Releases all associated resources
  10871. */
  10872. dispose(): void;
  10873. /**
  10874. * Gets hosting scene
  10875. * @returns the hosting scene
  10876. */
  10877. getScene(): Scene;
  10878. /**
  10879. * Does this action manager handles actions of any of the given triggers
  10880. * @param triggers defines the triggers to be tested
  10881. * @return a boolean indicating whether one (or more) of the triggers is handled
  10882. */
  10883. hasSpecificTriggers(triggers: number[]): boolean;
  10884. /**
  10885. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10886. * speed.
  10887. * @param triggerA defines the trigger to be tested
  10888. * @param triggerB defines the trigger to be tested
  10889. * @return a boolean indicating whether one (or more) of the triggers is handled
  10890. */
  10891. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10892. /**
  10893. * Does this action manager handles actions of a given trigger
  10894. * @param trigger defines the trigger to be tested
  10895. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10896. * @return whether the trigger is handled
  10897. */
  10898. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10899. /**
  10900. * Does this action manager has pointer triggers
  10901. */
  10902. readonly hasPointerTriggers: boolean;
  10903. /**
  10904. * Does this action manager has pick triggers
  10905. */
  10906. readonly hasPickTriggers: boolean;
  10907. /**
  10908. * Registers an action to this action manager
  10909. * @param action defines the action to be registered
  10910. * @return the action amended (prepared) after registration
  10911. */
  10912. registerAction(action: IAction): Nullable<IAction>;
  10913. /**
  10914. * Unregisters an action to this action manager
  10915. * @param action defines the action to be unregistered
  10916. * @return a boolean indicating whether the action has been unregistered
  10917. */
  10918. unregisterAction(action: IAction): Boolean;
  10919. /**
  10920. * Process a specific trigger
  10921. * @param trigger defines the trigger to process
  10922. * @param evt defines the event details to be processed
  10923. */
  10924. processTrigger(trigger: number, evt?: IActionEvent): void;
  10925. /** @hidden */
  10926. _getEffectiveTarget(target: any, propertyPath: string): any;
  10927. /** @hidden */
  10928. _getProperty(propertyPath: string): string;
  10929. /**
  10930. * Serialize this manager to a JSON object
  10931. * @param name defines the property name to store this manager
  10932. * @returns a JSON representation of this manager
  10933. */
  10934. serialize(name: string): any;
  10935. /**
  10936. * Creates a new ActionManager from a JSON data
  10937. * @param parsedActions defines the JSON data to read from
  10938. * @param object defines the hosting mesh
  10939. * @param scene defines the hosting scene
  10940. */
  10941. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10942. /**
  10943. * Get a trigger name by index
  10944. * @param trigger defines the trigger index
  10945. * @returns a trigger name
  10946. */
  10947. static GetTriggerName(trigger: number): string;
  10948. }
  10949. }
  10950. declare module BABYLON {
  10951. /**
  10952. * Class representing a ray with position and direction
  10953. */
  10954. export class Ray {
  10955. /** origin point */
  10956. origin: Vector3;
  10957. /** direction */
  10958. direction: Vector3;
  10959. /** length of the ray */
  10960. length: number;
  10961. private static readonly TmpVector3;
  10962. private _tmpRay;
  10963. /**
  10964. * Creates a new ray
  10965. * @param origin origin point
  10966. * @param direction direction
  10967. * @param length length of the ray
  10968. */
  10969. constructor(
  10970. /** origin point */
  10971. origin: Vector3,
  10972. /** direction */
  10973. direction: Vector3,
  10974. /** length of the ray */
  10975. length?: number);
  10976. /**
  10977. * Checks if the ray intersects a box
  10978. * @param minimum bound of the box
  10979. * @param maximum bound of the box
  10980. * @param intersectionTreshold extra extend to be added to the box in all direction
  10981. * @returns if the box was hit
  10982. */
  10983. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10984. /**
  10985. * Checks if the ray intersects a box
  10986. * @param box the bounding box to check
  10987. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10988. * @returns if the box was hit
  10989. */
  10990. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10991. /**
  10992. * If the ray hits a sphere
  10993. * @param sphere the bounding sphere to check
  10994. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10995. * @returns true if it hits the sphere
  10996. */
  10997. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10998. /**
  10999. * If the ray hits a triange
  11000. * @param vertex0 triangle vertex
  11001. * @param vertex1 triangle vertex
  11002. * @param vertex2 triangle vertex
  11003. * @returns intersection information if hit
  11004. */
  11005. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11006. /**
  11007. * Checks if ray intersects a plane
  11008. * @param plane the plane to check
  11009. * @returns the distance away it was hit
  11010. */
  11011. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11012. /**
  11013. * Calculate the intercept of a ray on a given axis
  11014. * @param axis to check 'x' | 'y' | 'z'
  11015. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11016. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11017. */
  11018. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11019. /**
  11020. * Checks if ray intersects a mesh
  11021. * @param mesh the mesh to check
  11022. * @param fastCheck if only the bounding box should checked
  11023. * @returns picking info of the intersecton
  11024. */
  11025. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11026. /**
  11027. * Checks if ray intersects a mesh
  11028. * @param meshes the meshes to check
  11029. * @param fastCheck if only the bounding box should checked
  11030. * @param results array to store result in
  11031. * @returns Array of picking infos
  11032. */
  11033. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11034. private _comparePickingInfo;
  11035. private static smallnum;
  11036. private static rayl;
  11037. /**
  11038. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11039. * @param sega the first point of the segment to test the intersection against
  11040. * @param segb the second point of the segment to test the intersection against
  11041. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11042. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11043. */
  11044. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11045. /**
  11046. * Update the ray from viewport position
  11047. * @param x position
  11048. * @param y y position
  11049. * @param viewportWidth viewport width
  11050. * @param viewportHeight viewport height
  11051. * @param world world matrix
  11052. * @param view view matrix
  11053. * @param projection projection matrix
  11054. * @returns this ray updated
  11055. */
  11056. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11057. /**
  11058. * Creates a ray with origin and direction of 0,0,0
  11059. * @returns the new ray
  11060. */
  11061. static Zero(): Ray;
  11062. /**
  11063. * Creates a new ray from screen space and viewport
  11064. * @param x position
  11065. * @param y y position
  11066. * @param viewportWidth viewport width
  11067. * @param viewportHeight viewport height
  11068. * @param world world matrix
  11069. * @param view view matrix
  11070. * @param projection projection matrix
  11071. * @returns new ray
  11072. */
  11073. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11074. /**
  11075. * 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
  11076. * transformed to the given world matrix.
  11077. * @param origin The origin point
  11078. * @param end The end point
  11079. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11080. * @returns the new ray
  11081. */
  11082. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Transforms a ray by a matrix
  11085. * @param ray ray to transform
  11086. * @param matrix matrix to apply
  11087. * @returns the resulting new ray
  11088. */
  11089. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11090. /**
  11091. * Transforms a ray by a matrix
  11092. * @param ray ray to transform
  11093. * @param matrix matrix to apply
  11094. * @param result ray to store result in
  11095. */
  11096. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11097. /**
  11098. * Unproject a ray from screen space to object space
  11099. * @param sourceX defines the screen space x coordinate to use
  11100. * @param sourceY defines the screen space y coordinate to use
  11101. * @param viewportWidth defines the current width of the viewport
  11102. * @param viewportHeight defines the current height of the viewport
  11103. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11104. * @param view defines the view matrix to use
  11105. * @param projection defines the projection matrix to use
  11106. */
  11107. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11108. }
  11109. /**
  11110. * Type used to define predicate used to select faces when a mesh intersection is detected
  11111. */
  11112. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11113. interface Scene {
  11114. /** @hidden */
  11115. _tempPickingRay: Nullable<Ray>;
  11116. /** @hidden */
  11117. _cachedRayForTransform: Ray;
  11118. /** @hidden */
  11119. _pickWithRayInverseMatrix: Matrix;
  11120. /** @hidden */
  11121. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11122. /** @hidden */
  11123. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11124. }
  11125. }
  11126. declare module BABYLON {
  11127. /**
  11128. * Groups all the scene component constants in one place to ease maintenance.
  11129. * @hidden
  11130. */
  11131. export class SceneComponentConstants {
  11132. static readonly NAME_EFFECTLAYER: string;
  11133. static readonly NAME_LAYER: string;
  11134. static readonly NAME_LENSFLARESYSTEM: string;
  11135. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11136. static readonly NAME_PARTICLESYSTEM: string;
  11137. static readonly NAME_GAMEPAD: string;
  11138. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11139. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11140. static readonly NAME_DEPTHRENDERER: string;
  11141. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11142. static readonly NAME_SPRITE: string;
  11143. static readonly NAME_OUTLINERENDERER: string;
  11144. static readonly NAME_PROCEDURALTEXTURE: string;
  11145. static readonly NAME_SHADOWGENERATOR: string;
  11146. static readonly NAME_OCTREE: string;
  11147. static readonly NAME_PHYSICSENGINE: string;
  11148. static readonly NAME_AUDIO: string;
  11149. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11150. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11151. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11152. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11153. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11154. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11155. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11156. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11157. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11158. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11159. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11160. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11161. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11162. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11163. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11164. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11165. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11166. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11167. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11168. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11169. static readonly STEP_AFTERRENDER_AUDIO: number;
  11170. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11171. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11172. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11173. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11174. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11175. static readonly STEP_POINTERMOVE_SPRITE: number;
  11176. static readonly STEP_POINTERDOWN_SPRITE: number;
  11177. static readonly STEP_POINTERUP_SPRITE: number;
  11178. }
  11179. /**
  11180. * This represents a scene component.
  11181. *
  11182. * This is used to decouple the dependency the scene is having on the different workloads like
  11183. * layers, post processes...
  11184. */
  11185. export interface ISceneComponent {
  11186. /**
  11187. * The name of the component. Each component must have a unique name.
  11188. */
  11189. name: string;
  11190. /**
  11191. * The scene the component belongs to.
  11192. */
  11193. scene: Scene;
  11194. /**
  11195. * Register the component to one instance of a scene.
  11196. */
  11197. register(): void;
  11198. /**
  11199. * Rebuilds the elements related to this component in case of
  11200. * context lost for instance.
  11201. */
  11202. rebuild(): void;
  11203. /**
  11204. * Disposes the component and the associated ressources.
  11205. */
  11206. dispose(): void;
  11207. }
  11208. /**
  11209. * This represents a SERIALIZABLE scene component.
  11210. *
  11211. * This extends Scene Component to add Serialization methods on top.
  11212. */
  11213. export interface ISceneSerializableComponent extends ISceneComponent {
  11214. /**
  11215. * Adds all the elements from the container to the scene
  11216. * @param container the container holding the elements
  11217. */
  11218. addFromContainer(container: AbstractScene): void;
  11219. /**
  11220. * Removes all the elements in the container from the scene
  11221. * @param container contains the elements to remove
  11222. * @param dispose if the removed element should be disposed (default: false)
  11223. */
  11224. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11225. /**
  11226. * Serializes the component data to the specified json object
  11227. * @param serializationObject The object to serialize to
  11228. */
  11229. serialize(serializationObject: any): void;
  11230. }
  11231. /**
  11232. * Strong typing of a Mesh related stage step action
  11233. */
  11234. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11235. /**
  11236. * Strong typing of a Evaluate Sub Mesh related stage step action
  11237. */
  11238. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11239. /**
  11240. * Strong typing of a Active Mesh related stage step action
  11241. */
  11242. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11243. /**
  11244. * Strong typing of a Camera related stage step action
  11245. */
  11246. export type CameraStageAction = (camera: Camera) => void;
  11247. /**
  11248. * Strong typing of a Camera Frame buffer related stage step action
  11249. */
  11250. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11251. /**
  11252. * Strong typing of a Render Target related stage step action
  11253. */
  11254. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11255. /**
  11256. * Strong typing of a RenderingGroup related stage step action
  11257. */
  11258. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11259. /**
  11260. * Strong typing of a Mesh Render related stage step action
  11261. */
  11262. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11263. /**
  11264. * Strong typing of a simple stage step action
  11265. */
  11266. export type SimpleStageAction = () => void;
  11267. /**
  11268. * Strong typing of a render target action.
  11269. */
  11270. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11271. /**
  11272. * Strong typing of a pointer move action.
  11273. */
  11274. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11275. /**
  11276. * Strong typing of a pointer up/down action.
  11277. */
  11278. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11279. /**
  11280. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11281. * @hidden
  11282. */
  11283. export class Stage<T extends Function> extends Array<{
  11284. index: number;
  11285. component: ISceneComponent;
  11286. action: T;
  11287. }> {
  11288. /**
  11289. * Hide ctor from the rest of the world.
  11290. * @param items The items to add.
  11291. */
  11292. private constructor();
  11293. /**
  11294. * Creates a new Stage.
  11295. * @returns A new instance of a Stage
  11296. */
  11297. static Create<T extends Function>(): Stage<T>;
  11298. /**
  11299. * Registers a step in an ordered way in the targeted stage.
  11300. * @param index Defines the position to register the step in
  11301. * @param component Defines the component attached to the step
  11302. * @param action Defines the action to launch during the step
  11303. */
  11304. registerStep(index: number, component: ISceneComponent, action: T): void;
  11305. /**
  11306. * Clears all the steps from the stage.
  11307. */
  11308. clear(): void;
  11309. }
  11310. }
  11311. declare module BABYLON {
  11312. interface Scene {
  11313. /** @hidden */
  11314. _pointerOverSprite: Nullable<Sprite>;
  11315. /** @hidden */
  11316. _pickedDownSprite: Nullable<Sprite>;
  11317. /** @hidden */
  11318. _tempSpritePickingRay: Nullable<Ray>;
  11319. /**
  11320. * All of the sprite managers added to this scene
  11321. * @see http://doc.babylonjs.com/babylon101/sprites
  11322. */
  11323. spriteManagers: Array<ISpriteManager>;
  11324. /**
  11325. * An event triggered when sprites rendering is about to start
  11326. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11327. */
  11328. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11329. /**
  11330. * An event triggered when sprites rendering is done
  11331. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11332. */
  11333. onAfterSpritesRenderingObservable: Observable<Scene>;
  11334. /** @hidden */
  11335. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11336. /** Launch a ray to try to pick a sprite in the scene
  11337. * @param x position on screen
  11338. * @param y position on screen
  11339. * @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
  11340. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11341. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11342. * @returns a PickingInfo
  11343. */
  11344. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11345. /** Use the given ray to pick a sprite in the scene
  11346. * @param ray The ray (in world space) to use to pick meshes
  11347. * @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
  11348. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11349. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11350. * @returns a PickingInfo
  11351. */
  11352. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11353. /** @hidden */
  11354. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11355. /** Launch a ray to try to pick sprites in the scene
  11356. * @param x position on screen
  11357. * @param y position on screen
  11358. * @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
  11359. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11360. * @returns a PickingInfo array
  11361. */
  11362. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11363. /** Use the given ray to pick sprites in the scene
  11364. * @param ray The ray (in world space) to use to pick meshes
  11365. * @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
  11366. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11367. * @returns a PickingInfo array
  11368. */
  11369. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11370. /**
  11371. * Force the sprite under the pointer
  11372. * @param sprite defines the sprite to use
  11373. */
  11374. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11375. /**
  11376. * Gets the sprite under the pointer
  11377. * @returns a Sprite or null if no sprite is under the pointer
  11378. */
  11379. getPointerOverSprite(): Nullable<Sprite>;
  11380. }
  11381. /**
  11382. * Defines the sprite scene component responsible to manage sprites
  11383. * in a given scene.
  11384. */
  11385. export class SpriteSceneComponent implements ISceneComponent {
  11386. /**
  11387. * The component name helpfull to identify the component in the list of scene components.
  11388. */
  11389. readonly name: string;
  11390. /**
  11391. * The scene the component belongs to.
  11392. */
  11393. scene: Scene;
  11394. /** @hidden */
  11395. private _spritePredicate;
  11396. /**
  11397. * Creates a new instance of the component for the given scene
  11398. * @param scene Defines the scene to register the component in
  11399. */
  11400. constructor(scene: Scene);
  11401. /**
  11402. * Registers the component in a given scene
  11403. */
  11404. register(): void;
  11405. /**
  11406. * Rebuilds the elements related to this component in case of
  11407. * context lost for instance.
  11408. */
  11409. rebuild(): void;
  11410. /**
  11411. * Disposes the component and the associated ressources.
  11412. */
  11413. dispose(): void;
  11414. private _pickSpriteButKeepRay;
  11415. private _pointerMove;
  11416. private _pointerDown;
  11417. private _pointerUp;
  11418. }
  11419. }
  11420. declare module BABYLON {
  11421. /** @hidden */
  11422. export var fogFragmentDeclaration: {
  11423. name: string;
  11424. shader: string;
  11425. };
  11426. }
  11427. declare module BABYLON {
  11428. /** @hidden */
  11429. export var fogFragment: {
  11430. name: string;
  11431. shader: string;
  11432. };
  11433. }
  11434. declare module BABYLON {
  11435. /** @hidden */
  11436. export var spritesPixelShader: {
  11437. name: string;
  11438. shader: string;
  11439. };
  11440. }
  11441. declare module BABYLON {
  11442. /** @hidden */
  11443. export var fogVertexDeclaration: {
  11444. name: string;
  11445. shader: string;
  11446. };
  11447. }
  11448. declare module BABYLON {
  11449. /** @hidden */
  11450. export var spritesVertexShader: {
  11451. name: string;
  11452. shader: string;
  11453. };
  11454. }
  11455. declare module BABYLON {
  11456. /**
  11457. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11458. */
  11459. export interface ISpriteManager extends IDisposable {
  11460. /**
  11461. * Restricts the camera to viewing objects with the same layerMask.
  11462. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11463. */
  11464. layerMask: number;
  11465. /**
  11466. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11467. */
  11468. isPickable: boolean;
  11469. /**
  11470. * Specifies the rendering group id for this mesh (0 by default)
  11471. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11472. */
  11473. renderingGroupId: number;
  11474. /**
  11475. * Defines the list of sprites managed by the manager.
  11476. */
  11477. sprites: Array<Sprite>;
  11478. /**
  11479. * Tests the intersection of a sprite with a specific ray.
  11480. * @param ray The ray we are sending to test the collision
  11481. * @param camera The camera space we are sending rays in
  11482. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11483. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11484. * @returns picking info or null.
  11485. */
  11486. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11487. /**
  11488. * Intersects the sprites with a ray
  11489. * @param ray defines the ray to intersect with
  11490. * @param camera defines the current active camera
  11491. * @param predicate defines a predicate used to select candidate sprites
  11492. * @returns null if no hit or a PickingInfo array
  11493. */
  11494. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11495. /**
  11496. * Renders the list of sprites on screen.
  11497. */
  11498. render(): void;
  11499. }
  11500. /**
  11501. * Class used to manage multiple sprites on the same spritesheet
  11502. * @see http://doc.babylonjs.com/babylon101/sprites
  11503. */
  11504. export class SpriteManager implements ISpriteManager {
  11505. /** defines the manager's name */
  11506. name: string;
  11507. /** Gets the list of sprites */
  11508. sprites: Sprite[];
  11509. /** Gets or sets the rendering group id (0 by default) */
  11510. renderingGroupId: number;
  11511. /** Gets or sets camera layer mask */
  11512. layerMask: number;
  11513. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11514. fogEnabled: boolean;
  11515. /** Gets or sets a boolean indicating if the sprites are pickable */
  11516. isPickable: boolean;
  11517. /** Defines the default width of a cell in the spritesheet */
  11518. cellWidth: number;
  11519. /** Defines the default height of a cell in the spritesheet */
  11520. cellHeight: number;
  11521. /** Associative array from JSON sprite data file */
  11522. private _cellData;
  11523. /** Array of sprite names from JSON sprite data file */
  11524. private _spriteMap;
  11525. /** True when packed cell data from JSON file is ready*/
  11526. private _packedAndReady;
  11527. /**
  11528. * An event triggered when the manager is disposed.
  11529. */
  11530. onDisposeObservable: Observable<SpriteManager>;
  11531. private _onDisposeObserver;
  11532. /**
  11533. * Callback called when the manager is disposed
  11534. */
  11535. onDispose: () => void;
  11536. private _capacity;
  11537. private _fromPacked;
  11538. private _spriteTexture;
  11539. private _epsilon;
  11540. private _scene;
  11541. private _vertexData;
  11542. private _buffer;
  11543. private _vertexBuffers;
  11544. private _indexBuffer;
  11545. private _effectBase;
  11546. private _effectFog;
  11547. /**
  11548. * Gets or sets the spritesheet texture
  11549. */
  11550. texture: Texture;
  11551. /**
  11552. * Creates a new sprite manager
  11553. * @param name defines the manager's name
  11554. * @param imgUrl defines the sprite sheet url
  11555. * @param capacity defines the maximum allowed number of sprites
  11556. * @param cellSize defines the size of a sprite cell
  11557. * @param scene defines the hosting scene
  11558. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11559. * @param samplingMode defines the smapling mode to use with spritesheet
  11560. * @param fromPacked set to false; do not alter
  11561. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11562. */
  11563. constructor(
  11564. /** defines the manager's name */
  11565. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11566. private _makePacked;
  11567. private _appendSpriteVertex;
  11568. /**
  11569. * Intersects the sprites with a ray
  11570. * @param ray defines the ray to intersect with
  11571. * @param camera defines the current active camera
  11572. * @param predicate defines a predicate used to select candidate sprites
  11573. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11574. * @returns null if no hit or a PickingInfo
  11575. */
  11576. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11577. /**
  11578. * Intersects the sprites with a ray
  11579. * @param ray defines the ray to intersect with
  11580. * @param camera defines the current active camera
  11581. * @param predicate defines a predicate used to select candidate sprites
  11582. * @returns null if no hit or a PickingInfo array
  11583. */
  11584. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11585. /**
  11586. * Render all child sprites
  11587. */
  11588. render(): void;
  11589. /**
  11590. * Release associated resources
  11591. */
  11592. dispose(): void;
  11593. }
  11594. }
  11595. declare module BABYLON {
  11596. /**
  11597. * Class used to represent a sprite
  11598. * @see http://doc.babylonjs.com/babylon101/sprites
  11599. */
  11600. export class Sprite {
  11601. /** defines the name */
  11602. name: string;
  11603. /** Gets or sets the current world position */
  11604. position: Vector3;
  11605. /** Gets or sets the main color */
  11606. color: Color4;
  11607. /** Gets or sets the width */
  11608. width: number;
  11609. /** Gets or sets the height */
  11610. height: number;
  11611. /** Gets or sets rotation angle */
  11612. angle: number;
  11613. /** Gets or sets the cell index in the sprite sheet */
  11614. cellIndex: number;
  11615. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11616. cellRef: string;
  11617. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11618. invertU: number;
  11619. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11620. invertV: number;
  11621. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11622. disposeWhenFinishedAnimating: boolean;
  11623. /** Gets the list of attached animations */
  11624. animations: Animation[];
  11625. /** Gets or sets a boolean indicating if the sprite can be picked */
  11626. isPickable: boolean;
  11627. /**
  11628. * Gets or sets the associated action manager
  11629. */
  11630. actionManager: Nullable<ActionManager>;
  11631. private _animationStarted;
  11632. private _loopAnimation;
  11633. private _fromIndex;
  11634. private _toIndex;
  11635. private _delay;
  11636. private _direction;
  11637. private _manager;
  11638. private _time;
  11639. private _onAnimationEnd;
  11640. /**
  11641. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11642. */
  11643. isVisible: boolean;
  11644. /**
  11645. * Gets or sets the sprite size
  11646. */
  11647. size: number;
  11648. /**
  11649. * Creates a new Sprite
  11650. * @param name defines the name
  11651. * @param manager defines the manager
  11652. */
  11653. constructor(
  11654. /** defines the name */
  11655. name: string, manager: ISpriteManager);
  11656. /**
  11657. * Starts an animation
  11658. * @param from defines the initial key
  11659. * @param to defines the end key
  11660. * @param loop defines if the animation must loop
  11661. * @param delay defines the start delay (in ms)
  11662. * @param onAnimationEnd defines a callback to call when animation ends
  11663. */
  11664. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11665. /** Stops current animation (if any) */
  11666. stopAnimation(): void;
  11667. /** @hidden */
  11668. _animate(deltaTime: number): void;
  11669. /** Release associated resources */
  11670. dispose(): void;
  11671. }
  11672. }
  11673. declare module BABYLON {
  11674. /**
  11675. * Information about the result of picking within a scene
  11676. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11677. */
  11678. export class PickingInfo {
  11679. /** @hidden */
  11680. _pickingUnavailable: boolean;
  11681. /**
  11682. * If the pick collided with an object
  11683. */
  11684. hit: boolean;
  11685. /**
  11686. * Distance away where the pick collided
  11687. */
  11688. distance: number;
  11689. /**
  11690. * The location of pick collision
  11691. */
  11692. pickedPoint: Nullable<Vector3>;
  11693. /**
  11694. * The mesh corresponding the the pick collision
  11695. */
  11696. pickedMesh: Nullable<AbstractMesh>;
  11697. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11698. bu: number;
  11699. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11700. bv: number;
  11701. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11702. faceId: number;
  11703. /** Id of the the submesh that was picked */
  11704. subMeshId: number;
  11705. /** If a sprite was picked, this will be the sprite the pick collided with */
  11706. pickedSprite: Nullable<Sprite>;
  11707. /**
  11708. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11709. */
  11710. originMesh: Nullable<AbstractMesh>;
  11711. /**
  11712. * The ray that was used to perform the picking.
  11713. */
  11714. ray: Nullable<Ray>;
  11715. /**
  11716. * Gets the normal correspodning to the face the pick collided with
  11717. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11718. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11719. * @returns The normal correspodning to the face the pick collided with
  11720. */
  11721. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11722. /**
  11723. * Gets the texture coordinates of where the pick occured
  11724. * @returns the vector containing the coordnates of the texture
  11725. */
  11726. getTextureCoordinates(): Nullable<Vector2>;
  11727. }
  11728. }
  11729. declare module BABYLON {
  11730. /**
  11731. * Gather the list of pointer event types as constants.
  11732. */
  11733. export class PointerEventTypes {
  11734. /**
  11735. * 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.
  11736. */
  11737. static readonly POINTERDOWN: number;
  11738. /**
  11739. * The pointerup event is fired when a pointer is no longer active.
  11740. */
  11741. static readonly POINTERUP: number;
  11742. /**
  11743. * The pointermove event is fired when a pointer changes coordinates.
  11744. */
  11745. static readonly POINTERMOVE: number;
  11746. /**
  11747. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11748. */
  11749. static readonly POINTERWHEEL: number;
  11750. /**
  11751. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11752. */
  11753. static readonly POINTERPICK: number;
  11754. /**
  11755. * The pointertap event is fired when a the object has been touched and released without drag.
  11756. */
  11757. static readonly POINTERTAP: number;
  11758. /**
  11759. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11760. */
  11761. static readonly POINTERDOUBLETAP: number;
  11762. }
  11763. /**
  11764. * Base class of pointer info types.
  11765. */
  11766. export class PointerInfoBase {
  11767. /**
  11768. * Defines the type of event (PointerEventTypes)
  11769. */
  11770. type: number;
  11771. /**
  11772. * Defines the related dom event
  11773. */
  11774. event: PointerEvent | MouseWheelEvent;
  11775. /**
  11776. * Instantiates the base class of pointers info.
  11777. * @param type Defines the type of event (PointerEventTypes)
  11778. * @param event Defines the related dom event
  11779. */
  11780. constructor(
  11781. /**
  11782. * Defines the type of event (PointerEventTypes)
  11783. */
  11784. type: number,
  11785. /**
  11786. * Defines the related dom event
  11787. */
  11788. event: PointerEvent | MouseWheelEvent);
  11789. }
  11790. /**
  11791. * This class is used to store pointer related info for the onPrePointerObservable event.
  11792. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11793. */
  11794. export class PointerInfoPre extends PointerInfoBase {
  11795. /**
  11796. * Ray from a pointer if availible (eg. 6dof controller)
  11797. */
  11798. ray: Nullable<Ray>;
  11799. /**
  11800. * Defines the local position of the pointer on the canvas.
  11801. */
  11802. localPosition: Vector2;
  11803. /**
  11804. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11805. */
  11806. skipOnPointerObservable: boolean;
  11807. /**
  11808. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11809. * @param type Defines the type of event (PointerEventTypes)
  11810. * @param event Defines the related dom event
  11811. * @param localX Defines the local x coordinates of the pointer when the event occured
  11812. * @param localY Defines the local y coordinates of the pointer when the event occured
  11813. */
  11814. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11815. }
  11816. /**
  11817. * This type contains all the data related to a pointer event in Babylon.js.
  11818. * 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.
  11819. */
  11820. export class PointerInfo extends PointerInfoBase {
  11821. /**
  11822. * Defines the picking info associated to the info (if any)\
  11823. */
  11824. pickInfo: Nullable<PickingInfo>;
  11825. /**
  11826. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11827. * @param type Defines the type of event (PointerEventTypes)
  11828. * @param event Defines the related dom event
  11829. * @param pickInfo Defines the picking info associated to the info (if any)\
  11830. */
  11831. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11832. /**
  11833. * Defines the picking info associated to the info (if any)\
  11834. */
  11835. pickInfo: Nullable<PickingInfo>);
  11836. }
  11837. /**
  11838. * Data relating to a touch event on the screen.
  11839. */
  11840. export interface PointerTouch {
  11841. /**
  11842. * X coordinate of touch.
  11843. */
  11844. x: number;
  11845. /**
  11846. * Y coordinate of touch.
  11847. */
  11848. y: number;
  11849. /**
  11850. * Id of touch. Unique for each finger.
  11851. */
  11852. pointerId: number;
  11853. /**
  11854. * Event type passed from DOM.
  11855. */
  11856. type: any;
  11857. }
  11858. }
  11859. declare module BABYLON {
  11860. /**
  11861. * Manage the mouse inputs to control the movement of a free camera.
  11862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11863. */
  11864. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11865. /**
  11866. * Define if touch is enabled in the mouse input
  11867. */
  11868. touchEnabled: boolean;
  11869. /**
  11870. * Defines the camera the input is attached to.
  11871. */
  11872. camera: FreeCamera;
  11873. /**
  11874. * Defines the buttons associated with the input to handle camera move.
  11875. */
  11876. buttons: number[];
  11877. /**
  11878. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11879. */
  11880. angularSensibility: number;
  11881. private _pointerInput;
  11882. private _onMouseMove;
  11883. private _observer;
  11884. private previousPosition;
  11885. /**
  11886. * Observable for when a pointer move event occurs containing the move offset
  11887. */
  11888. onPointerMovedObservable: Observable<{
  11889. offsetX: number;
  11890. offsetY: number;
  11891. }>;
  11892. /**
  11893. * @hidden
  11894. * If the camera should be rotated automatically based on pointer movement
  11895. */
  11896. _allowCameraRotation: boolean;
  11897. /**
  11898. * Manage the mouse inputs to control the movement of a free camera.
  11899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11900. * @param touchEnabled Defines if touch is enabled or not
  11901. */
  11902. constructor(
  11903. /**
  11904. * Define if touch is enabled in the mouse input
  11905. */
  11906. touchEnabled?: boolean);
  11907. /**
  11908. * Attach the input controls to a specific dom element to get the input from.
  11909. * @param element Defines the element the controls should be listened from
  11910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11911. */
  11912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11913. /**
  11914. * Called on JS contextmenu event.
  11915. * Override this method to provide functionality.
  11916. */
  11917. protected onContextMenu(evt: PointerEvent): void;
  11918. /**
  11919. * Detach the current controls from the specified dom element.
  11920. * @param element Defines the element to stop listening the inputs from
  11921. */
  11922. detachControl(element: Nullable<HTMLElement>): void;
  11923. /**
  11924. * Gets the class name of the current intput.
  11925. * @returns the class name
  11926. */
  11927. getClassName(): string;
  11928. /**
  11929. * Get the friendly name associated with the input class.
  11930. * @returns the input friendly name
  11931. */
  11932. getSimpleName(): string;
  11933. }
  11934. }
  11935. declare module BABYLON {
  11936. /**
  11937. * Manage the touch inputs to control the movement of a free camera.
  11938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11939. */
  11940. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11941. /**
  11942. * Defines the camera the input is attached to.
  11943. */
  11944. camera: FreeCamera;
  11945. /**
  11946. * Defines the touch sensibility for rotation.
  11947. * The higher the faster.
  11948. */
  11949. touchAngularSensibility: number;
  11950. /**
  11951. * Defines the touch sensibility for move.
  11952. * The higher the faster.
  11953. */
  11954. touchMoveSensibility: number;
  11955. private _offsetX;
  11956. private _offsetY;
  11957. private _pointerPressed;
  11958. private _pointerInput;
  11959. private _observer;
  11960. private _onLostFocus;
  11961. /**
  11962. * Attach the input controls to a specific dom element to get the input from.
  11963. * @param element Defines the element the controls should be listened from
  11964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11965. */
  11966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11967. /**
  11968. * Detach the current controls from the specified dom element.
  11969. * @param element Defines the element to stop listening the inputs from
  11970. */
  11971. detachControl(element: Nullable<HTMLElement>): void;
  11972. /**
  11973. * Update the current camera state depending on the inputs that have been used this frame.
  11974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11975. */
  11976. checkInputs(): void;
  11977. /**
  11978. * Gets the class name of the current intput.
  11979. * @returns the class name
  11980. */
  11981. getClassName(): string;
  11982. /**
  11983. * Get the friendly name associated with the input class.
  11984. * @returns the input friendly name
  11985. */
  11986. getSimpleName(): string;
  11987. }
  11988. }
  11989. declare module BABYLON {
  11990. /**
  11991. * Default Inputs manager for the FreeCamera.
  11992. * It groups all the default supported inputs for ease of use.
  11993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11994. */
  11995. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11996. /**
  11997. * @hidden
  11998. */
  11999. _mouseInput: Nullable<FreeCameraMouseInput>;
  12000. /**
  12001. * Instantiates a new FreeCameraInputsManager.
  12002. * @param camera Defines the camera the inputs belong to
  12003. */
  12004. constructor(camera: FreeCamera);
  12005. /**
  12006. * Add keyboard input support to the input manager.
  12007. * @returns the current input manager
  12008. */
  12009. addKeyboard(): FreeCameraInputsManager;
  12010. /**
  12011. * Add mouse input support to the input manager.
  12012. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12013. * @returns the current input manager
  12014. */
  12015. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12016. /**
  12017. * Removes the mouse input support from the manager
  12018. * @returns the current input manager
  12019. */
  12020. removeMouse(): FreeCameraInputsManager;
  12021. /**
  12022. * Add touch input support to the input manager.
  12023. * @returns the current input manager
  12024. */
  12025. addTouch(): FreeCameraInputsManager;
  12026. /**
  12027. * Remove all attached input methods from a camera
  12028. */
  12029. clear(): void;
  12030. }
  12031. }
  12032. declare module BABYLON {
  12033. /**
  12034. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12035. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12036. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12037. */
  12038. export class FreeCamera extends TargetCamera {
  12039. /**
  12040. * Define the collision ellipsoid of the camera.
  12041. * This is helpful to simulate a camera body like the player body around the camera
  12042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12043. */
  12044. ellipsoid: Vector3;
  12045. /**
  12046. * Define an offset for the position of the ellipsoid around the camera.
  12047. * This can be helpful to determine the center of the body near the gravity center of the body
  12048. * instead of its head.
  12049. */
  12050. ellipsoidOffset: Vector3;
  12051. /**
  12052. * Enable or disable collisions of the camera with the rest of the scene objects.
  12053. */
  12054. checkCollisions: boolean;
  12055. /**
  12056. * Enable or disable gravity on the camera.
  12057. */
  12058. applyGravity: boolean;
  12059. /**
  12060. * Define the input manager associated to the camera.
  12061. */
  12062. inputs: FreeCameraInputsManager;
  12063. /**
  12064. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12065. * Higher values reduce sensitivity.
  12066. */
  12067. /**
  12068. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12069. * Higher values reduce sensitivity.
  12070. */
  12071. angularSensibility: number;
  12072. /**
  12073. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12074. */
  12075. keysUp: number[];
  12076. /**
  12077. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12078. */
  12079. keysDown: number[];
  12080. /**
  12081. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12082. */
  12083. keysLeft: number[];
  12084. /**
  12085. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12086. */
  12087. keysRight: number[];
  12088. /**
  12089. * Event raised when the camera collide with a mesh in the scene.
  12090. */
  12091. onCollide: (collidedMesh: AbstractMesh) => void;
  12092. private _collider;
  12093. private _needMoveForGravity;
  12094. private _oldPosition;
  12095. private _diffPosition;
  12096. private _newPosition;
  12097. /** @hidden */
  12098. _localDirection: Vector3;
  12099. /** @hidden */
  12100. _transformedDirection: Vector3;
  12101. /**
  12102. * Instantiates a Free Camera.
  12103. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12104. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12105. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12106. * @param name Define the name of the camera in the scene
  12107. * @param position Define the start position of the camera in the scene
  12108. * @param scene Define the scene the camera belongs to
  12109. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12110. */
  12111. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12112. /**
  12113. * Attached controls to the current camera.
  12114. * @param element Defines the element the controls should be listened from
  12115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12116. */
  12117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12118. /**
  12119. * Detach the current controls from the camera.
  12120. * The camera will stop reacting to inputs.
  12121. * @param element Defines the element to stop listening the inputs from
  12122. */
  12123. detachControl(element: HTMLElement): void;
  12124. private _collisionMask;
  12125. /**
  12126. * Define a collision mask to limit the list of object the camera can collide with
  12127. */
  12128. collisionMask: number;
  12129. /** @hidden */
  12130. _collideWithWorld(displacement: Vector3): void;
  12131. private _onCollisionPositionChange;
  12132. /** @hidden */
  12133. _checkInputs(): void;
  12134. /** @hidden */
  12135. _decideIfNeedsToMove(): boolean;
  12136. /** @hidden */
  12137. _updatePosition(): void;
  12138. /**
  12139. * Destroy the camera and release the current resources hold by it.
  12140. */
  12141. dispose(): void;
  12142. /**
  12143. * Gets the current object class name.
  12144. * @return the class name
  12145. */
  12146. getClassName(): string;
  12147. }
  12148. }
  12149. declare module BABYLON {
  12150. /**
  12151. * Represents a gamepad control stick position
  12152. */
  12153. export class StickValues {
  12154. /**
  12155. * The x component of the control stick
  12156. */
  12157. x: number;
  12158. /**
  12159. * The y component of the control stick
  12160. */
  12161. y: number;
  12162. /**
  12163. * Initializes the gamepad x and y control stick values
  12164. * @param x The x component of the gamepad control stick value
  12165. * @param y The y component of the gamepad control stick value
  12166. */
  12167. constructor(
  12168. /**
  12169. * The x component of the control stick
  12170. */
  12171. x: number,
  12172. /**
  12173. * The y component of the control stick
  12174. */
  12175. y: number);
  12176. }
  12177. /**
  12178. * An interface which manages callbacks for gamepad button changes
  12179. */
  12180. export interface GamepadButtonChanges {
  12181. /**
  12182. * Called when a gamepad has been changed
  12183. */
  12184. changed: boolean;
  12185. /**
  12186. * Called when a gamepad press event has been triggered
  12187. */
  12188. pressChanged: boolean;
  12189. /**
  12190. * Called when a touch event has been triggered
  12191. */
  12192. touchChanged: boolean;
  12193. /**
  12194. * Called when a value has changed
  12195. */
  12196. valueChanged: boolean;
  12197. }
  12198. /**
  12199. * Represents a gamepad
  12200. */
  12201. export class Gamepad {
  12202. /**
  12203. * The id of the gamepad
  12204. */
  12205. id: string;
  12206. /**
  12207. * The index of the gamepad
  12208. */
  12209. index: number;
  12210. /**
  12211. * The browser gamepad
  12212. */
  12213. browserGamepad: any;
  12214. /**
  12215. * Specifies what type of gamepad this represents
  12216. */
  12217. type: number;
  12218. private _leftStick;
  12219. private _rightStick;
  12220. /** @hidden */
  12221. _isConnected: boolean;
  12222. private _leftStickAxisX;
  12223. private _leftStickAxisY;
  12224. private _rightStickAxisX;
  12225. private _rightStickAxisY;
  12226. /**
  12227. * Triggered when the left control stick has been changed
  12228. */
  12229. private _onleftstickchanged;
  12230. /**
  12231. * Triggered when the right control stick has been changed
  12232. */
  12233. private _onrightstickchanged;
  12234. /**
  12235. * Represents a gamepad controller
  12236. */
  12237. static GAMEPAD: number;
  12238. /**
  12239. * Represents a generic controller
  12240. */
  12241. static GENERIC: number;
  12242. /**
  12243. * Represents an XBox controller
  12244. */
  12245. static XBOX: number;
  12246. /**
  12247. * Represents a pose-enabled controller
  12248. */
  12249. static POSE_ENABLED: number;
  12250. /**
  12251. * Represents an Dual Shock controller
  12252. */
  12253. static DUALSHOCK: number;
  12254. /**
  12255. * Specifies whether the left control stick should be Y-inverted
  12256. */
  12257. protected _invertLeftStickY: boolean;
  12258. /**
  12259. * Specifies if the gamepad has been connected
  12260. */
  12261. readonly isConnected: boolean;
  12262. /**
  12263. * Initializes the gamepad
  12264. * @param id The id of the gamepad
  12265. * @param index The index of the gamepad
  12266. * @param browserGamepad The browser gamepad
  12267. * @param leftStickX The x component of the left joystick
  12268. * @param leftStickY The y component of the left joystick
  12269. * @param rightStickX The x component of the right joystick
  12270. * @param rightStickY The y component of the right joystick
  12271. */
  12272. constructor(
  12273. /**
  12274. * The id of the gamepad
  12275. */
  12276. id: string,
  12277. /**
  12278. * The index of the gamepad
  12279. */
  12280. index: number,
  12281. /**
  12282. * The browser gamepad
  12283. */
  12284. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12285. /**
  12286. * Callback triggered when the left joystick has changed
  12287. * @param callback
  12288. */
  12289. onleftstickchanged(callback: (values: StickValues) => void): void;
  12290. /**
  12291. * Callback triggered when the right joystick has changed
  12292. * @param callback
  12293. */
  12294. onrightstickchanged(callback: (values: StickValues) => void): void;
  12295. /**
  12296. * Gets the left joystick
  12297. */
  12298. /**
  12299. * Sets the left joystick values
  12300. */
  12301. leftStick: StickValues;
  12302. /**
  12303. * Gets the right joystick
  12304. */
  12305. /**
  12306. * Sets the right joystick value
  12307. */
  12308. rightStick: StickValues;
  12309. /**
  12310. * Updates the gamepad joystick positions
  12311. */
  12312. update(): void;
  12313. /**
  12314. * Disposes the gamepad
  12315. */
  12316. dispose(): void;
  12317. }
  12318. /**
  12319. * Represents a generic gamepad
  12320. */
  12321. export class GenericPad extends Gamepad {
  12322. private _buttons;
  12323. private _onbuttondown;
  12324. private _onbuttonup;
  12325. /**
  12326. * Observable triggered when a button has been pressed
  12327. */
  12328. onButtonDownObservable: Observable<number>;
  12329. /**
  12330. * Observable triggered when a button has been released
  12331. */
  12332. onButtonUpObservable: Observable<number>;
  12333. /**
  12334. * Callback triggered when a button has been pressed
  12335. * @param callback Called when a button has been pressed
  12336. */
  12337. onbuttondown(callback: (buttonPressed: number) => void): void;
  12338. /**
  12339. * Callback triggered when a button has been released
  12340. * @param callback Called when a button has been released
  12341. */
  12342. onbuttonup(callback: (buttonReleased: number) => void): void;
  12343. /**
  12344. * Initializes the generic gamepad
  12345. * @param id The id of the generic gamepad
  12346. * @param index The index of the generic gamepad
  12347. * @param browserGamepad The browser gamepad
  12348. */
  12349. constructor(id: string, index: number, browserGamepad: any);
  12350. private _setButtonValue;
  12351. /**
  12352. * Updates the generic gamepad
  12353. */
  12354. update(): void;
  12355. /**
  12356. * Disposes the generic gamepad
  12357. */
  12358. dispose(): void;
  12359. }
  12360. }
  12361. declare module BABYLON {
  12362. interface BaseEngine {
  12363. /**
  12364. * Creates a raw texture
  12365. * @param data defines the data to store in the texture
  12366. * @param width defines the width of the texture
  12367. * @param height defines the height of the texture
  12368. * @param format defines the format of the data
  12369. * @param generateMipMaps defines if the engine should generate the mip levels
  12370. * @param invertY defines if data must be stored with Y axis inverted
  12371. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12372. * @param compression defines the compression used (null by default)
  12373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12374. * @returns the raw texture inside an InternalTexture
  12375. */
  12376. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12377. /**
  12378. * Update a raw texture
  12379. * @param texture defines the texture to update
  12380. * @param data defines the data to store in the texture
  12381. * @param format defines the format of the data
  12382. * @param invertY defines if data must be stored with Y axis inverted
  12383. */
  12384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12385. /**
  12386. * Update a raw texture
  12387. * @param texture defines the texture to update
  12388. * @param data defines the data to store in the texture
  12389. * @param format defines the format of the data
  12390. * @param invertY defines if data must be stored with Y axis inverted
  12391. * @param compression defines the compression used (null by default)
  12392. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12393. */
  12394. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12395. /**
  12396. * Creates a new raw cube texture
  12397. * @param data defines the array of data to use to create each face
  12398. * @param size defines the size of the textures
  12399. * @param format defines the format of the data
  12400. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12401. * @param generateMipMaps defines if the engine should generate the mip levels
  12402. * @param invertY defines if data must be stored with Y axis inverted
  12403. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12404. * @param compression defines the compression used (null by default)
  12405. * @returns the cube texture as an InternalTexture
  12406. */
  12407. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12408. /**
  12409. * Update a raw cube texture
  12410. * @param texture defines the texture to udpdate
  12411. * @param data defines the data to store
  12412. * @param format defines the data format
  12413. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12414. * @param invertY defines if data must be stored with Y axis inverted
  12415. */
  12416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12417. /**
  12418. * Update a raw cube texture
  12419. * @param texture defines the texture to udpdate
  12420. * @param data defines the data to store
  12421. * @param format defines the data format
  12422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12423. * @param invertY defines if data must be stored with Y axis inverted
  12424. * @param compression defines the compression used (null by default)
  12425. */
  12426. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12427. /**
  12428. * Update a raw cube texture
  12429. * @param texture defines the texture to udpdate
  12430. * @param data defines the data to store
  12431. * @param format defines the data format
  12432. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12433. * @param invertY defines if data must be stored with Y axis inverted
  12434. * @param compression defines the compression used (null by default)
  12435. * @param level defines which level of the texture to update
  12436. */
  12437. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12438. /**
  12439. * Creates a new raw cube texture from a specified url
  12440. * @param url defines the url where the data is located
  12441. * @param scene defines the current scene
  12442. * @param size defines the size of the textures
  12443. * @param format defines the format of the data
  12444. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12445. * @param noMipmap defines if the engine should avoid generating the mip levels
  12446. * @param callback defines a callback used to extract texture data from loaded data
  12447. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12448. * @param onLoad defines a callback called when texture is loaded
  12449. * @param onError defines a callback called if there is an error
  12450. * @returns the cube texture as an InternalTexture
  12451. */
  12452. 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;
  12453. /**
  12454. * Creates a new raw cube texture from a specified url
  12455. * @param url defines the url where the data is located
  12456. * @param scene defines the current scene
  12457. * @param size defines the size of the textures
  12458. * @param format defines the format of the data
  12459. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12460. * @param noMipmap defines if the engine should avoid generating the mip levels
  12461. * @param callback defines a callback used to extract texture data from loaded data
  12462. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12463. * @param onLoad defines a callback called when texture is loaded
  12464. * @param onError defines a callback called if there is an error
  12465. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12466. * @param invertY defines if data must be stored with Y axis inverted
  12467. * @returns the cube texture as an InternalTexture
  12468. */
  12469. 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;
  12470. /**
  12471. * Creates a new raw 3D texture
  12472. * @param data defines the data used to create the texture
  12473. * @param width defines the width of the texture
  12474. * @param height defines the height of the texture
  12475. * @param depth defines the depth of the texture
  12476. * @param format defines the format of the texture
  12477. * @param generateMipMaps defines if the engine must generate mip levels
  12478. * @param invertY defines if data must be stored with Y axis inverted
  12479. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12480. * @param compression defines the compressed used (can be null)
  12481. * @param textureType defines the compressed used (can be null)
  12482. * @returns a new raw 3D texture (stored in an InternalTexture)
  12483. */
  12484. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12485. /**
  12486. * Update a raw 3D texture
  12487. * @param texture defines the texture to update
  12488. * @param data defines the data to store
  12489. * @param format defines the data format
  12490. * @param invertY defines if data must be stored with Y axis inverted
  12491. */
  12492. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12493. /**
  12494. * Update a raw 3D texture
  12495. * @param texture defines the texture to update
  12496. * @param data defines the data to store
  12497. * @param format defines the data format
  12498. * @param invertY defines if data must be stored with Y axis inverted
  12499. * @param compression defines the used compression (can be null)
  12500. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12501. */
  12502. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12503. }
  12504. }
  12505. declare module BABYLON {
  12506. /**
  12507. * Raw texture can help creating a texture directly from an array of data.
  12508. * This can be super useful if you either get the data from an uncompressed source or
  12509. * if you wish to create your texture pixel by pixel.
  12510. */
  12511. export class RawTexture extends Texture {
  12512. /**
  12513. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12514. */
  12515. format: number;
  12516. private _engine;
  12517. /**
  12518. * Instantiates a new RawTexture.
  12519. * Raw texture can help creating a texture directly from an array of data.
  12520. * This can be super useful if you either get the data from an uncompressed source or
  12521. * if you wish to create your texture pixel by pixel.
  12522. * @param data define the array of data to use to create the texture
  12523. * @param width define the width of the texture
  12524. * @param height define the height of the texture
  12525. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12526. * @param scene define the scene the texture belongs to
  12527. * @param generateMipMaps define whether mip maps should be generated or not
  12528. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12529. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12530. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12531. */
  12532. constructor(data: ArrayBufferView, width: number, height: number,
  12533. /**
  12534. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12535. */
  12536. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12537. /**
  12538. * Updates the texture underlying data.
  12539. * @param data Define the new data of the texture
  12540. */
  12541. update(data: ArrayBufferView): void;
  12542. /**
  12543. * Creates a luminance texture from some data.
  12544. * @param data Define the texture data
  12545. * @param width Define the width of the texture
  12546. * @param height Define the height of the texture
  12547. * @param scene Define the scene the texture belongs to
  12548. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12549. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12550. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12551. * @returns the luminance texture
  12552. */
  12553. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12554. /**
  12555. * Creates a luminance alpha texture from some data.
  12556. * @param data Define the texture data
  12557. * @param width Define the width of the texture
  12558. * @param height Define the height of the texture
  12559. * @param scene Define the scene the texture belongs to
  12560. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12563. * @returns the luminance alpha texture
  12564. */
  12565. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12566. /**
  12567. * Creates an alpha texture from some data.
  12568. * @param data Define the texture data
  12569. * @param width Define the width of the texture
  12570. * @param height Define the height of the texture
  12571. * @param scene Define the scene the texture belongs to
  12572. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12573. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12574. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12575. * @returns the alpha texture
  12576. */
  12577. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12578. /**
  12579. * Creates a RGB texture from some data.
  12580. * @param data Define the texture data
  12581. * @param width Define the width of the texture
  12582. * @param height Define the height of the texture
  12583. * @param scene Define the scene the texture belongs to
  12584. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12585. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12586. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12587. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12588. * @returns the RGB alpha texture
  12589. */
  12590. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12591. /**
  12592. * Creates a RGBA texture from some data.
  12593. * @param data Define the texture data
  12594. * @param width Define the width of the texture
  12595. * @param height Define the height of the texture
  12596. * @param scene Define the scene the texture belongs to
  12597. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12598. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12599. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12600. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12601. * @returns the RGBA texture
  12602. */
  12603. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12604. /**
  12605. * Creates a R texture from some data.
  12606. * @param data Define the texture data
  12607. * @param width Define the width of the texture
  12608. * @param height Define the height of the texture
  12609. * @param scene Define the scene the texture belongs to
  12610. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12611. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12612. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12613. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12614. * @returns the R texture
  12615. */
  12616. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12617. }
  12618. }
  12619. declare module BABYLON {
  12620. /**
  12621. * Interface for the size containing width and height
  12622. */
  12623. export interface ISize {
  12624. /**
  12625. * Width
  12626. */
  12627. width: number;
  12628. /**
  12629. * Heighht
  12630. */
  12631. height: number;
  12632. }
  12633. /**
  12634. * Size containing widht and height
  12635. */
  12636. export class Size implements ISize {
  12637. /**
  12638. * Width
  12639. */
  12640. width: number;
  12641. /**
  12642. * Height
  12643. */
  12644. height: number;
  12645. /**
  12646. * Creates a Size object from the given width and height (floats).
  12647. * @param width width of the new size
  12648. * @param height height of the new size
  12649. */
  12650. constructor(width: number, height: number);
  12651. /**
  12652. * Returns a string with the Size width and height
  12653. * @returns a string with the Size width and height
  12654. */
  12655. toString(): string;
  12656. /**
  12657. * "Size"
  12658. * @returns the string "Size"
  12659. */
  12660. getClassName(): string;
  12661. /**
  12662. * Returns the Size hash code.
  12663. * @returns a hash code for a unique width and height
  12664. */
  12665. getHashCode(): number;
  12666. /**
  12667. * Updates the current size from the given one.
  12668. * @param src the given size
  12669. */
  12670. copyFrom(src: Size): void;
  12671. /**
  12672. * Updates in place the current Size from the given floats.
  12673. * @param width width of the new size
  12674. * @param height height of the new size
  12675. * @returns the updated Size.
  12676. */
  12677. copyFromFloats(width: number, height: number): Size;
  12678. /**
  12679. * Updates in place the current Size from the given floats.
  12680. * @param width width to set
  12681. * @param height height to set
  12682. * @returns the updated Size.
  12683. */
  12684. set(width: number, height: number): Size;
  12685. /**
  12686. * Multiplies the width and height by numbers
  12687. * @param w factor to multiple the width by
  12688. * @param h factor to multiple the height by
  12689. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12690. */
  12691. multiplyByFloats(w: number, h: number): Size;
  12692. /**
  12693. * Clones the size
  12694. * @returns a new Size copied from the given one.
  12695. */
  12696. clone(): Size;
  12697. /**
  12698. * True if the current Size and the given one width and height are strictly equal.
  12699. * @param other the other size to compare against
  12700. * @returns True if the current Size and the given one width and height are strictly equal.
  12701. */
  12702. equals(other: Size): boolean;
  12703. /**
  12704. * The surface of the Size : width * height (float).
  12705. */
  12706. readonly surface: number;
  12707. /**
  12708. * Create a new size of zero
  12709. * @returns a new Size set to (0.0, 0.0)
  12710. */
  12711. static Zero(): Size;
  12712. /**
  12713. * Sums the width and height of two sizes
  12714. * @param otherSize size to add to this size
  12715. * @returns a new Size set as the addition result of the current Size and the given one.
  12716. */
  12717. add(otherSize: Size): Size;
  12718. /**
  12719. * Subtracts the width and height of two
  12720. * @param otherSize size to subtract to this size
  12721. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12722. */
  12723. subtract(otherSize: Size): Size;
  12724. /**
  12725. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12726. * @param start starting size to lerp between
  12727. * @param end end size to lerp between
  12728. * @param amount amount to lerp between the start and end values
  12729. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12730. */
  12731. static Lerp(start: Size, end: Size, amount: number): Size;
  12732. }
  12733. }
  12734. declare module BABYLON {
  12735. /**
  12736. * Defines a runtime animation
  12737. */
  12738. export class RuntimeAnimation {
  12739. private _events;
  12740. /**
  12741. * The current frame of the runtime animation
  12742. */
  12743. private _currentFrame;
  12744. /**
  12745. * The animation used by the runtime animation
  12746. */
  12747. private _animation;
  12748. /**
  12749. * The target of the runtime animation
  12750. */
  12751. private _target;
  12752. /**
  12753. * The initiating animatable
  12754. */
  12755. private _host;
  12756. /**
  12757. * The original value of the runtime animation
  12758. */
  12759. private _originalValue;
  12760. /**
  12761. * The original blend value of the runtime animation
  12762. */
  12763. private _originalBlendValue;
  12764. /**
  12765. * The offsets cache of the runtime animation
  12766. */
  12767. private _offsetsCache;
  12768. /**
  12769. * The high limits cache of the runtime animation
  12770. */
  12771. private _highLimitsCache;
  12772. /**
  12773. * Specifies if the runtime animation has been stopped
  12774. */
  12775. private _stopped;
  12776. /**
  12777. * The blending factor of the runtime animation
  12778. */
  12779. private _blendingFactor;
  12780. /**
  12781. * The BabylonJS scene
  12782. */
  12783. private _scene;
  12784. /**
  12785. * The current value of the runtime animation
  12786. */
  12787. private _currentValue;
  12788. /** @hidden */
  12789. _animationState: _IAnimationState;
  12790. /**
  12791. * The active target of the runtime animation
  12792. */
  12793. private _activeTargets;
  12794. private _currentActiveTarget;
  12795. private _directTarget;
  12796. /**
  12797. * The target path of the runtime animation
  12798. */
  12799. private _targetPath;
  12800. /**
  12801. * The weight of the runtime animation
  12802. */
  12803. private _weight;
  12804. /**
  12805. * The ratio offset of the runtime animation
  12806. */
  12807. private _ratioOffset;
  12808. /**
  12809. * The previous delay of the runtime animation
  12810. */
  12811. private _previousDelay;
  12812. /**
  12813. * The previous ratio of the runtime animation
  12814. */
  12815. private _previousRatio;
  12816. private _enableBlending;
  12817. private _keys;
  12818. private _minFrame;
  12819. private _maxFrame;
  12820. private _minValue;
  12821. private _maxValue;
  12822. private _targetIsArray;
  12823. /**
  12824. * Gets the current frame of the runtime animation
  12825. */
  12826. readonly currentFrame: number;
  12827. /**
  12828. * Gets the weight of the runtime animation
  12829. */
  12830. readonly weight: number;
  12831. /**
  12832. * Gets the current value of the runtime animation
  12833. */
  12834. readonly currentValue: any;
  12835. /**
  12836. * Gets the target path of the runtime animation
  12837. */
  12838. readonly targetPath: string;
  12839. /**
  12840. * Gets the actual target of the runtime animation
  12841. */
  12842. readonly target: any;
  12843. /** @hidden */
  12844. _onLoop: () => void;
  12845. /**
  12846. * Create a new RuntimeAnimation object
  12847. * @param target defines the target of the animation
  12848. * @param animation defines the source animation object
  12849. * @param scene defines the hosting scene
  12850. * @param host defines the initiating Animatable
  12851. */
  12852. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12853. private _preparePath;
  12854. /**
  12855. * Gets the animation from the runtime animation
  12856. */
  12857. readonly animation: Animation;
  12858. /**
  12859. * Resets the runtime animation to the beginning
  12860. * @param restoreOriginal defines whether to restore the target property to the original value
  12861. */
  12862. reset(restoreOriginal?: boolean): void;
  12863. /**
  12864. * Specifies if the runtime animation is stopped
  12865. * @returns Boolean specifying if the runtime animation is stopped
  12866. */
  12867. isStopped(): boolean;
  12868. /**
  12869. * Disposes of the runtime animation
  12870. */
  12871. dispose(): void;
  12872. /**
  12873. * Apply the interpolated value to the target
  12874. * @param currentValue defines the value computed by the animation
  12875. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12876. */
  12877. setValue(currentValue: any, weight: number): void;
  12878. private _getOriginalValues;
  12879. private _setValue;
  12880. /**
  12881. * Gets the loop pmode of the runtime animation
  12882. * @returns Loop Mode
  12883. */
  12884. private _getCorrectLoopMode;
  12885. /**
  12886. * Move the current animation to a given frame
  12887. * @param frame defines the frame to move to
  12888. */
  12889. goToFrame(frame: number): void;
  12890. /**
  12891. * @hidden Internal use only
  12892. */
  12893. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12894. /**
  12895. * Execute the current animation
  12896. * @param delay defines the delay to add to the current frame
  12897. * @param from defines the lower bound of the animation range
  12898. * @param to defines the upper bound of the animation range
  12899. * @param loop defines if the current animation must loop
  12900. * @param speedRatio defines the current speed ratio
  12901. * @param weight defines the weight of the animation (default is -1 so no weight)
  12902. * @param onLoop optional callback called when animation loops
  12903. * @returns a boolean indicating if the animation is running
  12904. */
  12905. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12906. }
  12907. }
  12908. declare module BABYLON {
  12909. /**
  12910. * Class used to store an actual running animation
  12911. */
  12912. export class Animatable {
  12913. /** defines the target object */
  12914. target: any;
  12915. /** defines the starting frame number (default is 0) */
  12916. fromFrame: number;
  12917. /** defines the ending frame number (default is 100) */
  12918. toFrame: number;
  12919. /** defines if the animation must loop (default is false) */
  12920. loopAnimation: boolean;
  12921. /** defines a callback to call when animation ends if it is not looping */
  12922. onAnimationEnd?: (() => void) | null | undefined;
  12923. /** defines a callback to call when animation loops */
  12924. onAnimationLoop?: (() => void) | null | undefined;
  12925. private _localDelayOffset;
  12926. private _pausedDelay;
  12927. private _runtimeAnimations;
  12928. private _paused;
  12929. private _scene;
  12930. private _speedRatio;
  12931. private _weight;
  12932. private _syncRoot;
  12933. /**
  12934. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12935. * This will only apply for non looping animation (default is true)
  12936. */
  12937. disposeOnEnd: boolean;
  12938. /**
  12939. * Gets a boolean indicating if the animation has started
  12940. */
  12941. animationStarted: boolean;
  12942. /**
  12943. * Observer raised when the animation ends
  12944. */
  12945. onAnimationEndObservable: Observable<Animatable>;
  12946. /**
  12947. * Observer raised when the animation loops
  12948. */
  12949. onAnimationLoopObservable: Observable<Animatable>;
  12950. /**
  12951. * Gets the root Animatable used to synchronize and normalize animations
  12952. */
  12953. readonly syncRoot: Nullable<Animatable>;
  12954. /**
  12955. * Gets the current frame of the first RuntimeAnimation
  12956. * Used to synchronize Animatables
  12957. */
  12958. readonly masterFrame: number;
  12959. /**
  12960. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12961. */
  12962. weight: number;
  12963. /**
  12964. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12965. */
  12966. speedRatio: number;
  12967. /**
  12968. * Creates a new Animatable
  12969. * @param scene defines the hosting scene
  12970. * @param target defines the target object
  12971. * @param fromFrame defines the starting frame number (default is 0)
  12972. * @param toFrame defines the ending frame number (default is 100)
  12973. * @param loopAnimation defines if the animation must loop (default is false)
  12974. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12975. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12976. * @param animations defines a group of animation to add to the new Animatable
  12977. * @param onAnimationLoop defines a callback to call when animation loops
  12978. */
  12979. constructor(scene: Scene,
  12980. /** defines the target object */
  12981. target: any,
  12982. /** defines the starting frame number (default is 0) */
  12983. fromFrame?: number,
  12984. /** defines the ending frame number (default is 100) */
  12985. toFrame?: number,
  12986. /** defines if the animation must loop (default is false) */
  12987. loopAnimation?: boolean, speedRatio?: number,
  12988. /** defines a callback to call when animation ends if it is not looping */
  12989. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12990. /** defines a callback to call when animation loops */
  12991. onAnimationLoop?: (() => void) | null | undefined);
  12992. /**
  12993. * Synchronize and normalize current Animatable with a source Animatable
  12994. * This is useful when using animation weights and when animations are not of the same length
  12995. * @param root defines the root Animatable to synchronize with
  12996. * @returns the current Animatable
  12997. */
  12998. syncWith(root: Animatable): Animatable;
  12999. /**
  13000. * Gets the list of runtime animations
  13001. * @returns an array of RuntimeAnimation
  13002. */
  13003. getAnimations(): RuntimeAnimation[];
  13004. /**
  13005. * Adds more animations to the current animatable
  13006. * @param target defines the target of the animations
  13007. * @param animations defines the new animations to add
  13008. */
  13009. appendAnimations(target: any, animations: Animation[]): void;
  13010. /**
  13011. * Gets the source animation for a specific property
  13012. * @param property defines the propertyu to look for
  13013. * @returns null or the source animation for the given property
  13014. */
  13015. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13016. /**
  13017. * Gets the runtime animation for a specific property
  13018. * @param property defines the propertyu to look for
  13019. * @returns null or the runtime animation for the given property
  13020. */
  13021. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13022. /**
  13023. * Resets the animatable to its original state
  13024. */
  13025. reset(): void;
  13026. /**
  13027. * Allows the animatable to blend with current running animations
  13028. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13029. * @param blendingSpeed defines the blending speed to use
  13030. */
  13031. enableBlending(blendingSpeed: number): void;
  13032. /**
  13033. * Disable animation blending
  13034. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13035. */
  13036. disableBlending(): void;
  13037. /**
  13038. * Jump directly to a given frame
  13039. * @param frame defines the frame to jump to
  13040. */
  13041. goToFrame(frame: number): void;
  13042. /**
  13043. * Pause the animation
  13044. */
  13045. pause(): void;
  13046. /**
  13047. * Restart the animation
  13048. */
  13049. restart(): void;
  13050. private _raiseOnAnimationEnd;
  13051. /**
  13052. * Stop and delete the current animation
  13053. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13054. * @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)
  13055. */
  13056. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13057. /**
  13058. * Wait asynchronously for the animation to end
  13059. * @returns a promise which will be fullfilled when the animation ends
  13060. */
  13061. waitAsync(): Promise<Animatable>;
  13062. /** @hidden */
  13063. _animate(delay: number): boolean;
  13064. }
  13065. interface Scene {
  13066. /** @hidden */
  13067. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13068. /** @hidden */
  13069. _processLateAnimationBindingsForMatrices(holder: {
  13070. totalWeight: number;
  13071. animations: RuntimeAnimation[];
  13072. originalValue: Matrix;
  13073. }): any;
  13074. /** @hidden */
  13075. _processLateAnimationBindingsForQuaternions(holder: {
  13076. totalWeight: number;
  13077. animations: RuntimeAnimation[];
  13078. originalValue: Quaternion;
  13079. }, refQuaternion: Quaternion): Quaternion;
  13080. /** @hidden */
  13081. _processLateAnimationBindings(): void;
  13082. /**
  13083. * Will start the animation sequence of a given target
  13084. * @param target defines the target
  13085. * @param from defines from which frame should animation start
  13086. * @param to defines until which frame should animation run.
  13087. * @param weight defines the weight to apply to the animation (1.0 by default)
  13088. * @param loop defines if the animation loops
  13089. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13090. * @param onAnimationEnd defines the function to be executed when the animation ends
  13091. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13092. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13093. * @param onAnimationLoop defines the callback to call when an animation loops
  13094. * @returns the animatable object created for this animation
  13095. */
  13096. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13097. /**
  13098. * Will start the animation sequence of a given target
  13099. * @param target defines the target
  13100. * @param from defines from which frame should animation start
  13101. * @param to defines until which frame should animation run.
  13102. * @param loop defines if the animation loops
  13103. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13104. * @param onAnimationEnd defines the function to be executed when the animation ends
  13105. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13106. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13107. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13108. * @param onAnimationLoop defines the callback to call when an animation loops
  13109. * @returns the animatable object created for this animation
  13110. */
  13111. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13112. /**
  13113. * Will start the animation sequence of a given target and its hierarchy
  13114. * @param target defines the target
  13115. * @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.
  13116. * @param from defines from which frame should animation start
  13117. * @param to defines until which frame should animation run.
  13118. * @param loop defines if the animation loops
  13119. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13120. * @param onAnimationEnd defines the function to be executed when the animation ends
  13121. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13122. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13123. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13124. * @param onAnimationLoop defines the callback to call when an animation loops
  13125. * @returns the list of created animatables
  13126. */
  13127. 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[];
  13128. /**
  13129. * Begin a new animation on a given node
  13130. * @param target defines the target where the animation will take place
  13131. * @param animations defines the list of animations to start
  13132. * @param from defines the initial value
  13133. * @param to defines the final value
  13134. * @param loop defines if you want animation to loop (off by default)
  13135. * @param speedRatio defines the speed ratio to apply to all animations
  13136. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13137. * @param onAnimationLoop defines the callback to call when an animation loops
  13138. * @returns the list of created animatables
  13139. */
  13140. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13141. /**
  13142. * Begin a new animation on a given node and its hierarchy
  13143. * @param target defines the root node where the animation will take place
  13144. * @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.
  13145. * @param animations defines the list of animations to start
  13146. * @param from defines the initial value
  13147. * @param to defines the final value
  13148. * @param loop defines if you want animation to loop (off by default)
  13149. * @param speedRatio defines the speed ratio to apply to all animations
  13150. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13151. * @param onAnimationLoop defines the callback to call when an animation loops
  13152. * @returns the list of animatables created for all nodes
  13153. */
  13154. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13155. /**
  13156. * Gets the animatable associated with a specific target
  13157. * @param target defines the target of the animatable
  13158. * @returns the required animatable if found
  13159. */
  13160. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13161. /**
  13162. * Gets all animatables associated with a given target
  13163. * @param target defines the target to look animatables for
  13164. * @returns an array of Animatables
  13165. */
  13166. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13167. /**
  13168. * Stops and removes all animations that have been applied to the scene
  13169. */
  13170. stopAllAnimations(): void;
  13171. }
  13172. interface Bone {
  13173. /**
  13174. * Copy an animation range from another bone
  13175. * @param source defines the source bone
  13176. * @param rangeName defines the range name to copy
  13177. * @param frameOffset defines the frame offset
  13178. * @param rescaleAsRequired defines if rescaling must be applied if required
  13179. * @param skelDimensionsRatio defines the scaling ratio
  13180. * @returns true if operation was successful
  13181. */
  13182. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13183. }
  13184. }
  13185. declare module BABYLON {
  13186. /**
  13187. * Class used to override all child animations of a given target
  13188. */
  13189. export class AnimationPropertiesOverride {
  13190. /**
  13191. * Gets or sets a value indicating if animation blending must be used
  13192. */
  13193. enableBlending: boolean;
  13194. /**
  13195. * Gets or sets the blending speed to use when enableBlending is true
  13196. */
  13197. blendingSpeed: number;
  13198. /**
  13199. * Gets or sets the default loop mode to use
  13200. */
  13201. loopMode: number;
  13202. }
  13203. }
  13204. declare module BABYLON {
  13205. /**
  13206. * Class used to handle skinning animations
  13207. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13208. */
  13209. export class Skeleton implements IAnimatable {
  13210. /** defines the skeleton name */
  13211. name: string;
  13212. /** defines the skeleton Id */
  13213. id: string;
  13214. /**
  13215. * Defines the list of child bones
  13216. */
  13217. bones: Bone[];
  13218. /**
  13219. * Defines an estimate of the dimension of the skeleton at rest
  13220. */
  13221. dimensionsAtRest: Vector3;
  13222. /**
  13223. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13224. */
  13225. needInitialSkinMatrix: boolean;
  13226. /**
  13227. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13228. */
  13229. overrideMesh: Nullable<AbstractMesh>;
  13230. /**
  13231. * Gets the list of animations attached to this skeleton
  13232. */
  13233. animations: Array<Animation>;
  13234. private _scene;
  13235. private _isDirty;
  13236. private _transformMatrices;
  13237. private _transformMatrixTexture;
  13238. private _meshesWithPoseMatrix;
  13239. private _animatables;
  13240. private _identity;
  13241. private _synchronizedWithMesh;
  13242. private _ranges;
  13243. private _lastAbsoluteTransformsUpdateId;
  13244. private _canUseTextureForBones;
  13245. private _uniqueId;
  13246. /** @hidden */
  13247. _numBonesWithLinkedTransformNode: number;
  13248. /** @hidden */
  13249. _hasWaitingData: Nullable<boolean>;
  13250. /**
  13251. * Specifies if the skeleton should be serialized
  13252. */
  13253. doNotSerialize: boolean;
  13254. private _useTextureToStoreBoneMatrices;
  13255. /**
  13256. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13257. * Please note that this option is not available if the hardware does not support it
  13258. */
  13259. useTextureToStoreBoneMatrices: boolean;
  13260. private _animationPropertiesOverride;
  13261. /**
  13262. * Gets or sets the animation properties override
  13263. */
  13264. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13265. /**
  13266. * List of inspectable custom properties (used by the Inspector)
  13267. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13268. */
  13269. inspectableCustomProperties: IInspectable[];
  13270. /**
  13271. * An observable triggered before computing the skeleton's matrices
  13272. */
  13273. onBeforeComputeObservable: Observable<Skeleton>;
  13274. /**
  13275. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13276. */
  13277. readonly isUsingTextureForMatrices: boolean;
  13278. /**
  13279. * Gets the unique ID of this skeleton
  13280. */
  13281. readonly uniqueId: number;
  13282. /**
  13283. * Creates a new skeleton
  13284. * @param name defines the skeleton name
  13285. * @param id defines the skeleton Id
  13286. * @param scene defines the hosting scene
  13287. */
  13288. constructor(
  13289. /** defines the skeleton name */
  13290. name: string,
  13291. /** defines the skeleton Id */
  13292. id: string, scene: Scene);
  13293. /**
  13294. * Gets the current object class name.
  13295. * @return the class name
  13296. */
  13297. getClassName(): string;
  13298. /**
  13299. * Returns an array containing the root bones
  13300. * @returns an array containing the root bones
  13301. */
  13302. getChildren(): Array<Bone>;
  13303. /**
  13304. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13305. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13306. * @returns a Float32Array containing matrices data
  13307. */
  13308. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13309. /**
  13310. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13311. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13312. * @returns a raw texture containing the data
  13313. */
  13314. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13315. /**
  13316. * Gets the current hosting scene
  13317. * @returns a scene object
  13318. */
  13319. getScene(): Scene;
  13320. /**
  13321. * Gets a string representing the current skeleton data
  13322. * @param fullDetails defines a boolean indicating if we want a verbose version
  13323. * @returns a string representing the current skeleton data
  13324. */
  13325. toString(fullDetails?: boolean): string;
  13326. /**
  13327. * Get bone's index searching by name
  13328. * @param name defines bone's name to search for
  13329. * @return the indice of the bone. Returns -1 if not found
  13330. */
  13331. getBoneIndexByName(name: string): number;
  13332. /**
  13333. * Creater a new animation range
  13334. * @param name defines the name of the range
  13335. * @param from defines the start key
  13336. * @param to defines the end key
  13337. */
  13338. createAnimationRange(name: string, from: number, to: number): void;
  13339. /**
  13340. * Delete a specific animation range
  13341. * @param name defines the name of the range
  13342. * @param deleteFrames defines if frames must be removed as well
  13343. */
  13344. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13345. /**
  13346. * Gets a specific animation range
  13347. * @param name defines the name of the range to look for
  13348. * @returns the requested animation range or null if not found
  13349. */
  13350. getAnimationRange(name: string): Nullable<AnimationRange>;
  13351. /**
  13352. * Gets the list of all animation ranges defined on this skeleton
  13353. * @returns an array
  13354. */
  13355. getAnimationRanges(): Nullable<AnimationRange>[];
  13356. /**
  13357. * Copy animation range from a source skeleton.
  13358. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13359. * @param source defines the source skeleton
  13360. * @param name defines the name of the range to copy
  13361. * @param rescaleAsRequired defines if rescaling must be applied if required
  13362. * @returns true if operation was successful
  13363. */
  13364. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13365. /**
  13366. * Forces the skeleton to go to rest pose
  13367. */
  13368. returnToRest(): void;
  13369. private _getHighestAnimationFrame;
  13370. /**
  13371. * Begin a specific animation range
  13372. * @param name defines the name of the range to start
  13373. * @param loop defines if looping must be turned on (false by default)
  13374. * @param speedRatio defines the speed ratio to apply (1 by default)
  13375. * @param onAnimationEnd defines a callback which will be called when animation will end
  13376. * @returns a new animatable
  13377. */
  13378. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13379. /** @hidden */
  13380. _markAsDirty(): void;
  13381. /** @hidden */
  13382. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13383. /** @hidden */
  13384. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13385. private _computeTransformMatrices;
  13386. /**
  13387. * Build all resources required to render a skeleton
  13388. */
  13389. prepare(): void;
  13390. /**
  13391. * Gets the list of animatables currently running for this skeleton
  13392. * @returns an array of animatables
  13393. */
  13394. getAnimatables(): IAnimatable[];
  13395. /**
  13396. * Clone the current skeleton
  13397. * @param name defines the name of the new skeleton
  13398. * @param id defines the id of the new skeleton
  13399. * @returns the new skeleton
  13400. */
  13401. clone(name: string, id: string): Skeleton;
  13402. /**
  13403. * Enable animation blending for this skeleton
  13404. * @param blendingSpeed defines the blending speed to apply
  13405. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13406. */
  13407. enableBlending(blendingSpeed?: number): void;
  13408. /**
  13409. * Releases all resources associated with the current skeleton
  13410. */
  13411. dispose(): void;
  13412. /**
  13413. * Serialize the skeleton in a JSON object
  13414. * @returns a JSON object
  13415. */
  13416. serialize(): any;
  13417. /**
  13418. * Creates a new skeleton from serialized data
  13419. * @param parsedSkeleton defines the serialized data
  13420. * @param scene defines the hosting scene
  13421. * @returns a new skeleton
  13422. */
  13423. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13424. /**
  13425. * Compute all node absolute transforms
  13426. * @param forceUpdate defines if computation must be done even if cache is up to date
  13427. */
  13428. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13429. /**
  13430. * Gets the root pose matrix
  13431. * @returns a matrix
  13432. */
  13433. getPoseMatrix(): Nullable<Matrix>;
  13434. /**
  13435. * Sorts bones per internal index
  13436. */
  13437. sortBones(): void;
  13438. private _sortBones;
  13439. }
  13440. }
  13441. declare module BABYLON {
  13442. /**
  13443. * Class used to store bone information
  13444. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13445. */
  13446. export class Bone extends Node {
  13447. /**
  13448. * defines the bone name
  13449. */
  13450. name: string;
  13451. private static _tmpVecs;
  13452. private static _tmpQuat;
  13453. private static _tmpMats;
  13454. /**
  13455. * Gets the list of child bones
  13456. */
  13457. children: Bone[];
  13458. /** Gets the animations associated with this bone */
  13459. animations: Animation[];
  13460. /**
  13461. * Gets or sets bone length
  13462. */
  13463. length: number;
  13464. /**
  13465. * @hidden Internal only
  13466. * Set this value to map this bone to a different index in the transform matrices
  13467. * Set this value to -1 to exclude the bone from the transform matrices
  13468. */
  13469. _index: Nullable<number>;
  13470. private _skeleton;
  13471. private _localMatrix;
  13472. private _restPose;
  13473. private _baseMatrix;
  13474. private _absoluteTransform;
  13475. private _invertedAbsoluteTransform;
  13476. private _parent;
  13477. private _scalingDeterminant;
  13478. private _worldTransform;
  13479. private _localScaling;
  13480. private _localRotation;
  13481. private _localPosition;
  13482. private _needToDecompose;
  13483. private _needToCompose;
  13484. /** @hidden */
  13485. _linkedTransformNode: Nullable<TransformNode>;
  13486. /** @hidden */
  13487. _waitingTransformNodeId: Nullable<string>;
  13488. /** @hidden */
  13489. /** @hidden */
  13490. _matrix: Matrix;
  13491. /**
  13492. * Create a new bone
  13493. * @param name defines the bone name
  13494. * @param skeleton defines the parent skeleton
  13495. * @param parentBone defines the parent (can be null if the bone is the root)
  13496. * @param localMatrix defines the local matrix
  13497. * @param restPose defines the rest pose matrix
  13498. * @param baseMatrix defines the base matrix
  13499. * @param index defines index of the bone in the hiearchy
  13500. */
  13501. constructor(
  13502. /**
  13503. * defines the bone name
  13504. */
  13505. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13506. /**
  13507. * Gets the current object class name.
  13508. * @return the class name
  13509. */
  13510. getClassName(): string;
  13511. /**
  13512. * Gets the parent skeleton
  13513. * @returns a skeleton
  13514. */
  13515. getSkeleton(): Skeleton;
  13516. /**
  13517. * Gets parent bone
  13518. * @returns a bone or null if the bone is the root of the bone hierarchy
  13519. */
  13520. getParent(): Nullable<Bone>;
  13521. /**
  13522. * Returns an array containing the root bones
  13523. * @returns an array containing the root bones
  13524. */
  13525. getChildren(): Array<Bone>;
  13526. /**
  13527. * Sets the parent bone
  13528. * @param parent defines the parent (can be null if the bone is the root)
  13529. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13530. */
  13531. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13532. /**
  13533. * Gets the local matrix
  13534. * @returns a matrix
  13535. */
  13536. getLocalMatrix(): Matrix;
  13537. /**
  13538. * Gets the base matrix (initial matrix which remains unchanged)
  13539. * @returns a matrix
  13540. */
  13541. getBaseMatrix(): Matrix;
  13542. /**
  13543. * Gets the rest pose matrix
  13544. * @returns a matrix
  13545. */
  13546. getRestPose(): Matrix;
  13547. /**
  13548. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13549. */
  13550. getWorldMatrix(): Matrix;
  13551. /**
  13552. * Sets the local matrix to rest pose matrix
  13553. */
  13554. returnToRest(): void;
  13555. /**
  13556. * Gets the inverse of the absolute transform matrix.
  13557. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13558. * @returns a matrix
  13559. */
  13560. getInvertedAbsoluteTransform(): Matrix;
  13561. /**
  13562. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13563. * @returns a matrix
  13564. */
  13565. getAbsoluteTransform(): Matrix;
  13566. /**
  13567. * Links with the given transform node.
  13568. * The local matrix of this bone is copied from the transform node every frame.
  13569. * @param transformNode defines the transform node to link to
  13570. */
  13571. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13572. /**
  13573. * Gets the node used to drive the bone's transformation
  13574. * @returns a transform node or null
  13575. */
  13576. getTransformNode(): Nullable<TransformNode>;
  13577. /** Gets or sets current position (in local space) */
  13578. position: Vector3;
  13579. /** Gets or sets current rotation (in local space) */
  13580. rotation: Vector3;
  13581. /** Gets or sets current rotation quaternion (in local space) */
  13582. rotationQuaternion: Quaternion;
  13583. /** Gets or sets current scaling (in local space) */
  13584. scaling: Vector3;
  13585. /**
  13586. * Gets the animation properties override
  13587. */
  13588. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13589. private _decompose;
  13590. private _compose;
  13591. /**
  13592. * Update the base and local matrices
  13593. * @param matrix defines the new base or local matrix
  13594. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13595. * @param updateLocalMatrix defines if the local matrix should be updated
  13596. */
  13597. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13598. /** @hidden */
  13599. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13600. /**
  13601. * Flag the bone as dirty (Forcing it to update everything)
  13602. */
  13603. markAsDirty(): void;
  13604. /** @hidden */
  13605. _markAsDirtyAndCompose(): void;
  13606. private _markAsDirtyAndDecompose;
  13607. /**
  13608. * Translate the bone in local or world space
  13609. * @param vec The amount to translate the bone
  13610. * @param space The space that the translation is in
  13611. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13612. */
  13613. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13614. /**
  13615. * Set the postion of the bone in local or world space
  13616. * @param position The position to set the bone
  13617. * @param space The space that the position is in
  13618. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13619. */
  13620. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13621. /**
  13622. * Set the absolute position of the bone (world space)
  13623. * @param position The position to set the bone
  13624. * @param mesh The mesh that this bone is attached to
  13625. */
  13626. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13627. /**
  13628. * Scale the bone on the x, y and z axes (in local space)
  13629. * @param x The amount to scale the bone on the x axis
  13630. * @param y The amount to scale the bone on the y axis
  13631. * @param z The amount to scale the bone on the z axis
  13632. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13633. */
  13634. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13635. /**
  13636. * Set the bone scaling in local space
  13637. * @param scale defines the scaling vector
  13638. */
  13639. setScale(scale: Vector3): void;
  13640. /**
  13641. * Gets the current scaling in local space
  13642. * @returns the current scaling vector
  13643. */
  13644. getScale(): Vector3;
  13645. /**
  13646. * Gets the current scaling in local space and stores it in a target vector
  13647. * @param result defines the target vector
  13648. */
  13649. getScaleToRef(result: Vector3): void;
  13650. /**
  13651. * Set the yaw, pitch, and roll of the bone in local or world space
  13652. * @param yaw The rotation of the bone on the y axis
  13653. * @param pitch The rotation of the bone on the x axis
  13654. * @param roll The rotation of the bone on the z axis
  13655. * @param space The space that the axes of rotation are in
  13656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13657. */
  13658. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13659. /**
  13660. * Add a rotation to the bone on an axis in local or world space
  13661. * @param axis The axis to rotate the bone on
  13662. * @param amount The amount to rotate the bone
  13663. * @param space The space that the axis is in
  13664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13665. */
  13666. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13667. /**
  13668. * Set the rotation of the bone to a particular axis angle in local or world space
  13669. * @param axis The axis to rotate the bone on
  13670. * @param angle The angle that the bone should be rotated to
  13671. * @param space The space that the axis is in
  13672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13673. */
  13674. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13675. /**
  13676. * Set the euler rotation of the bone in local of world space
  13677. * @param rotation The euler rotation that the bone should be set to
  13678. * @param space The space that the rotation is in
  13679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13680. */
  13681. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13682. /**
  13683. * Set the quaternion rotation of the bone in local of world space
  13684. * @param quat The quaternion rotation that the bone should be set to
  13685. * @param space The space that the rotation is in
  13686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13687. */
  13688. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13689. /**
  13690. * Set the rotation matrix of the bone in local of world space
  13691. * @param rotMat The rotation matrix that the bone should be set to
  13692. * @param space The space that the rotation is in
  13693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13694. */
  13695. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13696. private _rotateWithMatrix;
  13697. private _getNegativeRotationToRef;
  13698. /**
  13699. * Get the position of the bone in local or world space
  13700. * @param space The space that the returned position is in
  13701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13702. * @returns The position of the bone
  13703. */
  13704. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13705. /**
  13706. * Copy the position of the bone to a vector3 in local or world space
  13707. * @param space The space that the returned position is in
  13708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13709. * @param result The vector3 to copy the position to
  13710. */
  13711. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13712. /**
  13713. * Get the absolute position of the bone (world space)
  13714. * @param mesh The mesh that this bone is attached to
  13715. * @returns The absolute position of the bone
  13716. */
  13717. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13718. /**
  13719. * Copy the absolute position of the bone (world space) to the result param
  13720. * @param mesh The mesh that this bone is attached to
  13721. * @param result The vector3 to copy the absolute position to
  13722. */
  13723. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13724. /**
  13725. * Compute the absolute transforms of this bone and its children
  13726. */
  13727. computeAbsoluteTransforms(): void;
  13728. /**
  13729. * Get the world direction from an axis that is in the local space of the bone
  13730. * @param localAxis The local direction that is used to compute the world direction
  13731. * @param mesh The mesh that this bone is attached to
  13732. * @returns The world direction
  13733. */
  13734. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13735. /**
  13736. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13737. * @param localAxis The local direction that is used to compute the world direction
  13738. * @param mesh The mesh that this bone is attached to
  13739. * @param result The vector3 that the world direction will be copied to
  13740. */
  13741. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13742. /**
  13743. * Get the euler rotation of the bone in local or world space
  13744. * @param space The space that the rotation should be in
  13745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13746. * @returns The euler rotation
  13747. */
  13748. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13749. /**
  13750. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13751. * @param space The space that the rotation should be in
  13752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13753. * @param result The vector3 that the rotation should be copied to
  13754. */
  13755. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13756. /**
  13757. * Get the quaternion rotation of the bone in either local or world space
  13758. * @param space The space that the rotation should be in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. * @returns The quaternion rotation
  13761. */
  13762. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13763. /**
  13764. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13765. * @param space The space that the rotation should be in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. * @param result The quaternion that the rotation should be copied to
  13768. */
  13769. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13770. /**
  13771. * Get the rotation matrix of the bone in local or world space
  13772. * @param space The space that the rotation should be in
  13773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13774. * @returns The rotation matrix
  13775. */
  13776. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13777. /**
  13778. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13779. * @param space The space that the rotation should be in
  13780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13781. * @param result The quaternion that the rotation should be copied to
  13782. */
  13783. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13784. /**
  13785. * Get the world position of a point that is in the local space of the bone
  13786. * @param position The local position
  13787. * @param mesh The mesh that this bone is attached to
  13788. * @returns The world position
  13789. */
  13790. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13791. /**
  13792. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13793. * @param position The local position
  13794. * @param mesh The mesh that this bone is attached to
  13795. * @param result The vector3 that the world position should be copied to
  13796. */
  13797. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13798. /**
  13799. * Get the local position of a point that is in world space
  13800. * @param position The world position
  13801. * @param mesh The mesh that this bone is attached to
  13802. * @returns The local position
  13803. */
  13804. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13805. /**
  13806. * Get the local position of a point that is in world space and copy it to the result param
  13807. * @param position The world position
  13808. * @param mesh The mesh that this bone is attached to
  13809. * @param result The vector3 that the local position should be copied to
  13810. */
  13811. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13812. }
  13813. }
  13814. declare module BABYLON {
  13815. /**
  13816. * 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.
  13817. * @see https://doc.babylonjs.com/how_to/transformnode
  13818. */
  13819. export class TransformNode extends Node {
  13820. /**
  13821. * Object will not rotate to face the camera
  13822. */
  13823. static BILLBOARDMODE_NONE: number;
  13824. /**
  13825. * Object will rotate to face the camera but only on the x axis
  13826. */
  13827. static BILLBOARDMODE_X: number;
  13828. /**
  13829. * Object will rotate to face the camera but only on the y axis
  13830. */
  13831. static BILLBOARDMODE_Y: number;
  13832. /**
  13833. * Object will rotate to face the camera but only on the z axis
  13834. */
  13835. static BILLBOARDMODE_Z: number;
  13836. /**
  13837. * Object will rotate to face the camera
  13838. */
  13839. static BILLBOARDMODE_ALL: number;
  13840. /**
  13841. * Object will rotate to face the camera's position instead of orientation
  13842. */
  13843. static BILLBOARDMODE_USE_POSITION: number;
  13844. private _forward;
  13845. private _forwardInverted;
  13846. private _up;
  13847. private _right;
  13848. private _rightInverted;
  13849. private _position;
  13850. private _rotation;
  13851. private _rotationQuaternion;
  13852. protected _scaling: Vector3;
  13853. protected _isDirty: boolean;
  13854. private _transformToBoneReferal;
  13855. private _isAbsoluteSynced;
  13856. private _billboardMode;
  13857. /**
  13858. * Gets or sets the billboard mode. Default is 0.
  13859. *
  13860. * | Value | Type | Description |
  13861. * | --- | --- | --- |
  13862. * | 0 | BILLBOARDMODE_NONE | |
  13863. * | 1 | BILLBOARDMODE_X | |
  13864. * | 2 | BILLBOARDMODE_Y | |
  13865. * | 4 | BILLBOARDMODE_Z | |
  13866. * | 7 | BILLBOARDMODE_ALL | |
  13867. *
  13868. */
  13869. billboardMode: number;
  13870. private _preserveParentRotationForBillboard;
  13871. /**
  13872. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13873. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13874. */
  13875. preserveParentRotationForBillboard: boolean;
  13876. /**
  13877. * 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
  13878. */
  13879. scalingDeterminant: number;
  13880. private _infiniteDistance;
  13881. /**
  13882. * Gets or sets the distance of the object to max, often used by skybox
  13883. */
  13884. infiniteDistance: boolean;
  13885. /**
  13886. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13887. * By default the system will update normals to compensate
  13888. */
  13889. ignoreNonUniformScaling: boolean;
  13890. /**
  13891. * 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
  13892. */
  13893. reIntegrateRotationIntoRotationQuaternion: boolean;
  13894. /** @hidden */
  13895. _poseMatrix: Nullable<Matrix>;
  13896. /** @hidden */
  13897. _localMatrix: Matrix;
  13898. private _usePivotMatrix;
  13899. private _absolutePosition;
  13900. private _absoluteScaling;
  13901. private _absoluteRotationQuaternion;
  13902. private _pivotMatrix;
  13903. private _pivotMatrixInverse;
  13904. protected _postMultiplyPivotMatrix: boolean;
  13905. protected _isWorldMatrixFrozen: boolean;
  13906. /** @hidden */
  13907. _indexInSceneTransformNodesArray: number;
  13908. /**
  13909. * An event triggered after the world matrix is updated
  13910. */
  13911. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13912. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13913. /**
  13914. * Gets a string identifying the name of the class
  13915. * @returns "TransformNode" string
  13916. */
  13917. getClassName(): string;
  13918. /**
  13919. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13920. */
  13921. position: Vector3;
  13922. /**
  13923. * 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)).
  13924. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13925. */
  13926. rotation: Vector3;
  13927. /**
  13928. * 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)).
  13929. */
  13930. scaling: Vector3;
  13931. /**
  13932. * 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).
  13933. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13934. */
  13935. rotationQuaternion: Nullable<Quaternion>;
  13936. /**
  13937. * The forward direction of that transform in world space.
  13938. */
  13939. readonly forward: Vector3;
  13940. /**
  13941. * The up direction of that transform in world space.
  13942. */
  13943. readonly up: Vector3;
  13944. /**
  13945. * The right direction of that transform in world space.
  13946. */
  13947. readonly right: Vector3;
  13948. /**
  13949. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13950. * @param matrix the matrix to copy the pose from
  13951. * @returns this TransformNode.
  13952. */
  13953. updatePoseMatrix(matrix: Matrix): TransformNode;
  13954. /**
  13955. * Returns the mesh Pose matrix.
  13956. * @returns the pose matrix
  13957. */
  13958. getPoseMatrix(): Matrix;
  13959. /** @hidden */
  13960. _isSynchronized(): boolean;
  13961. /** @hidden */
  13962. _initCache(): void;
  13963. /**
  13964. * Flag the transform node as dirty (Forcing it to update everything)
  13965. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13966. * @returns this transform node
  13967. */
  13968. markAsDirty(property: string): TransformNode;
  13969. /**
  13970. * Returns the current mesh absolute position.
  13971. * Returns a Vector3.
  13972. */
  13973. readonly absolutePosition: Vector3;
  13974. /**
  13975. * Returns the current mesh absolute scaling.
  13976. * Returns a Vector3.
  13977. */
  13978. readonly absoluteScaling: Vector3;
  13979. /**
  13980. * Returns the current mesh absolute rotation.
  13981. * Returns a Quaternion.
  13982. */
  13983. readonly absoluteRotationQuaternion: Quaternion;
  13984. /**
  13985. * Sets a new matrix to apply before all other transformation
  13986. * @param matrix defines the transform matrix
  13987. * @returns the current TransformNode
  13988. */
  13989. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13990. /**
  13991. * Sets a new pivot matrix to the current node
  13992. * @param matrix defines the new pivot matrix to use
  13993. * @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
  13994. * @returns the current TransformNode
  13995. */
  13996. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13997. /**
  13998. * Returns the mesh pivot matrix.
  13999. * Default : Identity.
  14000. * @returns the matrix
  14001. */
  14002. getPivotMatrix(): Matrix;
  14003. /**
  14004. * Instantiate (when possible) or clone that node with its hierarchy
  14005. * @param newParent defines the new parent to use for the instance (or clone)
  14006. * @returns an instance (or a clone) of the current node with its hiearchy
  14007. */
  14008. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14009. /**
  14010. * Prevents the World matrix to be computed any longer
  14011. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14012. * @returns the TransformNode.
  14013. */
  14014. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14015. /**
  14016. * Allows back the World matrix computation.
  14017. * @returns the TransformNode.
  14018. */
  14019. unfreezeWorldMatrix(): this;
  14020. /**
  14021. * True if the World matrix has been frozen.
  14022. */
  14023. readonly isWorldMatrixFrozen: boolean;
  14024. /**
  14025. * Retuns the mesh absolute position in the World.
  14026. * @returns a Vector3.
  14027. */
  14028. getAbsolutePosition(): Vector3;
  14029. /**
  14030. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14031. * @param absolutePosition the absolute position to set
  14032. * @returns the TransformNode.
  14033. */
  14034. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14035. /**
  14036. * Sets the mesh position in its local space.
  14037. * @param vector3 the position to set in localspace
  14038. * @returns the TransformNode.
  14039. */
  14040. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14041. /**
  14042. * Returns the mesh position in the local space from the current World matrix values.
  14043. * @returns a new Vector3.
  14044. */
  14045. getPositionExpressedInLocalSpace(): Vector3;
  14046. /**
  14047. * Translates the mesh along the passed Vector3 in its local space.
  14048. * @param vector3 the distance to translate in localspace
  14049. * @returns the TransformNode.
  14050. */
  14051. locallyTranslate(vector3: Vector3): TransformNode;
  14052. private static _lookAtVectorCache;
  14053. /**
  14054. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14055. * @param targetPoint the position (must be in same space as current mesh) to look at
  14056. * @param yawCor optional yaw (y-axis) correction in radians
  14057. * @param pitchCor optional pitch (x-axis) correction in radians
  14058. * @param rollCor optional roll (z-axis) correction in radians
  14059. * @param space the choosen space of the target
  14060. * @returns the TransformNode.
  14061. */
  14062. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14063. /**
  14064. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14065. * This Vector3 is expressed in the World space.
  14066. * @param localAxis axis to rotate
  14067. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14068. */
  14069. getDirection(localAxis: Vector3): Vector3;
  14070. /**
  14071. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14072. * localAxis is expressed in the mesh local space.
  14073. * result is computed in the Wordl space from the mesh World matrix.
  14074. * @param localAxis axis to rotate
  14075. * @param result the resulting transformnode
  14076. * @returns this TransformNode.
  14077. */
  14078. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14079. /**
  14080. * Sets this transform node rotation to the given local axis.
  14081. * @param localAxis the axis in local space
  14082. * @param yawCor optional yaw (y-axis) correction in radians
  14083. * @param pitchCor optional pitch (x-axis) correction in radians
  14084. * @param rollCor optional roll (z-axis) correction in radians
  14085. * @returns this TransformNode
  14086. */
  14087. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14088. /**
  14089. * Sets a new pivot point to the current node
  14090. * @param point defines the new pivot point to use
  14091. * @param space defines if the point is in world or local space (local by default)
  14092. * @returns the current TransformNode
  14093. */
  14094. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14095. /**
  14096. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14097. * @returns the pivot point
  14098. */
  14099. getPivotPoint(): Vector3;
  14100. /**
  14101. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14102. * @param result the vector3 to store the result
  14103. * @returns this TransformNode.
  14104. */
  14105. getPivotPointToRef(result: Vector3): TransformNode;
  14106. /**
  14107. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14108. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14109. */
  14110. getAbsolutePivotPoint(): Vector3;
  14111. /**
  14112. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14113. * @param result vector3 to store the result
  14114. * @returns this TransformNode.
  14115. */
  14116. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14117. /**
  14118. * Defines the passed node as the parent of the current node.
  14119. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14120. * @see https://doc.babylonjs.com/how_to/parenting
  14121. * @param node the node ot set as the parent
  14122. * @returns this TransformNode.
  14123. */
  14124. setParent(node: Nullable<Node>): TransformNode;
  14125. private _nonUniformScaling;
  14126. /**
  14127. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14128. */
  14129. readonly nonUniformScaling: boolean;
  14130. /** @hidden */
  14131. _updateNonUniformScalingState(value: boolean): boolean;
  14132. /**
  14133. * Attach the current TransformNode to another TransformNode associated with a bone
  14134. * @param bone Bone affecting the TransformNode
  14135. * @param affectedTransformNode TransformNode associated with the bone
  14136. * @returns this object
  14137. */
  14138. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14139. /**
  14140. * Detach the transform node if its associated with a bone
  14141. * @returns this object
  14142. */
  14143. detachFromBone(): TransformNode;
  14144. private static _rotationAxisCache;
  14145. /**
  14146. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14147. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14148. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14149. * The passed axis is also normalized.
  14150. * @param axis the axis to rotate around
  14151. * @param amount the amount to rotate in radians
  14152. * @param space Space to rotate in (Default: local)
  14153. * @returns the TransformNode.
  14154. */
  14155. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14156. /**
  14157. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14158. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14159. * The passed axis is also normalized. .
  14160. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14161. * @param point the point to rotate around
  14162. * @param axis the axis to rotate around
  14163. * @param amount the amount to rotate in radians
  14164. * @returns the TransformNode
  14165. */
  14166. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14167. /**
  14168. * Translates the mesh along the axis vector for the passed distance in the given space.
  14169. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14170. * @param axis the axis to translate in
  14171. * @param distance the distance to translate
  14172. * @param space Space to rotate in (Default: local)
  14173. * @returns the TransformNode.
  14174. */
  14175. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14176. /**
  14177. * Adds a rotation step to the mesh current rotation.
  14178. * x, y, z are Euler angles expressed in radians.
  14179. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14180. * This means this rotation is made in the mesh local space only.
  14181. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14182. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14183. * ```javascript
  14184. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14185. * ```
  14186. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14187. * 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.
  14188. * @param x Rotation to add
  14189. * @param y Rotation to add
  14190. * @param z Rotation to add
  14191. * @returns the TransformNode.
  14192. */
  14193. addRotation(x: number, y: number, z: number): TransformNode;
  14194. /**
  14195. * @hidden
  14196. */
  14197. protected _getEffectiveParent(): Nullable<Node>;
  14198. /**
  14199. * Computes the world matrix of the node
  14200. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14201. * @returns the world matrix
  14202. */
  14203. computeWorldMatrix(force?: boolean): Matrix;
  14204. protected _afterComputeWorldMatrix(): void;
  14205. /**
  14206. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14207. * @param func callback function to add
  14208. *
  14209. * @returns the TransformNode.
  14210. */
  14211. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14212. /**
  14213. * Removes a registered callback function.
  14214. * @param func callback function to remove
  14215. * @returns the TransformNode.
  14216. */
  14217. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14218. /**
  14219. * Gets the position of the current mesh in camera space
  14220. * @param camera defines the camera to use
  14221. * @returns a position
  14222. */
  14223. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14224. /**
  14225. * Returns the distance from the mesh to the active camera
  14226. * @param camera defines the camera to use
  14227. * @returns the distance
  14228. */
  14229. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14230. /**
  14231. * Clone the current transform node
  14232. * @param name Name of the new clone
  14233. * @param newParent New parent for the clone
  14234. * @param doNotCloneChildren Do not clone children hierarchy
  14235. * @returns the new transform node
  14236. */
  14237. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14238. /**
  14239. * Serializes the objects information.
  14240. * @param currentSerializationObject defines the object to serialize in
  14241. * @returns the serialized object
  14242. */
  14243. serialize(currentSerializationObject?: any): any;
  14244. /**
  14245. * Returns a new TransformNode object parsed from the source provided.
  14246. * @param parsedTransformNode is the source.
  14247. * @param scene the scne the object belongs to
  14248. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14249. * @returns a new TransformNode object parsed from the source provided.
  14250. */
  14251. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14252. /**
  14253. * Get all child-transformNodes of this node
  14254. * @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
  14255. * @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
  14256. * @returns an array of TransformNode
  14257. */
  14258. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14259. /**
  14260. * Releases resources associated with this transform node.
  14261. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14262. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14263. */
  14264. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14265. /**
  14266. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14267. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14268. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14269. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14270. * @returns the current mesh
  14271. */
  14272. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14273. private _syncAbsoluteScalingAndRotation;
  14274. }
  14275. }
  14276. declare module BABYLON {
  14277. /**
  14278. * Defines the types of pose enabled controllers that are supported
  14279. */
  14280. export enum PoseEnabledControllerType {
  14281. /**
  14282. * HTC Vive
  14283. */
  14284. VIVE = 0,
  14285. /**
  14286. * Oculus Rift
  14287. */
  14288. OCULUS = 1,
  14289. /**
  14290. * Windows mixed reality
  14291. */
  14292. WINDOWS = 2,
  14293. /**
  14294. * Samsung gear VR
  14295. */
  14296. GEAR_VR = 3,
  14297. /**
  14298. * Google Daydream
  14299. */
  14300. DAYDREAM = 4,
  14301. /**
  14302. * Generic
  14303. */
  14304. GENERIC = 5
  14305. }
  14306. /**
  14307. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14308. */
  14309. export interface MutableGamepadButton {
  14310. /**
  14311. * Value of the button/trigger
  14312. */
  14313. value: number;
  14314. /**
  14315. * If the button/trigger is currently touched
  14316. */
  14317. touched: boolean;
  14318. /**
  14319. * If the button/trigger is currently pressed
  14320. */
  14321. pressed: boolean;
  14322. }
  14323. /**
  14324. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14325. * @hidden
  14326. */
  14327. export interface ExtendedGamepadButton extends GamepadButton {
  14328. /**
  14329. * If the button/trigger is currently pressed
  14330. */
  14331. readonly pressed: boolean;
  14332. /**
  14333. * If the button/trigger is currently touched
  14334. */
  14335. readonly touched: boolean;
  14336. /**
  14337. * Value of the button/trigger
  14338. */
  14339. readonly value: number;
  14340. }
  14341. /** @hidden */
  14342. export interface _GamePadFactory {
  14343. /**
  14344. * Returns wether or not the current gamepad can be created for this type of controller.
  14345. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14346. * @returns true if it can be created, otherwise false
  14347. */
  14348. canCreate(gamepadInfo: any): boolean;
  14349. /**
  14350. * Creates a new instance of the Gamepad.
  14351. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14352. * @returns the new gamepad instance
  14353. */
  14354. create(gamepadInfo: any): Gamepad;
  14355. }
  14356. /**
  14357. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14358. */
  14359. export class PoseEnabledControllerHelper {
  14360. /** @hidden */
  14361. static _ControllerFactories: _GamePadFactory[];
  14362. /** @hidden */
  14363. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14364. /**
  14365. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14366. * @param vrGamepad the gamepad to initialized
  14367. * @returns a vr controller of the type the gamepad identified as
  14368. */
  14369. static InitiateController(vrGamepad: any): Gamepad;
  14370. }
  14371. /**
  14372. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14373. */
  14374. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14375. /**
  14376. * If the controller is used in a webXR session
  14377. */
  14378. isXR: boolean;
  14379. private _deviceRoomPosition;
  14380. private _deviceRoomRotationQuaternion;
  14381. /**
  14382. * The device position in babylon space
  14383. */
  14384. devicePosition: Vector3;
  14385. /**
  14386. * The device rotation in babylon space
  14387. */
  14388. deviceRotationQuaternion: Quaternion;
  14389. /**
  14390. * The scale factor of the device in babylon space
  14391. */
  14392. deviceScaleFactor: number;
  14393. /**
  14394. * (Likely devicePosition should be used instead) The device position in its room space
  14395. */
  14396. position: Vector3;
  14397. /**
  14398. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14399. */
  14400. rotationQuaternion: Quaternion;
  14401. /**
  14402. * The type of controller (Eg. Windows mixed reality)
  14403. */
  14404. controllerType: PoseEnabledControllerType;
  14405. protected _calculatedPosition: Vector3;
  14406. private _calculatedRotation;
  14407. /**
  14408. * The raw pose from the device
  14409. */
  14410. rawPose: DevicePose;
  14411. private _trackPosition;
  14412. private _maxRotationDistFromHeadset;
  14413. private _draggedRoomRotation;
  14414. /**
  14415. * @hidden
  14416. */
  14417. _disableTrackPosition(fixedPosition: Vector3): void;
  14418. /**
  14419. * Internal, the mesh attached to the controller
  14420. * @hidden
  14421. */
  14422. _mesh: Nullable<AbstractMesh>;
  14423. private _poseControlledCamera;
  14424. private _leftHandSystemQuaternion;
  14425. /**
  14426. * Internal, matrix used to convert room space to babylon space
  14427. * @hidden
  14428. */
  14429. _deviceToWorld: Matrix;
  14430. /**
  14431. * Node to be used when casting a ray from the controller
  14432. * @hidden
  14433. */
  14434. _pointingPoseNode: Nullable<TransformNode>;
  14435. /**
  14436. * Name of the child mesh that can be used to cast a ray from the controller
  14437. */
  14438. static readonly POINTING_POSE: string;
  14439. /**
  14440. * Creates a new PoseEnabledController from a gamepad
  14441. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14442. */
  14443. constructor(browserGamepad: any);
  14444. private _workingMatrix;
  14445. /**
  14446. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14447. */
  14448. update(): void;
  14449. /**
  14450. * Updates only the pose device and mesh without doing any button event checking
  14451. */
  14452. protected _updatePoseAndMesh(): void;
  14453. /**
  14454. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14455. * @param poseData raw pose fromthe device
  14456. */
  14457. updateFromDevice(poseData: DevicePose): void;
  14458. /**
  14459. * @hidden
  14460. */
  14461. _meshAttachedObservable: Observable<AbstractMesh>;
  14462. /**
  14463. * Attaches a mesh to the controller
  14464. * @param mesh the mesh to be attached
  14465. */
  14466. attachToMesh(mesh: AbstractMesh): void;
  14467. /**
  14468. * Attaches the controllers mesh to a camera
  14469. * @param camera the camera the mesh should be attached to
  14470. */
  14471. attachToPoseControlledCamera(camera: TargetCamera): void;
  14472. /**
  14473. * Disposes of the controller
  14474. */
  14475. dispose(): void;
  14476. /**
  14477. * The mesh that is attached to the controller
  14478. */
  14479. readonly mesh: Nullable<AbstractMesh>;
  14480. /**
  14481. * Gets the ray of the controller in the direction the controller is pointing
  14482. * @param length the length the resulting ray should be
  14483. * @returns a ray in the direction the controller is pointing
  14484. */
  14485. getForwardRay(length?: number): Ray;
  14486. }
  14487. }
  14488. declare module BABYLON {
  14489. /**
  14490. * Defines the WebVRController object that represents controllers tracked in 3D space
  14491. */
  14492. export abstract class WebVRController extends PoseEnabledController {
  14493. /**
  14494. * Internal, the default controller model for the controller
  14495. */
  14496. protected _defaultModel: Nullable<AbstractMesh>;
  14497. /**
  14498. * Fired when the trigger state has changed
  14499. */
  14500. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14501. /**
  14502. * Fired when the main button state has changed
  14503. */
  14504. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14505. /**
  14506. * Fired when the secondary button state has changed
  14507. */
  14508. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14509. /**
  14510. * Fired when the pad state has changed
  14511. */
  14512. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14513. /**
  14514. * Fired when controllers stick values have changed
  14515. */
  14516. onPadValuesChangedObservable: Observable<StickValues>;
  14517. /**
  14518. * Array of button availible on the controller
  14519. */
  14520. protected _buttons: Array<MutableGamepadButton>;
  14521. private _onButtonStateChange;
  14522. /**
  14523. * Fired when a controller button's state has changed
  14524. * @param callback the callback containing the button that was modified
  14525. */
  14526. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14527. /**
  14528. * X and Y axis corresponding to the controllers joystick
  14529. */
  14530. pad: StickValues;
  14531. /**
  14532. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14533. */
  14534. hand: string;
  14535. /**
  14536. * The default controller model for the controller
  14537. */
  14538. readonly defaultModel: Nullable<AbstractMesh>;
  14539. /**
  14540. * Creates a new WebVRController from a gamepad
  14541. * @param vrGamepad the gamepad that the WebVRController should be created from
  14542. */
  14543. constructor(vrGamepad: any);
  14544. /**
  14545. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14546. */
  14547. update(): void;
  14548. /**
  14549. * Function to be called when a button is modified
  14550. */
  14551. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14552. /**
  14553. * Loads a mesh and attaches it to the controller
  14554. * @param scene the scene the mesh should be added to
  14555. * @param meshLoaded callback for when the mesh has been loaded
  14556. */
  14557. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14558. private _setButtonValue;
  14559. private _changes;
  14560. private _checkChanges;
  14561. /**
  14562. * Disposes of th webVRCOntroller
  14563. */
  14564. dispose(): void;
  14565. }
  14566. }
  14567. declare module BABYLON {
  14568. /**
  14569. * The HemisphericLight simulates the ambient environment light,
  14570. * so the passed direction is the light reflection direction, not the incoming direction.
  14571. */
  14572. export class HemisphericLight extends Light {
  14573. /**
  14574. * The groundColor is the light in the opposite direction to the one specified during creation.
  14575. * 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.
  14576. */
  14577. groundColor: Color3;
  14578. /**
  14579. * The light reflection direction, not the incoming direction.
  14580. */
  14581. direction: Vector3;
  14582. /**
  14583. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14584. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14585. * The HemisphericLight can't cast shadows.
  14586. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14587. * @param name The friendly name of the light
  14588. * @param direction The direction of the light reflection
  14589. * @param scene The scene the light belongs to
  14590. */
  14591. constructor(name: string, direction: Vector3, scene: Scene);
  14592. protected _buildUniformLayout(): void;
  14593. /**
  14594. * Returns the string "HemisphericLight".
  14595. * @return The class name
  14596. */
  14597. getClassName(): string;
  14598. /**
  14599. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14600. * Returns the updated direction.
  14601. * @param target The target the direction should point to
  14602. * @return The computed direction
  14603. */
  14604. setDirectionToTarget(target: Vector3): Vector3;
  14605. /**
  14606. * Returns the shadow generator associated to the light.
  14607. * @returns Always null for hemispheric lights because it does not support shadows.
  14608. */
  14609. getShadowGenerator(): Nullable<IShadowGenerator>;
  14610. /**
  14611. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14612. * @param effect The effect to update
  14613. * @param lightIndex The index of the light in the effect to update
  14614. * @returns The hemispheric light
  14615. */
  14616. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14617. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14618. /**
  14619. * Computes the world matrix of the node
  14620. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14621. * @param useWasUpdatedFlag defines a reserved property
  14622. * @returns the world matrix
  14623. */
  14624. computeWorldMatrix(): Matrix;
  14625. /**
  14626. * Returns the integer 3.
  14627. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14628. */
  14629. getTypeID(): number;
  14630. /**
  14631. * Prepares the list of defines specific to the light type.
  14632. * @param defines the list of defines
  14633. * @param lightIndex defines the index of the light for the effect
  14634. */
  14635. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14636. }
  14637. }
  14638. declare module BABYLON {
  14639. /** @hidden */
  14640. export var vrMultiviewToSingleviewPixelShader: {
  14641. name: string;
  14642. shader: string;
  14643. };
  14644. }
  14645. declare module BABYLON {
  14646. /**
  14647. * Renders to multiple views with a single draw call
  14648. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14649. */
  14650. export class MultiviewRenderTarget extends RenderTargetTexture {
  14651. /**
  14652. * Creates a multiview render target
  14653. * @param scene scene used with the render target
  14654. * @param size the size of the render target (used for each view)
  14655. */
  14656. constructor(scene: Scene, size?: number | {
  14657. width: number;
  14658. height: number;
  14659. } | {
  14660. ratio: number;
  14661. });
  14662. /**
  14663. * @hidden
  14664. * @param faceIndex the face index, if its a cube texture
  14665. */
  14666. _bindFrameBuffer(faceIndex?: number): void;
  14667. /**
  14668. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14669. * @returns the view count
  14670. */
  14671. getViewCount(): number;
  14672. }
  14673. }
  14674. declare module BABYLON {
  14675. /**
  14676. * Represents a camera frustum
  14677. */
  14678. export class Frustum {
  14679. /**
  14680. * Gets the planes representing the frustum
  14681. * @param transform matrix to be applied to the returned planes
  14682. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14683. */
  14684. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14685. /**
  14686. * Gets the near frustum plane transformed by the transform matrix
  14687. * @param transform transformation matrix to be applied to the resulting frustum plane
  14688. * @param frustumPlane the resuling frustum plane
  14689. */
  14690. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14691. /**
  14692. * Gets the far frustum plane transformed by the transform matrix
  14693. * @param transform transformation matrix to be applied to the resulting frustum plane
  14694. * @param frustumPlane the resuling frustum plane
  14695. */
  14696. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14697. /**
  14698. * Gets the left frustum plane transformed by the transform matrix
  14699. * @param transform transformation matrix to be applied to the resulting frustum plane
  14700. * @param frustumPlane the resuling frustum plane
  14701. */
  14702. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14703. /**
  14704. * Gets the right frustum plane transformed by the transform matrix
  14705. * @param transform transformation matrix to be applied to the resulting frustum plane
  14706. * @param frustumPlane the resuling frustum plane
  14707. */
  14708. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14709. /**
  14710. * Gets the top frustum plane transformed by the transform matrix
  14711. * @param transform transformation matrix to be applied to the resulting frustum plane
  14712. * @param frustumPlane the resuling frustum plane
  14713. */
  14714. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14715. /**
  14716. * Gets the bottom frustum plane transformed by the transform matrix
  14717. * @param transform transformation matrix to be applied to the resulting frustum plane
  14718. * @param frustumPlane the resuling frustum plane
  14719. */
  14720. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14721. /**
  14722. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14723. * @param transform transformation matrix to be applied to the resulting frustum planes
  14724. * @param frustumPlanes the resuling frustum planes
  14725. */
  14726. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14727. }
  14728. }
  14729. declare module BABYLON {
  14730. interface Engine {
  14731. /**
  14732. * Creates a new multiview render target
  14733. * @param width defines the width of the texture
  14734. * @param height defines the height of the texture
  14735. * @returns the created multiview texture
  14736. */
  14737. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14738. /**
  14739. * Binds a multiview framebuffer to be drawn to
  14740. * @param multiviewTexture texture to bind
  14741. */
  14742. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14743. }
  14744. interface Camera {
  14745. /**
  14746. * @hidden
  14747. * 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)
  14748. */
  14749. _useMultiviewToSingleView: boolean;
  14750. /**
  14751. * @hidden
  14752. * 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)
  14753. */
  14754. _multiviewTexture: Nullable<RenderTargetTexture>;
  14755. /**
  14756. * @hidden
  14757. * ensures the multiview texture of the camera exists and has the specified width/height
  14758. * @param width height to set on the multiview texture
  14759. * @param height width to set on the multiview texture
  14760. */
  14761. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14762. }
  14763. interface Scene {
  14764. /** @hidden */
  14765. _transformMatrixR: Matrix;
  14766. /** @hidden */
  14767. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14768. /** @hidden */
  14769. _createMultiviewUbo(): void;
  14770. /** @hidden */
  14771. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14772. /** @hidden */
  14773. _renderMultiviewToSingleView(camera: Camera): void;
  14774. }
  14775. }
  14776. declare module BABYLON {
  14777. /**
  14778. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14779. * This will not be used for webXR as it supports displaying texture arrays directly
  14780. */
  14781. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14782. /**
  14783. * Initializes a VRMultiviewToSingleview
  14784. * @param name name of the post process
  14785. * @param camera camera to be applied to
  14786. * @param scaleFactor scaling factor to the size of the output texture
  14787. */
  14788. constructor(name: string, camera: Camera, scaleFactor: number);
  14789. }
  14790. }
  14791. declare module BABYLON {
  14792. interface Engine {
  14793. /** @hidden */
  14794. _vrDisplay: any;
  14795. /** @hidden */
  14796. _vrSupported: boolean;
  14797. /** @hidden */
  14798. _oldSize: Size;
  14799. /** @hidden */
  14800. _oldHardwareScaleFactor: number;
  14801. /** @hidden */
  14802. _vrExclusivePointerMode: boolean;
  14803. /** @hidden */
  14804. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14805. /** @hidden */
  14806. _onVRDisplayPointerRestricted: () => void;
  14807. /** @hidden */
  14808. _onVRDisplayPointerUnrestricted: () => void;
  14809. /** @hidden */
  14810. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14811. /** @hidden */
  14812. _onVrDisplayDisconnect: Nullable<() => void>;
  14813. /** @hidden */
  14814. _onVrDisplayPresentChange: Nullable<() => void>;
  14815. /**
  14816. * Observable signaled when VR display mode changes
  14817. */
  14818. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14819. /**
  14820. * Observable signaled when VR request present is complete
  14821. */
  14822. onVRRequestPresentComplete: Observable<boolean>;
  14823. /**
  14824. * Observable signaled when VR request present starts
  14825. */
  14826. onVRRequestPresentStart: Observable<Engine>;
  14827. /**
  14828. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14829. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14830. */
  14831. isInVRExclusivePointerMode: boolean;
  14832. /**
  14833. * Gets a boolean indicating if a webVR device was detected
  14834. * @returns true if a webVR device was detected
  14835. */
  14836. isVRDevicePresent(): boolean;
  14837. /**
  14838. * Gets the current webVR device
  14839. * @returns the current webVR device (or null)
  14840. */
  14841. getVRDevice(): any;
  14842. /**
  14843. * Initializes a webVR display and starts listening to display change events
  14844. * The onVRDisplayChangedObservable will be notified upon these changes
  14845. * @returns A promise containing a VRDisplay and if vr is supported
  14846. */
  14847. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14848. /** @hidden */
  14849. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14850. /**
  14851. * Call this function to switch to webVR mode
  14852. * Will do nothing if webVR is not supported or if there is no webVR device
  14853. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14854. */
  14855. enableVR(): void;
  14856. /** @hidden */
  14857. _onVRFullScreenTriggered(): void;
  14858. }
  14859. }
  14860. declare module BABYLON {
  14861. /**
  14862. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14863. * IMPORTANT!! The data is right-hand data.
  14864. * @export
  14865. * @interface DevicePose
  14866. */
  14867. export interface DevicePose {
  14868. /**
  14869. * The position of the device, values in array are [x,y,z].
  14870. */
  14871. readonly position: Nullable<Float32Array>;
  14872. /**
  14873. * The linearVelocity of the device, values in array are [x,y,z].
  14874. */
  14875. readonly linearVelocity: Nullable<Float32Array>;
  14876. /**
  14877. * The linearAcceleration of the device, values in array are [x,y,z].
  14878. */
  14879. readonly linearAcceleration: Nullable<Float32Array>;
  14880. /**
  14881. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14882. */
  14883. readonly orientation: Nullable<Float32Array>;
  14884. /**
  14885. * The angularVelocity of the device, values in array are [x,y,z].
  14886. */
  14887. readonly angularVelocity: Nullable<Float32Array>;
  14888. /**
  14889. * The angularAcceleration of the device, values in array are [x,y,z].
  14890. */
  14891. readonly angularAcceleration: Nullable<Float32Array>;
  14892. }
  14893. /**
  14894. * Interface representing a pose controlled object in Babylon.
  14895. * A pose controlled object has both regular pose values as well as pose values
  14896. * from an external device such as a VR head mounted display
  14897. */
  14898. export interface PoseControlled {
  14899. /**
  14900. * The position of the object in babylon space.
  14901. */
  14902. position: Vector3;
  14903. /**
  14904. * The rotation quaternion of the object in babylon space.
  14905. */
  14906. rotationQuaternion: Quaternion;
  14907. /**
  14908. * The position of the device in babylon space.
  14909. */
  14910. devicePosition?: Vector3;
  14911. /**
  14912. * The rotation quaternion of the device in babylon space.
  14913. */
  14914. deviceRotationQuaternion: Quaternion;
  14915. /**
  14916. * The raw pose coming from the device.
  14917. */
  14918. rawPose: Nullable<DevicePose>;
  14919. /**
  14920. * The scale of the device to be used when translating from device space to babylon space.
  14921. */
  14922. deviceScaleFactor: number;
  14923. /**
  14924. * Updates the poseControlled values based on the input device pose.
  14925. * @param poseData the pose data to update the object with
  14926. */
  14927. updateFromDevice(poseData: DevicePose): void;
  14928. }
  14929. /**
  14930. * Set of options to customize the webVRCamera
  14931. */
  14932. export interface WebVROptions {
  14933. /**
  14934. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14935. */
  14936. trackPosition?: boolean;
  14937. /**
  14938. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14939. */
  14940. positionScale?: number;
  14941. /**
  14942. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14943. */
  14944. displayName?: string;
  14945. /**
  14946. * Should the native controller meshes be initialized. (default: true)
  14947. */
  14948. controllerMeshes?: boolean;
  14949. /**
  14950. * Creating a default HemiLight only on controllers. (default: true)
  14951. */
  14952. defaultLightingOnControllers?: boolean;
  14953. /**
  14954. * If you don't want to use the default VR button of the helper. (default: false)
  14955. */
  14956. useCustomVRButton?: boolean;
  14957. /**
  14958. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14959. */
  14960. customVRButton?: HTMLButtonElement;
  14961. /**
  14962. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14963. */
  14964. rayLength?: number;
  14965. /**
  14966. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14967. */
  14968. defaultHeight?: number;
  14969. /**
  14970. * If multiview should be used if availible (default: false)
  14971. */
  14972. useMultiview?: boolean;
  14973. }
  14974. /**
  14975. * This represents a WebVR camera.
  14976. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14977. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14978. */
  14979. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14980. private webVROptions;
  14981. /**
  14982. * @hidden
  14983. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14984. */
  14985. _vrDevice: any;
  14986. /**
  14987. * The rawPose of the vrDevice.
  14988. */
  14989. rawPose: Nullable<DevicePose>;
  14990. private _onVREnabled;
  14991. private _specsVersion;
  14992. private _attached;
  14993. private _frameData;
  14994. protected _descendants: Array<Node>;
  14995. private _deviceRoomPosition;
  14996. /** @hidden */
  14997. _deviceRoomRotationQuaternion: Quaternion;
  14998. private _standingMatrix;
  14999. /**
  15000. * Represents device position in babylon space.
  15001. */
  15002. devicePosition: Vector3;
  15003. /**
  15004. * Represents device rotation in babylon space.
  15005. */
  15006. deviceRotationQuaternion: Quaternion;
  15007. /**
  15008. * The scale of the device to be used when translating from device space to babylon space.
  15009. */
  15010. deviceScaleFactor: number;
  15011. private _deviceToWorld;
  15012. private _worldToDevice;
  15013. /**
  15014. * References to the webVR controllers for the vrDevice.
  15015. */
  15016. controllers: Array<WebVRController>;
  15017. /**
  15018. * Emits an event when a controller is attached.
  15019. */
  15020. onControllersAttachedObservable: Observable<WebVRController[]>;
  15021. /**
  15022. * Emits an event when a controller's mesh has been loaded;
  15023. */
  15024. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15025. /**
  15026. * Emits an event when the HMD's pose has been updated.
  15027. */
  15028. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15029. private _poseSet;
  15030. /**
  15031. * If the rig cameras be used as parent instead of this camera.
  15032. */
  15033. rigParenting: boolean;
  15034. private _lightOnControllers;
  15035. private _defaultHeight?;
  15036. /**
  15037. * Instantiates a WebVRFreeCamera.
  15038. * @param name The name of the WebVRFreeCamera
  15039. * @param position The starting anchor position for the camera
  15040. * @param scene The scene the camera belongs to
  15041. * @param webVROptions a set of customizable options for the webVRCamera
  15042. */
  15043. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15044. /**
  15045. * Gets the device distance from the ground in meters.
  15046. * @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.
  15047. */
  15048. deviceDistanceToRoomGround(): number;
  15049. /**
  15050. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15051. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15052. */
  15053. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15054. /**
  15055. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15056. * @returns A promise with a boolean set to if the standing matrix is supported.
  15057. */
  15058. useStandingMatrixAsync(): Promise<boolean>;
  15059. /**
  15060. * Disposes the camera
  15061. */
  15062. dispose(): void;
  15063. /**
  15064. * Gets a vrController by name.
  15065. * @param name The name of the controller to retreive
  15066. * @returns the controller matching the name specified or null if not found
  15067. */
  15068. getControllerByName(name: string): Nullable<WebVRController>;
  15069. private _leftController;
  15070. /**
  15071. * The controller corresponding to the users left hand.
  15072. */
  15073. readonly leftController: Nullable<WebVRController>;
  15074. private _rightController;
  15075. /**
  15076. * The controller corresponding to the users right hand.
  15077. */
  15078. readonly rightController: Nullable<WebVRController>;
  15079. /**
  15080. * Casts a ray forward from the vrCamera's gaze.
  15081. * @param length Length of the ray (default: 100)
  15082. * @returns the ray corresponding to the gaze
  15083. */
  15084. getForwardRay(length?: number): Ray;
  15085. /**
  15086. * @hidden
  15087. * Updates the camera based on device's frame data
  15088. */
  15089. _checkInputs(): void;
  15090. /**
  15091. * Updates the poseControlled values based on the input device pose.
  15092. * @param poseData Pose coming from the device
  15093. */
  15094. updateFromDevice(poseData: DevicePose): void;
  15095. private _htmlElementAttached;
  15096. private _detachIfAttached;
  15097. /**
  15098. * WebVR's attach control will start broadcasting frames to the device.
  15099. * Note that in certain browsers (chrome for example) this function must be called
  15100. * within a user-interaction callback. Example:
  15101. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15102. *
  15103. * @param element html element to attach the vrDevice to
  15104. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15105. */
  15106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15107. /**
  15108. * Detaches the camera from the html element and disables VR
  15109. *
  15110. * @param element html element to detach from
  15111. */
  15112. detachControl(element: HTMLElement): void;
  15113. /**
  15114. * @returns the name of this class
  15115. */
  15116. getClassName(): string;
  15117. /**
  15118. * Calls resetPose on the vrDisplay
  15119. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15120. */
  15121. resetToCurrentRotation(): void;
  15122. /**
  15123. * @hidden
  15124. * Updates the rig cameras (left and right eye)
  15125. */
  15126. _updateRigCameras(): void;
  15127. private _workingVector;
  15128. private _oneVector;
  15129. private _workingMatrix;
  15130. private updateCacheCalled;
  15131. private _correctPositionIfNotTrackPosition;
  15132. /**
  15133. * @hidden
  15134. * Updates the cached values of the camera
  15135. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15136. */
  15137. _updateCache(ignoreParentClass?: boolean): void;
  15138. /**
  15139. * @hidden
  15140. * Get current device position in babylon world
  15141. */
  15142. _computeDevicePosition(): void;
  15143. /**
  15144. * Updates the current device position and rotation in the babylon world
  15145. */
  15146. update(): void;
  15147. /**
  15148. * @hidden
  15149. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15150. * @returns an identity matrix
  15151. */
  15152. _getViewMatrix(): Matrix;
  15153. private _tmpMatrix;
  15154. /**
  15155. * This function is called by the two RIG cameras.
  15156. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15157. * @hidden
  15158. */
  15159. _getWebVRViewMatrix(): Matrix;
  15160. /** @hidden */
  15161. _getWebVRProjectionMatrix(): Matrix;
  15162. private _onGamepadConnectedObserver;
  15163. private _onGamepadDisconnectedObserver;
  15164. private _updateCacheWhenTrackingDisabledObserver;
  15165. /**
  15166. * Initializes the controllers and their meshes
  15167. */
  15168. initControllers(): void;
  15169. }
  15170. }
  15171. declare module BABYLON {
  15172. /**
  15173. * Size options for a post process
  15174. */
  15175. export type PostProcessOptions = {
  15176. width: number;
  15177. height: number;
  15178. };
  15179. /**
  15180. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15181. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15182. */
  15183. export class PostProcess {
  15184. /** Name of the PostProcess. */
  15185. name: string;
  15186. /**
  15187. * Gets or sets the unique id of the post process
  15188. */
  15189. uniqueId: number;
  15190. /**
  15191. * Width of the texture to apply the post process on
  15192. */
  15193. width: number;
  15194. /**
  15195. * Height of the texture to apply the post process on
  15196. */
  15197. height: number;
  15198. /**
  15199. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15200. * @hidden
  15201. */
  15202. _outputTexture: Nullable<InternalTexture>;
  15203. /**
  15204. * Sampling mode used by the shader
  15205. * See https://doc.babylonjs.com/classes/3.1/texture
  15206. */
  15207. renderTargetSamplingMode: number;
  15208. /**
  15209. * Clear color to use when screen clearing
  15210. */
  15211. clearColor: Color4;
  15212. /**
  15213. * If the buffer needs to be cleared before applying the post process. (default: true)
  15214. * Should be set to false if shader will overwrite all previous pixels.
  15215. */
  15216. autoClear: boolean;
  15217. /**
  15218. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15219. */
  15220. alphaMode: number;
  15221. /**
  15222. * Sets the setAlphaBlendConstants of the babylon engine
  15223. */
  15224. alphaConstants: Color4;
  15225. /**
  15226. * Animations to be used for the post processing
  15227. */
  15228. animations: Animation[];
  15229. /**
  15230. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15231. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15232. */
  15233. enablePixelPerfectMode: boolean;
  15234. /**
  15235. * Force the postprocess to be applied without taking in account viewport
  15236. */
  15237. forceFullscreenViewport: boolean;
  15238. /**
  15239. * List of inspectable custom properties (used by the Inspector)
  15240. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15241. */
  15242. inspectableCustomProperties: IInspectable[];
  15243. /**
  15244. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15245. *
  15246. * | Value | Type | Description |
  15247. * | ----- | ----------------------------------- | ----------- |
  15248. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15249. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15250. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15251. *
  15252. */
  15253. scaleMode: number;
  15254. /**
  15255. * Force textures to be a power of two (default: false)
  15256. */
  15257. alwaysForcePOT: boolean;
  15258. private _samples;
  15259. /**
  15260. * Number of sample textures (default: 1)
  15261. */
  15262. samples: number;
  15263. /**
  15264. * Modify the scale of the post process to be the same as the viewport (default: false)
  15265. */
  15266. adaptScaleToCurrentViewport: boolean;
  15267. private _camera;
  15268. private _scene;
  15269. private _engine;
  15270. private _options;
  15271. private _reusable;
  15272. private _textureType;
  15273. /**
  15274. * Smart array of input and output textures for the post process.
  15275. * @hidden
  15276. */
  15277. _textures: SmartArray<InternalTexture>;
  15278. /**
  15279. * The index in _textures that corresponds to the output texture.
  15280. * @hidden
  15281. */
  15282. _currentRenderTextureInd: number;
  15283. private _effect;
  15284. private _samplers;
  15285. private _fragmentUrl;
  15286. private _vertexUrl;
  15287. private _parameters;
  15288. private _scaleRatio;
  15289. protected _indexParameters: any;
  15290. private _shareOutputWithPostProcess;
  15291. private _texelSize;
  15292. private _forcedOutputTexture;
  15293. /**
  15294. * Returns the fragment url or shader name used in the post process.
  15295. * @returns the fragment url or name in the shader store.
  15296. */
  15297. getEffectName(): string;
  15298. /**
  15299. * An event triggered when the postprocess is activated.
  15300. */
  15301. onActivateObservable: Observable<Camera>;
  15302. private _onActivateObserver;
  15303. /**
  15304. * A function that is added to the onActivateObservable
  15305. */
  15306. onActivate: Nullable<(camera: Camera) => void>;
  15307. /**
  15308. * An event triggered when the postprocess changes its size.
  15309. */
  15310. onSizeChangedObservable: Observable<PostProcess>;
  15311. private _onSizeChangedObserver;
  15312. /**
  15313. * A function that is added to the onSizeChangedObservable
  15314. */
  15315. onSizeChanged: (postProcess: PostProcess) => void;
  15316. /**
  15317. * An event triggered when the postprocess applies its effect.
  15318. */
  15319. onApplyObservable: Observable<Effect>;
  15320. private _onApplyObserver;
  15321. /**
  15322. * A function that is added to the onApplyObservable
  15323. */
  15324. onApply: (effect: Effect) => void;
  15325. /**
  15326. * An event triggered before rendering the postprocess
  15327. */
  15328. onBeforeRenderObservable: Observable<Effect>;
  15329. private _onBeforeRenderObserver;
  15330. /**
  15331. * A function that is added to the onBeforeRenderObservable
  15332. */
  15333. onBeforeRender: (effect: Effect) => void;
  15334. /**
  15335. * An event triggered after rendering the postprocess
  15336. */
  15337. onAfterRenderObservable: Observable<Effect>;
  15338. private _onAfterRenderObserver;
  15339. /**
  15340. * A function that is added to the onAfterRenderObservable
  15341. */
  15342. onAfterRender: (efect: Effect) => void;
  15343. /**
  15344. * 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
  15345. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15346. */
  15347. inputTexture: InternalTexture;
  15348. /**
  15349. * Gets the camera which post process is applied to.
  15350. * @returns The camera the post process is applied to.
  15351. */
  15352. getCamera(): Camera;
  15353. /**
  15354. * Gets the texel size of the postprocess.
  15355. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15356. */
  15357. readonly texelSize: Vector2;
  15358. /**
  15359. * Creates a new instance PostProcess
  15360. * @param name The name of the PostProcess.
  15361. * @param fragmentUrl The url of the fragment shader to be used.
  15362. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15363. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15364. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15365. * @param camera The camera to apply the render pass to.
  15366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15367. * @param engine The engine which the post process will be applied. (default: current engine)
  15368. * @param reusable If the post process can be reused on the same frame. (default: false)
  15369. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15370. * @param textureType Type of textures used when performing the post process. (default: 0)
  15371. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15372. * @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
  15373. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15374. */
  15375. constructor(
  15376. /** Name of the PostProcess. */
  15377. 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);
  15378. /**
  15379. * Gets a string idenfifying the name of the class
  15380. * @returns "PostProcess" string
  15381. */
  15382. getClassName(): string;
  15383. /**
  15384. * Gets the engine which this post process belongs to.
  15385. * @returns The engine the post process was enabled with.
  15386. */
  15387. getEngine(): Engine;
  15388. /**
  15389. * The effect that is created when initializing the post process.
  15390. * @returns The created effect corresponding the the postprocess.
  15391. */
  15392. getEffect(): Effect;
  15393. /**
  15394. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15395. * @param postProcess The post process to share the output with.
  15396. * @returns This post process.
  15397. */
  15398. shareOutputWith(postProcess: PostProcess): PostProcess;
  15399. /**
  15400. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15401. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15402. */
  15403. useOwnOutput(): void;
  15404. /**
  15405. * Updates the effect with the current post process compile time values and recompiles the shader.
  15406. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15407. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15408. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15409. * @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
  15410. * @param onCompiled Called when the shader has been compiled.
  15411. * @param onError Called if there is an error when compiling a shader.
  15412. */
  15413. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15414. /**
  15415. * The post process is reusable if it can be used multiple times within one frame.
  15416. * @returns If the post process is reusable
  15417. */
  15418. isReusable(): boolean;
  15419. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15420. markTextureDirty(): void;
  15421. /**
  15422. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15423. * 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.
  15424. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15425. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15426. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15427. * @returns The target texture that was bound to be written to.
  15428. */
  15429. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15430. /**
  15431. * If the post process is supported.
  15432. */
  15433. readonly isSupported: boolean;
  15434. /**
  15435. * The aspect ratio of the output texture.
  15436. */
  15437. readonly aspectRatio: number;
  15438. /**
  15439. * Get a value indicating if the post-process is ready to be used
  15440. * @returns true if the post-process is ready (shader is compiled)
  15441. */
  15442. isReady(): boolean;
  15443. /**
  15444. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15445. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15446. */
  15447. apply(): Nullable<Effect>;
  15448. private _disposeTextures;
  15449. /**
  15450. * Disposes the post process.
  15451. * @param camera The camera to dispose the post process on.
  15452. */
  15453. dispose(camera?: Camera): void;
  15454. }
  15455. }
  15456. declare module BABYLON {
  15457. /** @hidden */
  15458. export var kernelBlurVaryingDeclaration: {
  15459. name: string;
  15460. shader: string;
  15461. };
  15462. }
  15463. declare module BABYLON {
  15464. /** @hidden */
  15465. export var kernelBlurFragment: {
  15466. name: string;
  15467. shader: string;
  15468. };
  15469. }
  15470. declare module BABYLON {
  15471. /** @hidden */
  15472. export var kernelBlurFragment2: {
  15473. name: string;
  15474. shader: string;
  15475. };
  15476. }
  15477. declare module BABYLON {
  15478. /** @hidden */
  15479. export var kernelBlurPixelShader: {
  15480. name: string;
  15481. shader: string;
  15482. };
  15483. }
  15484. declare module BABYLON {
  15485. /** @hidden */
  15486. export var kernelBlurVertex: {
  15487. name: string;
  15488. shader: string;
  15489. };
  15490. }
  15491. declare module BABYLON {
  15492. /** @hidden */
  15493. export var kernelBlurVertexShader: {
  15494. name: string;
  15495. shader: string;
  15496. };
  15497. }
  15498. declare module BABYLON {
  15499. /**
  15500. * The Blur Post Process which blurs an image based on a kernel and direction.
  15501. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15502. */
  15503. export class BlurPostProcess extends PostProcess {
  15504. /** The direction in which to blur the image. */
  15505. direction: Vector2;
  15506. private blockCompilation;
  15507. protected _kernel: number;
  15508. protected _idealKernel: number;
  15509. protected _packedFloat: boolean;
  15510. private _staticDefines;
  15511. /**
  15512. * Sets the length in pixels of the blur sample region
  15513. */
  15514. /**
  15515. * Gets the length in pixels of the blur sample region
  15516. */
  15517. kernel: number;
  15518. /**
  15519. * Sets wether or not the blur needs to unpack/repack floats
  15520. */
  15521. /**
  15522. * Gets wether or not the blur is unpacking/repacking floats
  15523. */
  15524. packedFloat: boolean;
  15525. /**
  15526. * Creates a new instance BlurPostProcess
  15527. * @param name The name of the effect.
  15528. * @param direction The direction in which to blur the image.
  15529. * @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.
  15530. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15531. * @param camera The camera to apply the render pass to.
  15532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15533. * @param engine The engine which the post process will be applied. (default: current engine)
  15534. * @param reusable If the post process can be reused on the same frame. (default: false)
  15535. * @param textureType Type of textures used when performing the post process. (default: 0)
  15536. * @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)
  15537. */
  15538. constructor(name: string,
  15539. /** The direction in which to blur the image. */
  15540. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15541. /**
  15542. * Updates the effect with the current post process compile time values and recompiles the shader.
  15543. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15544. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15545. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15546. * @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
  15547. * @param onCompiled Called when the shader has been compiled.
  15548. * @param onError Called if there is an error when compiling a shader.
  15549. */
  15550. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15551. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15552. /**
  15553. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15554. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15555. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15556. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15557. * The gaps between physical kernels are compensated for in the weighting of the samples
  15558. * @param idealKernel Ideal blur kernel.
  15559. * @return Nearest best kernel.
  15560. */
  15561. protected _nearestBestKernel(idealKernel: number): number;
  15562. /**
  15563. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15564. * @param x The point on the Gaussian distribution to sample.
  15565. * @return the value of the Gaussian function at x.
  15566. */
  15567. protected _gaussianWeight(x: number): number;
  15568. /**
  15569. * Generates a string that can be used as a floating point number in GLSL.
  15570. * @param x Value to print.
  15571. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15572. * @return GLSL float string.
  15573. */
  15574. protected _glslFloat(x: number, decimalFigures?: number): string;
  15575. }
  15576. }
  15577. declare module BABYLON {
  15578. /**
  15579. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15580. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15581. * You can then easily use it as a reflectionTexture on a flat surface.
  15582. * In case the surface is not a plane, please consider relying on reflection probes.
  15583. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15584. */
  15585. export class MirrorTexture extends RenderTargetTexture {
  15586. private scene;
  15587. /**
  15588. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15589. * 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.
  15590. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15591. */
  15592. mirrorPlane: Plane;
  15593. /**
  15594. * Define the blur ratio used to blur the reflection if needed.
  15595. */
  15596. blurRatio: number;
  15597. /**
  15598. * Define the adaptive blur kernel used to blur the reflection if needed.
  15599. * This will autocompute the closest best match for the `blurKernel`
  15600. */
  15601. adaptiveBlurKernel: number;
  15602. /**
  15603. * Define the blur kernel used to blur the reflection if needed.
  15604. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15605. */
  15606. blurKernel: number;
  15607. /**
  15608. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15609. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15610. */
  15611. blurKernelX: number;
  15612. /**
  15613. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15614. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15615. */
  15616. blurKernelY: number;
  15617. private _autoComputeBlurKernel;
  15618. protected _onRatioRescale(): void;
  15619. private _updateGammaSpace;
  15620. private _imageProcessingConfigChangeObserver;
  15621. private _transformMatrix;
  15622. private _mirrorMatrix;
  15623. private _savedViewMatrix;
  15624. private _blurX;
  15625. private _blurY;
  15626. private _adaptiveBlurKernel;
  15627. private _blurKernelX;
  15628. private _blurKernelY;
  15629. private _blurRatio;
  15630. /**
  15631. * Instantiates a Mirror Texture.
  15632. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15633. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15634. * You can then easily use it as a reflectionTexture on a flat surface.
  15635. * In case the surface is not a plane, please consider relying on reflection probes.
  15636. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15637. * @param name
  15638. * @param size
  15639. * @param scene
  15640. * @param generateMipMaps
  15641. * @param type
  15642. * @param samplingMode
  15643. * @param generateDepthBuffer
  15644. */
  15645. constructor(name: string, size: number | {
  15646. width: number;
  15647. height: number;
  15648. } | {
  15649. ratio: number;
  15650. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15651. private _preparePostProcesses;
  15652. /**
  15653. * Clone the mirror texture.
  15654. * @returns the cloned texture
  15655. */
  15656. clone(): MirrorTexture;
  15657. /**
  15658. * Serialize the texture to a JSON representation you could use in Parse later on
  15659. * @returns the serialized JSON representation
  15660. */
  15661. serialize(): any;
  15662. /**
  15663. * Dispose the texture and release its associated resources.
  15664. */
  15665. dispose(): void;
  15666. }
  15667. }
  15668. declare module BABYLON {
  15669. /**
  15670. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15671. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15672. */
  15673. export class Texture extends BaseTexture {
  15674. /**
  15675. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15676. */
  15677. static SerializeBuffers: boolean;
  15678. /** @hidden */
  15679. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15680. /** @hidden */
  15681. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15682. /** @hidden */
  15683. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15684. /** nearest is mag = nearest and min = nearest and mip = linear */
  15685. static readonly NEAREST_SAMPLINGMODE: number;
  15686. /** nearest is mag = nearest and min = nearest and mip = linear */
  15687. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15688. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15689. static readonly BILINEAR_SAMPLINGMODE: number;
  15690. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15691. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15692. /** Trilinear is mag = linear and min = linear and mip = linear */
  15693. static readonly TRILINEAR_SAMPLINGMODE: number;
  15694. /** Trilinear is mag = linear and min = linear and mip = linear */
  15695. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15696. /** mag = nearest and min = nearest and mip = nearest */
  15697. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15698. /** mag = nearest and min = linear and mip = nearest */
  15699. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15700. /** mag = nearest and min = linear and mip = linear */
  15701. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15702. /** mag = nearest and min = linear and mip = none */
  15703. static readonly NEAREST_LINEAR: number;
  15704. /** mag = nearest and min = nearest and mip = none */
  15705. static readonly NEAREST_NEAREST: number;
  15706. /** mag = linear and min = nearest and mip = nearest */
  15707. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15708. /** mag = linear and min = nearest and mip = linear */
  15709. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15710. /** mag = linear and min = linear and mip = none */
  15711. static readonly LINEAR_LINEAR: number;
  15712. /** mag = linear and min = nearest and mip = none */
  15713. static readonly LINEAR_NEAREST: number;
  15714. /** Explicit coordinates mode */
  15715. static readonly EXPLICIT_MODE: number;
  15716. /** Spherical coordinates mode */
  15717. static readonly SPHERICAL_MODE: number;
  15718. /** Planar coordinates mode */
  15719. static readonly PLANAR_MODE: number;
  15720. /** Cubic coordinates mode */
  15721. static readonly CUBIC_MODE: number;
  15722. /** Projection coordinates mode */
  15723. static readonly PROJECTION_MODE: number;
  15724. /** Inverse Cubic coordinates mode */
  15725. static readonly SKYBOX_MODE: number;
  15726. /** Inverse Cubic coordinates mode */
  15727. static readonly INVCUBIC_MODE: number;
  15728. /** Equirectangular coordinates mode */
  15729. static readonly EQUIRECTANGULAR_MODE: number;
  15730. /** Equirectangular Fixed coordinates mode */
  15731. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15732. /** Equirectangular Fixed Mirrored coordinates mode */
  15733. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15734. /** Texture is not repeating outside of 0..1 UVs */
  15735. static readonly CLAMP_ADDRESSMODE: number;
  15736. /** Texture is repeating outside of 0..1 UVs */
  15737. static readonly WRAP_ADDRESSMODE: number;
  15738. /** Texture is repeating and mirrored */
  15739. static readonly MIRROR_ADDRESSMODE: number;
  15740. /**
  15741. * 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
  15742. */
  15743. static UseSerializedUrlIfAny: boolean;
  15744. /**
  15745. * Define the url of the texture.
  15746. */
  15747. url: Nullable<string>;
  15748. /**
  15749. * Define an offset on the texture to offset the u coordinates of the UVs
  15750. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15751. */
  15752. uOffset: number;
  15753. /**
  15754. * Define an offset on the texture to offset the v coordinates of the UVs
  15755. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15756. */
  15757. vOffset: number;
  15758. /**
  15759. * Define an offset on the texture to scale the u coordinates of the UVs
  15760. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15761. */
  15762. uScale: number;
  15763. /**
  15764. * Define an offset on the texture to scale the v coordinates of the UVs
  15765. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15766. */
  15767. vScale: number;
  15768. /**
  15769. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15770. * @see http://doc.babylonjs.com/how_to/more_materials
  15771. */
  15772. uAng: number;
  15773. /**
  15774. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15775. * @see http://doc.babylonjs.com/how_to/more_materials
  15776. */
  15777. vAng: number;
  15778. /**
  15779. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15780. * @see http://doc.babylonjs.com/how_to/more_materials
  15781. */
  15782. wAng: number;
  15783. /**
  15784. * Defines the center of rotation (U)
  15785. */
  15786. uRotationCenter: number;
  15787. /**
  15788. * Defines the center of rotation (V)
  15789. */
  15790. vRotationCenter: number;
  15791. /**
  15792. * Defines the center of rotation (W)
  15793. */
  15794. wRotationCenter: number;
  15795. /**
  15796. * Are mip maps generated for this texture or not.
  15797. */
  15798. readonly noMipmap: boolean;
  15799. /**
  15800. * List of inspectable custom properties (used by the Inspector)
  15801. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15802. */
  15803. inspectableCustomProperties: Nullable<IInspectable[]>;
  15804. private _noMipmap;
  15805. /** @hidden */
  15806. _invertY: boolean;
  15807. private _rowGenerationMatrix;
  15808. private _cachedTextureMatrix;
  15809. private _projectionModeMatrix;
  15810. private _t0;
  15811. private _t1;
  15812. private _t2;
  15813. private _cachedUOffset;
  15814. private _cachedVOffset;
  15815. private _cachedUScale;
  15816. private _cachedVScale;
  15817. private _cachedUAng;
  15818. private _cachedVAng;
  15819. private _cachedWAng;
  15820. private _cachedProjectionMatrixId;
  15821. private _cachedCoordinatesMode;
  15822. /** @hidden */
  15823. protected _initialSamplingMode: number;
  15824. /** @hidden */
  15825. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15826. private _deleteBuffer;
  15827. protected _format: Nullable<number>;
  15828. private _delayedOnLoad;
  15829. private _delayedOnError;
  15830. /**
  15831. * Observable triggered once the texture has been loaded.
  15832. */
  15833. onLoadObservable: Observable<Texture>;
  15834. protected _isBlocking: boolean;
  15835. /**
  15836. * Is the texture preventing material to render while loading.
  15837. * If false, a default texture will be used instead of the loading one during the preparation step.
  15838. */
  15839. isBlocking: boolean;
  15840. /**
  15841. * Get the current sampling mode associated with the texture.
  15842. */
  15843. readonly samplingMode: number;
  15844. /**
  15845. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15846. */
  15847. readonly invertY: boolean;
  15848. /**
  15849. * Instantiates a new texture.
  15850. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15851. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15852. * @param url define the url of the picture to load as a texture
  15853. * @param scene define the scene or engine the texture will belong to
  15854. * @param noMipmap define if the texture will require mip maps or not
  15855. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15856. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15857. * @param onLoad define a callback triggered when the texture has been loaded
  15858. * @param onError define a callback triggered when an error occurred during the loading session
  15859. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15860. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15861. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15862. */
  15863. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15864. /**
  15865. * Update the url (and optional buffer) of this texture if url was null during construction.
  15866. * @param url the url of the texture
  15867. * @param buffer the buffer of the texture (defaults to null)
  15868. * @param onLoad callback called when the texture is loaded (defaults to null)
  15869. */
  15870. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15871. /**
  15872. * Finish the loading sequence of a texture flagged as delayed load.
  15873. * @hidden
  15874. */
  15875. delayLoad(): void;
  15876. private _prepareRowForTextureGeneration;
  15877. /**
  15878. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15879. * @returns the transform matrix of the texture.
  15880. */
  15881. getTextureMatrix(): Matrix;
  15882. /**
  15883. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15884. * @returns The reflection texture transform
  15885. */
  15886. getReflectionTextureMatrix(): Matrix;
  15887. /**
  15888. * Clones the texture.
  15889. * @returns the cloned texture
  15890. */
  15891. clone(): Texture;
  15892. /**
  15893. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15894. * @returns The JSON representation of the texture
  15895. */
  15896. serialize(): any;
  15897. /**
  15898. * Get the current class name of the texture useful for serialization or dynamic coding.
  15899. * @returns "Texture"
  15900. */
  15901. getClassName(): string;
  15902. /**
  15903. * Dispose the texture and release its associated resources.
  15904. */
  15905. dispose(): void;
  15906. /**
  15907. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15908. * @param parsedTexture Define the JSON representation of the texture
  15909. * @param scene Define the scene the parsed texture should be instantiated in
  15910. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15911. * @returns The parsed texture if successful
  15912. */
  15913. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15914. /**
  15915. * Creates a texture from its base 64 representation.
  15916. * @param data Define the base64 payload without the data: prefix
  15917. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15918. * @param scene Define the scene the texture should belong to
  15919. * @param noMipmap Forces the texture to not create mip map information if true
  15920. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15921. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15922. * @param onLoad define a callback triggered when the texture has been loaded
  15923. * @param onError define a callback triggered when an error occurred during the loading session
  15924. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15925. * @returns the created texture
  15926. */
  15927. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15928. /**
  15929. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15930. * @param data Define the base64 payload without the data: prefix
  15931. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15932. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15933. * @param scene Define the scene the texture should belong to
  15934. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15935. * @param noMipmap Forces the texture to not create mip map information if true
  15936. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15937. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15938. * @param onLoad define a callback triggered when the texture has been loaded
  15939. * @param onError define a callback triggered when an error occurred during the loading session
  15940. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15941. * @returns the created texture
  15942. */
  15943. 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;
  15944. }
  15945. }
  15946. declare module BABYLON {
  15947. /**
  15948. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15949. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15950. */
  15951. export class PostProcessManager {
  15952. private _scene;
  15953. private _indexBuffer;
  15954. private _vertexBuffers;
  15955. /**
  15956. * Creates a new instance PostProcess
  15957. * @param scene The scene that the post process is associated with.
  15958. */
  15959. constructor(scene: Scene);
  15960. private _prepareBuffers;
  15961. private _buildIndexBuffer;
  15962. /**
  15963. * Rebuilds the vertex buffers of the manager.
  15964. * @hidden
  15965. */
  15966. _rebuild(): void;
  15967. /**
  15968. * Prepares a frame to be run through a post process.
  15969. * @param sourceTexture The input texture to the post procesess. (default: null)
  15970. * @param postProcesses An array of post processes to be run. (default: null)
  15971. * @returns True if the post processes were able to be run.
  15972. * @hidden
  15973. */
  15974. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15975. /**
  15976. * Manually render a set of post processes to a texture.
  15977. * @param postProcesses An array of post processes to be run.
  15978. * @param targetTexture The target texture to render to.
  15979. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15980. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15981. * @param lodLevel defines which lod of the texture to render to
  15982. */
  15983. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15984. /**
  15985. * Finalize the result of the output of the postprocesses.
  15986. * @param doNotPresent If true the result will not be displayed to the screen.
  15987. * @param targetTexture The target texture to render to.
  15988. * @param faceIndex The index of the face to bind the target texture to.
  15989. * @param postProcesses The array of post processes to render.
  15990. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15991. * @hidden
  15992. */
  15993. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15994. /**
  15995. * Disposes of the post process manager.
  15996. */
  15997. dispose(): void;
  15998. }
  15999. }
  16000. declare module BABYLON {
  16001. /** Interface used by value gradients (color, factor, ...) */
  16002. export interface IValueGradient {
  16003. /**
  16004. * Gets or sets the gradient value (between 0 and 1)
  16005. */
  16006. gradient: number;
  16007. }
  16008. /** Class used to store color4 gradient */
  16009. export class ColorGradient implements IValueGradient {
  16010. /**
  16011. * Gets or sets the gradient value (between 0 and 1)
  16012. */
  16013. gradient: number;
  16014. /**
  16015. * Gets or sets first associated color
  16016. */
  16017. color1: Color4;
  16018. /**
  16019. * Gets or sets second associated color
  16020. */
  16021. color2?: Color4;
  16022. /**
  16023. * Will get a color picked randomly between color1 and color2.
  16024. * If color2 is undefined then color1 will be used
  16025. * @param result defines the target Color4 to store the result in
  16026. */
  16027. getColorToRef(result: Color4): void;
  16028. }
  16029. /** Class used to store color 3 gradient */
  16030. export class Color3Gradient implements IValueGradient {
  16031. /**
  16032. * Gets or sets the gradient value (between 0 and 1)
  16033. */
  16034. gradient: number;
  16035. /**
  16036. * Gets or sets the associated color
  16037. */
  16038. color: Color3;
  16039. }
  16040. /** Class used to store factor gradient */
  16041. export class FactorGradient implements IValueGradient {
  16042. /**
  16043. * Gets or sets the gradient value (between 0 and 1)
  16044. */
  16045. gradient: number;
  16046. /**
  16047. * Gets or sets first associated factor
  16048. */
  16049. factor1: number;
  16050. /**
  16051. * Gets or sets second associated factor
  16052. */
  16053. factor2?: number;
  16054. /**
  16055. * Will get a number picked randomly between factor1 and factor2.
  16056. * If factor2 is undefined then factor1 will be used
  16057. * @returns the picked number
  16058. */
  16059. getFactor(): number;
  16060. }
  16061. /**
  16062. * Helper used to simplify some generic gradient tasks
  16063. */
  16064. export class GradientHelper {
  16065. /**
  16066. * Gets the current gradient from an array of IValueGradient
  16067. * @param ratio defines the current ratio to get
  16068. * @param gradients defines the array of IValueGradient
  16069. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16070. */
  16071. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16072. }
  16073. }
  16074. declare module BABYLON {
  16075. /**
  16076. * A class extending Texture allowing drawing on a texture
  16077. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16078. */
  16079. export class DynamicTexture extends Texture {
  16080. private _generateMipMaps;
  16081. private _canvas;
  16082. private _context;
  16083. private _engine;
  16084. /**
  16085. * Creates a DynamicTexture
  16086. * @param name defines the name of the texture
  16087. * @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
  16088. * @param scene defines the scene where you want the texture
  16089. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16090. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16091. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16092. */
  16093. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16094. /**
  16095. * Get the current class name of the texture useful for serialization or dynamic coding.
  16096. * @returns "DynamicTexture"
  16097. */
  16098. getClassName(): string;
  16099. /**
  16100. * Gets the current state of canRescale
  16101. */
  16102. readonly canRescale: boolean;
  16103. private _recreate;
  16104. /**
  16105. * Scales the texture
  16106. * @param ratio the scale factor to apply to both width and height
  16107. */
  16108. scale(ratio: number): void;
  16109. /**
  16110. * Resizes the texture
  16111. * @param width the new width
  16112. * @param height the new height
  16113. */
  16114. scaleTo(width: number, height: number): void;
  16115. /**
  16116. * Gets the context of the canvas used by the texture
  16117. * @returns the canvas context of the dynamic texture
  16118. */
  16119. getContext(): CanvasRenderingContext2D;
  16120. /**
  16121. * Clears the texture
  16122. */
  16123. clear(): void;
  16124. /**
  16125. * Updates the texture
  16126. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16127. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16128. */
  16129. update(invertY?: boolean, premulAlpha?: boolean): void;
  16130. /**
  16131. * Draws text onto the texture
  16132. * @param text defines the text to be drawn
  16133. * @param x defines the placement of the text from the left
  16134. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16135. * @param font defines the font to be used with font-style, font-size, font-name
  16136. * @param color defines the color used for the text
  16137. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16138. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16139. * @param update defines whether texture is immediately update (default is true)
  16140. */
  16141. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16142. /**
  16143. * Clones the texture
  16144. * @returns the clone of the texture.
  16145. */
  16146. clone(): DynamicTexture;
  16147. /**
  16148. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16149. * @returns a serialized dynamic texture object
  16150. */
  16151. serialize(): any;
  16152. /** @hidden */
  16153. _rebuild(): void;
  16154. }
  16155. }
  16156. declare module BABYLON {
  16157. interface AbstractScene {
  16158. /**
  16159. * The list of procedural textures added to the scene
  16160. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16161. */
  16162. proceduralTextures: Array<ProceduralTexture>;
  16163. }
  16164. /**
  16165. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16166. * in a given scene.
  16167. */
  16168. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16169. /**
  16170. * The component name helpfull to identify the component in the list of scene components.
  16171. */
  16172. readonly name: string;
  16173. /**
  16174. * The scene the component belongs to.
  16175. */
  16176. scene: Scene;
  16177. /**
  16178. * Creates a new instance of the component for the given scene
  16179. * @param scene Defines the scene to register the component in
  16180. */
  16181. constructor(scene: Scene);
  16182. /**
  16183. * Registers the component in a given scene
  16184. */
  16185. register(): void;
  16186. /**
  16187. * Rebuilds the elements related to this component in case of
  16188. * context lost for instance.
  16189. */
  16190. rebuild(): void;
  16191. /**
  16192. * Disposes the component and the associated ressources.
  16193. */
  16194. dispose(): void;
  16195. private _beforeClear;
  16196. }
  16197. }
  16198. declare module BABYLON {
  16199. interface BaseEngine {
  16200. /**
  16201. * Creates a new render target cube texture
  16202. * @param size defines the size of the texture
  16203. * @param options defines the options used to create the texture
  16204. * @returns a new render target cube texture stored in an InternalTexture
  16205. */
  16206. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16207. }
  16208. }
  16209. declare module BABYLON {
  16210. /** @hidden */
  16211. export var proceduralVertexShader: {
  16212. name: string;
  16213. shader: string;
  16214. };
  16215. }
  16216. declare module BABYLON {
  16217. /**
  16218. * 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.
  16219. * This is the base class of any Procedural texture and contains most of the shareable code.
  16220. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16221. */
  16222. export class ProceduralTexture extends Texture {
  16223. isCube: boolean;
  16224. /**
  16225. * Define if the texture is enabled or not (disabled texture will not render)
  16226. */
  16227. isEnabled: boolean;
  16228. /**
  16229. * Define if the texture must be cleared before rendering (default is true)
  16230. */
  16231. autoClear: boolean;
  16232. /**
  16233. * Callback called when the texture is generated
  16234. */
  16235. onGenerated: () => void;
  16236. /**
  16237. * Event raised when the texture is generated
  16238. */
  16239. onGeneratedObservable: Observable<ProceduralTexture>;
  16240. /** @hidden */
  16241. _generateMipMaps: boolean;
  16242. /** @hidden **/
  16243. _effect: Effect;
  16244. /** @hidden */
  16245. _textures: {
  16246. [key: string]: Texture;
  16247. };
  16248. private _size;
  16249. private _currentRefreshId;
  16250. private _refreshRate;
  16251. private _vertexBuffers;
  16252. private _indexBuffer;
  16253. private _uniforms;
  16254. private _samplers;
  16255. private _fragment;
  16256. private _floats;
  16257. private _ints;
  16258. private _floatsArrays;
  16259. private _colors3;
  16260. private _colors4;
  16261. private _vectors2;
  16262. private _vectors3;
  16263. private _matrices;
  16264. private _fallbackTexture;
  16265. private _fallbackTextureUsed;
  16266. private _engine;
  16267. private _cachedDefines;
  16268. private _contentUpdateId;
  16269. private _contentData;
  16270. /**
  16271. * Instantiates a new procedural texture.
  16272. * 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.
  16273. * This is the base class of any Procedural texture and contains most of the shareable code.
  16274. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16275. * @param name Define the name of the texture
  16276. * @param size Define the size of the texture to create
  16277. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16278. * @param scene Define the scene the texture belongs to
  16279. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16280. * @param generateMipMaps Define if the texture should creates mip maps or not
  16281. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16282. */
  16283. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16284. /**
  16285. * The effect that is created when initializing the post process.
  16286. * @returns The created effect corresponding the the postprocess.
  16287. */
  16288. getEffect(): Effect;
  16289. /**
  16290. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16291. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16292. */
  16293. getContent(): Nullable<ArrayBufferView>;
  16294. private _createIndexBuffer;
  16295. /** @hidden */
  16296. _rebuild(): void;
  16297. /**
  16298. * Resets the texture in order to recreate its associated resources.
  16299. * This can be called in case of context loss
  16300. */
  16301. reset(): void;
  16302. protected _getDefines(): string;
  16303. /**
  16304. * Is the texture ready to be used ? (rendered at least once)
  16305. * @returns true if ready, otherwise, false.
  16306. */
  16307. isReady(): boolean;
  16308. /**
  16309. * Resets the refresh counter of the texture and start bak from scratch.
  16310. * Could be useful to regenerate the texture if it is setup to render only once.
  16311. */
  16312. resetRefreshCounter(): void;
  16313. /**
  16314. * Set the fragment shader to use in order to render the texture.
  16315. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16316. */
  16317. setFragment(fragment: any): void;
  16318. /**
  16319. * Define the refresh rate of the texture or the rendering frequency.
  16320. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16321. */
  16322. refreshRate: number;
  16323. /** @hidden */
  16324. _shouldRender(): boolean;
  16325. /**
  16326. * Get the size the texture is rendering at.
  16327. * @returns the size (texture is always squared)
  16328. */
  16329. getRenderSize(): number;
  16330. /**
  16331. * Resize the texture to new value.
  16332. * @param size Define the new size the texture should have
  16333. * @param generateMipMaps Define whether the new texture should create mip maps
  16334. */
  16335. resize(size: number, generateMipMaps: boolean): void;
  16336. private _checkUniform;
  16337. /**
  16338. * Set a texture in the shader program used to render.
  16339. * @param name Define the name of the uniform samplers as defined in the shader
  16340. * @param texture Define the texture to bind to this sampler
  16341. * @return the texture itself allowing "fluent" like uniform updates
  16342. */
  16343. setTexture(name: string, texture: Texture): ProceduralTexture;
  16344. /**
  16345. * Set a float in the shader.
  16346. * @param name Define the name of the uniform as defined in the shader
  16347. * @param value Define the value to give to the uniform
  16348. * @return the texture itself allowing "fluent" like uniform updates
  16349. */
  16350. setFloat(name: string, value: number): ProceduralTexture;
  16351. /**
  16352. * Set a int in the shader.
  16353. * @param name Define the name of the uniform as defined in the shader
  16354. * @param value Define the value to give to the uniform
  16355. * @return the texture itself allowing "fluent" like uniform updates
  16356. */
  16357. setInt(name: string, value: number): ProceduralTexture;
  16358. /**
  16359. * Set an array of floats in the shader.
  16360. * @param name Define the name of the uniform as defined in the shader
  16361. * @param value Define the value to give to the uniform
  16362. * @return the texture itself allowing "fluent" like uniform updates
  16363. */
  16364. setFloats(name: string, value: number[]): ProceduralTexture;
  16365. /**
  16366. * Set a vec3 in the shader from a Color3.
  16367. * @param name Define the name of the uniform as defined in the shader
  16368. * @param value Define the value to give to the uniform
  16369. * @return the texture itself allowing "fluent" like uniform updates
  16370. */
  16371. setColor3(name: string, value: Color3): ProceduralTexture;
  16372. /**
  16373. * Set a vec4 in the shader from a Color4.
  16374. * @param name Define the name of the uniform as defined in the shader
  16375. * @param value Define the value to give to the uniform
  16376. * @return the texture itself allowing "fluent" like uniform updates
  16377. */
  16378. setColor4(name: string, value: Color4): ProceduralTexture;
  16379. /**
  16380. * Set a vec2 in the shader from a Vector2.
  16381. * @param name Define the name of the uniform as defined in the shader
  16382. * @param value Define the value to give to the uniform
  16383. * @return the texture itself allowing "fluent" like uniform updates
  16384. */
  16385. setVector2(name: string, value: Vector2): ProceduralTexture;
  16386. /**
  16387. * Set a vec3 in the shader from a Vector3.
  16388. * @param name Define the name of the uniform as defined in the shader
  16389. * @param value Define the value to give to the uniform
  16390. * @return the texture itself allowing "fluent" like uniform updates
  16391. */
  16392. setVector3(name: string, value: Vector3): ProceduralTexture;
  16393. /**
  16394. * Set a mat4 in the shader from a MAtrix.
  16395. * @param name Define the name of the uniform as defined in the shader
  16396. * @param value Define the value to give to the uniform
  16397. * @return the texture itself allowing "fluent" like uniform updates
  16398. */
  16399. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16400. /**
  16401. * Render the texture to its associated render target.
  16402. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16403. */
  16404. render(useCameraPostProcess?: boolean): void;
  16405. /**
  16406. * Clone the texture.
  16407. * @returns the cloned texture
  16408. */
  16409. clone(): ProceduralTexture;
  16410. /**
  16411. * Dispose the texture and release its asoociated resources.
  16412. */
  16413. dispose(): void;
  16414. }
  16415. }
  16416. declare module BABYLON {
  16417. /**
  16418. * This represents the base class for particle system in Babylon.
  16419. * 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.
  16420. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16421. * @example https://doc.babylonjs.com/babylon101/particles
  16422. */
  16423. export class BaseParticleSystem {
  16424. /**
  16425. * Source color is added to the destination color without alpha affecting the result
  16426. */
  16427. static BLENDMODE_ONEONE: number;
  16428. /**
  16429. * Blend current color and particle color using particle’s alpha
  16430. */
  16431. static BLENDMODE_STANDARD: number;
  16432. /**
  16433. * Add current color and particle color multiplied by particle’s alpha
  16434. */
  16435. static BLENDMODE_ADD: number;
  16436. /**
  16437. * Multiply current color with particle color
  16438. */
  16439. static BLENDMODE_MULTIPLY: number;
  16440. /**
  16441. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16442. */
  16443. static BLENDMODE_MULTIPLYADD: number;
  16444. /**
  16445. * List of animations used by the particle system.
  16446. */
  16447. animations: Animation[];
  16448. /**
  16449. * The id of the Particle system.
  16450. */
  16451. id: string;
  16452. /**
  16453. * The friendly name of the Particle system.
  16454. */
  16455. name: string;
  16456. /**
  16457. * The rendering group used by the Particle system to chose when to render.
  16458. */
  16459. renderingGroupId: number;
  16460. /**
  16461. * The emitter represents the Mesh or position we are attaching the particle system to.
  16462. */
  16463. emitter: Nullable<AbstractMesh | Vector3>;
  16464. /**
  16465. * The maximum number of particles to emit per frame
  16466. */
  16467. emitRate: number;
  16468. /**
  16469. * If you want to launch only a few particles at once, that can be done, as well.
  16470. */
  16471. manualEmitCount: number;
  16472. /**
  16473. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16474. */
  16475. updateSpeed: number;
  16476. /**
  16477. * The amount of time the particle system is running (depends of the overall update speed).
  16478. */
  16479. targetStopDuration: number;
  16480. /**
  16481. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16482. */
  16483. disposeOnStop: boolean;
  16484. /**
  16485. * Minimum power of emitting particles.
  16486. */
  16487. minEmitPower: number;
  16488. /**
  16489. * Maximum power of emitting particles.
  16490. */
  16491. maxEmitPower: number;
  16492. /**
  16493. * Minimum life time of emitting particles.
  16494. */
  16495. minLifeTime: number;
  16496. /**
  16497. * Maximum life time of emitting particles.
  16498. */
  16499. maxLifeTime: number;
  16500. /**
  16501. * Minimum Size of emitting particles.
  16502. */
  16503. minSize: number;
  16504. /**
  16505. * Maximum Size of emitting particles.
  16506. */
  16507. maxSize: number;
  16508. /**
  16509. * Minimum scale of emitting particles on X axis.
  16510. */
  16511. minScaleX: number;
  16512. /**
  16513. * Maximum scale of emitting particles on X axis.
  16514. */
  16515. maxScaleX: number;
  16516. /**
  16517. * Minimum scale of emitting particles on Y axis.
  16518. */
  16519. minScaleY: number;
  16520. /**
  16521. * Maximum scale of emitting particles on Y axis.
  16522. */
  16523. maxScaleY: number;
  16524. /**
  16525. * Gets or sets the minimal initial rotation in radians.
  16526. */
  16527. minInitialRotation: number;
  16528. /**
  16529. * Gets or sets the maximal initial rotation in radians.
  16530. */
  16531. maxInitialRotation: number;
  16532. /**
  16533. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16534. */
  16535. minAngularSpeed: number;
  16536. /**
  16537. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16538. */
  16539. maxAngularSpeed: number;
  16540. /**
  16541. * The texture used to render each particle. (this can be a spritesheet)
  16542. */
  16543. particleTexture: Nullable<Texture>;
  16544. /**
  16545. * The layer mask we are rendering the particles through.
  16546. */
  16547. layerMask: number;
  16548. /**
  16549. * This can help using your own shader to render the particle system.
  16550. * The according effect will be created
  16551. */
  16552. customShader: any;
  16553. /**
  16554. * By default particle system starts as soon as they are created. This prevents the
  16555. * automatic start to happen and let you decide when to start emitting particles.
  16556. */
  16557. preventAutoStart: boolean;
  16558. private _noiseTexture;
  16559. /**
  16560. * Gets or sets a texture used to add random noise to particle positions
  16561. */
  16562. noiseTexture: Nullable<ProceduralTexture>;
  16563. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16564. noiseStrength: Vector3;
  16565. /**
  16566. * Callback triggered when the particle animation is ending.
  16567. */
  16568. onAnimationEnd: Nullable<() => void>;
  16569. /**
  16570. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16571. */
  16572. blendMode: number;
  16573. /**
  16574. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16575. * to override the particles.
  16576. */
  16577. forceDepthWrite: boolean;
  16578. /** 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 */
  16579. preWarmCycles: number;
  16580. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16581. preWarmStepOffset: number;
  16582. /**
  16583. * 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)
  16584. */
  16585. spriteCellChangeSpeed: number;
  16586. /**
  16587. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16588. */
  16589. startSpriteCellID: number;
  16590. /**
  16591. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16592. */
  16593. endSpriteCellID: number;
  16594. /**
  16595. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16596. */
  16597. spriteCellWidth: number;
  16598. /**
  16599. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16600. */
  16601. spriteCellHeight: number;
  16602. /**
  16603. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16604. */
  16605. spriteRandomStartCell: boolean;
  16606. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16607. translationPivot: Vector2;
  16608. /** @hidden */
  16609. protected _isAnimationSheetEnabled: boolean;
  16610. /**
  16611. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16612. */
  16613. beginAnimationOnStart: boolean;
  16614. /**
  16615. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16616. */
  16617. beginAnimationFrom: number;
  16618. /**
  16619. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16620. */
  16621. beginAnimationTo: number;
  16622. /**
  16623. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16624. */
  16625. beginAnimationLoop: boolean;
  16626. /**
  16627. * Gets or sets a world offset applied to all particles
  16628. */
  16629. worldOffset: Vector3;
  16630. /**
  16631. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16632. */
  16633. isAnimationSheetEnabled: boolean;
  16634. /**
  16635. * Get hosting scene
  16636. * @returns the scene
  16637. */
  16638. getScene(): Scene;
  16639. /**
  16640. * You can use gravity if you want to give an orientation to your particles.
  16641. */
  16642. gravity: Vector3;
  16643. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16644. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16645. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16646. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16647. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16648. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16649. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16650. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16651. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16652. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16653. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16654. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16655. protected _hasTargetStopDurationDependantGradient(): Nullable<boolean>;
  16656. /**
  16657. * Defines the delay in milliseconds before starting the system (0 by default)
  16658. */
  16659. startDelay: number;
  16660. /**
  16661. * Gets the current list of drag gradients.
  16662. * You must use addDragGradient and removeDragGradient to udpate this list
  16663. * @returns the list of drag gradients
  16664. */
  16665. getDragGradients(): Nullable<Array<FactorGradient>>;
  16666. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16667. limitVelocityDamping: number;
  16668. /**
  16669. * Gets the current list of limit velocity gradients.
  16670. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16671. * @returns the list of limit velocity gradients
  16672. */
  16673. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16674. /**
  16675. * Gets the current list of color gradients.
  16676. * You must use addColorGradient and removeColorGradient to udpate this list
  16677. * @returns the list of color gradients
  16678. */
  16679. getColorGradients(): Nullable<Array<ColorGradient>>;
  16680. /**
  16681. * Gets the current list of size gradients.
  16682. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16683. * @returns the list of size gradients
  16684. */
  16685. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16686. /**
  16687. * Gets the current list of color remap gradients.
  16688. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16689. * @returns the list of color remap gradients
  16690. */
  16691. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16692. /**
  16693. * Gets the current list of alpha remap gradients.
  16694. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16695. * @returns the list of alpha remap gradients
  16696. */
  16697. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16698. /**
  16699. * Gets the current list of life time gradients.
  16700. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16701. * @returns the list of life time gradients
  16702. */
  16703. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16704. /**
  16705. * Gets the current list of angular speed gradients.
  16706. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16707. * @returns the list of angular speed gradients
  16708. */
  16709. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16710. /**
  16711. * Gets the current list of velocity gradients.
  16712. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16713. * @returns the list of velocity gradients
  16714. */
  16715. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16716. /**
  16717. * Gets the current list of start size gradients.
  16718. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16719. * @returns the list of start size gradients
  16720. */
  16721. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16722. /**
  16723. * Gets the current list of emit rate gradients.
  16724. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16725. * @returns the list of emit rate gradients
  16726. */
  16727. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16728. /**
  16729. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16730. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16731. */
  16732. direction1: Vector3;
  16733. /**
  16734. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16735. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16736. */
  16737. direction2: Vector3;
  16738. /**
  16739. * 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.
  16740. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16741. */
  16742. minEmitBox: Vector3;
  16743. /**
  16744. * 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.
  16745. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16746. */
  16747. maxEmitBox: Vector3;
  16748. /**
  16749. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16750. */
  16751. color1: Color4;
  16752. /**
  16753. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16754. */
  16755. color2: Color4;
  16756. /**
  16757. * Color the particle will have at the end of its lifetime
  16758. */
  16759. colorDead: Color4;
  16760. /**
  16761. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16762. */
  16763. textureMask: Color4;
  16764. /**
  16765. * The particle emitter type defines the emitter used by the particle system.
  16766. * It can be for example box, sphere, or cone...
  16767. */
  16768. particleEmitterType: IParticleEmitterType;
  16769. /** @hidden */
  16770. _isSubEmitter: boolean;
  16771. /**
  16772. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16773. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16774. */
  16775. billboardMode: number;
  16776. protected _isBillboardBased: boolean;
  16777. /**
  16778. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16779. */
  16780. isBillboardBased: boolean;
  16781. /**
  16782. * The scene the particle system belongs to.
  16783. */
  16784. protected _scene: Scene;
  16785. /**
  16786. * Local cache of defines for image processing.
  16787. */
  16788. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16789. /**
  16790. * Default configuration related to image processing available in the standard Material.
  16791. */
  16792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16793. /**
  16794. * Gets the image processing configuration used either in this material.
  16795. */
  16796. /**
  16797. * Sets the Default image processing configuration used either in the this material.
  16798. *
  16799. * If sets to null, the scene one is in use.
  16800. */
  16801. imageProcessingConfiguration: ImageProcessingConfiguration;
  16802. /**
  16803. * Attaches a new image processing configuration to the Standard Material.
  16804. * @param configuration
  16805. */
  16806. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16807. /** @hidden */
  16808. protected _reset(): void;
  16809. /** @hidden */
  16810. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16811. /**
  16812. * Instantiates a particle system.
  16813. * 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.
  16814. * @param name The name of the particle system
  16815. */
  16816. constructor(name: string);
  16817. /**
  16818. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16819. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16820. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16821. * @returns the emitter
  16822. */
  16823. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16824. /**
  16825. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16826. * @param radius The radius of the hemisphere to emit from
  16827. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16828. * @returns the emitter
  16829. */
  16830. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16831. /**
  16832. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16833. * @param radius The radius of the sphere to emit from
  16834. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16835. * @returns the emitter
  16836. */
  16837. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16838. /**
  16839. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16840. * @param radius The radius of the sphere to emit from
  16841. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16842. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16843. * @returns the emitter
  16844. */
  16845. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16846. /**
  16847. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16848. * @param radius The radius of the emission cylinder
  16849. * @param height The height of the emission cylinder
  16850. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16851. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16852. * @returns the emitter
  16853. */
  16854. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16855. /**
  16856. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16857. * @param radius The radius of the cylinder to emit from
  16858. * @param height The height of the emission cylinder
  16859. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16862. * @returns the emitter
  16863. */
  16864. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16865. /**
  16866. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16867. * @param radius The radius of the cone to emit from
  16868. * @param angle The base angle of the cone
  16869. * @returns the emitter
  16870. */
  16871. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16872. /**
  16873. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16874. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16875. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16876. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16877. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16878. * @returns the emitter
  16879. */
  16880. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16881. }
  16882. }
  16883. declare module BABYLON {
  16884. /**
  16885. * Type of sub emitter
  16886. */
  16887. export enum SubEmitterType {
  16888. /**
  16889. * Attached to the particle over it's lifetime
  16890. */
  16891. ATTACHED = 0,
  16892. /**
  16893. * Created when the particle dies
  16894. */
  16895. END = 1
  16896. }
  16897. /**
  16898. * Sub emitter class used to emit particles from an existing particle
  16899. */
  16900. export class SubEmitter {
  16901. /**
  16902. * the particle system to be used by the sub emitter
  16903. */
  16904. particleSystem: ParticleSystem;
  16905. /**
  16906. * Type of the submitter (Default: END)
  16907. */
  16908. type: SubEmitterType;
  16909. /**
  16910. * 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)
  16911. * Note: This only is supported when using an emitter of type Mesh
  16912. */
  16913. inheritDirection: boolean;
  16914. /**
  16915. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16916. */
  16917. inheritedVelocityAmount: number;
  16918. /**
  16919. * Creates a sub emitter
  16920. * @param particleSystem the particle system to be used by the sub emitter
  16921. */
  16922. constructor(
  16923. /**
  16924. * the particle system to be used by the sub emitter
  16925. */
  16926. particleSystem: ParticleSystem);
  16927. /**
  16928. * Clones the sub emitter
  16929. * @returns the cloned sub emitter
  16930. */
  16931. clone(): SubEmitter;
  16932. /**
  16933. * Serialize current object to a JSON object
  16934. * @returns the serialized object
  16935. */
  16936. serialize(): any;
  16937. /** @hidden */
  16938. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16939. /**
  16940. * Creates a new SubEmitter from a serialized JSON version
  16941. * @param serializationObject defines the JSON object to read from
  16942. * @param scene defines the hosting scene
  16943. * @param rootUrl defines the rootUrl for data loading
  16944. * @returns a new SubEmitter
  16945. */
  16946. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16947. /** Release associated resources */
  16948. dispose(): void;
  16949. }
  16950. }
  16951. declare module BABYLON {
  16952. /** @hidden */
  16953. export var clipPlaneFragmentDeclaration: {
  16954. name: string;
  16955. shader: string;
  16956. };
  16957. }
  16958. declare module BABYLON {
  16959. /** @hidden */
  16960. export var imageProcessingDeclaration: {
  16961. name: string;
  16962. shader: string;
  16963. };
  16964. }
  16965. declare module BABYLON {
  16966. /** @hidden */
  16967. export var imageProcessingFunctions: {
  16968. name: string;
  16969. shader: string;
  16970. };
  16971. }
  16972. declare module BABYLON {
  16973. /** @hidden */
  16974. export var clipPlaneFragment: {
  16975. name: string;
  16976. shader: string;
  16977. };
  16978. }
  16979. declare module BABYLON {
  16980. /** @hidden */
  16981. export var particlesPixelShader: {
  16982. name: string;
  16983. shader: string;
  16984. };
  16985. }
  16986. declare module BABYLON {
  16987. /** @hidden */
  16988. export var clipPlaneVertexDeclaration: {
  16989. name: string;
  16990. shader: string;
  16991. };
  16992. }
  16993. declare module BABYLON {
  16994. /** @hidden */
  16995. export var clipPlaneVertex: {
  16996. name: string;
  16997. shader: string;
  16998. };
  16999. }
  17000. declare module BABYLON {
  17001. /** @hidden */
  17002. export var particlesVertexShader: {
  17003. name: string;
  17004. shader: string;
  17005. };
  17006. }
  17007. declare module BABYLON {
  17008. /**
  17009. * This represents a particle system in Babylon.
  17010. * 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.
  17011. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17012. * @example https://doc.babylonjs.com/babylon101/particles
  17013. */
  17014. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17015. /**
  17016. * Billboard mode will only apply to Y axis
  17017. */
  17018. static readonly BILLBOARDMODE_Y: number;
  17019. /**
  17020. * Billboard mode will apply to all axes
  17021. */
  17022. static readonly BILLBOARDMODE_ALL: number;
  17023. /**
  17024. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17025. */
  17026. static readonly BILLBOARDMODE_STRETCHED: number;
  17027. /**
  17028. * This function can be defined to provide custom update for active particles.
  17029. * This function will be called instead of regular update (age, position, color, etc.).
  17030. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17031. */
  17032. updateFunction: (particles: Particle[]) => void;
  17033. private _emitterWorldMatrix;
  17034. /**
  17035. * This function can be defined to specify initial direction for every new particle.
  17036. * It by default use the emitterType defined function
  17037. */
  17038. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17039. /**
  17040. * This function can be defined to specify initial position for every new particle.
  17041. * It by default use the emitterType defined function
  17042. */
  17043. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17044. /**
  17045. * @hidden
  17046. */
  17047. _inheritedVelocityOffset: Vector3;
  17048. /**
  17049. * An event triggered when the system is disposed
  17050. */
  17051. onDisposeObservable: Observable<ParticleSystem>;
  17052. private _onDisposeObserver;
  17053. /**
  17054. * Sets a callback that will be triggered when the system is disposed
  17055. */
  17056. onDispose: () => void;
  17057. private _particles;
  17058. private _epsilon;
  17059. private _capacity;
  17060. private _stockParticles;
  17061. private _newPartsExcess;
  17062. private _vertexData;
  17063. private _vertexBuffer;
  17064. private _vertexBuffers;
  17065. private _spriteBuffer;
  17066. private _indexBuffer;
  17067. private _effect;
  17068. private _customEffect;
  17069. private _cachedDefines;
  17070. private _scaledColorStep;
  17071. private _colorDiff;
  17072. private _scaledDirection;
  17073. private _scaledGravity;
  17074. private _currentRenderId;
  17075. private _alive;
  17076. private _useInstancing;
  17077. private _started;
  17078. private _stopped;
  17079. private _actualFrame;
  17080. private _scaledUpdateSpeed;
  17081. private _vertexBufferSize;
  17082. /** @hidden */
  17083. _currentEmitRateGradient: Nullable<FactorGradient>;
  17084. /** @hidden */
  17085. _currentEmitRate1: number;
  17086. /** @hidden */
  17087. _currentEmitRate2: number;
  17088. /** @hidden */
  17089. _currentStartSizeGradient: Nullable<FactorGradient>;
  17090. /** @hidden */
  17091. _currentStartSize1: number;
  17092. /** @hidden */
  17093. _currentStartSize2: number;
  17094. private readonly _rawTextureWidth;
  17095. private _rampGradientsTexture;
  17096. private _useRampGradients;
  17097. /** Gets or sets a boolean indicating that ramp gradients must be used
  17098. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17099. */
  17100. useRampGradients: boolean;
  17101. /**
  17102. * 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.
  17103. * 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: [])
  17104. */
  17105. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17106. private _subEmitters;
  17107. /**
  17108. * @hidden
  17109. * If the particle systems emitter should be disposed when the particle system is disposed
  17110. */
  17111. _disposeEmitterOnDispose: boolean;
  17112. /**
  17113. * The current active Sub-systems, this property is used by the root particle system only.
  17114. */
  17115. activeSubSystems: Array<ParticleSystem>;
  17116. private _rootParticleSystem;
  17117. /**
  17118. * Gets the current list of active particles
  17119. */
  17120. readonly particles: Particle[];
  17121. /**
  17122. * Returns the string "ParticleSystem"
  17123. * @returns a string containing the class name
  17124. */
  17125. getClassName(): string;
  17126. /**
  17127. * Instantiates a particle system.
  17128. * 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.
  17129. * @param name The name of the particle system
  17130. * @param capacity The max number of particles alive at the same time
  17131. * @param scene The scene the particle system belongs to
  17132. * @param customEffect a custom effect used to change the way particles are rendered by default
  17133. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17134. * @param epsilon Offset used to render the particles
  17135. */
  17136. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17137. private _addFactorGradient;
  17138. private _removeFactorGradient;
  17139. /**
  17140. * Adds a new life time gradient
  17141. * @param gradient defines the gradient to use (between 0 and 1)
  17142. * @param factor defines the life time factor to affect to the specified gradient
  17143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17144. * @returns the current particle system
  17145. */
  17146. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17147. /**
  17148. * Remove a specific life time gradient
  17149. * @param gradient defines the gradient to remove
  17150. * @returns the current particle system
  17151. */
  17152. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17153. /**
  17154. * Adds a new size gradient
  17155. * @param gradient defines the gradient to use (between 0 and 1)
  17156. * @param factor defines the size factor to affect to the specified gradient
  17157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17158. * @returns the current particle system
  17159. */
  17160. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17161. /**
  17162. * Remove a specific size gradient
  17163. * @param gradient defines the gradient to remove
  17164. * @returns the current particle system
  17165. */
  17166. removeSizeGradient(gradient: number): IParticleSystem;
  17167. /**
  17168. * Adds a new color remap gradient
  17169. * @param gradient defines the gradient to use (between 0 and 1)
  17170. * @param min defines the color remap minimal range
  17171. * @param max defines the color remap maximal range
  17172. * @returns the current particle system
  17173. */
  17174. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17175. /**
  17176. * Remove a specific color remap gradient
  17177. * @param gradient defines the gradient to remove
  17178. * @returns the current particle system
  17179. */
  17180. removeColorRemapGradient(gradient: number): IParticleSystem;
  17181. /**
  17182. * Adds a new alpha remap gradient
  17183. * @param gradient defines the gradient to use (between 0 and 1)
  17184. * @param min defines the alpha remap minimal range
  17185. * @param max defines the alpha remap maximal range
  17186. * @returns the current particle system
  17187. */
  17188. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17189. /**
  17190. * Remove a specific alpha remap gradient
  17191. * @param gradient defines the gradient to remove
  17192. * @returns the current particle system
  17193. */
  17194. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17195. /**
  17196. * Adds a new angular speed gradient
  17197. * @param gradient defines the gradient to use (between 0 and 1)
  17198. * @param factor defines the angular speed to affect to the specified gradient
  17199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17200. * @returns the current particle system
  17201. */
  17202. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17203. /**
  17204. * Remove a specific angular speed gradient
  17205. * @param gradient defines the gradient to remove
  17206. * @returns the current particle system
  17207. */
  17208. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17209. /**
  17210. * Adds a new velocity gradient
  17211. * @param gradient defines the gradient to use (between 0 and 1)
  17212. * @param factor defines the velocity to affect to the specified gradient
  17213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17214. * @returns the current particle system
  17215. */
  17216. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17217. /**
  17218. * Remove a specific velocity gradient
  17219. * @param gradient defines the gradient to remove
  17220. * @returns the current particle system
  17221. */
  17222. removeVelocityGradient(gradient: number): IParticleSystem;
  17223. /**
  17224. * Adds a new limit velocity gradient
  17225. * @param gradient defines the gradient to use (between 0 and 1)
  17226. * @param factor defines the limit velocity value to affect to the specified gradient
  17227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17228. * @returns the current particle system
  17229. */
  17230. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17231. /**
  17232. * Remove a specific limit velocity gradient
  17233. * @param gradient defines the gradient to remove
  17234. * @returns the current particle system
  17235. */
  17236. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17237. /**
  17238. * Adds a new drag gradient
  17239. * @param gradient defines the gradient to use (between 0 and 1)
  17240. * @param factor defines the drag value to affect to the specified gradient
  17241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17242. * @returns the current particle system
  17243. */
  17244. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17245. /**
  17246. * Remove a specific drag gradient
  17247. * @param gradient defines the gradient to remove
  17248. * @returns the current particle system
  17249. */
  17250. removeDragGradient(gradient: number): IParticleSystem;
  17251. /**
  17252. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17253. * @param gradient defines the gradient to use (between 0 and 1)
  17254. * @param factor defines the emit rate value to affect to the specified gradient
  17255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17256. * @returns the current particle system
  17257. */
  17258. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17259. /**
  17260. * Remove a specific emit rate gradient
  17261. * @param gradient defines the gradient to remove
  17262. * @returns the current particle system
  17263. */
  17264. removeEmitRateGradient(gradient: number): IParticleSystem;
  17265. /**
  17266. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17267. * @param gradient defines the gradient to use (between 0 and 1)
  17268. * @param factor defines the start size value to affect to the specified gradient
  17269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17270. * @returns the current particle system
  17271. */
  17272. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17273. /**
  17274. * Remove a specific start size gradient
  17275. * @param gradient defines the gradient to remove
  17276. * @returns the current particle system
  17277. */
  17278. removeStartSizeGradient(gradient: number): IParticleSystem;
  17279. private _createRampGradientTexture;
  17280. /**
  17281. * Gets the current list of ramp gradients.
  17282. * You must use addRampGradient and removeRampGradient to udpate this list
  17283. * @returns the list of ramp gradients
  17284. */
  17285. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17286. /**
  17287. * Adds a new ramp gradient used to remap particle colors
  17288. * @param gradient defines the gradient to use (between 0 and 1)
  17289. * @param color defines the color to affect to the specified gradient
  17290. * @returns the current particle system
  17291. */
  17292. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17293. /**
  17294. * Remove a specific ramp gradient
  17295. * @param gradient defines the gradient to remove
  17296. * @returns the current particle system
  17297. */
  17298. removeRampGradient(gradient: number): ParticleSystem;
  17299. /**
  17300. * Adds a new color gradient
  17301. * @param gradient defines the gradient to use (between 0 and 1)
  17302. * @param color1 defines the color to affect to the specified gradient
  17303. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17304. * @returns this particle system
  17305. */
  17306. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17307. /**
  17308. * Remove a specific color gradient
  17309. * @param gradient defines the gradient to remove
  17310. * @returns this particle system
  17311. */
  17312. removeColorGradient(gradient: number): IParticleSystem;
  17313. private _fetchR;
  17314. protected _reset(): void;
  17315. private _resetEffect;
  17316. private _createVertexBuffers;
  17317. private _createIndexBuffer;
  17318. /**
  17319. * Gets the maximum number of particles active at the same time.
  17320. * @returns The max number of active particles.
  17321. */
  17322. getCapacity(): number;
  17323. /**
  17324. * Gets whether there are still active particles in the system.
  17325. * @returns True if it is alive, otherwise false.
  17326. */
  17327. isAlive(): boolean;
  17328. /**
  17329. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17330. * @returns True if it has been started, otherwise false.
  17331. */
  17332. isStarted(): boolean;
  17333. private _prepareSubEmitterInternalArray;
  17334. /**
  17335. * Starts the particle system and begins to emit
  17336. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17337. */
  17338. start(delay?: number): void;
  17339. /**
  17340. * Stops the particle system.
  17341. * @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.
  17342. */
  17343. stop(stopSubEmitters?: boolean): void;
  17344. /**
  17345. * Remove all active particles
  17346. */
  17347. reset(): void;
  17348. /**
  17349. * @hidden (for internal use only)
  17350. */
  17351. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17352. /**
  17353. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17354. * Its lifetime will start back at 0.
  17355. */
  17356. recycleParticle: (particle: Particle) => void;
  17357. private _stopSubEmitters;
  17358. private _createParticle;
  17359. private _removeFromRoot;
  17360. private _emitFromParticle;
  17361. private _update;
  17362. /** @hidden */
  17363. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17364. /** @hidden */
  17365. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17366. /** @hidden */
  17367. private _getEffect;
  17368. /**
  17369. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17370. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17371. */
  17372. animate(preWarmOnly?: boolean): void;
  17373. private _appendParticleVertices;
  17374. /**
  17375. * Rebuilds the particle system.
  17376. */
  17377. rebuild(): void;
  17378. /**
  17379. * Is this system ready to be used/rendered
  17380. * @return true if the system is ready
  17381. */
  17382. isReady(): boolean;
  17383. private _render;
  17384. /**
  17385. * Renders the particle system in its current state.
  17386. * @returns the current number of particles
  17387. */
  17388. render(): number;
  17389. /**
  17390. * Disposes the particle system and free the associated resources
  17391. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17392. */
  17393. dispose(disposeTexture?: boolean): void;
  17394. /**
  17395. * Clones the particle system.
  17396. * @param name The name of the cloned object
  17397. * @param newEmitter The new emitter to use
  17398. * @returns the cloned particle system
  17399. */
  17400. clone(name: string, newEmitter: any): ParticleSystem;
  17401. /**
  17402. * Serializes the particle system to a JSON object.
  17403. * @returns the JSON object
  17404. */
  17405. serialize(): any;
  17406. /** @hidden */
  17407. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17408. /** @hidden */
  17409. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17410. /**
  17411. * Parses a JSON object to create a particle system.
  17412. * @param parsedParticleSystem The JSON object to parse
  17413. * @param scene The scene to create the particle system in
  17414. * @param rootUrl The root url to use to load external dependencies like texture
  17415. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17416. * @returns the Parsed particle system
  17417. */
  17418. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17419. }
  17420. }
  17421. declare module BABYLON {
  17422. /**
  17423. * A particle represents one of the element emitted by a particle system.
  17424. * This is mainly define by its coordinates, direction, velocity and age.
  17425. */
  17426. export class Particle {
  17427. /**
  17428. * The particle system the particle belongs to.
  17429. */
  17430. particleSystem: ParticleSystem;
  17431. private static _Count;
  17432. /**
  17433. * Unique ID of the particle
  17434. */
  17435. id: number;
  17436. /**
  17437. * The world position of the particle in the scene.
  17438. */
  17439. position: Vector3;
  17440. /**
  17441. * The world direction of the particle in the scene.
  17442. */
  17443. direction: Vector3;
  17444. /**
  17445. * The color of the particle.
  17446. */
  17447. color: Color4;
  17448. /**
  17449. * The color change of the particle per step.
  17450. */
  17451. colorStep: Color4;
  17452. /**
  17453. * Defines how long will the life of the particle be.
  17454. */
  17455. lifeTime: number;
  17456. /**
  17457. * The current age of the particle.
  17458. */
  17459. age: number;
  17460. /**
  17461. * The current size of the particle.
  17462. */
  17463. size: number;
  17464. /**
  17465. * The current scale of the particle.
  17466. */
  17467. scale: Vector2;
  17468. /**
  17469. * The current angle of the particle.
  17470. */
  17471. angle: number;
  17472. /**
  17473. * Defines how fast is the angle changing.
  17474. */
  17475. angularSpeed: number;
  17476. /**
  17477. * Defines the cell index used by the particle to be rendered from a sprite.
  17478. */
  17479. cellIndex: number;
  17480. /**
  17481. * The information required to support color remapping
  17482. */
  17483. remapData: Vector4;
  17484. /** @hidden */
  17485. _randomCellOffset?: number;
  17486. /** @hidden */
  17487. _initialDirection: Nullable<Vector3>;
  17488. /** @hidden */
  17489. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17490. /** @hidden */
  17491. _initialStartSpriteCellID: number;
  17492. /** @hidden */
  17493. _initialEndSpriteCellID: number;
  17494. /** @hidden */
  17495. _currentColorGradient: Nullable<ColorGradient>;
  17496. /** @hidden */
  17497. _currentColor1: Color4;
  17498. /** @hidden */
  17499. _currentColor2: Color4;
  17500. /** @hidden */
  17501. _currentSizeGradient: Nullable<FactorGradient>;
  17502. /** @hidden */
  17503. _currentSize1: number;
  17504. /** @hidden */
  17505. _currentSize2: number;
  17506. /** @hidden */
  17507. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17508. /** @hidden */
  17509. _currentAngularSpeed1: number;
  17510. /** @hidden */
  17511. _currentAngularSpeed2: number;
  17512. /** @hidden */
  17513. _currentVelocityGradient: Nullable<FactorGradient>;
  17514. /** @hidden */
  17515. _currentVelocity1: number;
  17516. /** @hidden */
  17517. _currentVelocity2: number;
  17518. /** @hidden */
  17519. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17520. /** @hidden */
  17521. _currentLimitVelocity1: number;
  17522. /** @hidden */
  17523. _currentLimitVelocity2: number;
  17524. /** @hidden */
  17525. _currentDragGradient: Nullable<FactorGradient>;
  17526. /** @hidden */
  17527. _currentDrag1: number;
  17528. /** @hidden */
  17529. _currentDrag2: number;
  17530. /** @hidden */
  17531. _randomNoiseCoordinates1: Vector3;
  17532. /** @hidden */
  17533. _randomNoiseCoordinates2: Vector3;
  17534. /**
  17535. * Creates a new instance Particle
  17536. * @param particleSystem the particle system the particle belongs to
  17537. */
  17538. constructor(
  17539. /**
  17540. * The particle system the particle belongs to.
  17541. */
  17542. particleSystem: ParticleSystem);
  17543. private updateCellInfoFromSystem;
  17544. /**
  17545. * Defines how the sprite cell index is updated for the particle
  17546. */
  17547. updateCellIndex(): void;
  17548. /** @hidden */
  17549. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17550. /** @hidden */
  17551. _inheritParticleInfoToSubEmitters(): void;
  17552. /** @hidden */
  17553. _reset(): void;
  17554. /**
  17555. * Copy the properties of particle to another one.
  17556. * @param other the particle to copy the information to.
  17557. */
  17558. copyTo(other: Particle): void;
  17559. }
  17560. }
  17561. declare module BABYLON {
  17562. /**
  17563. * Particle emitter represents a volume emitting particles.
  17564. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17565. */
  17566. export interface IParticleEmitterType {
  17567. /**
  17568. * Called by the particle System when the direction is computed for the created particle.
  17569. * @param worldMatrix is the world matrix of the particle system
  17570. * @param directionToUpdate is the direction vector to update with the result
  17571. * @param particle is the particle we are computed the direction for
  17572. */
  17573. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17574. /**
  17575. * Called by the particle System when the position is computed for the created particle.
  17576. * @param worldMatrix is the world matrix of the particle system
  17577. * @param positionToUpdate is the position vector to update with the result
  17578. * @param particle is the particle we are computed the position for
  17579. */
  17580. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17581. /**
  17582. * Clones the current emitter and returns a copy of it
  17583. * @returns the new emitter
  17584. */
  17585. clone(): IParticleEmitterType;
  17586. /**
  17587. * Called by the GPUParticleSystem to setup the update shader
  17588. * @param effect defines the update shader
  17589. */
  17590. applyToShader(effect: Effect): void;
  17591. /**
  17592. * Returns a string to use to update the GPU particles update shader
  17593. * @returns the effect defines string
  17594. */
  17595. getEffectDefines(): string;
  17596. /**
  17597. * Returns a string representing the class name
  17598. * @returns a string containing the class name
  17599. */
  17600. getClassName(): string;
  17601. /**
  17602. * Serializes the particle system to a JSON object.
  17603. * @returns the JSON object
  17604. */
  17605. serialize(): any;
  17606. /**
  17607. * Parse properties from a JSON object
  17608. * @param serializationObject defines the JSON object
  17609. */
  17610. parse(serializationObject: any): void;
  17611. }
  17612. }
  17613. declare module BABYLON {
  17614. /**
  17615. * Particle emitter emitting particles from the inside of a box.
  17616. * It emits the particles randomly between 2 given directions.
  17617. */
  17618. export class BoxParticleEmitter implements IParticleEmitterType {
  17619. /**
  17620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17621. */
  17622. direction1: Vector3;
  17623. /**
  17624. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17625. */
  17626. direction2: Vector3;
  17627. /**
  17628. * 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.
  17629. */
  17630. minEmitBox: Vector3;
  17631. /**
  17632. * 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.
  17633. */
  17634. maxEmitBox: Vector3;
  17635. /**
  17636. * Creates a new instance BoxParticleEmitter
  17637. */
  17638. constructor();
  17639. /**
  17640. * Called by the particle System when the direction is computed for the created particle.
  17641. * @param worldMatrix is the world matrix of the particle system
  17642. * @param directionToUpdate is the direction vector to update with the result
  17643. * @param particle is the particle we are computed the direction for
  17644. */
  17645. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17646. /**
  17647. * Called by the particle System when the position is computed for the created particle.
  17648. * @param worldMatrix is the world matrix of the particle system
  17649. * @param positionToUpdate is the position vector to update with the result
  17650. * @param particle is the particle we are computed the position for
  17651. */
  17652. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17653. /**
  17654. * Clones the current emitter and returns a copy of it
  17655. * @returns the new emitter
  17656. */
  17657. clone(): BoxParticleEmitter;
  17658. /**
  17659. * Called by the GPUParticleSystem to setup the update shader
  17660. * @param effect defines the update shader
  17661. */
  17662. applyToShader(effect: Effect): void;
  17663. /**
  17664. * Returns a string to use to update the GPU particles update shader
  17665. * @returns a string containng the defines string
  17666. */
  17667. getEffectDefines(): string;
  17668. /**
  17669. * Returns the string "BoxParticleEmitter"
  17670. * @returns a string containing the class name
  17671. */
  17672. getClassName(): string;
  17673. /**
  17674. * Serializes the particle system to a JSON object.
  17675. * @returns the JSON object
  17676. */
  17677. serialize(): any;
  17678. /**
  17679. * Parse properties from a JSON object
  17680. * @param serializationObject defines the JSON object
  17681. */
  17682. parse(serializationObject: any): void;
  17683. }
  17684. }
  17685. declare module BABYLON {
  17686. /**
  17687. * Particle emitter emitting particles from the inside of a cone.
  17688. * It emits the particles alongside the cone volume from the base to the particle.
  17689. * The emission direction might be randomized.
  17690. */
  17691. export class ConeParticleEmitter implements IParticleEmitterType {
  17692. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17693. directionRandomizer: number;
  17694. private _radius;
  17695. private _angle;
  17696. private _height;
  17697. /**
  17698. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17699. */
  17700. radiusRange: number;
  17701. /**
  17702. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17703. */
  17704. heightRange: number;
  17705. /**
  17706. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17707. */
  17708. emitFromSpawnPointOnly: boolean;
  17709. /**
  17710. * Gets or sets the radius of the emission cone
  17711. */
  17712. radius: number;
  17713. /**
  17714. * Gets or sets the angle of the emission cone
  17715. */
  17716. angle: number;
  17717. private _buildHeight;
  17718. /**
  17719. * Creates a new instance ConeParticleEmitter
  17720. * @param radius the radius of the emission cone (1 by default)
  17721. * @param angle the cone base angle (PI by default)
  17722. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17723. */
  17724. constructor(radius?: number, angle?: number,
  17725. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17726. directionRandomizer?: number);
  17727. /**
  17728. * Called by the particle System when the direction is computed for the created particle.
  17729. * @param worldMatrix is the world matrix of the particle system
  17730. * @param directionToUpdate is the direction vector to update with the result
  17731. * @param particle is the particle we are computed the direction for
  17732. */
  17733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17734. /**
  17735. * Called by the particle System when the position is computed for the created particle.
  17736. * @param worldMatrix is the world matrix of the particle system
  17737. * @param positionToUpdate is the position vector to update with the result
  17738. * @param particle is the particle we are computed the position for
  17739. */
  17740. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17741. /**
  17742. * Clones the current emitter and returns a copy of it
  17743. * @returns the new emitter
  17744. */
  17745. clone(): ConeParticleEmitter;
  17746. /**
  17747. * Called by the GPUParticleSystem to setup the update shader
  17748. * @param effect defines the update shader
  17749. */
  17750. applyToShader(effect: Effect): void;
  17751. /**
  17752. * Returns a string to use to update the GPU particles update shader
  17753. * @returns a string containng the defines string
  17754. */
  17755. getEffectDefines(): string;
  17756. /**
  17757. * Returns the string "ConeParticleEmitter"
  17758. * @returns a string containing the class name
  17759. */
  17760. getClassName(): string;
  17761. /**
  17762. * Serializes the particle system to a JSON object.
  17763. * @returns the JSON object
  17764. */
  17765. serialize(): any;
  17766. /**
  17767. * Parse properties from a JSON object
  17768. * @param serializationObject defines the JSON object
  17769. */
  17770. parse(serializationObject: any): void;
  17771. }
  17772. }
  17773. declare module BABYLON {
  17774. /**
  17775. * Particle emitter emitting particles from the inside of a cylinder.
  17776. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17777. */
  17778. export class CylinderParticleEmitter implements IParticleEmitterType {
  17779. /**
  17780. * The radius of the emission cylinder.
  17781. */
  17782. radius: number;
  17783. /**
  17784. * The height of the emission cylinder.
  17785. */
  17786. height: number;
  17787. /**
  17788. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17789. */
  17790. radiusRange: number;
  17791. /**
  17792. * How much to randomize the particle direction [0-1].
  17793. */
  17794. directionRandomizer: number;
  17795. /**
  17796. * Creates a new instance CylinderParticleEmitter
  17797. * @param radius the radius of the emission cylinder (1 by default)
  17798. * @param height the height of the emission cylinder (1 by default)
  17799. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17800. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17801. */
  17802. constructor(
  17803. /**
  17804. * The radius of the emission cylinder.
  17805. */
  17806. radius?: number,
  17807. /**
  17808. * The height of the emission cylinder.
  17809. */
  17810. height?: number,
  17811. /**
  17812. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17813. */
  17814. radiusRange?: number,
  17815. /**
  17816. * How much to randomize the particle direction [0-1].
  17817. */
  17818. directionRandomizer?: number);
  17819. /**
  17820. * Called by the particle System when the direction is computed for the created particle.
  17821. * @param worldMatrix is the world matrix of the particle system
  17822. * @param directionToUpdate is the direction vector to update with the result
  17823. * @param particle is the particle we are computed the direction for
  17824. */
  17825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17826. /**
  17827. * Called by the particle System when the position is computed for the created particle.
  17828. * @param worldMatrix is the world matrix of the particle system
  17829. * @param positionToUpdate is the position vector to update with the result
  17830. * @param particle is the particle we are computed the position for
  17831. */
  17832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17833. /**
  17834. * Clones the current emitter and returns a copy of it
  17835. * @returns the new emitter
  17836. */
  17837. clone(): CylinderParticleEmitter;
  17838. /**
  17839. * Called by the GPUParticleSystem to setup the update shader
  17840. * @param effect defines the update shader
  17841. */
  17842. applyToShader(effect: Effect): void;
  17843. /**
  17844. * Returns a string to use to update the GPU particles update shader
  17845. * @returns a string containng the defines string
  17846. */
  17847. getEffectDefines(): string;
  17848. /**
  17849. * Returns the string "CylinderParticleEmitter"
  17850. * @returns a string containing the class name
  17851. */
  17852. getClassName(): string;
  17853. /**
  17854. * Serializes the particle system to a JSON object.
  17855. * @returns the JSON object
  17856. */
  17857. serialize(): any;
  17858. /**
  17859. * Parse properties from a JSON object
  17860. * @param serializationObject defines the JSON object
  17861. */
  17862. parse(serializationObject: any): void;
  17863. }
  17864. /**
  17865. * Particle emitter emitting particles from the inside of a cylinder.
  17866. * It emits the particles randomly between two vectors.
  17867. */
  17868. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17869. /**
  17870. * The min limit of the emission direction.
  17871. */
  17872. direction1: Vector3;
  17873. /**
  17874. * The max limit of the emission direction.
  17875. */
  17876. direction2: Vector3;
  17877. /**
  17878. * Creates a new instance CylinderDirectedParticleEmitter
  17879. * @param radius the radius of the emission cylinder (1 by default)
  17880. * @param height the height of the emission cylinder (1 by default)
  17881. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17882. * @param direction1 the min limit of the emission direction (up vector by default)
  17883. * @param direction2 the max limit of the emission direction (up vector by default)
  17884. */
  17885. constructor(radius?: number, height?: number, radiusRange?: number,
  17886. /**
  17887. * The min limit of the emission direction.
  17888. */
  17889. direction1?: Vector3,
  17890. /**
  17891. * The max limit of the emission direction.
  17892. */
  17893. direction2?: Vector3);
  17894. /**
  17895. * Called by the particle System when the direction is computed for the created particle.
  17896. * @param worldMatrix is the world matrix of the particle system
  17897. * @param directionToUpdate is the direction vector to update with the result
  17898. * @param particle is the particle we are computed the direction for
  17899. */
  17900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17901. /**
  17902. * Clones the current emitter and returns a copy of it
  17903. * @returns the new emitter
  17904. */
  17905. clone(): CylinderDirectedParticleEmitter;
  17906. /**
  17907. * Called by the GPUParticleSystem to setup the update shader
  17908. * @param effect defines the update shader
  17909. */
  17910. applyToShader(effect: Effect): void;
  17911. /**
  17912. * Returns a string to use to update the GPU particles update shader
  17913. * @returns a string containng the defines string
  17914. */
  17915. getEffectDefines(): string;
  17916. /**
  17917. * Returns the string "CylinderDirectedParticleEmitter"
  17918. * @returns a string containing the class name
  17919. */
  17920. getClassName(): string;
  17921. /**
  17922. * Serializes the particle system to a JSON object.
  17923. * @returns the JSON object
  17924. */
  17925. serialize(): any;
  17926. /**
  17927. * Parse properties from a JSON object
  17928. * @param serializationObject defines the JSON object
  17929. */
  17930. parse(serializationObject: any): void;
  17931. }
  17932. }
  17933. declare module BABYLON {
  17934. /**
  17935. * Particle emitter emitting particles from the inside of a hemisphere.
  17936. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17937. */
  17938. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17939. /**
  17940. * The radius of the emission hemisphere.
  17941. */
  17942. radius: number;
  17943. /**
  17944. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17945. */
  17946. radiusRange: number;
  17947. /**
  17948. * How much to randomize the particle direction [0-1].
  17949. */
  17950. directionRandomizer: number;
  17951. /**
  17952. * Creates a new instance HemisphericParticleEmitter
  17953. * @param radius the radius of the emission hemisphere (1 by default)
  17954. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17955. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17956. */
  17957. constructor(
  17958. /**
  17959. * The radius of the emission hemisphere.
  17960. */
  17961. radius?: number,
  17962. /**
  17963. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17964. */
  17965. radiusRange?: number,
  17966. /**
  17967. * How much to randomize the particle direction [0-1].
  17968. */
  17969. directionRandomizer?: number);
  17970. /**
  17971. * Called by the particle System when the direction is computed for the created particle.
  17972. * @param worldMatrix is the world matrix of the particle system
  17973. * @param directionToUpdate is the direction vector to update with the result
  17974. * @param particle is the particle we are computed the direction for
  17975. */
  17976. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17977. /**
  17978. * Called by the particle System when the position is computed for the created particle.
  17979. * @param worldMatrix is the world matrix of the particle system
  17980. * @param positionToUpdate is the position vector to update with the result
  17981. * @param particle is the particle we are computed the position for
  17982. */
  17983. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17984. /**
  17985. * Clones the current emitter and returns a copy of it
  17986. * @returns the new emitter
  17987. */
  17988. clone(): HemisphericParticleEmitter;
  17989. /**
  17990. * Called by the GPUParticleSystem to setup the update shader
  17991. * @param effect defines the update shader
  17992. */
  17993. applyToShader(effect: Effect): void;
  17994. /**
  17995. * Returns a string to use to update the GPU particles update shader
  17996. * @returns a string containng the defines string
  17997. */
  17998. getEffectDefines(): string;
  17999. /**
  18000. * Returns the string "HemisphericParticleEmitter"
  18001. * @returns a string containing the class name
  18002. */
  18003. getClassName(): string;
  18004. /**
  18005. * Serializes the particle system to a JSON object.
  18006. * @returns the JSON object
  18007. */
  18008. serialize(): any;
  18009. /**
  18010. * Parse properties from a JSON object
  18011. * @param serializationObject defines the JSON object
  18012. */
  18013. parse(serializationObject: any): void;
  18014. }
  18015. }
  18016. declare module BABYLON {
  18017. /**
  18018. * Particle emitter emitting particles from a point.
  18019. * It emits the particles randomly between 2 given directions.
  18020. */
  18021. export class PointParticleEmitter implements IParticleEmitterType {
  18022. /**
  18023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18024. */
  18025. direction1: Vector3;
  18026. /**
  18027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18028. */
  18029. direction2: Vector3;
  18030. /**
  18031. * Creates a new instance PointParticleEmitter
  18032. */
  18033. constructor();
  18034. /**
  18035. * Called by the particle System when the direction is computed for the created particle.
  18036. * @param worldMatrix is the world matrix of the particle system
  18037. * @param directionToUpdate is the direction vector to update with the result
  18038. * @param particle is the particle we are computed the direction for
  18039. */
  18040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18041. /**
  18042. * Called by the particle System when the position is computed for the created particle.
  18043. * @param worldMatrix is the world matrix of the particle system
  18044. * @param positionToUpdate is the position vector to update with the result
  18045. * @param particle is the particle we are computed the position for
  18046. */
  18047. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18048. /**
  18049. * Clones the current emitter and returns a copy of it
  18050. * @returns the new emitter
  18051. */
  18052. clone(): PointParticleEmitter;
  18053. /**
  18054. * Called by the GPUParticleSystem to setup the update shader
  18055. * @param effect defines the update shader
  18056. */
  18057. applyToShader(effect: Effect): void;
  18058. /**
  18059. * Returns a string to use to update the GPU particles update shader
  18060. * @returns a string containng the defines string
  18061. */
  18062. getEffectDefines(): string;
  18063. /**
  18064. * Returns the string "PointParticleEmitter"
  18065. * @returns a string containing the class name
  18066. */
  18067. getClassName(): string;
  18068. /**
  18069. * Serializes the particle system to a JSON object.
  18070. * @returns the JSON object
  18071. */
  18072. serialize(): any;
  18073. /**
  18074. * Parse properties from a JSON object
  18075. * @param serializationObject defines the JSON object
  18076. */
  18077. parse(serializationObject: any): void;
  18078. }
  18079. }
  18080. declare module BABYLON {
  18081. /**
  18082. * Particle emitter emitting particles from the inside of a sphere.
  18083. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18084. */
  18085. export class SphereParticleEmitter implements IParticleEmitterType {
  18086. /**
  18087. * The radius of the emission sphere.
  18088. */
  18089. radius: number;
  18090. /**
  18091. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18092. */
  18093. radiusRange: number;
  18094. /**
  18095. * How much to randomize the particle direction [0-1].
  18096. */
  18097. directionRandomizer: number;
  18098. /**
  18099. * Creates a new instance SphereParticleEmitter
  18100. * @param radius the radius of the emission sphere (1 by default)
  18101. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18102. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18103. */
  18104. constructor(
  18105. /**
  18106. * The radius of the emission sphere.
  18107. */
  18108. radius?: number,
  18109. /**
  18110. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18111. */
  18112. radiusRange?: number,
  18113. /**
  18114. * How much to randomize the particle direction [0-1].
  18115. */
  18116. directionRandomizer?: number);
  18117. /**
  18118. * Called by the particle System when the direction is computed for the created particle.
  18119. * @param worldMatrix is the world matrix of the particle system
  18120. * @param directionToUpdate is the direction vector to update with the result
  18121. * @param particle is the particle we are computed the direction for
  18122. */
  18123. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18124. /**
  18125. * Called by the particle System when the position is computed for the created particle.
  18126. * @param worldMatrix is the world matrix of the particle system
  18127. * @param positionToUpdate is the position vector to update with the result
  18128. * @param particle is the particle we are computed the position for
  18129. */
  18130. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18131. /**
  18132. * Clones the current emitter and returns a copy of it
  18133. * @returns the new emitter
  18134. */
  18135. clone(): SphereParticleEmitter;
  18136. /**
  18137. * Called by the GPUParticleSystem to setup the update shader
  18138. * @param effect defines the update shader
  18139. */
  18140. applyToShader(effect: Effect): void;
  18141. /**
  18142. * Returns a string to use to update the GPU particles update shader
  18143. * @returns a string containng the defines string
  18144. */
  18145. getEffectDefines(): string;
  18146. /**
  18147. * Returns the string "SphereParticleEmitter"
  18148. * @returns a string containing the class name
  18149. */
  18150. getClassName(): string;
  18151. /**
  18152. * Serializes the particle system to a JSON object.
  18153. * @returns the JSON object
  18154. */
  18155. serialize(): any;
  18156. /**
  18157. * Parse properties from a JSON object
  18158. * @param serializationObject defines the JSON object
  18159. */
  18160. parse(serializationObject: any): void;
  18161. }
  18162. /**
  18163. * Particle emitter emitting particles from the inside of a sphere.
  18164. * It emits the particles randomly between two vectors.
  18165. */
  18166. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18167. /**
  18168. * The min limit of the emission direction.
  18169. */
  18170. direction1: Vector3;
  18171. /**
  18172. * The max limit of the emission direction.
  18173. */
  18174. direction2: Vector3;
  18175. /**
  18176. * Creates a new instance SphereDirectedParticleEmitter
  18177. * @param radius the radius of the emission sphere (1 by default)
  18178. * @param direction1 the min limit of the emission direction (up vector by default)
  18179. * @param direction2 the max limit of the emission direction (up vector by default)
  18180. */
  18181. constructor(radius?: number,
  18182. /**
  18183. * The min limit of the emission direction.
  18184. */
  18185. direction1?: Vector3,
  18186. /**
  18187. * The max limit of the emission direction.
  18188. */
  18189. direction2?: Vector3);
  18190. /**
  18191. * Called by the particle System when the direction is computed for the created particle.
  18192. * @param worldMatrix is the world matrix of the particle system
  18193. * @param directionToUpdate is the direction vector to update with the result
  18194. * @param particle is the particle we are computed the direction for
  18195. */
  18196. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18197. /**
  18198. * Clones the current emitter and returns a copy of it
  18199. * @returns the new emitter
  18200. */
  18201. clone(): SphereDirectedParticleEmitter;
  18202. /**
  18203. * Called by the GPUParticleSystem to setup the update shader
  18204. * @param effect defines the update shader
  18205. */
  18206. applyToShader(effect: Effect): void;
  18207. /**
  18208. * Returns a string to use to update the GPU particles update shader
  18209. * @returns a string containng the defines string
  18210. */
  18211. getEffectDefines(): string;
  18212. /**
  18213. * Returns the string "SphereDirectedParticleEmitter"
  18214. * @returns a string containing the class name
  18215. */
  18216. getClassName(): string;
  18217. /**
  18218. * Serializes the particle system to a JSON object.
  18219. * @returns the JSON object
  18220. */
  18221. serialize(): any;
  18222. /**
  18223. * Parse properties from a JSON object
  18224. * @param serializationObject defines the JSON object
  18225. */
  18226. parse(serializationObject: any): void;
  18227. }
  18228. }
  18229. declare module BABYLON {
  18230. /**
  18231. * Interface representing a particle system in Babylon.js.
  18232. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18233. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18234. */
  18235. export interface IParticleSystem {
  18236. /**
  18237. * List of animations used by the particle system.
  18238. */
  18239. animations: Animation[];
  18240. /**
  18241. * The id of the Particle system.
  18242. */
  18243. id: string;
  18244. /**
  18245. * The name of the Particle system.
  18246. */
  18247. name: string;
  18248. /**
  18249. * The emitter represents the Mesh or position we are attaching the particle system to.
  18250. */
  18251. emitter: Nullable<AbstractMesh | Vector3>;
  18252. /**
  18253. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18254. */
  18255. isBillboardBased: boolean;
  18256. /**
  18257. * The rendering group used by the Particle system to chose when to render.
  18258. */
  18259. renderingGroupId: number;
  18260. /**
  18261. * The layer mask we are rendering the particles through.
  18262. */
  18263. layerMask: number;
  18264. /**
  18265. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18266. */
  18267. updateSpeed: number;
  18268. /**
  18269. * The amount of time the particle system is running (depends of the overall update speed).
  18270. */
  18271. targetStopDuration: number;
  18272. /**
  18273. * The texture used to render each particle. (this can be a spritesheet)
  18274. */
  18275. particleTexture: Nullable<Texture>;
  18276. /**
  18277. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18278. */
  18279. blendMode: number;
  18280. /**
  18281. * Minimum life time of emitting particles.
  18282. */
  18283. minLifeTime: number;
  18284. /**
  18285. * Maximum life time of emitting particles.
  18286. */
  18287. maxLifeTime: number;
  18288. /**
  18289. * Minimum Size of emitting particles.
  18290. */
  18291. minSize: number;
  18292. /**
  18293. * Maximum Size of emitting particles.
  18294. */
  18295. maxSize: number;
  18296. /**
  18297. * Minimum scale of emitting particles on X axis.
  18298. */
  18299. minScaleX: number;
  18300. /**
  18301. * Maximum scale of emitting particles on X axis.
  18302. */
  18303. maxScaleX: number;
  18304. /**
  18305. * Minimum scale of emitting particles on Y axis.
  18306. */
  18307. minScaleY: number;
  18308. /**
  18309. * Maximum scale of emitting particles on Y axis.
  18310. */
  18311. maxScaleY: number;
  18312. /**
  18313. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18314. */
  18315. color1: Color4;
  18316. /**
  18317. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18318. */
  18319. color2: Color4;
  18320. /**
  18321. * Color the particle will have at the end of its lifetime.
  18322. */
  18323. colorDead: Color4;
  18324. /**
  18325. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18326. */
  18327. emitRate: number;
  18328. /**
  18329. * You can use gravity if you want to give an orientation to your particles.
  18330. */
  18331. gravity: Vector3;
  18332. /**
  18333. * Minimum power of emitting particles.
  18334. */
  18335. minEmitPower: number;
  18336. /**
  18337. * Maximum power of emitting particles.
  18338. */
  18339. maxEmitPower: number;
  18340. /**
  18341. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18342. */
  18343. minAngularSpeed: number;
  18344. /**
  18345. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18346. */
  18347. maxAngularSpeed: number;
  18348. /**
  18349. * Gets or sets the minimal initial rotation in radians.
  18350. */
  18351. minInitialRotation: number;
  18352. /**
  18353. * Gets or sets the maximal initial rotation in radians.
  18354. */
  18355. maxInitialRotation: number;
  18356. /**
  18357. * The particle emitter type defines the emitter used by the particle system.
  18358. * It can be for example box, sphere, or cone...
  18359. */
  18360. particleEmitterType: Nullable<IParticleEmitterType>;
  18361. /**
  18362. * Defines the delay in milliseconds before starting the system (0 by default)
  18363. */
  18364. startDelay: number;
  18365. /**
  18366. * 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
  18367. */
  18368. preWarmCycles: number;
  18369. /**
  18370. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18371. */
  18372. preWarmStepOffset: number;
  18373. /**
  18374. * 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)
  18375. */
  18376. spriteCellChangeSpeed: number;
  18377. /**
  18378. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18379. */
  18380. startSpriteCellID: number;
  18381. /**
  18382. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18383. */
  18384. endSpriteCellID: number;
  18385. /**
  18386. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18387. */
  18388. spriteCellWidth: number;
  18389. /**
  18390. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18391. */
  18392. spriteCellHeight: number;
  18393. /**
  18394. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18395. */
  18396. spriteRandomStartCell: boolean;
  18397. /**
  18398. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18399. */
  18400. isAnimationSheetEnabled: boolean;
  18401. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18402. translationPivot: Vector2;
  18403. /**
  18404. * Gets or sets a texture used to add random noise to particle positions
  18405. */
  18406. noiseTexture: Nullable<BaseTexture>;
  18407. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18408. noiseStrength: Vector3;
  18409. /**
  18410. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18411. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18412. */
  18413. billboardMode: number;
  18414. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18415. limitVelocityDamping: number;
  18416. /**
  18417. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18418. */
  18419. beginAnimationOnStart: boolean;
  18420. /**
  18421. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18422. */
  18423. beginAnimationFrom: number;
  18424. /**
  18425. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18426. */
  18427. beginAnimationTo: number;
  18428. /**
  18429. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18430. */
  18431. beginAnimationLoop: boolean;
  18432. /**
  18433. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18434. */
  18435. disposeOnStop: boolean;
  18436. /**
  18437. * Gets the maximum number of particles active at the same time.
  18438. * @returns The max number of active particles.
  18439. */
  18440. getCapacity(): number;
  18441. /**
  18442. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18443. * @returns True if it has been started, otherwise false.
  18444. */
  18445. isStarted(): boolean;
  18446. /**
  18447. * Animates the particle system for this frame.
  18448. */
  18449. animate(): void;
  18450. /**
  18451. * Renders the particle system in its current state.
  18452. * @returns the current number of particles
  18453. */
  18454. render(): number;
  18455. /**
  18456. * Dispose the particle system and frees its associated resources.
  18457. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18458. */
  18459. dispose(disposeTexture?: boolean): void;
  18460. /**
  18461. * Clones the particle system.
  18462. * @param name The name of the cloned object
  18463. * @param newEmitter The new emitter to use
  18464. * @returns the cloned particle system
  18465. */
  18466. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18467. /**
  18468. * Serializes the particle system to a JSON object.
  18469. * @returns the JSON object
  18470. */
  18471. serialize(): any;
  18472. /**
  18473. * Rebuild the particle system
  18474. */
  18475. rebuild(): void;
  18476. /**
  18477. * Starts the particle system and begins to emit
  18478. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18479. */
  18480. start(delay?: number): void;
  18481. /**
  18482. * Stops the particle system.
  18483. */
  18484. stop(): void;
  18485. /**
  18486. * Remove all active particles
  18487. */
  18488. reset(): void;
  18489. /**
  18490. * Is this system ready to be used/rendered
  18491. * @return true if the system is ready
  18492. */
  18493. isReady(): boolean;
  18494. /**
  18495. * Adds a new color gradient
  18496. * @param gradient defines the gradient to use (between 0 and 1)
  18497. * @param color1 defines the color to affect to the specified gradient
  18498. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18499. * @returns the current particle system
  18500. */
  18501. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18502. /**
  18503. * Remove a specific color gradient
  18504. * @param gradient defines the gradient to remove
  18505. * @returns the current particle system
  18506. */
  18507. removeColorGradient(gradient: number): IParticleSystem;
  18508. /**
  18509. * Adds a new size gradient
  18510. * @param gradient defines the gradient to use (between 0 and 1)
  18511. * @param factor defines the size factor to affect to the specified gradient
  18512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18513. * @returns the current particle system
  18514. */
  18515. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18516. /**
  18517. * Remove a specific size gradient
  18518. * @param gradient defines the gradient to remove
  18519. * @returns the current particle system
  18520. */
  18521. removeSizeGradient(gradient: number): IParticleSystem;
  18522. /**
  18523. * Gets the current list of color gradients.
  18524. * You must use addColorGradient and removeColorGradient to udpate this list
  18525. * @returns the list of color gradients
  18526. */
  18527. getColorGradients(): Nullable<Array<ColorGradient>>;
  18528. /**
  18529. * Gets the current list of size gradients.
  18530. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18531. * @returns the list of size gradients
  18532. */
  18533. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18534. /**
  18535. * Gets the current list of angular speed gradients.
  18536. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18537. * @returns the list of angular speed gradients
  18538. */
  18539. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18540. /**
  18541. * Adds a new angular speed gradient
  18542. * @param gradient defines the gradient to use (between 0 and 1)
  18543. * @param factor defines the angular speed to affect to the specified gradient
  18544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18545. * @returns the current particle system
  18546. */
  18547. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18548. /**
  18549. * Remove a specific angular speed gradient
  18550. * @param gradient defines the gradient to remove
  18551. * @returns the current particle system
  18552. */
  18553. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18554. /**
  18555. * Gets the current list of velocity gradients.
  18556. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18557. * @returns the list of velocity gradients
  18558. */
  18559. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18560. /**
  18561. * Adds a new velocity gradient
  18562. * @param gradient defines the gradient to use (between 0 and 1)
  18563. * @param factor defines the velocity to affect to the specified gradient
  18564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18565. * @returns the current particle system
  18566. */
  18567. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18568. /**
  18569. * Remove a specific velocity gradient
  18570. * @param gradient defines the gradient to remove
  18571. * @returns the current particle system
  18572. */
  18573. removeVelocityGradient(gradient: number): IParticleSystem;
  18574. /**
  18575. * Gets the current list of limit velocity gradients.
  18576. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18577. * @returns the list of limit velocity gradients
  18578. */
  18579. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18580. /**
  18581. * Adds a new limit velocity gradient
  18582. * @param gradient defines the gradient to use (between 0 and 1)
  18583. * @param factor defines the limit velocity to affect to the specified gradient
  18584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18585. * @returns the current particle system
  18586. */
  18587. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18588. /**
  18589. * Remove a specific limit velocity gradient
  18590. * @param gradient defines the gradient to remove
  18591. * @returns the current particle system
  18592. */
  18593. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18594. /**
  18595. * Adds a new drag gradient
  18596. * @param gradient defines the gradient to use (between 0 and 1)
  18597. * @param factor defines the drag to affect to the specified gradient
  18598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18599. * @returns the current particle system
  18600. */
  18601. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18602. /**
  18603. * Remove a specific drag gradient
  18604. * @param gradient defines the gradient to remove
  18605. * @returns the current particle system
  18606. */
  18607. removeDragGradient(gradient: number): IParticleSystem;
  18608. /**
  18609. * Gets the current list of drag gradients.
  18610. * You must use addDragGradient and removeDragGradient to udpate this list
  18611. * @returns the list of drag gradients
  18612. */
  18613. getDragGradients(): Nullable<Array<FactorGradient>>;
  18614. /**
  18615. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18616. * @param gradient defines the gradient to use (between 0 and 1)
  18617. * @param factor defines the emit rate to affect to the specified gradient
  18618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18619. * @returns the current particle system
  18620. */
  18621. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18622. /**
  18623. * Remove a specific emit rate gradient
  18624. * @param gradient defines the gradient to remove
  18625. * @returns the current particle system
  18626. */
  18627. removeEmitRateGradient(gradient: number): IParticleSystem;
  18628. /**
  18629. * Gets the current list of emit rate gradients.
  18630. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18631. * @returns the list of emit rate gradients
  18632. */
  18633. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18634. /**
  18635. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18636. * @param gradient defines the gradient to use (between 0 and 1)
  18637. * @param factor defines the start size to affect to the specified gradient
  18638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18639. * @returns the current particle system
  18640. */
  18641. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18642. /**
  18643. * Remove a specific start size gradient
  18644. * @param gradient defines the gradient to remove
  18645. * @returns the current particle system
  18646. */
  18647. removeStartSizeGradient(gradient: number): IParticleSystem;
  18648. /**
  18649. * Gets the current list of start size gradients.
  18650. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18651. * @returns the list of start size gradients
  18652. */
  18653. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18654. /**
  18655. * Adds a new life time gradient
  18656. * @param gradient defines the gradient to use (between 0 and 1)
  18657. * @param factor defines the life time factor to affect to the specified gradient
  18658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18659. * @returns the current particle system
  18660. */
  18661. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18662. /**
  18663. * Remove a specific life time gradient
  18664. * @param gradient defines the gradient to remove
  18665. * @returns the current particle system
  18666. */
  18667. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18668. /**
  18669. * Gets the current list of life time gradients.
  18670. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18671. * @returns the list of life time gradients
  18672. */
  18673. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18674. /**
  18675. * Gets the current list of color gradients.
  18676. * You must use addColorGradient and removeColorGradient to udpate this list
  18677. * @returns the list of color gradients
  18678. */
  18679. getColorGradients(): Nullable<Array<ColorGradient>>;
  18680. /**
  18681. * Adds a new ramp gradient used to remap particle colors
  18682. * @param gradient defines the gradient to use (between 0 and 1)
  18683. * @param color defines the color to affect to the specified gradient
  18684. * @returns the current particle system
  18685. */
  18686. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18687. /**
  18688. * Gets the current list of ramp gradients.
  18689. * You must use addRampGradient and removeRampGradient to udpate this list
  18690. * @returns the list of ramp gradients
  18691. */
  18692. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18693. /** Gets or sets a boolean indicating that ramp gradients must be used
  18694. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18695. */
  18696. useRampGradients: boolean;
  18697. /**
  18698. * Adds a new color remap gradient
  18699. * @param gradient defines the gradient to use (between 0 and 1)
  18700. * @param min defines the color remap minimal range
  18701. * @param max defines the color remap maximal range
  18702. * @returns the current particle system
  18703. */
  18704. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18705. /**
  18706. * Gets the current list of color remap gradients.
  18707. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18708. * @returns the list of color remap gradients
  18709. */
  18710. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18711. /**
  18712. * Adds a new alpha remap gradient
  18713. * @param gradient defines the gradient to use (between 0 and 1)
  18714. * @param min defines the alpha remap minimal range
  18715. * @param max defines the alpha remap maximal range
  18716. * @returns the current particle system
  18717. */
  18718. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18719. /**
  18720. * Gets the current list of alpha remap gradients.
  18721. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18722. * @returns the list of alpha remap gradients
  18723. */
  18724. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18725. /**
  18726. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18727. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18728. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18729. * @returns the emitter
  18730. */
  18731. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18732. /**
  18733. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18734. * @param radius The radius of the hemisphere to emit from
  18735. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18736. * @returns the emitter
  18737. */
  18738. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18739. /**
  18740. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18741. * @param radius The radius of the sphere to emit from
  18742. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18743. * @returns the emitter
  18744. */
  18745. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18746. /**
  18747. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18748. * @param radius The radius of the sphere to emit from
  18749. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18750. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18751. * @returns the emitter
  18752. */
  18753. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18754. /**
  18755. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18756. * @param radius The radius of the emission cylinder
  18757. * @param height The height of the emission cylinder
  18758. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18759. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18760. * @returns the emitter
  18761. */
  18762. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18763. /**
  18764. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18765. * @param radius The radius of the cylinder to emit from
  18766. * @param height The height of the emission cylinder
  18767. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18768. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18769. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18770. * @returns the emitter
  18771. */
  18772. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18773. /**
  18774. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18775. * @param radius The radius of the cone to emit from
  18776. * @param angle The base angle of the cone
  18777. * @returns the emitter
  18778. */
  18779. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18780. /**
  18781. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18782. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18783. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18784. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18785. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18786. * @returns the emitter
  18787. */
  18788. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18789. /**
  18790. * Get hosting scene
  18791. * @returns the scene
  18792. */
  18793. getScene(): Scene;
  18794. }
  18795. }
  18796. declare module BABYLON {
  18797. /**
  18798. * Creates an instance based on a source mesh.
  18799. */
  18800. export class InstancedMesh extends AbstractMesh {
  18801. private _sourceMesh;
  18802. private _currentLOD;
  18803. /** @hidden */
  18804. _indexInSourceMeshInstanceArray: number;
  18805. constructor(name: string, source: Mesh);
  18806. /**
  18807. * Returns the string "InstancedMesh".
  18808. */
  18809. getClassName(): string;
  18810. /** Gets the list of lights affecting that mesh */
  18811. readonly lightSources: Light[];
  18812. _resyncLightSources(): void;
  18813. _resyncLighSource(light: Light): void;
  18814. _removeLightSource(light: Light, dispose: boolean): void;
  18815. /**
  18816. * If the source mesh receives shadows
  18817. */
  18818. readonly receiveShadows: boolean;
  18819. /**
  18820. * The material of the source mesh
  18821. */
  18822. readonly material: Nullable<Material>;
  18823. /**
  18824. * Visibility of the source mesh
  18825. */
  18826. readonly visibility: number;
  18827. /**
  18828. * Skeleton of the source mesh
  18829. */
  18830. readonly skeleton: Nullable<Skeleton>;
  18831. /**
  18832. * Rendering ground id of the source mesh
  18833. */
  18834. renderingGroupId: number;
  18835. /**
  18836. * Returns the total number of vertices (integer).
  18837. */
  18838. getTotalVertices(): number;
  18839. /**
  18840. * Returns a positive integer : the total number of indices in this mesh geometry.
  18841. * @returns the numner of indices or zero if the mesh has no geometry.
  18842. */
  18843. getTotalIndices(): number;
  18844. /**
  18845. * The source mesh of the instance
  18846. */
  18847. readonly sourceMesh: Mesh;
  18848. /**
  18849. * Is this node ready to be used/rendered
  18850. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18851. * @return {boolean} is it ready
  18852. */
  18853. isReady(completeCheck?: boolean): boolean;
  18854. /**
  18855. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18856. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18857. * @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.
  18858. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18859. */
  18860. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18861. /**
  18862. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18863. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18864. * The `data` are either a numeric array either a Float32Array.
  18865. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18866. * 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).
  18867. * Note that a new underlying VertexBuffer object is created each call.
  18868. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18869. *
  18870. * Possible `kind` values :
  18871. * - VertexBuffer.PositionKind
  18872. * - VertexBuffer.UVKind
  18873. * - VertexBuffer.UV2Kind
  18874. * - VertexBuffer.UV3Kind
  18875. * - VertexBuffer.UV4Kind
  18876. * - VertexBuffer.UV5Kind
  18877. * - VertexBuffer.UV6Kind
  18878. * - VertexBuffer.ColorKind
  18879. * - VertexBuffer.MatricesIndicesKind
  18880. * - VertexBuffer.MatricesIndicesExtraKind
  18881. * - VertexBuffer.MatricesWeightsKind
  18882. * - VertexBuffer.MatricesWeightsExtraKind
  18883. *
  18884. * Returns the Mesh.
  18885. */
  18886. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18887. /**
  18888. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18889. * If the mesh has no geometry, it is simply returned as it is.
  18890. * The `data` are either a numeric array either a Float32Array.
  18891. * No new underlying VertexBuffer object is created.
  18892. * 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.
  18893. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18894. *
  18895. * Possible `kind` values :
  18896. * - VertexBuffer.PositionKind
  18897. * - VertexBuffer.UVKind
  18898. * - VertexBuffer.UV2Kind
  18899. * - VertexBuffer.UV3Kind
  18900. * - VertexBuffer.UV4Kind
  18901. * - VertexBuffer.UV5Kind
  18902. * - VertexBuffer.UV6Kind
  18903. * - VertexBuffer.ColorKind
  18904. * - VertexBuffer.MatricesIndicesKind
  18905. * - VertexBuffer.MatricesIndicesExtraKind
  18906. * - VertexBuffer.MatricesWeightsKind
  18907. * - VertexBuffer.MatricesWeightsExtraKind
  18908. *
  18909. * Returns the Mesh.
  18910. */
  18911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18912. /**
  18913. * Sets the mesh indices.
  18914. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18915. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18916. * This method creates a new index buffer each call.
  18917. * Returns the Mesh.
  18918. */
  18919. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18920. /**
  18921. * Boolean : True if the mesh owns the requested kind of data.
  18922. */
  18923. isVerticesDataPresent(kind: string): boolean;
  18924. /**
  18925. * Returns an array of indices (IndicesArray).
  18926. */
  18927. getIndices(): Nullable<IndicesArray>;
  18928. readonly _positions: Nullable<Vector3[]>;
  18929. /**
  18930. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18931. * This means the mesh underlying bounding box and sphere are recomputed.
  18932. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18933. * @returns the current mesh
  18934. */
  18935. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18936. /** @hidden */
  18937. _preActivate(): InstancedMesh;
  18938. /** @hidden */
  18939. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18940. /** @hidden */
  18941. _postActivate(): void;
  18942. getWorldMatrix(): Matrix;
  18943. readonly isAnInstance: boolean;
  18944. /**
  18945. * Returns the current associated LOD AbstractMesh.
  18946. */
  18947. getLOD(camera: Camera): AbstractMesh;
  18948. /** @hidden */
  18949. _syncSubMeshes(): InstancedMesh;
  18950. /** @hidden */
  18951. _generatePointsArray(): boolean;
  18952. /**
  18953. * Creates a new InstancedMesh from the current mesh.
  18954. * - name (string) : the cloned mesh name
  18955. * - newParent (optional Node) : the optional Node to parent the clone to.
  18956. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18957. *
  18958. * Returns the clone.
  18959. */
  18960. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18961. /**
  18962. * Disposes the InstancedMesh.
  18963. * Returns nothing.
  18964. */
  18965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18966. }
  18967. }
  18968. declare module BABYLON {
  18969. /**
  18970. * Defines the options associated with the creation of a shader material.
  18971. */
  18972. export interface IShaderMaterialOptions {
  18973. /**
  18974. * Does the material work in alpha blend mode
  18975. */
  18976. needAlphaBlending: boolean;
  18977. /**
  18978. * Does the material work in alpha test mode
  18979. */
  18980. needAlphaTesting: boolean;
  18981. /**
  18982. * The list of attribute names used in the shader
  18983. */
  18984. attributes: string[];
  18985. /**
  18986. * The list of unifrom names used in the shader
  18987. */
  18988. uniforms: string[];
  18989. /**
  18990. * The list of UBO names used in the shader
  18991. */
  18992. uniformBuffers: string[];
  18993. /**
  18994. * The list of sampler names used in the shader
  18995. */
  18996. samplers: string[];
  18997. /**
  18998. * The list of defines used in the shader
  18999. */
  19000. defines: string[];
  19001. }
  19002. /**
  19003. * 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.
  19004. *
  19005. * This returned material effects how the mesh will look based on the code in the shaders.
  19006. *
  19007. * @see http://doc.babylonjs.com/how_to/shader_material
  19008. */
  19009. export class ShaderMaterial extends Material {
  19010. private _shaderPath;
  19011. private _options;
  19012. private _textures;
  19013. private _textureArrays;
  19014. private _floats;
  19015. private _ints;
  19016. private _floatsArrays;
  19017. private _colors3;
  19018. private _colors3Arrays;
  19019. private _colors4;
  19020. private _colors4Arrays;
  19021. private _vectors2;
  19022. private _vectors3;
  19023. private _vectors4;
  19024. private _matrices;
  19025. private _matrices3x3;
  19026. private _matrices2x2;
  19027. private _vectors2Arrays;
  19028. private _vectors3Arrays;
  19029. private _vectors4Arrays;
  19030. private _cachedWorldViewMatrix;
  19031. private _cachedWorldViewProjectionMatrix;
  19032. private _renderId;
  19033. /**
  19034. * Instantiate a new shader material.
  19035. * 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.
  19036. * This returned material effects how the mesh will look based on the code in the shaders.
  19037. * @see http://doc.babylonjs.com/how_to/shader_material
  19038. * @param name Define the name of the material in the scene
  19039. * @param scene Define the scene the material belongs to
  19040. * @param shaderPath Defines the route to the shader code in one of three ways:
  19041. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19042. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19043. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19044. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19045. * @param options Define the options used to create the shader
  19046. */
  19047. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19048. /**
  19049. * Gets the options used to compile the shader.
  19050. * They can be modified to trigger a new compilation
  19051. */
  19052. readonly options: IShaderMaterialOptions;
  19053. /**
  19054. * Gets the current class name of the material e.g. "ShaderMaterial"
  19055. * Mainly use in serialization.
  19056. * @returns the class name
  19057. */
  19058. getClassName(): string;
  19059. /**
  19060. * Specifies if the material will require alpha blending
  19061. * @returns a boolean specifying if alpha blending is needed
  19062. */
  19063. needAlphaBlending(): boolean;
  19064. /**
  19065. * Specifies if this material should be rendered in alpha test mode
  19066. * @returns a boolean specifying if an alpha test is needed.
  19067. */
  19068. needAlphaTesting(): boolean;
  19069. private _checkUniform;
  19070. /**
  19071. * Set a texture in the shader.
  19072. * @param name Define the name of the uniform samplers as defined in the shader
  19073. * @param texture Define the texture to bind to this sampler
  19074. * @return the material itself allowing "fluent" like uniform updates
  19075. */
  19076. setTexture(name: string, texture: Texture): ShaderMaterial;
  19077. /**
  19078. * Set a texture array in the shader.
  19079. * @param name Define the name of the uniform sampler array as defined in the shader
  19080. * @param textures Define the list of textures to bind to this sampler
  19081. * @return the material itself allowing "fluent" like uniform updates
  19082. */
  19083. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19084. /**
  19085. * Set a float in the shader.
  19086. * @param name Define the name of the uniform as defined in the shader
  19087. * @param value Define the value to give to the uniform
  19088. * @return the material itself allowing "fluent" like uniform updates
  19089. */
  19090. setFloat(name: string, value: number): ShaderMaterial;
  19091. /**
  19092. * Set a int in the shader.
  19093. * @param name Define the name of the uniform as defined in the shader
  19094. * @param value Define the value to give to the uniform
  19095. * @return the material itself allowing "fluent" like uniform updates
  19096. */
  19097. setInt(name: string, value: number): ShaderMaterial;
  19098. /**
  19099. * Set an array of floats in the shader.
  19100. * @param name Define the name of the uniform as defined in the shader
  19101. * @param value Define the value to give to the uniform
  19102. * @return the material itself allowing "fluent" like uniform updates
  19103. */
  19104. setFloats(name: string, value: number[]): ShaderMaterial;
  19105. /**
  19106. * Set a vec3 in the shader from a Color3.
  19107. * @param name Define the name of the uniform as defined in the shader
  19108. * @param value Define the value to give to the uniform
  19109. * @return the material itself allowing "fluent" like uniform updates
  19110. */
  19111. setColor3(name: string, value: Color3): ShaderMaterial;
  19112. /**
  19113. * Set a vec3 array in the shader from a Color3 array.
  19114. * @param name Define the name of the uniform as defined in the shader
  19115. * @param value Define the value to give to the uniform
  19116. * @return the material itself allowing "fluent" like uniform updates
  19117. */
  19118. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19119. /**
  19120. * Set a vec4 in the shader from a Color4.
  19121. * @param name Define the name of the uniform as defined in the shader
  19122. * @param value Define the value to give to the uniform
  19123. * @return the material itself allowing "fluent" like uniform updates
  19124. */
  19125. setColor4(name: string, value: Color4): ShaderMaterial;
  19126. /**
  19127. * Set a vec4 array in the shader from a Color4 array.
  19128. * @param name Define the name of the uniform as defined in the shader
  19129. * @param value Define the value to give to the uniform
  19130. * @return the material itself allowing "fluent" like uniform updates
  19131. */
  19132. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19133. /**
  19134. * Set a vec2 in the shader from a Vector2.
  19135. * @param name Define the name of the uniform as defined in the shader
  19136. * @param value Define the value to give to the uniform
  19137. * @return the material itself allowing "fluent" like uniform updates
  19138. */
  19139. setVector2(name: string, value: Vector2): ShaderMaterial;
  19140. /**
  19141. * Set a vec3 in the shader from a Vector3.
  19142. * @param name Define the name of the uniform as defined in the shader
  19143. * @param value Define the value to give to the uniform
  19144. * @return the material itself allowing "fluent" like uniform updates
  19145. */
  19146. setVector3(name: string, value: Vector3): ShaderMaterial;
  19147. /**
  19148. * Set a vec4 in the shader from a Vector4.
  19149. * @param name Define the name of the uniform as defined in the shader
  19150. * @param value Define the value to give to the uniform
  19151. * @return the material itself allowing "fluent" like uniform updates
  19152. */
  19153. setVector4(name: string, value: Vector4): ShaderMaterial;
  19154. /**
  19155. * Set a mat4 in the shader from a Matrix.
  19156. * @param name Define the name of the uniform as defined in the shader
  19157. * @param value Define the value to give to the uniform
  19158. * @return the material itself allowing "fluent" like uniform updates
  19159. */
  19160. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19161. /**
  19162. * Set a mat3 in the shader from a Float32Array.
  19163. * @param name Define the name of the uniform as defined in the shader
  19164. * @param value Define the value to give to the uniform
  19165. * @return the material itself allowing "fluent" like uniform updates
  19166. */
  19167. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19168. /**
  19169. * Set a mat2 in the shader from a Float32Array.
  19170. * @param name Define the name of the uniform as defined in the shader
  19171. * @param value Define the value to give to the uniform
  19172. * @return the material itself allowing "fluent" like uniform updates
  19173. */
  19174. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19175. /**
  19176. * Set a vec2 array in the shader from a number array.
  19177. * @param name Define the name of the uniform as defined in the shader
  19178. * @param value Define the value to give to the uniform
  19179. * @return the material itself allowing "fluent" like uniform updates
  19180. */
  19181. setArray2(name: string, value: number[]): ShaderMaterial;
  19182. /**
  19183. * Set a vec3 array in the shader from a number array.
  19184. * @param name Define the name of the uniform as defined in the shader
  19185. * @param value Define the value to give to the uniform
  19186. * @return the material itself allowing "fluent" like uniform updates
  19187. */
  19188. setArray3(name: string, value: number[]): ShaderMaterial;
  19189. /**
  19190. * Set a vec4 array in the shader from a number array.
  19191. * @param name Define the name of the uniform as defined in the shader
  19192. * @param value Define the value to give to the uniform
  19193. * @return the material itself allowing "fluent" like uniform updates
  19194. */
  19195. setArray4(name: string, value: number[]): ShaderMaterial;
  19196. private _checkCache;
  19197. /**
  19198. * Specifies that the submesh is ready to be used
  19199. * @param mesh defines the mesh to check
  19200. * @param subMesh defines which submesh to check
  19201. * @param useInstances specifies that instances should be used
  19202. * @returns a boolean indicating that the submesh is ready or not
  19203. */
  19204. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19205. /**
  19206. * Checks if the material is ready to render the requested mesh
  19207. * @param mesh Define the mesh to render
  19208. * @param useInstances Define whether or not the material is used with instances
  19209. * @returns true if ready, otherwise false
  19210. */
  19211. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19212. /**
  19213. * Binds the world matrix to the material
  19214. * @param world defines the world transformation matrix
  19215. */
  19216. bindOnlyWorldMatrix(world: Matrix): void;
  19217. /**
  19218. * Binds the material to the mesh
  19219. * @param world defines the world transformation matrix
  19220. * @param mesh defines the mesh to bind the material to
  19221. */
  19222. bind(world: Matrix, mesh?: Mesh): void;
  19223. /**
  19224. * Gets the active textures from the material
  19225. * @returns an array of textures
  19226. */
  19227. getActiveTextures(): BaseTexture[];
  19228. /**
  19229. * Specifies if the material uses a texture
  19230. * @param texture defines the texture to check against the material
  19231. * @returns a boolean specifying if the material uses the texture
  19232. */
  19233. hasTexture(texture: BaseTexture): boolean;
  19234. /**
  19235. * Makes a duplicate of the material, and gives it a new name
  19236. * @param name defines the new name for the duplicated material
  19237. * @returns the cloned material
  19238. */
  19239. clone(name: string): ShaderMaterial;
  19240. /**
  19241. * Disposes the material
  19242. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19243. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19244. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19245. */
  19246. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19247. /**
  19248. * Serializes this material in a JSON representation
  19249. * @returns the serialized material object
  19250. */
  19251. serialize(): any;
  19252. /**
  19253. * Creates a shader material from parsed shader material data
  19254. * @param source defines the JSON represnetation of the material
  19255. * @param scene defines the hosting scene
  19256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19257. * @returns a new material
  19258. */
  19259. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19260. }
  19261. }
  19262. declare module BABYLON {
  19263. /** @hidden */
  19264. export var colorPixelShader: {
  19265. name: string;
  19266. shader: string;
  19267. };
  19268. }
  19269. declare module BABYLON {
  19270. /** @hidden */
  19271. export var colorVertexShader: {
  19272. name: string;
  19273. shader: string;
  19274. };
  19275. }
  19276. declare module BABYLON {
  19277. /**
  19278. * Line mesh
  19279. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19280. */
  19281. export class LinesMesh extends Mesh {
  19282. /**
  19283. * If vertex color should be applied to the mesh
  19284. */
  19285. readonly useVertexColor?: boolean | undefined;
  19286. /**
  19287. * If vertex alpha should be applied to the mesh
  19288. */
  19289. readonly useVertexAlpha?: boolean | undefined;
  19290. /**
  19291. * Color of the line (Default: White)
  19292. */
  19293. color: Color3;
  19294. /**
  19295. * Alpha of the line (Default: 1)
  19296. */
  19297. alpha: number;
  19298. /**
  19299. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19300. * This margin is expressed in world space coordinates, so its value may vary.
  19301. * Default value is 0.1
  19302. */
  19303. intersectionThreshold: number;
  19304. private _colorShader;
  19305. private color4;
  19306. /**
  19307. * Creates a new LinesMesh
  19308. * @param name defines the name
  19309. * @param scene defines the hosting scene
  19310. * @param parent defines the parent mesh if any
  19311. * @param source defines the optional source LinesMesh used to clone data from
  19312. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19313. * When false, achieved by calling a clone(), also passing False.
  19314. * This will make creation of children, recursive.
  19315. * @param useVertexColor defines if this LinesMesh supports vertex color
  19316. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19317. */
  19318. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19319. /**
  19320. * If vertex color should be applied to the mesh
  19321. */
  19322. useVertexColor?: boolean | undefined,
  19323. /**
  19324. * If vertex alpha should be applied to the mesh
  19325. */
  19326. useVertexAlpha?: boolean | undefined);
  19327. private _addClipPlaneDefine;
  19328. private _removeClipPlaneDefine;
  19329. isReady(): boolean;
  19330. /**
  19331. * Returns the string "LineMesh"
  19332. */
  19333. getClassName(): string;
  19334. /**
  19335. * @hidden
  19336. */
  19337. /**
  19338. * @hidden
  19339. */
  19340. material: Material;
  19341. /**
  19342. * @hidden
  19343. */
  19344. readonly checkCollisions: boolean;
  19345. /** @hidden */
  19346. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19347. /** @hidden */
  19348. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19349. /**
  19350. * Disposes of the line mesh
  19351. * @param doNotRecurse If children should be disposed
  19352. */
  19353. dispose(doNotRecurse?: boolean): void;
  19354. /**
  19355. * Returns a new LineMesh object cloned from the current one.
  19356. */
  19357. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19358. /**
  19359. * Creates a new InstancedLinesMesh object from the mesh model.
  19360. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19361. * @param name defines the name of the new instance
  19362. * @returns a new InstancedLinesMesh
  19363. */
  19364. createInstance(name: string): InstancedLinesMesh;
  19365. }
  19366. /**
  19367. * Creates an instance based on a source LinesMesh
  19368. */
  19369. export class InstancedLinesMesh extends InstancedMesh {
  19370. /**
  19371. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19372. * This margin is expressed in world space coordinates, so its value may vary.
  19373. * Initilized with the intersectionThreshold value of the source LinesMesh
  19374. */
  19375. intersectionThreshold: number;
  19376. constructor(name: string, source: LinesMesh);
  19377. /**
  19378. * Returns the string "InstancedLinesMesh".
  19379. */
  19380. getClassName(): string;
  19381. }
  19382. }
  19383. declare module BABYLON {
  19384. /** @hidden */
  19385. export var linePixelShader: {
  19386. name: string;
  19387. shader: string;
  19388. };
  19389. }
  19390. declare module BABYLON {
  19391. /** @hidden */
  19392. export var lineVertexShader: {
  19393. name: string;
  19394. shader: string;
  19395. };
  19396. }
  19397. declare module BABYLON {
  19398. interface AbstractMesh {
  19399. /**
  19400. * Gets the edgesRenderer associated with the mesh
  19401. */
  19402. edgesRenderer: Nullable<EdgesRenderer>;
  19403. }
  19404. interface LinesMesh {
  19405. /**
  19406. * Enables the edge rendering mode on the mesh.
  19407. * This mode makes the mesh edges visible
  19408. * @param epsilon defines the maximal distance between two angles to detect a face
  19409. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19410. * @returns the currentAbstractMesh
  19411. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19412. */
  19413. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19414. }
  19415. interface InstancedLinesMesh {
  19416. /**
  19417. * Enables the edge rendering mode on the mesh.
  19418. * This mode makes the mesh edges visible
  19419. * @param epsilon defines the maximal distance between two angles to detect a face
  19420. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19421. * @returns the current InstancedLinesMesh
  19422. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19423. */
  19424. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19425. }
  19426. /**
  19427. * Defines the minimum contract an Edges renderer should follow.
  19428. */
  19429. export interface IEdgesRenderer extends IDisposable {
  19430. /**
  19431. * Gets or sets a boolean indicating if the edgesRenderer is active
  19432. */
  19433. isEnabled: boolean;
  19434. /**
  19435. * Renders the edges of the attached mesh,
  19436. */
  19437. render(): void;
  19438. /**
  19439. * Checks wether or not the edges renderer is ready to render.
  19440. * @return true if ready, otherwise false.
  19441. */
  19442. isReady(): boolean;
  19443. }
  19444. /**
  19445. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19446. */
  19447. export class EdgesRenderer implements IEdgesRenderer {
  19448. /**
  19449. * Define the size of the edges with an orthographic camera
  19450. */
  19451. edgesWidthScalerForOrthographic: number;
  19452. /**
  19453. * Define the size of the edges with a perspective camera
  19454. */
  19455. edgesWidthScalerForPerspective: number;
  19456. protected _source: AbstractMesh;
  19457. protected _linesPositions: number[];
  19458. protected _linesNormals: number[];
  19459. protected _linesIndices: number[];
  19460. protected _epsilon: number;
  19461. protected _indicesCount: number;
  19462. protected _lineShader: ShaderMaterial;
  19463. protected _ib: DataBuffer;
  19464. protected _buffers: {
  19465. [key: string]: Nullable<VertexBuffer>;
  19466. };
  19467. protected _checkVerticesInsteadOfIndices: boolean;
  19468. private _meshRebuildObserver;
  19469. private _meshDisposeObserver;
  19470. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19471. isEnabled: boolean;
  19472. /**
  19473. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19474. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19475. * @param source Mesh used to create edges
  19476. * @param epsilon sum of angles in adjacency to check for edge
  19477. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19478. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19479. */
  19480. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19481. protected _prepareRessources(): void;
  19482. /** @hidden */
  19483. _rebuild(): void;
  19484. /**
  19485. * Releases the required resources for the edges renderer
  19486. */
  19487. dispose(): void;
  19488. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19489. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19490. /**
  19491. * Checks if the pair of p0 and p1 is en edge
  19492. * @param faceIndex
  19493. * @param edge
  19494. * @param faceNormals
  19495. * @param p0
  19496. * @param p1
  19497. * @private
  19498. */
  19499. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19500. /**
  19501. * push line into the position, normal and index buffer
  19502. * @protected
  19503. */
  19504. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19505. /**
  19506. * Generates lines edges from adjacencjes
  19507. * @private
  19508. */
  19509. _generateEdgesLines(): void;
  19510. /**
  19511. * Checks wether or not the edges renderer is ready to render.
  19512. * @return true if ready, otherwise false.
  19513. */
  19514. isReady(): boolean;
  19515. /**
  19516. * Renders the edges of the attached mesh,
  19517. */
  19518. render(): void;
  19519. }
  19520. /**
  19521. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19522. */
  19523. export class LineEdgesRenderer extends EdgesRenderer {
  19524. /**
  19525. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19526. * @param source LineMesh used to generate edges
  19527. * @param epsilon not important (specified angle for edge detection)
  19528. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19529. */
  19530. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19531. /**
  19532. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19533. */
  19534. _generateEdgesLines(): void;
  19535. }
  19536. }
  19537. declare module BABYLON {
  19538. /**
  19539. * This represents the object necessary to create a rendering group.
  19540. * This is exclusively used and created by the rendering manager.
  19541. * To modify the behavior, you use the available helpers in your scene or meshes.
  19542. * @hidden
  19543. */
  19544. export class RenderingGroup {
  19545. index: number;
  19546. private static _zeroVector;
  19547. private _scene;
  19548. private _opaqueSubMeshes;
  19549. private _transparentSubMeshes;
  19550. private _alphaTestSubMeshes;
  19551. private _depthOnlySubMeshes;
  19552. private _particleSystems;
  19553. private _spriteManagers;
  19554. private _opaqueSortCompareFn;
  19555. private _alphaTestSortCompareFn;
  19556. private _transparentSortCompareFn;
  19557. private _renderOpaque;
  19558. private _renderAlphaTest;
  19559. private _renderTransparent;
  19560. /** @hidden */
  19561. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19562. onBeforeTransparentRendering: () => void;
  19563. /**
  19564. * Set the opaque sort comparison function.
  19565. * If null the sub meshes will be render in the order they were created
  19566. */
  19567. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19568. /**
  19569. * Set the alpha test sort comparison function.
  19570. * If null the sub meshes will be render in the order they were created
  19571. */
  19572. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19573. /**
  19574. * Set the transparent sort comparison function.
  19575. * If null the sub meshes will be render in the order they were created
  19576. */
  19577. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19578. /**
  19579. * Creates a new rendering group.
  19580. * @param index The rendering group index
  19581. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19582. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19583. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19584. */
  19585. 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>);
  19586. /**
  19587. * Render all the sub meshes contained in the group.
  19588. * @param customRenderFunction Used to override the default render behaviour of the group.
  19589. * @returns true if rendered some submeshes.
  19590. */
  19591. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19592. /**
  19593. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19594. * @param subMeshes The submeshes to render
  19595. */
  19596. private renderOpaqueSorted;
  19597. /**
  19598. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19599. * @param subMeshes The submeshes to render
  19600. */
  19601. private renderAlphaTestSorted;
  19602. /**
  19603. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19604. * @param subMeshes The submeshes to render
  19605. */
  19606. private renderTransparentSorted;
  19607. /**
  19608. * Renders the submeshes in a specified order.
  19609. * @param subMeshes The submeshes to sort before render
  19610. * @param sortCompareFn The comparison function use to sort
  19611. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19612. * @param transparent Specifies to activate blending if true
  19613. */
  19614. private static renderSorted;
  19615. /**
  19616. * Renders the submeshes in the order they were dispatched (no sort applied).
  19617. * @param subMeshes The submeshes to render
  19618. */
  19619. private static renderUnsorted;
  19620. /**
  19621. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19622. * are rendered back to front if in the same alpha index.
  19623. *
  19624. * @param a The first submesh
  19625. * @param b The second submesh
  19626. * @returns The result of the comparison
  19627. */
  19628. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19629. /**
  19630. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19631. * are rendered back to front.
  19632. *
  19633. * @param a The first submesh
  19634. * @param b The second submesh
  19635. * @returns The result of the comparison
  19636. */
  19637. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19638. /**
  19639. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19640. * are rendered front to back (prevent overdraw).
  19641. *
  19642. * @param a The first submesh
  19643. * @param b The second submesh
  19644. * @returns The result of the comparison
  19645. */
  19646. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19647. /**
  19648. * Resets the different lists of submeshes to prepare a new frame.
  19649. */
  19650. prepare(): void;
  19651. dispose(): void;
  19652. /**
  19653. * Inserts the submesh in its correct queue depending on its material.
  19654. * @param subMesh The submesh to dispatch
  19655. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19656. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19657. */
  19658. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19659. dispatchSprites(spriteManager: ISpriteManager): void;
  19660. dispatchParticles(particleSystem: IParticleSystem): void;
  19661. private _renderParticles;
  19662. private _renderSprites;
  19663. }
  19664. }
  19665. declare module BABYLON {
  19666. /**
  19667. * Interface describing the different options available in the rendering manager
  19668. * regarding Auto Clear between groups.
  19669. */
  19670. export interface IRenderingManagerAutoClearSetup {
  19671. /**
  19672. * Defines whether or not autoclear is enable.
  19673. */
  19674. autoClear: boolean;
  19675. /**
  19676. * Defines whether or not to autoclear the depth buffer.
  19677. */
  19678. depth: boolean;
  19679. /**
  19680. * Defines whether or not to autoclear the stencil buffer.
  19681. */
  19682. stencil: boolean;
  19683. }
  19684. /**
  19685. * This class is used by the onRenderingGroupObservable
  19686. */
  19687. export class RenderingGroupInfo {
  19688. /**
  19689. * The Scene that being rendered
  19690. */
  19691. scene: Scene;
  19692. /**
  19693. * The camera currently used for the rendering pass
  19694. */
  19695. camera: Nullable<Camera>;
  19696. /**
  19697. * The ID of the renderingGroup being processed
  19698. */
  19699. renderingGroupId: number;
  19700. }
  19701. /**
  19702. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19703. * It is enable to manage the different groups as well as the different necessary sort functions.
  19704. * This should not be used directly aside of the few static configurations
  19705. */
  19706. export class RenderingManager {
  19707. /**
  19708. * The max id used for rendering groups (not included)
  19709. */
  19710. static MAX_RENDERINGGROUPS: number;
  19711. /**
  19712. * The min id used for rendering groups (included)
  19713. */
  19714. static MIN_RENDERINGGROUPS: number;
  19715. /**
  19716. * Used to globally prevent autoclearing scenes.
  19717. */
  19718. static AUTOCLEAR: boolean;
  19719. /**
  19720. * @hidden
  19721. */
  19722. _useSceneAutoClearSetup: boolean;
  19723. private _scene;
  19724. private _renderingGroups;
  19725. private _depthStencilBufferAlreadyCleaned;
  19726. private _autoClearDepthStencil;
  19727. private _customOpaqueSortCompareFn;
  19728. private _customAlphaTestSortCompareFn;
  19729. private _customTransparentSortCompareFn;
  19730. private _renderingGroupInfo;
  19731. /**
  19732. * Instantiates a new rendering group for a particular scene
  19733. * @param scene Defines the scene the groups belongs to
  19734. */
  19735. constructor(scene: Scene);
  19736. private _clearDepthStencilBuffer;
  19737. /**
  19738. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19739. * @hidden
  19740. */
  19741. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19742. /**
  19743. * Resets the different information of the group to prepare a new frame
  19744. * @hidden
  19745. */
  19746. reset(): void;
  19747. /**
  19748. * Dispose and release the group and its associated resources.
  19749. * @hidden
  19750. */
  19751. dispose(): void;
  19752. /**
  19753. * Clear the info related to rendering groups preventing retention points during dispose.
  19754. */
  19755. freeRenderingGroups(): void;
  19756. private _prepareRenderingGroup;
  19757. /**
  19758. * Add a sprite manager to the rendering manager in order to render it this frame.
  19759. * @param spriteManager Define the sprite manager to render
  19760. */
  19761. dispatchSprites(spriteManager: ISpriteManager): void;
  19762. /**
  19763. * Add a particle system to the rendering manager in order to render it this frame.
  19764. * @param particleSystem Define the particle system to render
  19765. */
  19766. dispatchParticles(particleSystem: IParticleSystem): void;
  19767. /**
  19768. * Add a submesh to the manager in order to render it this frame
  19769. * @param subMesh The submesh to dispatch
  19770. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19771. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19772. */
  19773. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19774. /**
  19775. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19776. * This allowed control for front to back rendering or reversly depending of the special needs.
  19777. *
  19778. * @param renderingGroupId The rendering group id corresponding to its index
  19779. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19780. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19781. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19782. */
  19783. 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;
  19784. /**
  19785. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19786. *
  19787. * @param renderingGroupId The rendering group id corresponding to its index
  19788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19789. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19790. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19791. */
  19792. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19793. /**
  19794. * Gets the current auto clear configuration for one rendering group of the rendering
  19795. * manager.
  19796. * @param index the rendering group index to get the information for
  19797. * @returns The auto clear setup for the requested rendering group
  19798. */
  19799. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19800. }
  19801. }
  19802. declare module BABYLON {
  19803. /**
  19804. * This Helps creating a texture that will be created from a camera in your scene.
  19805. * It is basically a dynamic texture that could be used to create special effects for instance.
  19806. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19807. */
  19808. export class RenderTargetTexture extends Texture {
  19809. isCube: boolean;
  19810. /**
  19811. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19812. */
  19813. static readonly REFRESHRATE_RENDER_ONCE: number;
  19814. /**
  19815. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19816. */
  19817. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19818. /**
  19819. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19820. * the central point of your effect and can save a lot of performances.
  19821. */
  19822. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19823. /**
  19824. * Use this predicate to dynamically define the list of mesh you want to render.
  19825. * If set, the renderList property will be overwritten.
  19826. */
  19827. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19828. private _renderList;
  19829. /**
  19830. * Use this list to define the list of mesh you want to render.
  19831. */
  19832. renderList: Nullable<Array<AbstractMesh>>;
  19833. private _hookArray;
  19834. /**
  19835. * Define if particles should be rendered in your texture.
  19836. */
  19837. renderParticles: boolean;
  19838. /**
  19839. * Define if sprites should be rendered in your texture.
  19840. */
  19841. renderSprites: boolean;
  19842. /**
  19843. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19844. */
  19845. coordinatesMode: number;
  19846. /**
  19847. * Define the camera used to render the texture.
  19848. */
  19849. activeCamera: Nullable<Camera>;
  19850. /**
  19851. * Override the render function of the texture with your own one.
  19852. */
  19853. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19854. /**
  19855. * Define if camera post processes should be use while rendering the texture.
  19856. */
  19857. useCameraPostProcesses: boolean;
  19858. /**
  19859. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19860. */
  19861. ignoreCameraViewport: boolean;
  19862. private _postProcessManager;
  19863. private _postProcesses;
  19864. private _resizeObserver;
  19865. /**
  19866. * An event triggered when the texture is unbind.
  19867. */
  19868. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19869. /**
  19870. * An event triggered when the texture is unbind.
  19871. */
  19872. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19873. private _onAfterUnbindObserver;
  19874. /**
  19875. * Set a after unbind callback in the texture.
  19876. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19877. */
  19878. onAfterUnbind: () => void;
  19879. /**
  19880. * An event triggered before rendering the texture
  19881. */
  19882. onBeforeRenderObservable: Observable<number>;
  19883. private _onBeforeRenderObserver;
  19884. /**
  19885. * Set a before render callback in the texture.
  19886. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19887. */
  19888. onBeforeRender: (faceIndex: number) => void;
  19889. /**
  19890. * An event triggered after rendering the texture
  19891. */
  19892. onAfterRenderObservable: Observable<number>;
  19893. private _onAfterRenderObserver;
  19894. /**
  19895. * Set a after render callback in the texture.
  19896. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19897. */
  19898. onAfterRender: (faceIndex: number) => void;
  19899. /**
  19900. * An event triggered after the texture clear
  19901. */
  19902. onClearObservable: Observable<Engine>;
  19903. private _onClearObserver;
  19904. /**
  19905. * Set a clear callback in the texture.
  19906. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19907. */
  19908. onClear: (Engine: Engine) => void;
  19909. /**
  19910. * An event triggered when the texture is resized.
  19911. */
  19912. onResizeObservable: Observable<RenderTargetTexture>;
  19913. /**
  19914. * Define the clear color of the Render Target if it should be different from the scene.
  19915. */
  19916. clearColor: Color4;
  19917. protected _size: number | {
  19918. width: number;
  19919. height: number;
  19920. };
  19921. protected _initialSizeParameter: number | {
  19922. width: number;
  19923. height: number;
  19924. } | {
  19925. ratio: number;
  19926. };
  19927. protected _sizeRatio: Nullable<number>;
  19928. /** @hidden */
  19929. _generateMipMaps: boolean;
  19930. protected _renderingManager: RenderingManager;
  19931. /** @hidden */
  19932. _waitingRenderList: string[];
  19933. protected _doNotChangeAspectRatio: boolean;
  19934. protected _currentRefreshId: number;
  19935. protected _refreshRate: number;
  19936. protected _textureMatrix: Matrix;
  19937. protected _samples: number;
  19938. protected _renderTargetOptions: RenderTargetCreationOptions;
  19939. /**
  19940. * Gets render target creation options that were used.
  19941. */
  19942. readonly renderTargetOptions: RenderTargetCreationOptions;
  19943. protected _engine: Engine;
  19944. protected _onRatioRescale(): void;
  19945. /**
  19946. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19947. * It must define where the camera used to render the texture is set
  19948. */
  19949. boundingBoxPosition: Vector3;
  19950. private _boundingBoxSize;
  19951. /**
  19952. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19953. * When defined, the cubemap will switch to local mode
  19954. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19955. * @example https://www.babylonjs-playground.com/#RNASML
  19956. */
  19957. boundingBoxSize: Vector3;
  19958. /**
  19959. * In case the RTT has been created with a depth texture, get the associated
  19960. * depth texture.
  19961. * Otherwise, return null.
  19962. */
  19963. depthStencilTexture: Nullable<InternalTexture>;
  19964. /**
  19965. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19966. * or used a shadow, depth texture...
  19967. * @param name The friendly name of the texture
  19968. * @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)
  19969. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19970. * @param generateMipMaps True if mip maps need to be generated after render.
  19971. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19972. * @param type The type of the buffer in the RTT (int, half float, float...)
  19973. * @param isCube True if a cube texture needs to be created
  19974. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19975. * @param generateDepthBuffer True to generate a depth buffer
  19976. * @param generateStencilBuffer True to generate a stencil buffer
  19977. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19978. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19979. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19980. */
  19981. constructor(name: string, size: number | {
  19982. width: number;
  19983. height: number;
  19984. } | {
  19985. ratio: number;
  19986. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19987. /**
  19988. * Creates a depth stencil texture.
  19989. * This is only available in WebGL 2 or with the depth texture extension available.
  19990. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19991. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19992. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19993. */
  19994. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19995. private _processSizeParameter;
  19996. /**
  19997. * Define the number of samples to use in case of MSAA.
  19998. * It defaults to one meaning no MSAA has been enabled.
  19999. */
  20000. samples: number;
  20001. /**
  20002. * Resets the refresh counter of the texture and start bak from scratch.
  20003. * Could be useful to regenerate the texture if it is setup to render only once.
  20004. */
  20005. resetRefreshCounter(): void;
  20006. /**
  20007. * Define the refresh rate of the texture or the rendering frequency.
  20008. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20009. */
  20010. refreshRate: number;
  20011. /**
  20012. * Adds a post process to the render target rendering passes.
  20013. * @param postProcess define the post process to add
  20014. */
  20015. addPostProcess(postProcess: PostProcess): void;
  20016. /**
  20017. * Clear all the post processes attached to the render target
  20018. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20019. */
  20020. clearPostProcesses(dispose?: boolean): void;
  20021. /**
  20022. * Remove one of the post process from the list of attached post processes to the texture
  20023. * @param postProcess define the post process to remove from the list
  20024. */
  20025. removePostProcess(postProcess: PostProcess): void;
  20026. /** @hidden */
  20027. _shouldRender(): boolean;
  20028. /**
  20029. * Gets the actual render size of the texture.
  20030. * @returns the width of the render size
  20031. */
  20032. getRenderSize(): number;
  20033. /**
  20034. * Gets the actual render width of the texture.
  20035. * @returns the width of the render size
  20036. */
  20037. getRenderWidth(): number;
  20038. /**
  20039. * Gets the actual render height of the texture.
  20040. * @returns the height of the render size
  20041. */
  20042. getRenderHeight(): number;
  20043. /**
  20044. * Get if the texture can be rescaled or not.
  20045. */
  20046. readonly canRescale: boolean;
  20047. /**
  20048. * Resize the texture using a ratio.
  20049. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20050. */
  20051. scale(ratio: number): void;
  20052. /**
  20053. * Get the texture reflection matrix used to rotate/transform the reflection.
  20054. * @returns the reflection matrix
  20055. */
  20056. getReflectionTextureMatrix(): Matrix;
  20057. /**
  20058. * Resize the texture to a new desired size.
  20059. * Be carrefull as it will recreate all the data in the new texture.
  20060. * @param size Define the new size. It can be:
  20061. * - a number for squared texture,
  20062. * - an object containing { width: number, height: number }
  20063. * - or an object containing a ratio { ratio: number }
  20064. */
  20065. resize(size: number | {
  20066. width: number;
  20067. height: number;
  20068. } | {
  20069. ratio: number;
  20070. }): void;
  20071. /**
  20072. * Renders all the objects from the render list into the texture.
  20073. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20074. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20075. */
  20076. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20077. private _bestReflectionRenderTargetDimension;
  20078. /**
  20079. * @hidden
  20080. * @param faceIndex face index to bind to if this is a cubetexture
  20081. */
  20082. _bindFrameBuffer(faceIndex?: number): void;
  20083. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20084. private renderToTarget;
  20085. /**
  20086. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20087. * This allowed control for front to back rendering or reversly depending of the special needs.
  20088. *
  20089. * @param renderingGroupId The rendering group id corresponding to its index
  20090. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20091. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20092. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20093. */
  20094. 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;
  20095. /**
  20096. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20097. *
  20098. * @param renderingGroupId The rendering group id corresponding to its index
  20099. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20100. */
  20101. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20102. /**
  20103. * Clones the texture.
  20104. * @returns the cloned texture
  20105. */
  20106. clone(): RenderTargetTexture;
  20107. /**
  20108. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20109. * @returns The JSON representation of the texture
  20110. */
  20111. serialize(): any;
  20112. /**
  20113. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20114. */
  20115. disposeFramebufferObjects(): void;
  20116. /**
  20117. * Dispose the texture and release its associated resources.
  20118. */
  20119. dispose(): void;
  20120. /** @hidden */
  20121. _rebuild(): void;
  20122. /**
  20123. * Clear the info related to rendering groups preventing retention point in material dispose.
  20124. */
  20125. freeRenderingGroups(): void;
  20126. /**
  20127. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20128. * @returns the view count
  20129. */
  20130. getViewCount(): number;
  20131. }
  20132. }
  20133. declare module BABYLON {
  20134. /**
  20135. * Base class for the main features of a material in Babylon.js
  20136. */
  20137. export class Material implements IAnimatable {
  20138. /**
  20139. * Returns the triangle fill mode
  20140. */
  20141. static readonly TriangleFillMode: number;
  20142. /**
  20143. * Returns the wireframe mode
  20144. */
  20145. static readonly WireFrameFillMode: number;
  20146. /**
  20147. * Returns the point fill mode
  20148. */
  20149. static readonly PointFillMode: number;
  20150. /**
  20151. * Returns the point list draw mode
  20152. */
  20153. static readonly PointListDrawMode: number;
  20154. /**
  20155. * Returns the line list draw mode
  20156. */
  20157. static readonly LineListDrawMode: number;
  20158. /**
  20159. * Returns the line loop draw mode
  20160. */
  20161. static readonly LineLoopDrawMode: number;
  20162. /**
  20163. * Returns the line strip draw mode
  20164. */
  20165. static readonly LineStripDrawMode: number;
  20166. /**
  20167. * Returns the triangle strip draw mode
  20168. */
  20169. static readonly TriangleStripDrawMode: number;
  20170. /**
  20171. * Returns the triangle fan draw mode
  20172. */
  20173. static readonly TriangleFanDrawMode: number;
  20174. /**
  20175. * Stores the clock-wise side orientation
  20176. */
  20177. static readonly ClockWiseSideOrientation: number;
  20178. /**
  20179. * Stores the counter clock-wise side orientation
  20180. */
  20181. static readonly CounterClockWiseSideOrientation: number;
  20182. /**
  20183. * The dirty texture flag value
  20184. */
  20185. static readonly TextureDirtyFlag: number;
  20186. /**
  20187. * The dirty light flag value
  20188. */
  20189. static readonly LightDirtyFlag: number;
  20190. /**
  20191. * The dirty fresnel flag value
  20192. */
  20193. static readonly FresnelDirtyFlag: number;
  20194. /**
  20195. * The dirty attribute flag value
  20196. */
  20197. static readonly AttributesDirtyFlag: number;
  20198. /**
  20199. * The dirty misc flag value
  20200. */
  20201. static readonly MiscDirtyFlag: number;
  20202. /**
  20203. * The all dirty flag value
  20204. */
  20205. static readonly AllDirtyFlag: number;
  20206. /**
  20207. * The ID of the material
  20208. */
  20209. id: string;
  20210. /**
  20211. * Gets or sets the unique id of the material
  20212. */
  20213. uniqueId: number;
  20214. /**
  20215. * The name of the material
  20216. */
  20217. name: string;
  20218. /**
  20219. * Gets or sets user defined metadata
  20220. */
  20221. metadata: any;
  20222. /**
  20223. * For internal use only. Please do not use.
  20224. */
  20225. reservedDataStore: any;
  20226. /**
  20227. * Specifies if the ready state should be checked on each call
  20228. */
  20229. checkReadyOnEveryCall: boolean;
  20230. /**
  20231. * Specifies if the ready state should be checked once
  20232. */
  20233. checkReadyOnlyOnce: boolean;
  20234. /**
  20235. * The state of the material
  20236. */
  20237. state: string;
  20238. /**
  20239. * The alpha value of the material
  20240. */
  20241. protected _alpha: number;
  20242. /**
  20243. * List of inspectable custom properties (used by the Inspector)
  20244. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20245. */
  20246. inspectableCustomProperties: IInspectable[];
  20247. /**
  20248. * Sets the alpha value of the material
  20249. */
  20250. /**
  20251. * Gets the alpha value of the material
  20252. */
  20253. alpha: number;
  20254. /**
  20255. * Specifies if back face culling is enabled
  20256. */
  20257. protected _backFaceCulling: boolean;
  20258. /**
  20259. * Sets the back-face culling state
  20260. */
  20261. /**
  20262. * Gets the back-face culling state
  20263. */
  20264. backFaceCulling: boolean;
  20265. /**
  20266. * Stores the value for side orientation
  20267. */
  20268. sideOrientation: number;
  20269. /**
  20270. * Callback triggered when the material is compiled
  20271. */
  20272. onCompiled: Nullable<(effect: Effect) => void>;
  20273. /**
  20274. * Callback triggered when an error occurs
  20275. */
  20276. onError: Nullable<(effect: Effect, errors: string) => void>;
  20277. /**
  20278. * Callback triggered to get the render target textures
  20279. */
  20280. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20281. /**
  20282. * Gets a boolean indicating that current material needs to register RTT
  20283. */
  20284. readonly hasRenderTargetTextures: boolean;
  20285. /**
  20286. * Specifies if the material should be serialized
  20287. */
  20288. doNotSerialize: boolean;
  20289. /**
  20290. * @hidden
  20291. */
  20292. _storeEffectOnSubMeshes: boolean;
  20293. /**
  20294. * Stores the animations for the material
  20295. */
  20296. animations: Nullable<Array<Animation>>;
  20297. /**
  20298. * An event triggered when the material is disposed
  20299. */
  20300. onDisposeObservable: Observable<Material>;
  20301. /**
  20302. * An observer which watches for dispose events
  20303. */
  20304. private _onDisposeObserver;
  20305. private _onUnBindObservable;
  20306. /**
  20307. * Called during a dispose event
  20308. */
  20309. onDispose: () => void;
  20310. private _onBindObservable;
  20311. /**
  20312. * An event triggered when the material is bound
  20313. */
  20314. readonly onBindObservable: Observable<AbstractMesh>;
  20315. /**
  20316. * An observer which watches for bind events
  20317. */
  20318. private _onBindObserver;
  20319. /**
  20320. * Called during a bind event
  20321. */
  20322. onBind: (Mesh: AbstractMesh) => void;
  20323. /**
  20324. * An event triggered when the material is unbound
  20325. */
  20326. readonly onUnBindObservable: Observable<Material>;
  20327. /**
  20328. * Stores the value of the alpha mode
  20329. */
  20330. private _alphaMode;
  20331. /**
  20332. * Sets the value of the alpha mode.
  20333. *
  20334. * | Value | Type | Description |
  20335. * | --- | --- | --- |
  20336. * | 0 | ALPHA_DISABLE | |
  20337. * | 1 | ALPHA_ADD | |
  20338. * | 2 | ALPHA_COMBINE | |
  20339. * | 3 | ALPHA_SUBTRACT | |
  20340. * | 4 | ALPHA_MULTIPLY | |
  20341. * | 5 | ALPHA_MAXIMIZED | |
  20342. * | 6 | ALPHA_ONEONE | |
  20343. * | 7 | ALPHA_PREMULTIPLIED | |
  20344. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20345. * | 9 | ALPHA_INTERPOLATE | |
  20346. * | 10 | ALPHA_SCREENMODE | |
  20347. *
  20348. */
  20349. /**
  20350. * Gets the value of the alpha mode
  20351. */
  20352. alphaMode: number;
  20353. /**
  20354. * Stores the state of the need depth pre-pass value
  20355. */
  20356. private _needDepthPrePass;
  20357. /**
  20358. * Sets the need depth pre-pass value
  20359. */
  20360. /**
  20361. * Gets the depth pre-pass value
  20362. */
  20363. needDepthPrePass: boolean;
  20364. /**
  20365. * Specifies if depth writing should be disabled
  20366. */
  20367. disableDepthWrite: boolean;
  20368. /**
  20369. * Specifies if depth writing should be forced
  20370. */
  20371. forceDepthWrite: boolean;
  20372. /**
  20373. * Specifies if there should be a separate pass for culling
  20374. */
  20375. separateCullingPass: boolean;
  20376. /**
  20377. * Stores the state specifing if fog should be enabled
  20378. */
  20379. private _fogEnabled;
  20380. /**
  20381. * Sets the state for enabling fog
  20382. */
  20383. /**
  20384. * Gets the value of the fog enabled state
  20385. */
  20386. fogEnabled: boolean;
  20387. /**
  20388. * Stores the size of points
  20389. */
  20390. pointSize: number;
  20391. /**
  20392. * Stores the z offset value
  20393. */
  20394. zOffset: number;
  20395. /**
  20396. * Gets a value specifying if wireframe mode is enabled
  20397. */
  20398. /**
  20399. * Sets the state of wireframe mode
  20400. */
  20401. wireframe: boolean;
  20402. /**
  20403. * Gets the value specifying if point clouds are enabled
  20404. */
  20405. /**
  20406. * Sets the state of point cloud mode
  20407. */
  20408. pointsCloud: boolean;
  20409. /**
  20410. * Gets the material fill mode
  20411. */
  20412. /**
  20413. * Sets the material fill mode
  20414. */
  20415. fillMode: number;
  20416. /**
  20417. * @hidden
  20418. * Stores the effects for the material
  20419. */
  20420. _effect: Nullable<Effect>;
  20421. /**
  20422. * @hidden
  20423. * Specifies if the material was previously ready
  20424. */
  20425. _wasPreviouslyReady: boolean;
  20426. /**
  20427. * Specifies if uniform buffers should be used
  20428. */
  20429. private _useUBO;
  20430. /**
  20431. * Stores a reference to the scene
  20432. */
  20433. private _scene;
  20434. /**
  20435. * Stores the fill mode state
  20436. */
  20437. private _fillMode;
  20438. /**
  20439. * Specifies if the depth write state should be cached
  20440. */
  20441. private _cachedDepthWriteState;
  20442. /**
  20443. * Stores the uniform buffer
  20444. */
  20445. protected _uniformBuffer: UniformBuffer;
  20446. /** @hidden */
  20447. _indexInSceneMaterialArray: number;
  20448. /** @hidden */
  20449. meshMap: Nullable<{
  20450. [id: string]: AbstractMesh | undefined;
  20451. }>;
  20452. /**
  20453. * Creates a material instance
  20454. * @param name defines the name of the material
  20455. * @param scene defines the scene to reference
  20456. * @param doNotAdd specifies if the material should be added to the scene
  20457. */
  20458. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20459. /**
  20460. * Returns a string representation of the current material
  20461. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20462. * @returns a string with material information
  20463. */
  20464. toString(fullDetails?: boolean): string;
  20465. /**
  20466. * Gets the class name of the material
  20467. * @returns a string with the class name of the material
  20468. */
  20469. getClassName(): string;
  20470. /**
  20471. * Specifies if updates for the material been locked
  20472. */
  20473. readonly isFrozen: boolean;
  20474. /**
  20475. * Locks updates for the material
  20476. */
  20477. freeze(): void;
  20478. /**
  20479. * Unlocks updates for the material
  20480. */
  20481. unfreeze(): void;
  20482. /**
  20483. * Specifies if the material is ready to be used
  20484. * @param mesh defines the mesh to check
  20485. * @param useInstances specifies if instances should be used
  20486. * @returns a boolean indicating if the material is ready to be used
  20487. */
  20488. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20489. /**
  20490. * Specifies that the submesh is ready to be used
  20491. * @param mesh defines the mesh to check
  20492. * @param subMesh defines which submesh to check
  20493. * @param useInstances specifies that instances should be used
  20494. * @returns a boolean indicating that the submesh is ready or not
  20495. */
  20496. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20497. /**
  20498. * Returns the material effect
  20499. * @returns the effect associated with the material
  20500. */
  20501. getEffect(): Nullable<Effect>;
  20502. /**
  20503. * Returns the current scene
  20504. * @returns a Scene
  20505. */
  20506. getScene(): Scene;
  20507. /**
  20508. * Specifies if the material will require alpha blending
  20509. * @returns a boolean specifying if alpha blending is needed
  20510. */
  20511. needAlphaBlending(): boolean;
  20512. /**
  20513. * Specifies if the mesh will require alpha blending
  20514. * @param mesh defines the mesh to check
  20515. * @returns a boolean specifying if alpha blending is needed for the mesh
  20516. */
  20517. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20518. /**
  20519. * Specifies if this material should be rendered in alpha test mode
  20520. * @returns a boolean specifying if an alpha test is needed.
  20521. */
  20522. needAlphaTesting(): boolean;
  20523. /**
  20524. * Gets the texture used for the alpha test
  20525. * @returns the texture to use for alpha testing
  20526. */
  20527. getAlphaTestTexture(): Nullable<BaseTexture>;
  20528. /**
  20529. * Marks the material to indicate that it needs to be re-calculated
  20530. */
  20531. markDirty(): void;
  20532. /** @hidden */
  20533. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20534. /**
  20535. * Binds the material to the mesh
  20536. * @param world defines the world transformation matrix
  20537. * @param mesh defines the mesh to bind the material to
  20538. */
  20539. bind(world: Matrix, mesh?: Mesh): void;
  20540. /**
  20541. * Binds the submesh to the material
  20542. * @param world defines the world transformation matrix
  20543. * @param mesh defines the mesh containing the submesh
  20544. * @param subMesh defines the submesh to bind the material to
  20545. */
  20546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20547. /**
  20548. * Binds the world matrix to the material
  20549. * @param world defines the world transformation matrix
  20550. */
  20551. bindOnlyWorldMatrix(world: Matrix): void;
  20552. /**
  20553. * Binds the scene's uniform buffer to the effect.
  20554. * @param effect defines the effect to bind to the scene uniform buffer
  20555. * @param sceneUbo defines the uniform buffer storing scene data
  20556. */
  20557. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20558. /**
  20559. * Binds the view matrix to the effect
  20560. * @param effect defines the effect to bind the view matrix to
  20561. */
  20562. bindView(effect: Effect): void;
  20563. /**
  20564. * Binds the view projection matrix to the effect
  20565. * @param effect defines the effect to bind the view projection matrix to
  20566. */
  20567. bindViewProjection(effect: Effect): void;
  20568. /**
  20569. * Specifies if material alpha testing should be turned on for the mesh
  20570. * @param mesh defines the mesh to check
  20571. */
  20572. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20573. /**
  20574. * Processes to execute after binding the material to a mesh
  20575. * @param mesh defines the rendered mesh
  20576. */
  20577. protected _afterBind(mesh?: Mesh): void;
  20578. /**
  20579. * Unbinds the material from the mesh
  20580. */
  20581. unbind(): void;
  20582. /**
  20583. * Gets the active textures from the material
  20584. * @returns an array of textures
  20585. */
  20586. getActiveTextures(): BaseTexture[];
  20587. /**
  20588. * Specifies if the material uses a texture
  20589. * @param texture defines the texture to check against the material
  20590. * @returns a boolean specifying if the material uses the texture
  20591. */
  20592. hasTexture(texture: BaseTexture): boolean;
  20593. /**
  20594. * Makes a duplicate of the material, and gives it a new name
  20595. * @param name defines the new name for the duplicated material
  20596. * @returns the cloned material
  20597. */
  20598. clone(name: string): Nullable<Material>;
  20599. /**
  20600. * Gets the meshes bound to the material
  20601. * @returns an array of meshes bound to the material
  20602. */
  20603. getBindedMeshes(): AbstractMesh[];
  20604. /**
  20605. * Force shader compilation
  20606. * @param mesh defines the mesh associated with this material
  20607. * @param onCompiled defines a function to execute once the material is compiled
  20608. * @param options defines the options to configure the compilation
  20609. */
  20610. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20611. clipPlane: boolean;
  20612. }>): void;
  20613. /**
  20614. * Force shader compilation
  20615. * @param mesh defines the mesh that will use this material
  20616. * @param options defines additional options for compiling the shaders
  20617. * @returns a promise that resolves when the compilation completes
  20618. */
  20619. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20620. clipPlane: boolean;
  20621. }>): Promise<void>;
  20622. private static readonly _AllDirtyCallBack;
  20623. private static readonly _ImageProcessingDirtyCallBack;
  20624. private static readonly _TextureDirtyCallBack;
  20625. private static readonly _FresnelDirtyCallBack;
  20626. private static readonly _MiscDirtyCallBack;
  20627. private static readonly _LightsDirtyCallBack;
  20628. private static readonly _AttributeDirtyCallBack;
  20629. private static _FresnelAndMiscDirtyCallBack;
  20630. private static _TextureAndMiscDirtyCallBack;
  20631. private static readonly _DirtyCallbackArray;
  20632. private static readonly _RunDirtyCallBacks;
  20633. /**
  20634. * Marks a define in the material to indicate that it needs to be re-computed
  20635. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20636. */
  20637. markAsDirty(flag: number): void;
  20638. /**
  20639. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20640. * @param func defines a function which checks material defines against the submeshes
  20641. */
  20642. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20643. /**
  20644. * Indicates that we need to re-calculated for all submeshes
  20645. */
  20646. protected _markAllSubMeshesAsAllDirty(): void;
  20647. /**
  20648. * Indicates that image processing needs to be re-calculated for all submeshes
  20649. */
  20650. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20651. /**
  20652. * Indicates that textures need to be re-calculated for all submeshes
  20653. */
  20654. protected _markAllSubMeshesAsTexturesDirty(): void;
  20655. /**
  20656. * Indicates that fresnel needs to be re-calculated for all submeshes
  20657. */
  20658. protected _markAllSubMeshesAsFresnelDirty(): void;
  20659. /**
  20660. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20661. */
  20662. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20663. /**
  20664. * Indicates that lights need to be re-calculated for all submeshes
  20665. */
  20666. protected _markAllSubMeshesAsLightsDirty(): void;
  20667. /**
  20668. * Indicates that attributes need to be re-calculated for all submeshes
  20669. */
  20670. protected _markAllSubMeshesAsAttributesDirty(): void;
  20671. /**
  20672. * Indicates that misc needs to be re-calculated for all submeshes
  20673. */
  20674. protected _markAllSubMeshesAsMiscDirty(): void;
  20675. /**
  20676. * Indicates that textures and misc need to be re-calculated for all submeshes
  20677. */
  20678. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20679. /**
  20680. * Disposes the material
  20681. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20682. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20683. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20684. */
  20685. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20686. /** @hidden */
  20687. private releaseVertexArrayObject;
  20688. /**
  20689. * Serializes this material
  20690. * @returns the serialized material object
  20691. */
  20692. serialize(): any;
  20693. /**
  20694. * Creates a material from parsed material data
  20695. * @param parsedMaterial defines parsed material data
  20696. * @param scene defines the hosting scene
  20697. * @param rootUrl defines the root URL to use to load textures
  20698. * @returns a new material
  20699. */
  20700. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20701. }
  20702. }
  20703. declare module BABYLON {
  20704. /**
  20705. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20706. * separate meshes. This can be use to improve performances.
  20707. * @see http://doc.babylonjs.com/how_to/multi_materials
  20708. */
  20709. export class MultiMaterial extends Material {
  20710. private _subMaterials;
  20711. /**
  20712. * Gets or Sets the list of Materials used within the multi material.
  20713. * They need to be ordered according to the submeshes order in the associated mesh
  20714. */
  20715. subMaterials: Nullable<Material>[];
  20716. /**
  20717. * Function used to align with Node.getChildren()
  20718. * @returns the list of Materials used within the multi material
  20719. */
  20720. getChildren(): Nullable<Material>[];
  20721. /**
  20722. * Instantiates a new Multi Material
  20723. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20724. * separate meshes. This can be use to improve performances.
  20725. * @see http://doc.babylonjs.com/how_to/multi_materials
  20726. * @param name Define the name in the scene
  20727. * @param scene Define the scene the material belongs to
  20728. */
  20729. constructor(name: string, scene: Scene);
  20730. private _hookArray;
  20731. /**
  20732. * Get one of the submaterial by its index in the submaterials array
  20733. * @param index The index to look the sub material at
  20734. * @returns The Material if the index has been defined
  20735. */
  20736. getSubMaterial(index: number): Nullable<Material>;
  20737. /**
  20738. * Get the list of active textures for the whole sub materials list.
  20739. * @returns All the textures that will be used during the rendering
  20740. */
  20741. getActiveTextures(): BaseTexture[];
  20742. /**
  20743. * Gets the current class name of the material e.g. "MultiMaterial"
  20744. * Mainly use in serialization.
  20745. * @returns the class name
  20746. */
  20747. getClassName(): string;
  20748. /**
  20749. * Checks if the material is ready to render the requested sub mesh
  20750. * @param mesh Define the mesh the submesh belongs to
  20751. * @param subMesh Define the sub mesh to look readyness for
  20752. * @param useInstances Define whether or not the material is used with instances
  20753. * @returns true if ready, otherwise false
  20754. */
  20755. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20756. /**
  20757. * Clones the current material and its related sub materials
  20758. * @param name Define the name of the newly cloned material
  20759. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20760. * @returns the cloned material
  20761. */
  20762. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20763. /**
  20764. * Serializes the materials into a JSON representation.
  20765. * @returns the JSON representation
  20766. */
  20767. serialize(): any;
  20768. /**
  20769. * Dispose the material and release its associated resources
  20770. * @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)
  20771. * @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)
  20772. * @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)
  20773. */
  20774. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20775. /**
  20776. * Creates a MultiMaterial from parsed MultiMaterial data.
  20777. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20778. * @param scene defines the hosting scene
  20779. * @returns a new MultiMaterial
  20780. */
  20781. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20782. }
  20783. }
  20784. declare module BABYLON {
  20785. /**
  20786. * Base class for submeshes
  20787. */
  20788. export class BaseSubMesh {
  20789. /** @hidden */
  20790. _materialDefines: Nullable<MaterialDefines>;
  20791. /** @hidden */
  20792. _materialEffect: Nullable<Effect>;
  20793. /**
  20794. * Gets associated effect
  20795. */
  20796. readonly effect: Nullable<Effect>;
  20797. /**
  20798. * Sets associated effect (effect used to render this submesh)
  20799. * @param effect defines the effect to associate with
  20800. * @param defines defines the set of defines used to compile this effect
  20801. */
  20802. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20803. }
  20804. /**
  20805. * Defines a subdivision inside a mesh
  20806. */
  20807. export class SubMesh extends BaseSubMesh implements ICullable {
  20808. /** the material index to use */
  20809. materialIndex: number;
  20810. /** vertex index start */
  20811. verticesStart: number;
  20812. /** vertices count */
  20813. verticesCount: number;
  20814. /** index start */
  20815. indexStart: number;
  20816. /** indices count */
  20817. indexCount: number;
  20818. /** @hidden */
  20819. _linesIndexCount: number;
  20820. private _mesh;
  20821. private _renderingMesh;
  20822. private _boundingInfo;
  20823. private _linesIndexBuffer;
  20824. /** @hidden */
  20825. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20826. /** @hidden */
  20827. _trianglePlanes: Plane[];
  20828. /** @hidden */
  20829. _lastColliderTransformMatrix: Nullable<Matrix>;
  20830. /** @hidden */
  20831. _renderId: number;
  20832. /** @hidden */
  20833. _alphaIndex: number;
  20834. /** @hidden */
  20835. _distanceToCamera: number;
  20836. /** @hidden */
  20837. _id: number;
  20838. private _currentMaterial;
  20839. /**
  20840. * Add a new submesh to a mesh
  20841. * @param materialIndex defines the material index to use
  20842. * @param verticesStart defines vertex index start
  20843. * @param verticesCount defines vertices count
  20844. * @param indexStart defines index start
  20845. * @param indexCount defines indices count
  20846. * @param mesh defines the parent mesh
  20847. * @param renderingMesh defines an optional rendering mesh
  20848. * @param createBoundingBox defines if bounding box should be created for this submesh
  20849. * @returns the new submesh
  20850. */
  20851. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20852. /**
  20853. * Creates a new submesh
  20854. * @param materialIndex defines the material index to use
  20855. * @param verticesStart defines vertex index start
  20856. * @param verticesCount defines vertices count
  20857. * @param indexStart defines index start
  20858. * @param indexCount defines indices count
  20859. * @param mesh defines the parent mesh
  20860. * @param renderingMesh defines an optional rendering mesh
  20861. * @param createBoundingBox defines if bounding box should be created for this submesh
  20862. */
  20863. constructor(
  20864. /** the material index to use */
  20865. materialIndex: number,
  20866. /** vertex index start */
  20867. verticesStart: number,
  20868. /** vertices count */
  20869. verticesCount: number,
  20870. /** index start */
  20871. indexStart: number,
  20872. /** indices count */
  20873. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20874. /**
  20875. * Returns true if this submesh covers the entire parent mesh
  20876. * @ignorenaming
  20877. */
  20878. readonly IsGlobal: boolean;
  20879. /**
  20880. * Returns the submesh BoudingInfo object
  20881. * @returns current bounding info (or mesh's one if the submesh is global)
  20882. */
  20883. getBoundingInfo(): BoundingInfo;
  20884. /**
  20885. * Sets the submesh BoundingInfo
  20886. * @param boundingInfo defines the new bounding info to use
  20887. * @returns the SubMesh
  20888. */
  20889. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20890. /**
  20891. * Returns the mesh of the current submesh
  20892. * @return the parent mesh
  20893. */
  20894. getMesh(): AbstractMesh;
  20895. /**
  20896. * Returns the rendering mesh of the submesh
  20897. * @returns the rendering mesh (could be different from parent mesh)
  20898. */
  20899. getRenderingMesh(): Mesh;
  20900. /**
  20901. * Returns the submesh material
  20902. * @returns null or the current material
  20903. */
  20904. getMaterial(): Nullable<Material>;
  20905. /**
  20906. * Sets a new updated BoundingInfo object to the submesh
  20907. * @param data defines an optional position array to use to determine the bounding info
  20908. * @returns the SubMesh
  20909. */
  20910. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20911. /** @hidden */
  20912. _checkCollision(collider: Collider): boolean;
  20913. /**
  20914. * Updates the submesh BoundingInfo
  20915. * @param world defines the world matrix to use to update the bounding info
  20916. * @returns the submesh
  20917. */
  20918. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20919. /**
  20920. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20921. * @param frustumPlanes defines the frustum planes
  20922. * @returns true if the submesh is intersecting with the frustum
  20923. */
  20924. isInFrustum(frustumPlanes: Plane[]): boolean;
  20925. /**
  20926. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20927. * @param frustumPlanes defines the frustum planes
  20928. * @returns true if the submesh is inside the frustum
  20929. */
  20930. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20931. /**
  20932. * Renders the submesh
  20933. * @param enableAlphaMode defines if alpha needs to be used
  20934. * @returns the submesh
  20935. */
  20936. render(enableAlphaMode: boolean): SubMesh;
  20937. /**
  20938. * @hidden
  20939. */
  20940. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20941. /**
  20942. * Checks if the submesh intersects with a ray
  20943. * @param ray defines the ray to test
  20944. * @returns true is the passed ray intersects the submesh bounding box
  20945. */
  20946. canIntersects(ray: Ray): boolean;
  20947. /**
  20948. * Intersects current submesh with a ray
  20949. * @param ray defines the ray to test
  20950. * @param positions defines mesh's positions array
  20951. * @param indices defines mesh's indices array
  20952. * @param fastCheck defines if only bounding info should be used
  20953. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20954. * @returns intersection info or null if no intersection
  20955. */
  20956. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20957. /** @hidden */
  20958. private _intersectLines;
  20959. /** @hidden */
  20960. private _intersectUnIndexedLines;
  20961. /** @hidden */
  20962. private _intersectTriangles;
  20963. /** @hidden */
  20964. private _intersectUnIndexedTriangles;
  20965. /** @hidden */
  20966. _rebuild(): void;
  20967. /**
  20968. * Creates a new submesh from the passed mesh
  20969. * @param newMesh defines the new hosting mesh
  20970. * @param newRenderingMesh defines an optional rendering mesh
  20971. * @returns the new submesh
  20972. */
  20973. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20974. /**
  20975. * Release associated resources
  20976. */
  20977. dispose(): void;
  20978. /**
  20979. * Gets the class name
  20980. * @returns the string "SubMesh".
  20981. */
  20982. getClassName(): string;
  20983. /**
  20984. * Creates a new submesh from indices data
  20985. * @param materialIndex the index of the main mesh material
  20986. * @param startIndex the index where to start the copy in the mesh indices array
  20987. * @param indexCount the number of indices to copy then from the startIndex
  20988. * @param mesh the main mesh to create the submesh from
  20989. * @param renderingMesh the optional rendering mesh
  20990. * @returns a new submesh
  20991. */
  20992. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20993. }
  20994. }
  20995. declare module BABYLON {
  20996. /**
  20997. * Class used to represent data loading progression
  20998. */
  20999. export class SceneLoaderFlags {
  21000. private static _ForceFullSceneLoadingForIncremental;
  21001. private static _ShowLoadingScreen;
  21002. private static _CleanBoneMatrixWeights;
  21003. private static _loggingLevel;
  21004. /**
  21005. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21006. */
  21007. static ForceFullSceneLoadingForIncremental: boolean;
  21008. /**
  21009. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21010. */
  21011. static ShowLoadingScreen: boolean;
  21012. /**
  21013. * Defines the current logging level (while loading the scene)
  21014. * @ignorenaming
  21015. */
  21016. static loggingLevel: number;
  21017. /**
  21018. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21019. */
  21020. static CleanBoneMatrixWeights: boolean;
  21021. }
  21022. }
  21023. declare module BABYLON {
  21024. /**
  21025. * Class used to store geometry data (vertex buffers + index buffer)
  21026. */
  21027. export class Geometry implements IGetSetVerticesData {
  21028. /**
  21029. * Gets or sets the ID of the geometry
  21030. */
  21031. id: string;
  21032. /**
  21033. * Gets or sets the unique ID of the geometry
  21034. */
  21035. uniqueId: number;
  21036. /**
  21037. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21038. */
  21039. delayLoadState: number;
  21040. /**
  21041. * Gets the file containing the data to load when running in delay load state
  21042. */
  21043. delayLoadingFile: Nullable<string>;
  21044. /**
  21045. * Callback called when the geometry is updated
  21046. */
  21047. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21048. private _scene;
  21049. private _engine;
  21050. private _meshes;
  21051. private _totalVertices;
  21052. /** @hidden */
  21053. _indices: IndicesArray;
  21054. /** @hidden */
  21055. _vertexBuffers: {
  21056. [key: string]: VertexBuffer;
  21057. };
  21058. private _isDisposed;
  21059. private _extend;
  21060. private _boundingBias;
  21061. /** @hidden */
  21062. _delayInfo: Array<string>;
  21063. private _indexBuffer;
  21064. private _indexBufferIsUpdatable;
  21065. /** @hidden */
  21066. _boundingInfo: Nullable<BoundingInfo>;
  21067. /** @hidden */
  21068. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21069. /** @hidden */
  21070. _softwareSkinningFrameId: number;
  21071. private _vertexArrayObjects;
  21072. private _updatable;
  21073. /** @hidden */
  21074. _positions: Nullable<Vector3[]>;
  21075. /**
  21076. * 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
  21077. */
  21078. /**
  21079. * 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
  21080. */
  21081. boundingBias: Vector2;
  21082. /**
  21083. * Static function used to attach a new empty geometry to a mesh
  21084. * @param mesh defines the mesh to attach the geometry to
  21085. * @returns the new Geometry
  21086. */
  21087. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21088. /**
  21089. * Creates a new geometry
  21090. * @param id defines the unique ID
  21091. * @param scene defines the hosting scene
  21092. * @param vertexData defines the VertexData used to get geometry data
  21093. * @param updatable defines if geometry must be updatable (false by default)
  21094. * @param mesh defines the mesh that will be associated with the geometry
  21095. */
  21096. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21097. /**
  21098. * Gets the current extend of the geometry
  21099. */
  21100. readonly extend: {
  21101. minimum: Vector3;
  21102. maximum: Vector3;
  21103. };
  21104. /**
  21105. * Gets the hosting scene
  21106. * @returns the hosting Scene
  21107. */
  21108. getScene(): Scene;
  21109. /**
  21110. * Gets the hosting engine
  21111. * @returns the hosting Engine
  21112. */
  21113. getEngine(): Engine;
  21114. /**
  21115. * Defines if the geometry is ready to use
  21116. * @returns true if the geometry is ready to be used
  21117. */
  21118. isReady(): boolean;
  21119. /**
  21120. * Gets a value indicating that the geometry should not be serialized
  21121. */
  21122. readonly doNotSerialize: boolean;
  21123. /** @hidden */
  21124. _rebuild(): void;
  21125. /**
  21126. * Affects all geometry data in one call
  21127. * @param vertexData defines the geometry data
  21128. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21129. */
  21130. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21131. /**
  21132. * Set specific vertex data
  21133. * @param kind defines the data kind (Position, normal, etc...)
  21134. * @param data defines the vertex data to use
  21135. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21136. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21137. */
  21138. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21139. /**
  21140. * Removes a specific vertex data
  21141. * @param kind defines the data kind (Position, normal, etc...)
  21142. */
  21143. removeVerticesData(kind: string): void;
  21144. /**
  21145. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21146. * @param buffer defines the vertex buffer to use
  21147. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21148. */
  21149. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21150. /**
  21151. * Update a specific vertex buffer
  21152. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21153. * It will do nothing if the buffer is not updatable
  21154. * @param kind defines the data kind (Position, normal, etc...)
  21155. * @param data defines the data to use
  21156. * @param offset defines the offset in the target buffer where to store the data
  21157. * @param useBytes set to true if the offset is in bytes
  21158. */
  21159. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21160. /**
  21161. * Update a specific vertex buffer
  21162. * This function will create a new buffer if the current one is not updatable
  21163. * @param kind defines the data kind (Position, normal, etc...)
  21164. * @param data defines the data to use
  21165. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21166. */
  21167. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21168. private _updateBoundingInfo;
  21169. /** @hidden */
  21170. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21171. /**
  21172. * Gets total number of vertices
  21173. * @returns the total number of vertices
  21174. */
  21175. getTotalVertices(): number;
  21176. /**
  21177. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21178. * @param kind defines the data kind (Position, normal, etc...)
  21179. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21180. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21181. * @returns a float array containing vertex data
  21182. */
  21183. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21184. /**
  21185. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21186. * @param kind defines the data kind (Position, normal, etc...)
  21187. * @returns true if the vertex buffer with the specified kind is updatable
  21188. */
  21189. isVertexBufferUpdatable(kind: string): boolean;
  21190. /**
  21191. * Gets a specific vertex buffer
  21192. * @param kind defines the data kind (Position, normal, etc...)
  21193. * @returns a VertexBuffer
  21194. */
  21195. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21196. /**
  21197. * Returns all vertex buffers
  21198. * @return an object holding all vertex buffers indexed by kind
  21199. */
  21200. getVertexBuffers(): Nullable<{
  21201. [key: string]: VertexBuffer;
  21202. }>;
  21203. /**
  21204. * Gets a boolean indicating if specific vertex buffer is present
  21205. * @param kind defines the data kind (Position, normal, etc...)
  21206. * @returns true if data is present
  21207. */
  21208. isVerticesDataPresent(kind: string): boolean;
  21209. /**
  21210. * Gets a list of all attached data kinds (Position, normal, etc...)
  21211. * @returns a list of string containing all kinds
  21212. */
  21213. getVerticesDataKinds(): string[];
  21214. /**
  21215. * Update index buffer
  21216. * @param indices defines the indices to store in the index buffer
  21217. * @param offset defines the offset in the target buffer where to store the data
  21218. * @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)
  21219. */
  21220. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21221. /**
  21222. * Creates a new index buffer
  21223. * @param indices defines the indices to store in the index buffer
  21224. * @param totalVertices defines the total number of vertices (could be null)
  21225. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21226. */
  21227. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21228. /**
  21229. * Return the total number of indices
  21230. * @returns the total number of indices
  21231. */
  21232. getTotalIndices(): number;
  21233. /**
  21234. * Gets the index buffer array
  21235. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21236. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21237. * @returns the index buffer array
  21238. */
  21239. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21240. /**
  21241. * Gets the index buffer
  21242. * @return the index buffer
  21243. */
  21244. getIndexBuffer(): Nullable<DataBuffer>;
  21245. /** @hidden */
  21246. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21247. /**
  21248. * Release the associated resources for a specific mesh
  21249. * @param mesh defines the source mesh
  21250. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21251. */
  21252. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21253. /**
  21254. * Apply current geometry to a given mesh
  21255. * @param mesh defines the mesh to apply geometry to
  21256. */
  21257. applyToMesh(mesh: Mesh): void;
  21258. private _updateExtend;
  21259. private _applyToMesh;
  21260. private notifyUpdate;
  21261. /**
  21262. * Load the geometry if it was flagged as delay loaded
  21263. * @param scene defines the hosting scene
  21264. * @param onLoaded defines a callback called when the geometry is loaded
  21265. */
  21266. load(scene: Scene, onLoaded?: () => void): void;
  21267. private _queueLoad;
  21268. /**
  21269. * Invert the geometry to move from a right handed system to a left handed one.
  21270. */
  21271. toLeftHanded(): void;
  21272. /** @hidden */
  21273. _resetPointsArrayCache(): void;
  21274. /** @hidden */
  21275. _generatePointsArray(): boolean;
  21276. /**
  21277. * Gets a value indicating if the geometry is disposed
  21278. * @returns true if the geometry was disposed
  21279. */
  21280. isDisposed(): boolean;
  21281. private _disposeVertexArrayObjects;
  21282. /**
  21283. * Free all associated resources
  21284. */
  21285. dispose(): void;
  21286. /**
  21287. * Clone the current geometry into a new geometry
  21288. * @param id defines the unique ID of the new geometry
  21289. * @returns a new geometry object
  21290. */
  21291. copy(id: string): Geometry;
  21292. /**
  21293. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21294. * @return a JSON representation of the current geometry data (without the vertices data)
  21295. */
  21296. serialize(): any;
  21297. private toNumberArray;
  21298. /**
  21299. * Serialize all vertices data into a JSON oject
  21300. * @returns a JSON representation of the current geometry data
  21301. */
  21302. serializeVerticeData(): any;
  21303. /**
  21304. * Extracts a clone of a mesh geometry
  21305. * @param mesh defines the source mesh
  21306. * @param id defines the unique ID of the new geometry object
  21307. * @returns the new geometry object
  21308. */
  21309. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21310. /**
  21311. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21312. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21313. * Be aware Math.random() could cause collisions, but:
  21314. * "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"
  21315. * @returns a string containing a new GUID
  21316. */
  21317. static RandomId(): string;
  21318. /** @hidden */
  21319. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21320. private static _CleanMatricesWeights;
  21321. /**
  21322. * Create a new geometry from persisted data (Using .babylon file format)
  21323. * @param parsedVertexData defines the persisted data
  21324. * @param scene defines the hosting scene
  21325. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21326. * @returns the new geometry object
  21327. */
  21328. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21329. }
  21330. }
  21331. declare module BABYLON {
  21332. /**
  21333. * Define an interface for all classes that will get and set the data on vertices
  21334. */
  21335. export interface IGetSetVerticesData {
  21336. /**
  21337. * Gets a boolean indicating if specific vertex data is present
  21338. * @param kind defines the vertex data kind to use
  21339. * @returns true is data kind is present
  21340. */
  21341. isVerticesDataPresent(kind: string): boolean;
  21342. /**
  21343. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21344. * @param kind defines the data kind (Position, normal, etc...)
  21345. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21346. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21347. * @returns a float array containing vertex data
  21348. */
  21349. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21350. /**
  21351. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21352. * @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.
  21353. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21354. * @returns the indices array or an empty array if the mesh has no geometry
  21355. */
  21356. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21357. /**
  21358. * Set specific vertex data
  21359. * @param kind defines the data kind (Position, normal, etc...)
  21360. * @param data defines the vertex data to use
  21361. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21362. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21363. */
  21364. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21365. /**
  21366. * Update a specific associated vertex buffer
  21367. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21368. * - VertexBuffer.PositionKind
  21369. * - VertexBuffer.UVKind
  21370. * - VertexBuffer.UV2Kind
  21371. * - VertexBuffer.UV3Kind
  21372. * - VertexBuffer.UV4Kind
  21373. * - VertexBuffer.UV5Kind
  21374. * - VertexBuffer.UV6Kind
  21375. * - VertexBuffer.ColorKind
  21376. * - VertexBuffer.MatricesIndicesKind
  21377. * - VertexBuffer.MatricesIndicesExtraKind
  21378. * - VertexBuffer.MatricesWeightsKind
  21379. * - VertexBuffer.MatricesWeightsExtraKind
  21380. * @param data defines the data source
  21381. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21382. * @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)
  21383. */
  21384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21385. /**
  21386. * Creates a new index buffer
  21387. * @param indices defines the indices to store in the index buffer
  21388. * @param totalVertices defines the total number of vertices (could be null)
  21389. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21390. */
  21391. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21392. }
  21393. /**
  21394. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21395. */
  21396. export class VertexData {
  21397. /**
  21398. * Mesh side orientation : usually the external or front surface
  21399. */
  21400. static readonly FRONTSIDE: number;
  21401. /**
  21402. * Mesh side orientation : usually the internal or back surface
  21403. */
  21404. static readonly BACKSIDE: number;
  21405. /**
  21406. * Mesh side orientation : both internal and external or front and back surfaces
  21407. */
  21408. static readonly DOUBLESIDE: number;
  21409. /**
  21410. * Mesh side orientation : by default, `FRONTSIDE`
  21411. */
  21412. static readonly DEFAULTSIDE: number;
  21413. /**
  21414. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21415. */
  21416. positions: Nullable<FloatArray>;
  21417. /**
  21418. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21419. */
  21420. normals: Nullable<FloatArray>;
  21421. /**
  21422. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21423. */
  21424. tangents: Nullable<FloatArray>;
  21425. /**
  21426. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21427. */
  21428. uvs: Nullable<FloatArray>;
  21429. /**
  21430. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21431. */
  21432. uvs2: Nullable<FloatArray>;
  21433. /**
  21434. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21435. */
  21436. uvs3: Nullable<FloatArray>;
  21437. /**
  21438. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21439. */
  21440. uvs4: Nullable<FloatArray>;
  21441. /**
  21442. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21443. */
  21444. uvs5: Nullable<FloatArray>;
  21445. /**
  21446. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21447. */
  21448. uvs6: Nullable<FloatArray>;
  21449. /**
  21450. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21451. */
  21452. colors: Nullable<FloatArray>;
  21453. /**
  21454. * 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).
  21455. */
  21456. matricesIndices: Nullable<FloatArray>;
  21457. /**
  21458. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21459. */
  21460. matricesWeights: Nullable<FloatArray>;
  21461. /**
  21462. * An array extending the number of possible indices
  21463. */
  21464. matricesIndicesExtra: Nullable<FloatArray>;
  21465. /**
  21466. * An array extending the number of possible weights when the number of indices is extended
  21467. */
  21468. matricesWeightsExtra: Nullable<FloatArray>;
  21469. /**
  21470. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21471. */
  21472. indices: Nullable<IndicesArray>;
  21473. /**
  21474. * Uses the passed data array to set the set the values for the specified kind of data
  21475. * @param data a linear array of floating numbers
  21476. * @param kind the type of data that is being set, eg positions, colors etc
  21477. */
  21478. set(data: FloatArray, kind: string): void;
  21479. /**
  21480. * Associates the vertexData to the passed Mesh.
  21481. * Sets it as updatable or not (default `false`)
  21482. * @param mesh the mesh the vertexData is applied to
  21483. * @param updatable when used and having the value true allows new data to update the vertexData
  21484. * @returns the VertexData
  21485. */
  21486. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21487. /**
  21488. * Associates the vertexData to the passed Geometry.
  21489. * Sets it as updatable or not (default `false`)
  21490. * @param geometry the geometry the vertexData is applied to
  21491. * @param updatable when used and having the value true allows new data to update the vertexData
  21492. * @returns VertexData
  21493. */
  21494. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21495. /**
  21496. * Updates the associated mesh
  21497. * @param mesh the mesh to be updated
  21498. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21499. * @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
  21500. * @returns VertexData
  21501. */
  21502. updateMesh(mesh: Mesh): VertexData;
  21503. /**
  21504. * Updates the associated geometry
  21505. * @param geometry the geometry to be updated
  21506. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21507. * @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
  21508. * @returns VertexData.
  21509. */
  21510. updateGeometry(geometry: Geometry): VertexData;
  21511. private _applyTo;
  21512. private _update;
  21513. /**
  21514. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21515. * @param matrix the transforming matrix
  21516. * @returns the VertexData
  21517. */
  21518. transform(matrix: Matrix): VertexData;
  21519. /**
  21520. * Merges the passed VertexData into the current one
  21521. * @param other the VertexData to be merged into the current one
  21522. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21523. * @returns the modified VertexData
  21524. */
  21525. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21526. private _mergeElement;
  21527. private _validate;
  21528. /**
  21529. * Serializes the VertexData
  21530. * @returns a serialized object
  21531. */
  21532. serialize(): any;
  21533. /**
  21534. * Extracts the vertexData from a mesh
  21535. * @param mesh the mesh from which to extract the VertexData
  21536. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21537. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21538. * @returns the object VertexData associated to the passed mesh
  21539. */
  21540. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21541. /**
  21542. * Extracts the vertexData from the geometry
  21543. * @param geometry the geometry from which to extract the VertexData
  21544. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21545. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21546. * @returns the object VertexData associated to the passed mesh
  21547. */
  21548. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21549. private static _ExtractFrom;
  21550. /**
  21551. * Creates the VertexData for a Ribbon
  21552. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21553. * * pathArray array of paths, each of which an array of successive Vector3
  21554. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21555. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21556. * * 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
  21557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21558. * * 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)
  21559. * * 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)
  21560. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21561. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21562. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21563. * @returns the VertexData of the ribbon
  21564. */
  21565. static CreateRibbon(options: {
  21566. pathArray: Vector3[][];
  21567. closeArray?: boolean;
  21568. closePath?: boolean;
  21569. offset?: number;
  21570. sideOrientation?: number;
  21571. frontUVs?: Vector4;
  21572. backUVs?: Vector4;
  21573. invertUV?: boolean;
  21574. uvs?: Vector2[];
  21575. colors?: Color4[];
  21576. }): VertexData;
  21577. /**
  21578. * Creates the VertexData for a box
  21579. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21580. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21581. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21582. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21583. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21584. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21585. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21587. * * 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)
  21588. * * 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)
  21589. * @returns the VertexData of the box
  21590. */
  21591. static CreateBox(options: {
  21592. size?: number;
  21593. width?: number;
  21594. height?: number;
  21595. depth?: number;
  21596. faceUV?: Vector4[];
  21597. faceColors?: Color4[];
  21598. sideOrientation?: number;
  21599. frontUVs?: Vector4;
  21600. backUVs?: Vector4;
  21601. }): VertexData;
  21602. /**
  21603. * Creates the VertexData for a tiled box
  21604. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21605. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21606. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21607. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21608. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21609. * @returns the VertexData of the box
  21610. */
  21611. static CreateTiledBox(options: {
  21612. pattern?: number;
  21613. width?: number;
  21614. height?: number;
  21615. depth?: number;
  21616. tileSize?: number;
  21617. tileWidth?: number;
  21618. tileHeight?: number;
  21619. alignHorizontal?: number;
  21620. alignVertical?: number;
  21621. faceUV?: Vector4[];
  21622. faceColors?: Color4[];
  21623. sideOrientation?: number;
  21624. }): VertexData;
  21625. /**
  21626. * Creates the VertexData for a tiled plane
  21627. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21628. * * pattern a limited pattern arrangement depending on the number
  21629. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21630. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21631. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21632. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21633. * * 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)
  21634. * * 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)
  21635. * @returns the VertexData of the tiled plane
  21636. */
  21637. static CreateTiledPlane(options: {
  21638. pattern?: number;
  21639. tileSize?: number;
  21640. tileWidth?: number;
  21641. tileHeight?: number;
  21642. size?: number;
  21643. width?: number;
  21644. height?: number;
  21645. alignHorizontal?: number;
  21646. alignVertical?: number;
  21647. sideOrientation?: number;
  21648. frontUVs?: Vector4;
  21649. backUVs?: Vector4;
  21650. }): VertexData;
  21651. /**
  21652. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21653. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21654. * * segments sets the number of horizontal strips optional, default 32
  21655. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21656. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21657. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21658. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21659. * * 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
  21660. * * 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
  21661. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21662. * * 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)
  21663. * * 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)
  21664. * @returns the VertexData of the ellipsoid
  21665. */
  21666. static CreateSphere(options: {
  21667. segments?: number;
  21668. diameter?: number;
  21669. diameterX?: number;
  21670. diameterY?: number;
  21671. diameterZ?: number;
  21672. arc?: number;
  21673. slice?: number;
  21674. sideOrientation?: number;
  21675. frontUVs?: Vector4;
  21676. backUVs?: Vector4;
  21677. }): VertexData;
  21678. /**
  21679. * Creates the VertexData for a cylinder, cone or prism
  21680. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21681. * * height sets the height (y direction) of the cylinder, optional, default 2
  21682. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21683. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21684. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21685. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21686. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21687. * * 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
  21688. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21689. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21690. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21691. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21693. * * 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)
  21694. * * 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)
  21695. * @returns the VertexData of the cylinder, cone or prism
  21696. */
  21697. static CreateCylinder(options: {
  21698. height?: number;
  21699. diameterTop?: number;
  21700. diameterBottom?: number;
  21701. diameter?: number;
  21702. tessellation?: number;
  21703. subdivisions?: number;
  21704. arc?: number;
  21705. faceColors?: Color4[];
  21706. faceUV?: Vector4[];
  21707. hasRings?: boolean;
  21708. enclose?: boolean;
  21709. sideOrientation?: number;
  21710. frontUVs?: Vector4;
  21711. backUVs?: Vector4;
  21712. }): VertexData;
  21713. /**
  21714. * Creates the VertexData for a torus
  21715. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21716. * * diameter the diameter of the torus, optional default 1
  21717. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21718. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21720. * * 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)
  21721. * * 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)
  21722. * @returns the VertexData of the torus
  21723. */
  21724. static CreateTorus(options: {
  21725. diameter?: number;
  21726. thickness?: number;
  21727. tessellation?: number;
  21728. sideOrientation?: number;
  21729. frontUVs?: Vector4;
  21730. backUVs?: Vector4;
  21731. }): VertexData;
  21732. /**
  21733. * Creates the VertexData of the LineSystem
  21734. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21735. * - lines an array of lines, each line being an array of successive Vector3
  21736. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21737. * @returns the VertexData of the LineSystem
  21738. */
  21739. static CreateLineSystem(options: {
  21740. lines: Vector3[][];
  21741. colors?: Nullable<Color4[][]>;
  21742. }): VertexData;
  21743. /**
  21744. * Create the VertexData for a DashedLines
  21745. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21746. * - points an array successive Vector3
  21747. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21748. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21749. * - dashNb the intended total number of dashes, optional, default 200
  21750. * @returns the VertexData for the DashedLines
  21751. */
  21752. static CreateDashedLines(options: {
  21753. points: Vector3[];
  21754. dashSize?: number;
  21755. gapSize?: number;
  21756. dashNb?: number;
  21757. }): VertexData;
  21758. /**
  21759. * Creates the VertexData for a Ground
  21760. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21761. * - width the width (x direction) of the ground, optional, default 1
  21762. * - height the height (z direction) of the ground, optional, default 1
  21763. * - subdivisions the number of subdivisions per side, optional, default 1
  21764. * @returns the VertexData of the Ground
  21765. */
  21766. static CreateGround(options: {
  21767. width?: number;
  21768. height?: number;
  21769. subdivisions?: number;
  21770. subdivisionsX?: number;
  21771. subdivisionsY?: number;
  21772. }): VertexData;
  21773. /**
  21774. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21775. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21776. * * xmin the ground minimum X coordinate, optional, default -1
  21777. * * zmin the ground minimum Z coordinate, optional, default -1
  21778. * * xmax the ground maximum X coordinate, optional, default 1
  21779. * * zmax the ground maximum Z coordinate, optional, default 1
  21780. * * 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}
  21781. * * 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}
  21782. * @returns the VertexData of the TiledGround
  21783. */
  21784. static CreateTiledGround(options: {
  21785. xmin: number;
  21786. zmin: number;
  21787. xmax: number;
  21788. zmax: number;
  21789. subdivisions?: {
  21790. w: number;
  21791. h: number;
  21792. };
  21793. precision?: {
  21794. w: number;
  21795. h: number;
  21796. };
  21797. }): VertexData;
  21798. /**
  21799. * Creates the VertexData of the Ground designed from a heightmap
  21800. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21801. * * width the width (x direction) of the ground
  21802. * * height the height (z direction) of the ground
  21803. * * subdivisions the number of subdivisions per side
  21804. * * minHeight the minimum altitude on the ground, optional, default 0
  21805. * * maxHeight the maximum altitude on the ground, optional default 1
  21806. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21807. * * buffer the array holding the image color data
  21808. * * bufferWidth the width of image
  21809. * * bufferHeight the height of image
  21810. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21811. * @returns the VertexData of the Ground designed from a heightmap
  21812. */
  21813. static CreateGroundFromHeightMap(options: {
  21814. width: number;
  21815. height: number;
  21816. subdivisions: number;
  21817. minHeight: number;
  21818. maxHeight: number;
  21819. colorFilter: Color3;
  21820. buffer: Uint8Array;
  21821. bufferWidth: number;
  21822. bufferHeight: number;
  21823. alphaFilter: number;
  21824. }): VertexData;
  21825. /**
  21826. * Creates the VertexData for a Plane
  21827. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21828. * * size sets the width and height of the plane to the value of size, optional default 1
  21829. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21830. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21831. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21832. * * 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)
  21833. * * 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)
  21834. * @returns the VertexData of the box
  21835. */
  21836. static CreatePlane(options: {
  21837. size?: number;
  21838. width?: number;
  21839. height?: number;
  21840. sideOrientation?: number;
  21841. frontUVs?: Vector4;
  21842. backUVs?: Vector4;
  21843. }): VertexData;
  21844. /**
  21845. * Creates the VertexData of the Disc or regular Polygon
  21846. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21847. * * radius the radius of the disc, optional default 0.5
  21848. * * tessellation the number of polygon sides, optional, default 64
  21849. * * 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
  21850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21851. * * 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)
  21852. * * 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)
  21853. * @returns the VertexData of the box
  21854. */
  21855. static CreateDisc(options: {
  21856. radius?: number;
  21857. tessellation?: number;
  21858. arc?: number;
  21859. sideOrientation?: number;
  21860. frontUVs?: Vector4;
  21861. backUVs?: Vector4;
  21862. }): VertexData;
  21863. /**
  21864. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21865. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21866. * @param polygon a mesh built from polygonTriangulation.build()
  21867. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21868. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21869. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21870. * @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)
  21871. * @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)
  21872. * @returns the VertexData of the Polygon
  21873. */
  21874. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21875. /**
  21876. * Creates the VertexData of the IcoSphere
  21877. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21878. * * radius the radius of the IcoSphere, optional default 1
  21879. * * radiusX allows stretching in the x direction, optional, default radius
  21880. * * radiusY allows stretching in the y direction, optional, default radius
  21881. * * radiusZ allows stretching in the z direction, optional, default radius
  21882. * * flat when true creates a flat shaded mesh, optional, default true
  21883. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21885. * * 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)
  21886. * * 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)
  21887. * @returns the VertexData of the IcoSphere
  21888. */
  21889. static CreateIcoSphere(options: {
  21890. radius?: number;
  21891. radiusX?: number;
  21892. radiusY?: number;
  21893. radiusZ?: number;
  21894. flat?: boolean;
  21895. subdivisions?: number;
  21896. sideOrientation?: number;
  21897. frontUVs?: Vector4;
  21898. backUVs?: Vector4;
  21899. }): VertexData;
  21900. /**
  21901. * Creates the VertexData for a Polyhedron
  21902. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21903. * * type provided types are:
  21904. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21905. * * 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)
  21906. * * size the size of the IcoSphere, optional default 1
  21907. * * sizeX allows stretching in the x direction, optional, default size
  21908. * * sizeY allows stretching in the y direction, optional, default size
  21909. * * sizeZ allows stretching in the z direction, optional, default size
  21910. * * 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
  21911. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21912. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21913. * * flat when true creates a flat shaded mesh, optional, default true
  21914. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21916. * * 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)
  21917. * * 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)
  21918. * @returns the VertexData of the Polyhedron
  21919. */
  21920. static CreatePolyhedron(options: {
  21921. type?: number;
  21922. size?: number;
  21923. sizeX?: number;
  21924. sizeY?: number;
  21925. sizeZ?: number;
  21926. custom?: any;
  21927. faceUV?: Vector4[];
  21928. faceColors?: Color4[];
  21929. flat?: boolean;
  21930. sideOrientation?: number;
  21931. frontUVs?: Vector4;
  21932. backUVs?: Vector4;
  21933. }): VertexData;
  21934. /**
  21935. * Creates the VertexData for a TorusKnot
  21936. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21937. * * radius the radius of the torus knot, optional, default 2
  21938. * * tube the thickness of the tube, optional, default 0.5
  21939. * * radialSegments the number of sides on each tube segments, optional, default 32
  21940. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21941. * * p the number of windings around the z axis, optional, default 2
  21942. * * q the number of windings around the x axis, optional, default 3
  21943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21944. * * 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)
  21945. * * 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)
  21946. * @returns the VertexData of the Torus Knot
  21947. */
  21948. static CreateTorusKnot(options: {
  21949. radius?: number;
  21950. tube?: number;
  21951. radialSegments?: number;
  21952. tubularSegments?: number;
  21953. p?: number;
  21954. q?: number;
  21955. sideOrientation?: number;
  21956. frontUVs?: Vector4;
  21957. backUVs?: Vector4;
  21958. }): VertexData;
  21959. /**
  21960. * Compute normals for given positions and indices
  21961. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21962. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21963. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21964. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21965. * * facetNormals : optional array of facet normals (vector3)
  21966. * * facetPositions : optional array of facet positions (vector3)
  21967. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21968. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21969. * * bInfo : optional bounding info, required for facetPartitioning computation
  21970. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21971. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21972. * * useRightHandedSystem: optional boolean to for right handed system computation
  21973. * * depthSort : optional boolean to enable the facet depth sort computation
  21974. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21975. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21976. */
  21977. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21978. facetNormals?: any;
  21979. facetPositions?: any;
  21980. facetPartitioning?: any;
  21981. ratio?: number;
  21982. bInfo?: any;
  21983. bbSize?: Vector3;
  21984. subDiv?: any;
  21985. useRightHandedSystem?: boolean;
  21986. depthSort?: boolean;
  21987. distanceTo?: Vector3;
  21988. depthSortedFacets?: any;
  21989. }): void;
  21990. /** @hidden */
  21991. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21992. /**
  21993. * Applies VertexData created from the imported parameters to the geometry
  21994. * @param parsedVertexData the parsed data from an imported file
  21995. * @param geometry the geometry to apply the VertexData to
  21996. */
  21997. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21998. }
  21999. }
  22000. declare module BABYLON {
  22001. /**
  22002. * Defines a target to use with MorphTargetManager
  22003. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22004. */
  22005. export class MorphTarget implements IAnimatable {
  22006. /** defines the name of the target */
  22007. name: string;
  22008. /**
  22009. * Gets or sets the list of animations
  22010. */
  22011. animations: Animation[];
  22012. private _scene;
  22013. private _positions;
  22014. private _normals;
  22015. private _tangents;
  22016. private _uvs;
  22017. private _influence;
  22018. /**
  22019. * Observable raised when the influence changes
  22020. */
  22021. onInfluenceChanged: Observable<boolean>;
  22022. /** @hidden */
  22023. _onDataLayoutChanged: Observable<void>;
  22024. /**
  22025. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22026. */
  22027. influence: number;
  22028. /**
  22029. * Gets or sets the id of the morph Target
  22030. */
  22031. id: string;
  22032. private _animationPropertiesOverride;
  22033. /**
  22034. * Gets or sets the animation properties override
  22035. */
  22036. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22037. /**
  22038. * Creates a new MorphTarget
  22039. * @param name defines the name of the target
  22040. * @param influence defines the influence to use
  22041. * @param scene defines the scene the morphtarget belongs to
  22042. */
  22043. constructor(
  22044. /** defines the name of the target */
  22045. name: string, influence?: number, scene?: Nullable<Scene>);
  22046. /**
  22047. * Gets a boolean defining if the target contains position data
  22048. */
  22049. readonly hasPositions: boolean;
  22050. /**
  22051. * Gets a boolean defining if the target contains normal data
  22052. */
  22053. readonly hasNormals: boolean;
  22054. /**
  22055. * Gets a boolean defining if the target contains tangent data
  22056. */
  22057. readonly hasTangents: boolean;
  22058. /**
  22059. * Gets a boolean defining if the target contains texture coordinates data
  22060. */
  22061. readonly hasUVs: boolean;
  22062. /**
  22063. * Affects position data to this target
  22064. * @param data defines the position data to use
  22065. */
  22066. setPositions(data: Nullable<FloatArray>): void;
  22067. /**
  22068. * Gets the position data stored in this target
  22069. * @returns a FloatArray containing the position data (or null if not present)
  22070. */
  22071. getPositions(): Nullable<FloatArray>;
  22072. /**
  22073. * Affects normal data to this target
  22074. * @param data defines the normal data to use
  22075. */
  22076. setNormals(data: Nullable<FloatArray>): void;
  22077. /**
  22078. * Gets the normal data stored in this target
  22079. * @returns a FloatArray containing the normal data (or null if not present)
  22080. */
  22081. getNormals(): Nullable<FloatArray>;
  22082. /**
  22083. * Affects tangent data to this target
  22084. * @param data defines the tangent data to use
  22085. */
  22086. setTangents(data: Nullable<FloatArray>): void;
  22087. /**
  22088. * Gets the tangent data stored in this target
  22089. * @returns a FloatArray containing the tangent data (or null if not present)
  22090. */
  22091. getTangents(): Nullable<FloatArray>;
  22092. /**
  22093. * Affects texture coordinates data to this target
  22094. * @param data defines the texture coordinates data to use
  22095. */
  22096. setUVs(data: Nullable<FloatArray>): void;
  22097. /**
  22098. * Gets the texture coordinates data stored in this target
  22099. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22100. */
  22101. getUVs(): Nullable<FloatArray>;
  22102. /**
  22103. * Serializes the current target into a Serialization object
  22104. * @returns the serialized object
  22105. */
  22106. serialize(): any;
  22107. /**
  22108. * Returns the string "MorphTarget"
  22109. * @returns "MorphTarget"
  22110. */
  22111. getClassName(): string;
  22112. /**
  22113. * Creates a new target from serialized data
  22114. * @param serializationObject defines the serialized data to use
  22115. * @returns a new MorphTarget
  22116. */
  22117. static Parse(serializationObject: any): MorphTarget;
  22118. /**
  22119. * Creates a MorphTarget from mesh data
  22120. * @param mesh defines the source mesh
  22121. * @param name defines the name to use for the new target
  22122. * @param influence defines the influence to attach to the target
  22123. * @returns a new MorphTarget
  22124. */
  22125. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22126. }
  22127. }
  22128. declare module BABYLON {
  22129. /**
  22130. * This class is used to deform meshes using morphing between different targets
  22131. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22132. */
  22133. export class MorphTargetManager {
  22134. private _targets;
  22135. private _targetInfluenceChangedObservers;
  22136. private _targetDataLayoutChangedObservers;
  22137. private _activeTargets;
  22138. private _scene;
  22139. private _influences;
  22140. private _supportsNormals;
  22141. private _supportsTangents;
  22142. private _supportsUVs;
  22143. private _vertexCount;
  22144. private _uniqueId;
  22145. private _tempInfluences;
  22146. /**
  22147. * Gets or sets a boolean indicating if normals must be morphed
  22148. */
  22149. enableNormalMorphing: boolean;
  22150. /**
  22151. * Gets or sets a boolean indicating if tangents must be morphed
  22152. */
  22153. enableTangentMorphing: boolean;
  22154. /**
  22155. * Gets or sets a boolean indicating if UV must be morphed
  22156. */
  22157. enableUVMorphing: boolean;
  22158. /**
  22159. * Creates a new MorphTargetManager
  22160. * @param scene defines the current scene
  22161. */
  22162. constructor(scene?: Nullable<Scene>);
  22163. /**
  22164. * Gets the unique ID of this manager
  22165. */
  22166. readonly uniqueId: number;
  22167. /**
  22168. * Gets the number of vertices handled by this manager
  22169. */
  22170. readonly vertexCount: number;
  22171. /**
  22172. * Gets a boolean indicating if this manager supports morphing of normals
  22173. */
  22174. readonly supportsNormals: boolean;
  22175. /**
  22176. * Gets a boolean indicating if this manager supports morphing of tangents
  22177. */
  22178. readonly supportsTangents: boolean;
  22179. /**
  22180. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22181. */
  22182. readonly supportsUVs: boolean;
  22183. /**
  22184. * Gets the number of targets stored in this manager
  22185. */
  22186. readonly numTargets: number;
  22187. /**
  22188. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22189. */
  22190. readonly numInfluencers: number;
  22191. /**
  22192. * Gets the list of influences (one per target)
  22193. */
  22194. readonly influences: Float32Array;
  22195. /**
  22196. * Gets the active target at specified index. An active target is a target with an influence > 0
  22197. * @param index defines the index to check
  22198. * @returns the requested target
  22199. */
  22200. getActiveTarget(index: number): MorphTarget;
  22201. /**
  22202. * Gets the target at specified index
  22203. * @param index defines the index to check
  22204. * @returns the requested target
  22205. */
  22206. getTarget(index: number): MorphTarget;
  22207. /**
  22208. * Add a new target to this manager
  22209. * @param target defines the target to add
  22210. */
  22211. addTarget(target: MorphTarget): void;
  22212. /**
  22213. * Removes a target from the manager
  22214. * @param target defines the target to remove
  22215. */
  22216. removeTarget(target: MorphTarget): void;
  22217. /**
  22218. * Serializes the current manager into a Serialization object
  22219. * @returns the serialized object
  22220. */
  22221. serialize(): any;
  22222. private _syncActiveTargets;
  22223. /**
  22224. * Syncrhonize the targets with all the meshes using this morph target manager
  22225. */
  22226. synchronize(): void;
  22227. /**
  22228. * Creates a new MorphTargetManager from serialized data
  22229. * @param serializationObject defines the serialized data
  22230. * @param scene defines the hosting scene
  22231. * @returns the new MorphTargetManager
  22232. */
  22233. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22234. }
  22235. }
  22236. declare module BABYLON {
  22237. /**
  22238. * Class used to represent a specific level of detail of a mesh
  22239. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22240. */
  22241. export class MeshLODLevel {
  22242. /** Defines the distance where this level should start being displayed */
  22243. distance: number;
  22244. /** Defines the mesh to use to render this level */
  22245. mesh: Nullable<Mesh>;
  22246. /**
  22247. * Creates a new LOD level
  22248. * @param distance defines the distance where this level should star being displayed
  22249. * @param mesh defines the mesh to use to render this level
  22250. */
  22251. constructor(
  22252. /** Defines the distance where this level should start being displayed */
  22253. distance: number,
  22254. /** Defines the mesh to use to render this level */
  22255. mesh: Nullable<Mesh>);
  22256. }
  22257. }
  22258. declare module BABYLON {
  22259. /**
  22260. * Mesh representing the gorund
  22261. */
  22262. export class GroundMesh extends Mesh {
  22263. /** If octree should be generated */
  22264. generateOctree: boolean;
  22265. private _heightQuads;
  22266. /** @hidden */
  22267. _subdivisionsX: number;
  22268. /** @hidden */
  22269. _subdivisionsY: number;
  22270. /** @hidden */
  22271. _width: number;
  22272. /** @hidden */
  22273. _height: number;
  22274. /** @hidden */
  22275. _minX: number;
  22276. /** @hidden */
  22277. _maxX: number;
  22278. /** @hidden */
  22279. _minZ: number;
  22280. /** @hidden */
  22281. _maxZ: number;
  22282. constructor(name: string, scene: Scene);
  22283. /**
  22284. * "GroundMesh"
  22285. * @returns "GroundMesh"
  22286. */
  22287. getClassName(): string;
  22288. /**
  22289. * The minimum of x and y subdivisions
  22290. */
  22291. readonly subdivisions: number;
  22292. /**
  22293. * X subdivisions
  22294. */
  22295. readonly subdivisionsX: number;
  22296. /**
  22297. * Y subdivisions
  22298. */
  22299. readonly subdivisionsY: number;
  22300. /**
  22301. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22302. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22303. * @param chunksCount the number of subdivisions for x and y
  22304. * @param octreeBlocksSize (Default: 32)
  22305. */
  22306. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22307. /**
  22308. * Returns a height (y) value in the Worl system :
  22309. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22310. * @param x x coordinate
  22311. * @param z z coordinate
  22312. * @returns the ground y position if (x, z) are outside the ground surface.
  22313. */
  22314. getHeightAtCoordinates(x: number, z: number): number;
  22315. /**
  22316. * Returns a normalized vector (Vector3) orthogonal to the ground
  22317. * at the ground coordinates (x, z) expressed in the World system.
  22318. * @param x x coordinate
  22319. * @param z z coordinate
  22320. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22321. */
  22322. getNormalAtCoordinates(x: number, z: number): Vector3;
  22323. /**
  22324. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22325. * at the ground coordinates (x, z) expressed in the World system.
  22326. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22327. * @param x x coordinate
  22328. * @param z z coordinate
  22329. * @param ref vector to store the result
  22330. * @returns the GroundMesh.
  22331. */
  22332. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22333. /**
  22334. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22335. * if the ground has been updated.
  22336. * This can be used in the render loop.
  22337. * @returns the GroundMesh.
  22338. */
  22339. updateCoordinateHeights(): GroundMesh;
  22340. private _getFacetAt;
  22341. private _initHeightQuads;
  22342. private _computeHeightQuads;
  22343. /**
  22344. * Serializes this ground mesh
  22345. * @param serializationObject object to write serialization to
  22346. */
  22347. serialize(serializationObject: any): void;
  22348. /**
  22349. * Parses a serialized ground mesh
  22350. * @param parsedMesh the serialized mesh
  22351. * @param scene the scene to create the ground mesh in
  22352. * @returns the created ground mesh
  22353. */
  22354. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22355. }
  22356. }
  22357. declare module BABYLON {
  22358. /**
  22359. * Interface for Physics-Joint data
  22360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22361. */
  22362. export interface PhysicsJointData {
  22363. /**
  22364. * The main pivot of the joint
  22365. */
  22366. mainPivot?: Vector3;
  22367. /**
  22368. * The connected pivot of the joint
  22369. */
  22370. connectedPivot?: Vector3;
  22371. /**
  22372. * The main axis of the joint
  22373. */
  22374. mainAxis?: Vector3;
  22375. /**
  22376. * The connected axis of the joint
  22377. */
  22378. connectedAxis?: Vector3;
  22379. /**
  22380. * The collision of the joint
  22381. */
  22382. collision?: boolean;
  22383. /**
  22384. * Native Oimo/Cannon/Energy data
  22385. */
  22386. nativeParams?: any;
  22387. }
  22388. /**
  22389. * This is a holder class for the physics joint created by the physics plugin
  22390. * It holds a set of functions to control the underlying joint
  22391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22392. */
  22393. export class PhysicsJoint {
  22394. /**
  22395. * The type of the physics joint
  22396. */
  22397. type: number;
  22398. /**
  22399. * The data for the physics joint
  22400. */
  22401. jointData: PhysicsJointData;
  22402. private _physicsJoint;
  22403. protected _physicsPlugin: IPhysicsEnginePlugin;
  22404. /**
  22405. * Initializes the physics joint
  22406. * @param type The type of the physics joint
  22407. * @param jointData The data for the physics joint
  22408. */
  22409. constructor(
  22410. /**
  22411. * The type of the physics joint
  22412. */
  22413. type: number,
  22414. /**
  22415. * The data for the physics joint
  22416. */
  22417. jointData: PhysicsJointData);
  22418. /**
  22419. * Gets the physics joint
  22420. */
  22421. /**
  22422. * Sets the physics joint
  22423. */
  22424. physicsJoint: any;
  22425. /**
  22426. * Sets the physics plugin
  22427. */
  22428. physicsPlugin: IPhysicsEnginePlugin;
  22429. /**
  22430. * Execute a function that is physics-plugin specific.
  22431. * @param {Function} func the function that will be executed.
  22432. * It accepts two parameters: the physics world and the physics joint
  22433. */
  22434. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22435. /**
  22436. * Distance-Joint type
  22437. */
  22438. static DistanceJoint: number;
  22439. /**
  22440. * Hinge-Joint type
  22441. */
  22442. static HingeJoint: number;
  22443. /**
  22444. * Ball-and-Socket joint type
  22445. */
  22446. static BallAndSocketJoint: number;
  22447. /**
  22448. * Wheel-Joint type
  22449. */
  22450. static WheelJoint: number;
  22451. /**
  22452. * Slider-Joint type
  22453. */
  22454. static SliderJoint: number;
  22455. /**
  22456. * Prismatic-Joint type
  22457. */
  22458. static PrismaticJoint: number;
  22459. /**
  22460. * Universal-Joint type
  22461. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22462. */
  22463. static UniversalJoint: number;
  22464. /**
  22465. * Hinge-Joint 2 type
  22466. */
  22467. static Hinge2Joint: number;
  22468. /**
  22469. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22470. */
  22471. static PointToPointJoint: number;
  22472. /**
  22473. * Spring-Joint type
  22474. */
  22475. static SpringJoint: number;
  22476. /**
  22477. * Lock-Joint type
  22478. */
  22479. static LockJoint: number;
  22480. }
  22481. /**
  22482. * A class representing a physics distance joint
  22483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22484. */
  22485. export class DistanceJoint extends PhysicsJoint {
  22486. /**
  22487. *
  22488. * @param jointData The data for the Distance-Joint
  22489. */
  22490. constructor(jointData: DistanceJointData);
  22491. /**
  22492. * Update the predefined distance.
  22493. * @param maxDistance The maximum preferred distance
  22494. * @param minDistance The minimum preferred distance
  22495. */
  22496. updateDistance(maxDistance: number, minDistance?: number): void;
  22497. }
  22498. /**
  22499. * Represents a Motor-Enabled Joint
  22500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22501. */
  22502. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22503. /**
  22504. * Initializes the Motor-Enabled Joint
  22505. * @param type The type of the joint
  22506. * @param jointData The physica joint data for the joint
  22507. */
  22508. constructor(type: number, jointData: PhysicsJointData);
  22509. /**
  22510. * Set the motor values.
  22511. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22512. * @param force the force to apply
  22513. * @param maxForce max force for this motor.
  22514. */
  22515. setMotor(force?: number, maxForce?: number): void;
  22516. /**
  22517. * Set the motor's limits.
  22518. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22519. * @param upperLimit The upper limit of the motor
  22520. * @param lowerLimit The lower limit of the motor
  22521. */
  22522. setLimit(upperLimit: number, lowerLimit?: number): void;
  22523. }
  22524. /**
  22525. * This class represents a single physics Hinge-Joint
  22526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22527. */
  22528. export class HingeJoint extends MotorEnabledJoint {
  22529. /**
  22530. * Initializes the Hinge-Joint
  22531. * @param jointData The joint data for the Hinge-Joint
  22532. */
  22533. constructor(jointData: PhysicsJointData);
  22534. /**
  22535. * Set the motor values.
  22536. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22537. * @param {number} force the force to apply
  22538. * @param {number} maxForce max force for this motor.
  22539. */
  22540. setMotor(force?: number, maxForce?: number): void;
  22541. /**
  22542. * Set the motor's limits.
  22543. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22544. * @param upperLimit The upper limit of the motor
  22545. * @param lowerLimit The lower limit of the motor
  22546. */
  22547. setLimit(upperLimit: number, lowerLimit?: number): void;
  22548. }
  22549. /**
  22550. * This class represents a dual hinge physics joint (same as wheel joint)
  22551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22552. */
  22553. export class Hinge2Joint extends MotorEnabledJoint {
  22554. /**
  22555. * Initializes the Hinge2-Joint
  22556. * @param jointData The joint data for the Hinge2-Joint
  22557. */
  22558. constructor(jointData: PhysicsJointData);
  22559. /**
  22560. * Set the motor values.
  22561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22562. * @param {number} targetSpeed the speed the motor is to reach
  22563. * @param {number} maxForce max force for this motor.
  22564. * @param {motorIndex} the motor's index, 0 or 1.
  22565. */
  22566. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22567. /**
  22568. * Set the motor limits.
  22569. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22570. * @param {number} upperLimit the upper limit
  22571. * @param {number} lowerLimit lower limit
  22572. * @param {motorIndex} the motor's index, 0 or 1.
  22573. */
  22574. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22575. }
  22576. /**
  22577. * Interface for a motor enabled joint
  22578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22579. */
  22580. export interface IMotorEnabledJoint {
  22581. /**
  22582. * Physics joint
  22583. */
  22584. physicsJoint: any;
  22585. /**
  22586. * Sets the motor of the motor-enabled joint
  22587. * @param force The force of the motor
  22588. * @param maxForce The maximum force of the motor
  22589. * @param motorIndex The index of the motor
  22590. */
  22591. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22592. /**
  22593. * Sets the limit of the motor
  22594. * @param upperLimit The upper limit of the motor
  22595. * @param lowerLimit The lower limit of the motor
  22596. * @param motorIndex The index of the motor
  22597. */
  22598. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22599. }
  22600. /**
  22601. * Joint data for a Distance-Joint
  22602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22603. */
  22604. export interface DistanceJointData extends PhysicsJointData {
  22605. /**
  22606. * Max distance the 2 joint objects can be apart
  22607. */
  22608. maxDistance: number;
  22609. }
  22610. /**
  22611. * Joint data from a spring joint
  22612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22613. */
  22614. export interface SpringJointData extends PhysicsJointData {
  22615. /**
  22616. * Length of the spring
  22617. */
  22618. length: number;
  22619. /**
  22620. * Stiffness of the spring
  22621. */
  22622. stiffness: number;
  22623. /**
  22624. * Damping of the spring
  22625. */
  22626. damping: number;
  22627. /** this callback will be called when applying the force to the impostors. */
  22628. forceApplicationCallback: () => void;
  22629. }
  22630. }
  22631. declare module BABYLON {
  22632. /**
  22633. * Holds the data for the raycast result
  22634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22635. */
  22636. export class PhysicsRaycastResult {
  22637. private _hasHit;
  22638. private _hitDistance;
  22639. private _hitNormalWorld;
  22640. private _hitPointWorld;
  22641. private _rayFromWorld;
  22642. private _rayToWorld;
  22643. /**
  22644. * Gets if there was a hit
  22645. */
  22646. readonly hasHit: boolean;
  22647. /**
  22648. * Gets the distance from the hit
  22649. */
  22650. readonly hitDistance: number;
  22651. /**
  22652. * Gets the hit normal/direction in the world
  22653. */
  22654. readonly hitNormalWorld: Vector3;
  22655. /**
  22656. * Gets the hit point in the world
  22657. */
  22658. readonly hitPointWorld: Vector3;
  22659. /**
  22660. * Gets the ray "start point" of the ray in the world
  22661. */
  22662. readonly rayFromWorld: Vector3;
  22663. /**
  22664. * Gets the ray "end point" of the ray in the world
  22665. */
  22666. readonly rayToWorld: Vector3;
  22667. /**
  22668. * Sets the hit data (normal & point in world space)
  22669. * @param hitNormalWorld defines the normal in world space
  22670. * @param hitPointWorld defines the point in world space
  22671. */
  22672. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22673. /**
  22674. * Sets the distance from the start point to the hit point
  22675. * @param distance
  22676. */
  22677. setHitDistance(distance: number): void;
  22678. /**
  22679. * Calculates the distance manually
  22680. */
  22681. calculateHitDistance(): void;
  22682. /**
  22683. * Resets all the values to default
  22684. * @param from The from point on world space
  22685. * @param to The to point on world space
  22686. */
  22687. reset(from?: Vector3, to?: Vector3): void;
  22688. }
  22689. /**
  22690. * Interface for the size containing width and height
  22691. */
  22692. interface IXYZ {
  22693. /**
  22694. * X
  22695. */
  22696. x: number;
  22697. /**
  22698. * Y
  22699. */
  22700. y: number;
  22701. /**
  22702. * Z
  22703. */
  22704. z: number;
  22705. }
  22706. }
  22707. declare module BABYLON {
  22708. /**
  22709. * Interface used to describe a physics joint
  22710. */
  22711. export interface PhysicsImpostorJoint {
  22712. /** Defines the main impostor to which the joint is linked */
  22713. mainImpostor: PhysicsImpostor;
  22714. /** Defines the impostor that is connected to the main impostor using this joint */
  22715. connectedImpostor: PhysicsImpostor;
  22716. /** Defines the joint itself */
  22717. joint: PhysicsJoint;
  22718. }
  22719. /** @hidden */
  22720. export interface IPhysicsEnginePlugin {
  22721. world: any;
  22722. name: string;
  22723. setGravity(gravity: Vector3): void;
  22724. setTimeStep(timeStep: number): void;
  22725. getTimeStep(): number;
  22726. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22727. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22728. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22729. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22730. removePhysicsBody(impostor: PhysicsImpostor): void;
  22731. generateJoint(joint: PhysicsImpostorJoint): void;
  22732. removeJoint(joint: PhysicsImpostorJoint): void;
  22733. isSupported(): boolean;
  22734. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22735. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22736. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22737. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22738. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22739. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22740. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22741. getBodyMass(impostor: PhysicsImpostor): number;
  22742. getBodyFriction(impostor: PhysicsImpostor): number;
  22743. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22744. getBodyRestitution(impostor: PhysicsImpostor): number;
  22745. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22746. getBodyPressure?(impostor: PhysicsImpostor): number;
  22747. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22748. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22749. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22750. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22751. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22752. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22753. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22754. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22755. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22756. sleepBody(impostor: PhysicsImpostor): void;
  22757. wakeUpBody(impostor: PhysicsImpostor): void;
  22758. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22759. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22760. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22761. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22762. getRadius(impostor: PhysicsImpostor): number;
  22763. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22764. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22765. dispose(): void;
  22766. }
  22767. /**
  22768. * Interface used to define a physics engine
  22769. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22770. */
  22771. export interface IPhysicsEngine {
  22772. /**
  22773. * Gets the gravity vector used by the simulation
  22774. */
  22775. gravity: Vector3;
  22776. /**
  22777. * Sets the gravity vector used by the simulation
  22778. * @param gravity defines the gravity vector to use
  22779. */
  22780. setGravity(gravity: Vector3): void;
  22781. /**
  22782. * Set the time step of the physics engine.
  22783. * Default is 1/60.
  22784. * To slow it down, enter 1/600 for example.
  22785. * To speed it up, 1/30
  22786. * @param newTimeStep the new timestep to apply to this world.
  22787. */
  22788. setTimeStep(newTimeStep: number): void;
  22789. /**
  22790. * Get the time step of the physics engine.
  22791. * @returns the current time step
  22792. */
  22793. getTimeStep(): number;
  22794. /**
  22795. * Release all resources
  22796. */
  22797. dispose(): void;
  22798. /**
  22799. * Gets the name of the current physics plugin
  22800. * @returns the name of the plugin
  22801. */
  22802. getPhysicsPluginName(): string;
  22803. /**
  22804. * Adding a new impostor for the impostor tracking.
  22805. * This will be done by the impostor itself.
  22806. * @param impostor the impostor to add
  22807. */
  22808. addImpostor(impostor: PhysicsImpostor): void;
  22809. /**
  22810. * Remove an impostor from the engine.
  22811. * This impostor and its mesh will not longer be updated by the physics engine.
  22812. * @param impostor the impostor to remove
  22813. */
  22814. removeImpostor(impostor: PhysicsImpostor): void;
  22815. /**
  22816. * Add a joint to the physics engine
  22817. * @param mainImpostor defines the main impostor to which the joint is added.
  22818. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22819. * @param joint defines the joint that will connect both impostors.
  22820. */
  22821. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22822. /**
  22823. * Removes a joint from the simulation
  22824. * @param mainImpostor defines the impostor used with the joint
  22825. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22826. * @param joint defines the joint to remove
  22827. */
  22828. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22829. /**
  22830. * Gets the current plugin used to run the simulation
  22831. * @returns current plugin
  22832. */
  22833. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22834. /**
  22835. * Gets the list of physic impostors
  22836. * @returns an array of PhysicsImpostor
  22837. */
  22838. getImpostors(): Array<PhysicsImpostor>;
  22839. /**
  22840. * Gets the impostor for a physics enabled object
  22841. * @param object defines the object impersonated by the impostor
  22842. * @returns the PhysicsImpostor or null if not found
  22843. */
  22844. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22845. /**
  22846. * Gets the impostor for a physics body object
  22847. * @param body defines physics body used by the impostor
  22848. * @returns the PhysicsImpostor or null if not found
  22849. */
  22850. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22851. /**
  22852. * Does a raycast in the physics world
  22853. * @param from when should the ray start?
  22854. * @param to when should the ray end?
  22855. * @returns PhysicsRaycastResult
  22856. */
  22857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22858. /**
  22859. * Called by the scene. No need to call it.
  22860. * @param delta defines the timespam between frames
  22861. */
  22862. _step(delta: number): void;
  22863. }
  22864. }
  22865. declare module BABYLON {
  22866. /**
  22867. * The interface for the physics imposter parameters
  22868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22869. */
  22870. export interface PhysicsImpostorParameters {
  22871. /**
  22872. * The mass of the physics imposter
  22873. */
  22874. mass: number;
  22875. /**
  22876. * The friction of the physics imposter
  22877. */
  22878. friction?: number;
  22879. /**
  22880. * The coefficient of restitution of the physics imposter
  22881. */
  22882. restitution?: number;
  22883. /**
  22884. * The native options of the physics imposter
  22885. */
  22886. nativeOptions?: any;
  22887. /**
  22888. * Specifies if the parent should be ignored
  22889. */
  22890. ignoreParent?: boolean;
  22891. /**
  22892. * Specifies if bi-directional transformations should be disabled
  22893. */
  22894. disableBidirectionalTransformation?: boolean;
  22895. /**
  22896. * The pressure inside the physics imposter, soft object only
  22897. */
  22898. pressure?: number;
  22899. /**
  22900. * The stiffness the physics imposter, soft object only
  22901. */
  22902. stiffness?: number;
  22903. /**
  22904. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22905. */
  22906. velocityIterations?: number;
  22907. /**
  22908. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22909. */
  22910. positionIterations?: number;
  22911. /**
  22912. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22913. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22914. * Add to fix multiple points
  22915. */
  22916. fixedPoints?: number;
  22917. /**
  22918. * The collision margin around a soft object
  22919. */
  22920. margin?: number;
  22921. /**
  22922. * The collision margin around a soft object
  22923. */
  22924. damping?: number;
  22925. /**
  22926. * The path for a rope based on an extrusion
  22927. */
  22928. path?: any;
  22929. /**
  22930. * The shape of an extrusion used for a rope based on an extrusion
  22931. */
  22932. shape?: any;
  22933. }
  22934. /**
  22935. * Interface for a physics-enabled object
  22936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22937. */
  22938. export interface IPhysicsEnabledObject {
  22939. /**
  22940. * The position of the physics-enabled object
  22941. */
  22942. position: Vector3;
  22943. /**
  22944. * The rotation of the physics-enabled object
  22945. */
  22946. rotationQuaternion: Nullable<Quaternion>;
  22947. /**
  22948. * The scale of the physics-enabled object
  22949. */
  22950. scaling: Vector3;
  22951. /**
  22952. * The rotation of the physics-enabled object
  22953. */
  22954. rotation?: Vector3;
  22955. /**
  22956. * The parent of the physics-enabled object
  22957. */
  22958. parent?: any;
  22959. /**
  22960. * The bounding info of the physics-enabled object
  22961. * @returns The bounding info of the physics-enabled object
  22962. */
  22963. getBoundingInfo(): BoundingInfo;
  22964. /**
  22965. * Computes the world matrix
  22966. * @param force Specifies if the world matrix should be computed by force
  22967. * @returns A world matrix
  22968. */
  22969. computeWorldMatrix(force: boolean): Matrix;
  22970. /**
  22971. * Gets the world matrix
  22972. * @returns A world matrix
  22973. */
  22974. getWorldMatrix?(): Matrix;
  22975. /**
  22976. * Gets the child meshes
  22977. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22978. * @returns An array of abstract meshes
  22979. */
  22980. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22981. /**
  22982. * Gets the vertex data
  22983. * @param kind The type of vertex data
  22984. * @returns A nullable array of numbers, or a float32 array
  22985. */
  22986. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22987. /**
  22988. * Gets the indices from the mesh
  22989. * @returns A nullable array of index arrays
  22990. */
  22991. getIndices?(): Nullable<IndicesArray>;
  22992. /**
  22993. * Gets the scene from the mesh
  22994. * @returns the indices array or null
  22995. */
  22996. getScene?(): Scene;
  22997. /**
  22998. * Gets the absolute position from the mesh
  22999. * @returns the absolute position
  23000. */
  23001. getAbsolutePosition(): Vector3;
  23002. /**
  23003. * Gets the absolute pivot point from the mesh
  23004. * @returns the absolute pivot point
  23005. */
  23006. getAbsolutePivotPoint(): Vector3;
  23007. /**
  23008. * Rotates the mesh
  23009. * @param axis The axis of rotation
  23010. * @param amount The amount of rotation
  23011. * @param space The space of the rotation
  23012. * @returns The rotation transform node
  23013. */
  23014. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23015. /**
  23016. * Translates the mesh
  23017. * @param axis The axis of translation
  23018. * @param distance The distance of translation
  23019. * @param space The space of the translation
  23020. * @returns The transform node
  23021. */
  23022. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23023. /**
  23024. * Sets the absolute position of the mesh
  23025. * @param absolutePosition The absolute position of the mesh
  23026. * @returns The transform node
  23027. */
  23028. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23029. /**
  23030. * Gets the class name of the mesh
  23031. * @returns The class name
  23032. */
  23033. getClassName(): string;
  23034. }
  23035. /**
  23036. * Represents a physics imposter
  23037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23038. */
  23039. export class PhysicsImpostor {
  23040. /**
  23041. * The physics-enabled object used as the physics imposter
  23042. */
  23043. object: IPhysicsEnabledObject;
  23044. /**
  23045. * The type of the physics imposter
  23046. */
  23047. type: number;
  23048. private _options;
  23049. private _scene?;
  23050. /**
  23051. * The default object size of the imposter
  23052. */
  23053. static DEFAULT_OBJECT_SIZE: Vector3;
  23054. /**
  23055. * The identity quaternion of the imposter
  23056. */
  23057. static IDENTITY_QUATERNION: Quaternion;
  23058. /** @hidden */
  23059. _pluginData: any;
  23060. private _physicsEngine;
  23061. private _physicsBody;
  23062. private _bodyUpdateRequired;
  23063. private _onBeforePhysicsStepCallbacks;
  23064. private _onAfterPhysicsStepCallbacks;
  23065. /** @hidden */
  23066. _onPhysicsCollideCallbacks: Array<{
  23067. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23068. otherImpostors: Array<PhysicsImpostor>;
  23069. }>;
  23070. private _deltaPosition;
  23071. private _deltaRotation;
  23072. private _deltaRotationConjugated;
  23073. /** @hidden */
  23074. _isFromLine: boolean;
  23075. private _parent;
  23076. private _isDisposed;
  23077. private static _tmpVecs;
  23078. private static _tmpQuat;
  23079. /**
  23080. * Specifies if the physics imposter is disposed
  23081. */
  23082. readonly isDisposed: boolean;
  23083. /**
  23084. * Gets the mass of the physics imposter
  23085. */
  23086. mass: number;
  23087. /**
  23088. * Gets the coefficient of friction
  23089. */
  23090. /**
  23091. * Sets the coefficient of friction
  23092. */
  23093. friction: number;
  23094. /**
  23095. * Gets the coefficient of restitution
  23096. */
  23097. /**
  23098. * Sets the coefficient of restitution
  23099. */
  23100. restitution: number;
  23101. /**
  23102. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23103. */
  23104. /**
  23105. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23106. */
  23107. pressure: number;
  23108. /**
  23109. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23110. */
  23111. /**
  23112. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23113. */
  23114. stiffness: number;
  23115. /**
  23116. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23117. */
  23118. /**
  23119. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23120. */
  23121. velocityIterations: number;
  23122. /**
  23123. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23124. */
  23125. /**
  23126. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23127. */
  23128. positionIterations: number;
  23129. /**
  23130. * The unique id of the physics imposter
  23131. * set by the physics engine when adding this impostor to the array
  23132. */
  23133. uniqueId: number;
  23134. /**
  23135. * @hidden
  23136. */
  23137. soft: boolean;
  23138. /**
  23139. * @hidden
  23140. */
  23141. segments: number;
  23142. private _joints;
  23143. /**
  23144. * Initializes the physics imposter
  23145. * @param object The physics-enabled object used as the physics imposter
  23146. * @param type The type of the physics imposter
  23147. * @param _options The options for the physics imposter
  23148. * @param _scene The Babylon scene
  23149. */
  23150. constructor(
  23151. /**
  23152. * The physics-enabled object used as the physics imposter
  23153. */
  23154. object: IPhysicsEnabledObject,
  23155. /**
  23156. * The type of the physics imposter
  23157. */
  23158. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23159. /**
  23160. * This function will completly initialize this impostor.
  23161. * It will create a new body - but only if this mesh has no parent.
  23162. * If it has, this impostor will not be used other than to define the impostor
  23163. * of the child mesh.
  23164. * @hidden
  23165. */
  23166. _init(): void;
  23167. private _getPhysicsParent;
  23168. /**
  23169. * Should a new body be generated.
  23170. * @returns boolean specifying if body initialization is required
  23171. */
  23172. isBodyInitRequired(): boolean;
  23173. /**
  23174. * Sets the updated scaling
  23175. * @param updated Specifies if the scaling is updated
  23176. */
  23177. setScalingUpdated(): void;
  23178. /**
  23179. * Force a regeneration of this or the parent's impostor's body.
  23180. * Use under cautious - This will remove all joints already implemented.
  23181. */
  23182. forceUpdate(): void;
  23183. /**
  23184. * Gets the body that holds this impostor. Either its own, or its parent.
  23185. */
  23186. /**
  23187. * Set the physics body. Used mainly by the physics engine/plugin
  23188. */
  23189. physicsBody: any;
  23190. /**
  23191. * Get the parent of the physics imposter
  23192. * @returns Physics imposter or null
  23193. */
  23194. /**
  23195. * Sets the parent of the physics imposter
  23196. */
  23197. parent: Nullable<PhysicsImpostor>;
  23198. /**
  23199. * Resets the update flags
  23200. */
  23201. resetUpdateFlags(): void;
  23202. /**
  23203. * Gets the object extend size
  23204. * @returns the object extend size
  23205. */
  23206. getObjectExtendSize(): Vector3;
  23207. /**
  23208. * Gets the object center
  23209. * @returns The object center
  23210. */
  23211. getObjectCenter(): Vector3;
  23212. /**
  23213. * Get a specific parametes from the options parameter
  23214. * @param paramName The object parameter name
  23215. * @returns The object parameter
  23216. */
  23217. getParam(paramName: string): any;
  23218. /**
  23219. * Sets a specific parameter in the options given to the physics plugin
  23220. * @param paramName The parameter name
  23221. * @param value The value of the parameter
  23222. */
  23223. setParam(paramName: string, value: number): void;
  23224. /**
  23225. * Specifically change the body's mass option. Won't recreate the physics body object
  23226. * @param mass The mass of the physics imposter
  23227. */
  23228. setMass(mass: number): void;
  23229. /**
  23230. * Gets the linear velocity
  23231. * @returns linear velocity or null
  23232. */
  23233. getLinearVelocity(): Nullable<Vector3>;
  23234. /**
  23235. * Sets the linear velocity
  23236. * @param velocity linear velocity or null
  23237. */
  23238. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23239. /**
  23240. * Gets the angular velocity
  23241. * @returns angular velocity or null
  23242. */
  23243. getAngularVelocity(): Nullable<Vector3>;
  23244. /**
  23245. * Sets the angular velocity
  23246. * @param velocity The velocity or null
  23247. */
  23248. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23249. /**
  23250. * Execute a function with the physics plugin native code
  23251. * Provide a function the will have two variables - the world object and the physics body object
  23252. * @param func The function to execute with the physics plugin native code
  23253. */
  23254. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23255. /**
  23256. * Register a function that will be executed before the physics world is stepping forward
  23257. * @param func The function to execute before the physics world is stepped forward
  23258. */
  23259. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23260. /**
  23261. * Unregister a function that will be executed before the physics world is stepping forward
  23262. * @param func The function to execute before the physics world is stepped forward
  23263. */
  23264. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23265. /**
  23266. * Register a function that will be executed after the physics step
  23267. * @param func The function to execute after physics step
  23268. */
  23269. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23270. /**
  23271. * Unregisters a function that will be executed after the physics step
  23272. * @param func The function to execute after physics step
  23273. */
  23274. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23275. /**
  23276. * register a function that will be executed when this impostor collides against a different body
  23277. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23278. * @param func Callback that is executed on collision
  23279. */
  23280. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23281. /**
  23282. * Unregisters the physics imposter on contact
  23283. * @param collideAgainst The physics object to collide against
  23284. * @param func Callback to execute on collision
  23285. */
  23286. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23287. private _tmpQuat;
  23288. private _tmpQuat2;
  23289. /**
  23290. * Get the parent rotation
  23291. * @returns The parent rotation
  23292. */
  23293. getParentsRotation(): Quaternion;
  23294. /**
  23295. * this function is executed by the physics engine.
  23296. */
  23297. beforeStep: () => void;
  23298. /**
  23299. * this function is executed by the physics engine
  23300. */
  23301. afterStep: () => void;
  23302. /**
  23303. * Legacy collision detection event support
  23304. */
  23305. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23306. /**
  23307. * event and body object due to cannon's event-based architecture.
  23308. */
  23309. onCollide: (e: {
  23310. body: any;
  23311. }) => void;
  23312. /**
  23313. * Apply a force
  23314. * @param force The force to apply
  23315. * @param contactPoint The contact point for the force
  23316. * @returns The physics imposter
  23317. */
  23318. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23319. /**
  23320. * Apply an impulse
  23321. * @param force The impulse force
  23322. * @param contactPoint The contact point for the impulse force
  23323. * @returns The physics imposter
  23324. */
  23325. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23326. /**
  23327. * A help function to create a joint
  23328. * @param otherImpostor A physics imposter used to create a joint
  23329. * @param jointType The type of joint
  23330. * @param jointData The data for the joint
  23331. * @returns The physics imposter
  23332. */
  23333. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23334. /**
  23335. * Add a joint to this impostor with a different impostor
  23336. * @param otherImpostor A physics imposter used to add a joint
  23337. * @param joint The joint to add
  23338. * @returns The physics imposter
  23339. */
  23340. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23341. /**
  23342. * Add an anchor to a cloth impostor
  23343. * @param otherImpostor rigid impostor to anchor to
  23344. * @param width ratio across width from 0 to 1
  23345. * @param height ratio up height from 0 to 1
  23346. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23347. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23348. * @returns impostor the soft imposter
  23349. */
  23350. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23351. /**
  23352. * Add a hook to a rope impostor
  23353. * @param otherImpostor rigid impostor to anchor to
  23354. * @param length ratio across rope from 0 to 1
  23355. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23356. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23357. * @returns impostor the rope imposter
  23358. */
  23359. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23360. /**
  23361. * Will keep this body still, in a sleep mode.
  23362. * @returns the physics imposter
  23363. */
  23364. sleep(): PhysicsImpostor;
  23365. /**
  23366. * Wake the body up.
  23367. * @returns The physics imposter
  23368. */
  23369. wakeUp(): PhysicsImpostor;
  23370. /**
  23371. * Clones the physics imposter
  23372. * @param newObject The physics imposter clones to this physics-enabled object
  23373. * @returns A nullable physics imposter
  23374. */
  23375. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23376. /**
  23377. * Disposes the physics imposter
  23378. */
  23379. dispose(): void;
  23380. /**
  23381. * Sets the delta position
  23382. * @param position The delta position amount
  23383. */
  23384. setDeltaPosition(position: Vector3): void;
  23385. /**
  23386. * Sets the delta rotation
  23387. * @param rotation The delta rotation amount
  23388. */
  23389. setDeltaRotation(rotation: Quaternion): void;
  23390. /**
  23391. * Gets the box size of the physics imposter and stores the result in the input parameter
  23392. * @param result Stores the box size
  23393. * @returns The physics imposter
  23394. */
  23395. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23396. /**
  23397. * Gets the radius of the physics imposter
  23398. * @returns Radius of the physics imposter
  23399. */
  23400. getRadius(): number;
  23401. /**
  23402. * Sync a bone with this impostor
  23403. * @param bone The bone to sync to the impostor.
  23404. * @param boneMesh The mesh that the bone is influencing.
  23405. * @param jointPivot The pivot of the joint / bone in local space.
  23406. * @param distToJoint Optional distance from the impostor to the joint.
  23407. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23408. */
  23409. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23410. /**
  23411. * Sync impostor to a bone
  23412. * @param bone The bone that the impostor will be synced to.
  23413. * @param boneMesh The mesh that the bone is influencing.
  23414. * @param jointPivot The pivot of the joint / bone in local space.
  23415. * @param distToJoint Optional distance from the impostor to the joint.
  23416. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23417. * @param boneAxis Optional vector3 axis the bone is aligned with
  23418. */
  23419. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23420. /**
  23421. * No-Imposter type
  23422. */
  23423. static NoImpostor: number;
  23424. /**
  23425. * Sphere-Imposter type
  23426. */
  23427. static SphereImpostor: number;
  23428. /**
  23429. * Box-Imposter type
  23430. */
  23431. static BoxImpostor: number;
  23432. /**
  23433. * Plane-Imposter type
  23434. */
  23435. static PlaneImpostor: number;
  23436. /**
  23437. * Mesh-imposter type
  23438. */
  23439. static MeshImpostor: number;
  23440. /**
  23441. * Capsule-Impostor type (Ammo.js plugin only)
  23442. */
  23443. static CapsuleImpostor: number;
  23444. /**
  23445. * Cylinder-Imposter type
  23446. */
  23447. static CylinderImpostor: number;
  23448. /**
  23449. * Particle-Imposter type
  23450. */
  23451. static ParticleImpostor: number;
  23452. /**
  23453. * Heightmap-Imposter type
  23454. */
  23455. static HeightmapImpostor: number;
  23456. /**
  23457. * ConvexHull-Impostor type (Ammo.js plugin only)
  23458. */
  23459. static ConvexHullImpostor: number;
  23460. /**
  23461. * Rope-Imposter type
  23462. */
  23463. static RopeImpostor: number;
  23464. /**
  23465. * Cloth-Imposter type
  23466. */
  23467. static ClothImpostor: number;
  23468. /**
  23469. * Softbody-Imposter type
  23470. */
  23471. static SoftbodyImpostor: number;
  23472. }
  23473. }
  23474. declare module BABYLON {
  23475. /**
  23476. * @hidden
  23477. **/
  23478. export class _CreationDataStorage {
  23479. closePath?: boolean;
  23480. closeArray?: boolean;
  23481. idx: number[];
  23482. dashSize: number;
  23483. gapSize: number;
  23484. path3D: Path3D;
  23485. pathArray: Vector3[][];
  23486. arc: number;
  23487. radius: number;
  23488. cap: number;
  23489. tessellation: number;
  23490. }
  23491. /**
  23492. * @hidden
  23493. **/
  23494. class _InstanceDataStorage {
  23495. visibleInstances: any;
  23496. batchCache: _InstancesBatch;
  23497. instancesBufferSize: number;
  23498. instancesBuffer: Nullable<Buffer>;
  23499. instancesData: Float32Array;
  23500. overridenInstanceCount: number;
  23501. isFrozen: boolean;
  23502. previousBatch: Nullable<_InstancesBatch>;
  23503. hardwareInstancedRendering: boolean;
  23504. sideOrientation: number;
  23505. }
  23506. /**
  23507. * @hidden
  23508. **/
  23509. export class _InstancesBatch {
  23510. mustReturn: boolean;
  23511. visibleInstances: Nullable<InstancedMesh[]>[];
  23512. renderSelf: boolean[];
  23513. hardwareInstancedRendering: boolean[];
  23514. }
  23515. /**
  23516. * Class used to represent renderable models
  23517. */
  23518. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23519. /**
  23520. * Mesh side orientation : usually the external or front surface
  23521. */
  23522. static readonly FRONTSIDE: number;
  23523. /**
  23524. * Mesh side orientation : usually the internal or back surface
  23525. */
  23526. static readonly BACKSIDE: number;
  23527. /**
  23528. * Mesh side orientation : both internal and external or front and back surfaces
  23529. */
  23530. static readonly DOUBLESIDE: number;
  23531. /**
  23532. * Mesh side orientation : by default, `FRONTSIDE`
  23533. */
  23534. static readonly DEFAULTSIDE: number;
  23535. /**
  23536. * Mesh cap setting : no cap
  23537. */
  23538. static readonly NO_CAP: number;
  23539. /**
  23540. * Mesh cap setting : one cap at the beginning of the mesh
  23541. */
  23542. static readonly CAP_START: number;
  23543. /**
  23544. * Mesh cap setting : one cap at the end of the mesh
  23545. */
  23546. static readonly CAP_END: number;
  23547. /**
  23548. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23549. */
  23550. static readonly CAP_ALL: number;
  23551. /**
  23552. * Mesh pattern setting : no flip or rotate
  23553. */
  23554. static readonly NO_FLIP: number;
  23555. /**
  23556. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23557. */
  23558. static readonly FLIP_TILE: number;
  23559. /**
  23560. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23561. */
  23562. static readonly ROTATE_TILE: number;
  23563. /**
  23564. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23565. */
  23566. static readonly FLIP_ROW: number;
  23567. /**
  23568. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23569. */
  23570. static readonly ROTATE_ROW: number;
  23571. /**
  23572. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23573. */
  23574. static readonly FLIP_N_ROTATE_TILE: number;
  23575. /**
  23576. * Mesh pattern setting : rotate pattern and rotate
  23577. */
  23578. static readonly FLIP_N_ROTATE_ROW: number;
  23579. /**
  23580. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23581. */
  23582. static readonly CENTER: number;
  23583. /**
  23584. * Mesh tile positioning : part tiles on left
  23585. */
  23586. static readonly LEFT: number;
  23587. /**
  23588. * Mesh tile positioning : part tiles on right
  23589. */
  23590. static readonly RIGHT: number;
  23591. /**
  23592. * Mesh tile positioning : part tiles on top
  23593. */
  23594. static readonly TOP: number;
  23595. /**
  23596. * Mesh tile positioning : part tiles on bottom
  23597. */
  23598. static readonly BOTTOM: number;
  23599. /**
  23600. * Gets the default side orientation.
  23601. * @param orientation the orientation to value to attempt to get
  23602. * @returns the default orientation
  23603. * @hidden
  23604. */
  23605. static _GetDefaultSideOrientation(orientation?: number): number;
  23606. private _internalMeshDataInfo;
  23607. /**
  23608. * An event triggered before rendering the mesh
  23609. */
  23610. readonly onBeforeRenderObservable: Observable<Mesh>;
  23611. /**
  23612. * An event triggered before binding the mesh
  23613. */
  23614. readonly onBeforeBindObservable: Observable<Mesh>;
  23615. /**
  23616. * An event triggered after rendering the mesh
  23617. */
  23618. readonly onAfterRenderObservable: Observable<Mesh>;
  23619. /**
  23620. * An event triggered before drawing the mesh
  23621. */
  23622. readonly onBeforeDrawObservable: Observable<Mesh>;
  23623. private _onBeforeDrawObserver;
  23624. /**
  23625. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23626. */
  23627. onBeforeDraw: () => void;
  23628. readonly hasInstances: boolean;
  23629. /**
  23630. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23631. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23632. */
  23633. delayLoadState: number;
  23634. /**
  23635. * Gets the list of instances created from this mesh
  23636. * it is not supposed to be modified manually.
  23637. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23638. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23639. */
  23640. instances: InstancedMesh[];
  23641. /**
  23642. * Gets the file containing delay loading data for this mesh
  23643. */
  23644. delayLoadingFile: string;
  23645. /** @hidden */
  23646. _binaryInfo: any;
  23647. /**
  23648. * User defined function used to change how LOD level selection is done
  23649. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23650. */
  23651. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23652. /**
  23653. * Gets or sets the morph target manager
  23654. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23655. */
  23656. morphTargetManager: Nullable<MorphTargetManager>;
  23657. /** @hidden */
  23658. _creationDataStorage: Nullable<_CreationDataStorage>;
  23659. /** @hidden */
  23660. _geometry: Nullable<Geometry>;
  23661. /** @hidden */
  23662. _delayInfo: Array<string>;
  23663. /** @hidden */
  23664. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23665. /** @hidden */
  23666. _instanceDataStorage: _InstanceDataStorage;
  23667. private _effectiveMaterial;
  23668. /** @hidden */
  23669. _shouldGenerateFlatShading: boolean;
  23670. /** @hidden */
  23671. _originalBuilderSideOrientation: number;
  23672. /**
  23673. * Use this property to change the original side orientation defined at construction time
  23674. */
  23675. overrideMaterialSideOrientation: Nullable<number>;
  23676. /**
  23677. * Gets the source mesh (the one used to clone this one from)
  23678. */
  23679. readonly source: Nullable<Mesh>;
  23680. /**
  23681. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23682. */
  23683. isUnIndexed: boolean;
  23684. /**
  23685. * @constructor
  23686. * @param name The value used by scene.getMeshByName() to do a lookup.
  23687. * @param scene The scene to add this mesh to.
  23688. * @param parent The parent of this mesh, if it has one
  23689. * @param source An optional Mesh from which geometry is shared, cloned.
  23690. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23691. * When false, achieved by calling a clone(), also passing False.
  23692. * This will make creation of children, recursive.
  23693. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23694. */
  23695. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23696. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23697. /**
  23698. * Gets the class name
  23699. * @returns the string "Mesh".
  23700. */
  23701. getClassName(): string;
  23702. /** @hidden */
  23703. readonly _isMesh: boolean;
  23704. /**
  23705. * Returns a description of this mesh
  23706. * @param fullDetails define if full details about this mesh must be used
  23707. * @returns a descriptive string representing this mesh
  23708. */
  23709. toString(fullDetails?: boolean): string;
  23710. /** @hidden */
  23711. _unBindEffect(): void;
  23712. /**
  23713. * Gets a boolean indicating if this mesh has LOD
  23714. */
  23715. readonly hasLODLevels: boolean;
  23716. /**
  23717. * Gets the list of MeshLODLevel associated with the current mesh
  23718. * @returns an array of MeshLODLevel
  23719. */
  23720. getLODLevels(): MeshLODLevel[];
  23721. private _sortLODLevels;
  23722. /**
  23723. * Add a mesh as LOD level triggered at the given distance.
  23724. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23725. * @param distance The distance from the center of the object to show this level
  23726. * @param mesh The mesh to be added as LOD level (can be null)
  23727. * @return This mesh (for chaining)
  23728. */
  23729. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23730. /**
  23731. * Returns the LOD level mesh at the passed distance or null if not found.
  23732. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23733. * @param distance The distance from the center of the object to show this level
  23734. * @returns a Mesh or `null`
  23735. */
  23736. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23737. /**
  23738. * Remove a mesh from the LOD array
  23739. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23740. * @param mesh defines the mesh to be removed
  23741. * @return This mesh (for chaining)
  23742. */
  23743. removeLODLevel(mesh: Mesh): Mesh;
  23744. /**
  23745. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23746. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23747. * @param camera defines the camera to use to compute distance
  23748. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23749. * @return This mesh (for chaining)
  23750. */
  23751. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23752. /**
  23753. * Gets the mesh internal Geometry object
  23754. */
  23755. readonly geometry: Nullable<Geometry>;
  23756. /**
  23757. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23758. * @returns the total number of vertices
  23759. */
  23760. getTotalVertices(): number;
  23761. /**
  23762. * Returns the content of an associated vertex buffer
  23763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23764. * - VertexBuffer.PositionKind
  23765. * - VertexBuffer.UVKind
  23766. * - VertexBuffer.UV2Kind
  23767. * - VertexBuffer.UV3Kind
  23768. * - VertexBuffer.UV4Kind
  23769. * - VertexBuffer.UV5Kind
  23770. * - VertexBuffer.UV6Kind
  23771. * - VertexBuffer.ColorKind
  23772. * - VertexBuffer.MatricesIndicesKind
  23773. * - VertexBuffer.MatricesIndicesExtraKind
  23774. * - VertexBuffer.MatricesWeightsKind
  23775. * - VertexBuffer.MatricesWeightsExtraKind
  23776. * @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
  23777. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23778. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23779. */
  23780. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23781. /**
  23782. * Returns the mesh VertexBuffer object from the requested `kind`
  23783. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23784. * - VertexBuffer.PositionKind
  23785. * - VertexBuffer.NormalKind
  23786. * - VertexBuffer.UVKind
  23787. * - VertexBuffer.UV2Kind
  23788. * - VertexBuffer.UV3Kind
  23789. * - VertexBuffer.UV4Kind
  23790. * - VertexBuffer.UV5Kind
  23791. * - VertexBuffer.UV6Kind
  23792. * - VertexBuffer.ColorKind
  23793. * - VertexBuffer.MatricesIndicesKind
  23794. * - VertexBuffer.MatricesIndicesExtraKind
  23795. * - VertexBuffer.MatricesWeightsKind
  23796. * - VertexBuffer.MatricesWeightsExtraKind
  23797. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23798. */
  23799. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23800. /**
  23801. * Tests if a specific vertex buffer is associated with this mesh
  23802. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23803. * - VertexBuffer.PositionKind
  23804. * - VertexBuffer.NormalKind
  23805. * - VertexBuffer.UVKind
  23806. * - VertexBuffer.UV2Kind
  23807. * - VertexBuffer.UV3Kind
  23808. * - VertexBuffer.UV4Kind
  23809. * - VertexBuffer.UV5Kind
  23810. * - VertexBuffer.UV6Kind
  23811. * - VertexBuffer.ColorKind
  23812. * - VertexBuffer.MatricesIndicesKind
  23813. * - VertexBuffer.MatricesIndicesExtraKind
  23814. * - VertexBuffer.MatricesWeightsKind
  23815. * - VertexBuffer.MatricesWeightsExtraKind
  23816. * @returns a boolean
  23817. */
  23818. isVerticesDataPresent(kind: string): boolean;
  23819. /**
  23820. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23821. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23822. * - VertexBuffer.PositionKind
  23823. * - VertexBuffer.UVKind
  23824. * - VertexBuffer.UV2Kind
  23825. * - VertexBuffer.UV3Kind
  23826. * - VertexBuffer.UV4Kind
  23827. * - VertexBuffer.UV5Kind
  23828. * - VertexBuffer.UV6Kind
  23829. * - VertexBuffer.ColorKind
  23830. * - VertexBuffer.MatricesIndicesKind
  23831. * - VertexBuffer.MatricesIndicesExtraKind
  23832. * - VertexBuffer.MatricesWeightsKind
  23833. * - VertexBuffer.MatricesWeightsExtraKind
  23834. * @returns a boolean
  23835. */
  23836. isVertexBufferUpdatable(kind: string): boolean;
  23837. /**
  23838. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23839. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23840. * - VertexBuffer.PositionKind
  23841. * - VertexBuffer.NormalKind
  23842. * - VertexBuffer.UVKind
  23843. * - VertexBuffer.UV2Kind
  23844. * - VertexBuffer.UV3Kind
  23845. * - VertexBuffer.UV4Kind
  23846. * - VertexBuffer.UV5Kind
  23847. * - VertexBuffer.UV6Kind
  23848. * - VertexBuffer.ColorKind
  23849. * - VertexBuffer.MatricesIndicesKind
  23850. * - VertexBuffer.MatricesIndicesExtraKind
  23851. * - VertexBuffer.MatricesWeightsKind
  23852. * - VertexBuffer.MatricesWeightsExtraKind
  23853. * @returns an array of strings
  23854. */
  23855. getVerticesDataKinds(): string[];
  23856. /**
  23857. * Returns a positive integer : the total number of indices in this mesh geometry.
  23858. * @returns the numner of indices or zero if the mesh has no geometry.
  23859. */
  23860. getTotalIndices(): number;
  23861. /**
  23862. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23863. * @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.
  23864. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23865. * @returns the indices array or an empty array if the mesh has no geometry
  23866. */
  23867. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23868. readonly isBlocked: boolean;
  23869. /**
  23870. * Determine if the current mesh is ready to be rendered
  23871. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23872. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23873. * @returns true if all associated assets are ready (material, textures, shaders)
  23874. */
  23875. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23876. /**
  23877. * 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.
  23878. */
  23879. readonly areNormalsFrozen: boolean;
  23880. /**
  23881. * 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.
  23882. * @returns the current mesh
  23883. */
  23884. freezeNormals(): Mesh;
  23885. /**
  23886. * 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
  23887. * @returns the current mesh
  23888. */
  23889. unfreezeNormals(): Mesh;
  23890. /**
  23891. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23892. */
  23893. overridenInstanceCount: number;
  23894. /** @hidden */
  23895. _preActivate(): Mesh;
  23896. /** @hidden */
  23897. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23898. /** @hidden */
  23899. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23900. /**
  23901. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23902. * This means the mesh underlying bounding box and sphere are recomputed.
  23903. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23904. * @returns the current mesh
  23905. */
  23906. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23907. /** @hidden */
  23908. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23909. /**
  23910. * This function will subdivide the mesh into multiple submeshes
  23911. * @param count defines the expected number of submeshes
  23912. */
  23913. subdivide(count: number): void;
  23914. /**
  23915. * Copy a FloatArray into a specific associated vertex buffer
  23916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23917. * - VertexBuffer.PositionKind
  23918. * - VertexBuffer.UVKind
  23919. * - VertexBuffer.UV2Kind
  23920. * - VertexBuffer.UV3Kind
  23921. * - VertexBuffer.UV4Kind
  23922. * - VertexBuffer.UV5Kind
  23923. * - VertexBuffer.UV6Kind
  23924. * - VertexBuffer.ColorKind
  23925. * - VertexBuffer.MatricesIndicesKind
  23926. * - VertexBuffer.MatricesIndicesExtraKind
  23927. * - VertexBuffer.MatricesWeightsKind
  23928. * - VertexBuffer.MatricesWeightsExtraKind
  23929. * @param data defines the data source
  23930. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23931. * @param stride defines the data stride size (can be null)
  23932. * @returns the current mesh
  23933. */
  23934. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23935. /**
  23936. * Flags an associated vertex buffer as updatable
  23937. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23938. * - VertexBuffer.PositionKind
  23939. * - VertexBuffer.UVKind
  23940. * - VertexBuffer.UV2Kind
  23941. * - VertexBuffer.UV3Kind
  23942. * - VertexBuffer.UV4Kind
  23943. * - VertexBuffer.UV5Kind
  23944. * - VertexBuffer.UV6Kind
  23945. * - VertexBuffer.ColorKind
  23946. * - VertexBuffer.MatricesIndicesKind
  23947. * - VertexBuffer.MatricesIndicesExtraKind
  23948. * - VertexBuffer.MatricesWeightsKind
  23949. * - VertexBuffer.MatricesWeightsExtraKind
  23950. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23951. */
  23952. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23953. /**
  23954. * Sets the mesh global Vertex Buffer
  23955. * @param buffer defines the buffer to use
  23956. * @returns the current mesh
  23957. */
  23958. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23959. /**
  23960. * Update a specific associated vertex buffer
  23961. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23962. * - VertexBuffer.PositionKind
  23963. * - VertexBuffer.UVKind
  23964. * - VertexBuffer.UV2Kind
  23965. * - VertexBuffer.UV3Kind
  23966. * - VertexBuffer.UV4Kind
  23967. * - VertexBuffer.UV5Kind
  23968. * - VertexBuffer.UV6Kind
  23969. * - VertexBuffer.ColorKind
  23970. * - VertexBuffer.MatricesIndicesKind
  23971. * - VertexBuffer.MatricesIndicesExtraKind
  23972. * - VertexBuffer.MatricesWeightsKind
  23973. * - VertexBuffer.MatricesWeightsExtraKind
  23974. * @param data defines the data source
  23975. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23976. * @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)
  23977. * @returns the current mesh
  23978. */
  23979. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23980. /**
  23981. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23982. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23983. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23984. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23985. * @returns the current mesh
  23986. */
  23987. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23988. /**
  23989. * Creates a un-shared specific occurence of the geometry for the mesh.
  23990. * @returns the current mesh
  23991. */
  23992. makeGeometryUnique(): Mesh;
  23993. /**
  23994. * Set the index buffer of this mesh
  23995. * @param indices defines the source data
  23996. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23997. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23998. * @returns the current mesh
  23999. */
  24000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24001. /**
  24002. * Update the current index buffer
  24003. * @param indices defines the source data
  24004. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24005. * @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)
  24006. * @returns the current mesh
  24007. */
  24008. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24009. /**
  24010. * Invert the geometry to move from a right handed system to a left handed one.
  24011. * @returns the current mesh
  24012. */
  24013. toLeftHanded(): Mesh;
  24014. /** @hidden */
  24015. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24016. /** @hidden */
  24017. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24018. /**
  24019. * Registers for this mesh a javascript function called just before the rendering process
  24020. * @param func defines the function to call before rendering this mesh
  24021. * @returns the current mesh
  24022. */
  24023. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24024. /**
  24025. * Disposes a previously registered javascript function called before the rendering
  24026. * @param func defines the function to remove
  24027. * @returns the current mesh
  24028. */
  24029. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24030. /**
  24031. * Registers for this mesh a javascript function called just after the rendering is complete
  24032. * @param func defines the function to call after rendering this mesh
  24033. * @returns the current mesh
  24034. */
  24035. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24036. /**
  24037. * Disposes a previously registered javascript function called after the rendering.
  24038. * @param func defines the function to remove
  24039. * @returns the current mesh
  24040. */
  24041. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24042. /** @hidden */
  24043. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24044. /** @hidden */
  24045. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24046. /** @hidden */
  24047. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24048. /** @hidden */
  24049. _rebuild(): void;
  24050. /** @hidden */
  24051. _freeze(): void;
  24052. /** @hidden */
  24053. _unFreeze(): void;
  24054. /**
  24055. * 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
  24056. * @param subMesh defines the subMesh to render
  24057. * @param enableAlphaMode defines if alpha mode can be changed
  24058. * @returns the current mesh
  24059. */
  24060. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24061. private _onBeforeDraw;
  24062. /**
  24063. * Renormalize the mesh and patch it up if there are no weights
  24064. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24065. * However in the case of zero weights then we set just a single influence to 1.
  24066. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24067. */
  24068. cleanMatrixWeights(): void;
  24069. private normalizeSkinFourWeights;
  24070. private normalizeSkinWeightsAndExtra;
  24071. /**
  24072. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24073. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24074. * the user know there was an issue with importing the mesh
  24075. * @returns a validation object with skinned, valid and report string
  24076. */
  24077. validateSkinning(): {
  24078. skinned: boolean;
  24079. valid: boolean;
  24080. report: string;
  24081. };
  24082. /** @hidden */
  24083. _checkDelayState(): Mesh;
  24084. private _queueLoad;
  24085. /**
  24086. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24087. * A mesh is in the frustum if its bounding box intersects the frustum
  24088. * @param frustumPlanes defines the frustum to test
  24089. * @returns true if the mesh is in the frustum planes
  24090. */
  24091. isInFrustum(frustumPlanes: Plane[]): boolean;
  24092. /**
  24093. * Sets the mesh material by the material or multiMaterial `id` property
  24094. * @param id is a string identifying the material or the multiMaterial
  24095. * @returns the current mesh
  24096. */
  24097. setMaterialByID(id: string): Mesh;
  24098. /**
  24099. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24100. * @returns an array of IAnimatable
  24101. */
  24102. getAnimatables(): IAnimatable[];
  24103. /**
  24104. * Modifies the mesh geometry according to the passed transformation matrix.
  24105. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24106. * The mesh normals are modified using the same transformation.
  24107. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24108. * @param transform defines the transform matrix to use
  24109. * @see http://doc.babylonjs.com/resources/baking_transformations
  24110. * @returns the current mesh
  24111. */
  24112. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24113. /**
  24114. * Modifies the mesh geometry according to its own current World Matrix.
  24115. * The mesh World Matrix is then reset.
  24116. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24117. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24118. * @see http://doc.babylonjs.com/resources/baking_transformations
  24119. * @returns the current mesh
  24120. */
  24121. bakeCurrentTransformIntoVertices(): Mesh;
  24122. /** @hidden */
  24123. readonly _positions: Nullable<Vector3[]>;
  24124. /** @hidden */
  24125. _resetPointsArrayCache(): Mesh;
  24126. /** @hidden */
  24127. _generatePointsArray(): boolean;
  24128. /**
  24129. * Returns a new Mesh object generated from the current mesh properties.
  24130. * This method must not get confused with createInstance()
  24131. * @param name is a string, the name given to the new mesh
  24132. * @param newParent can be any Node object (default `null`)
  24133. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24134. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24135. * @returns a new mesh
  24136. */
  24137. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24138. /**
  24139. * Releases resources associated with this mesh.
  24140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24142. */
  24143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24144. /**
  24145. * Modifies the mesh geometry according to a displacement map.
  24146. * 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.
  24147. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24148. * @param url is a string, the URL from the image file is to be downloaded.
  24149. * @param minHeight is the lower limit of the displacement.
  24150. * @param maxHeight is the upper limit of the displacement.
  24151. * @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.
  24152. * @param uvOffset is an optional vector2 used to offset UV.
  24153. * @param uvScale is an optional vector2 used to scale UV.
  24154. * @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.
  24155. * @returns the Mesh.
  24156. */
  24157. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24158. /**
  24159. * Modifies the mesh geometry according to a displacementMap buffer.
  24160. * 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.
  24161. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24162. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24163. * @param heightMapWidth is the width of the buffer image.
  24164. * @param heightMapHeight is the height of the buffer image.
  24165. * @param minHeight is the lower limit of the displacement.
  24166. * @param maxHeight is the upper limit of the displacement.
  24167. * @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.
  24168. * @param uvOffset is an optional vector2 used to offset UV.
  24169. * @param uvScale is an optional vector2 used to scale UV.
  24170. * @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.
  24171. * @returns the Mesh.
  24172. */
  24173. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24174. /**
  24175. * Modify the mesh to get a flat shading rendering.
  24176. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24177. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24178. * @returns current mesh
  24179. */
  24180. convertToFlatShadedMesh(): Mesh;
  24181. /**
  24182. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24183. * In other words, more vertices, no more indices and a single bigger VBO.
  24184. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24185. * @returns current mesh
  24186. */
  24187. convertToUnIndexedMesh(): Mesh;
  24188. /**
  24189. * Inverses facet orientations.
  24190. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24191. * @param flipNormals will also inverts the normals
  24192. * @returns current mesh
  24193. */
  24194. flipFaces(flipNormals?: boolean): Mesh;
  24195. /**
  24196. * Increase the number of facets and hence vertices in a mesh
  24197. * Vertex normals are interpolated from existing vertex normals
  24198. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24199. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24200. */
  24201. increaseVertices(numberPerEdge: number): void;
  24202. /**
  24203. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24204. * This will undo any application of covertToFlatShadedMesh
  24205. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24206. */
  24207. forceSharedVertices(): void;
  24208. /** @hidden */
  24209. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24210. /** @hidden */
  24211. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24212. /**
  24213. * Creates a new InstancedMesh object from the mesh model.
  24214. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24215. * @param name defines the name of the new instance
  24216. * @returns a new InstancedMesh
  24217. */
  24218. createInstance(name: string): InstancedMesh;
  24219. /**
  24220. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24221. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24222. * @returns the current mesh
  24223. */
  24224. synchronizeInstances(): Mesh;
  24225. /**
  24226. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24227. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24228. * This should be used together with the simplification to avoid disappearing triangles.
  24229. * @param successCallback an optional success callback to be called after the optimization finished.
  24230. * @returns the current mesh
  24231. */
  24232. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24233. /**
  24234. * Serialize current mesh
  24235. * @param serializationObject defines the object which will receive the serialization data
  24236. */
  24237. serialize(serializationObject: any): void;
  24238. /** @hidden */
  24239. _syncGeometryWithMorphTargetManager(): void;
  24240. /** @hidden */
  24241. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24242. /**
  24243. * Returns a new Mesh object parsed from the source provided.
  24244. * @param parsedMesh is the source
  24245. * @param scene defines the hosting scene
  24246. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24247. * @returns a new Mesh
  24248. */
  24249. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24250. /**
  24251. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24252. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24253. * @param name defines the name of the mesh to create
  24254. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24255. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24256. * @param closePath creates a seam between the first and the last points of each path of the path array
  24257. * @param offset is taken in account only if the `pathArray` is containing a single path
  24258. * @param scene defines the hosting scene
  24259. * @param updatable defines if the mesh must be flagged as updatable
  24260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24261. * @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)
  24262. * @returns a new Mesh
  24263. */
  24264. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24265. /**
  24266. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24267. * @param name defines the name of the mesh to create
  24268. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24269. * @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
  24270. * @param scene defines the hosting scene
  24271. * @param updatable defines if the mesh must be flagged as updatable
  24272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24273. * @returns a new Mesh
  24274. */
  24275. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24276. /**
  24277. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24278. * @param name defines the name of the mesh to create
  24279. * @param size sets the size (float) of each box side (default 1)
  24280. * @param scene defines the hosting scene
  24281. * @param updatable defines if the mesh must be flagged as updatable
  24282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24283. * @returns a new Mesh
  24284. */
  24285. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24286. /**
  24287. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24288. * @param name defines the name of the mesh to create
  24289. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24290. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24291. * @param scene defines the hosting scene
  24292. * @param updatable defines if the mesh must be flagged as updatable
  24293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24294. * @returns a new Mesh
  24295. */
  24296. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24297. /**
  24298. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24299. * @param name defines the name of the mesh to create
  24300. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24301. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24302. * @param scene defines the hosting scene
  24303. * @returns a new Mesh
  24304. */
  24305. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24306. /**
  24307. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24308. * @param name defines the name of the mesh to create
  24309. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24310. * @param diameterTop set the top cap diameter (floats, default 1)
  24311. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24312. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24313. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24314. * @param scene defines the hosting scene
  24315. * @param updatable defines if the mesh must be flagged as updatable
  24316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24317. * @returns a new Mesh
  24318. */
  24319. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24320. /**
  24321. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24322. * @param name defines the name of the mesh to create
  24323. * @param diameter sets the diameter size (float) of the torus (default 1)
  24324. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24325. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24326. * @param scene defines the hosting scene
  24327. * @param updatable defines if the mesh must be flagged as updatable
  24328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24329. * @returns a new Mesh
  24330. */
  24331. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24332. /**
  24333. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24334. * @param name defines the name of the mesh to create
  24335. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24336. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24337. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24338. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24339. * @param p the number of windings on X axis (positive integers, default 2)
  24340. * @param q the number of windings on Y axis (positive integers, default 3)
  24341. * @param scene defines the hosting scene
  24342. * @param updatable defines if the mesh must be flagged as updatable
  24343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24344. * @returns a new Mesh
  24345. */
  24346. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24347. /**
  24348. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24349. * @param name defines the name of the mesh to create
  24350. * @param points is an array successive Vector3
  24351. * @param scene defines the hosting scene
  24352. * @param updatable defines if the mesh must be flagged as updatable
  24353. * @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).
  24354. * @returns a new Mesh
  24355. */
  24356. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24357. /**
  24358. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24359. * @param name defines the name of the mesh to create
  24360. * @param points is an array successive Vector3
  24361. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24362. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24363. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24364. * @param scene defines the hosting scene
  24365. * @param updatable defines if the mesh must be flagged as updatable
  24366. * @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)
  24367. * @returns a new Mesh
  24368. */
  24369. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24370. /**
  24371. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24372. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24373. * 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.
  24374. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24375. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24376. * Remember you can only change the shape positions, not their number when updating a polygon.
  24377. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24378. * @param name defines the name of the mesh to create
  24379. * @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
  24380. * @param scene defines the hosting scene
  24381. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24382. * @param updatable defines if the mesh must be flagged as updatable
  24383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24384. * @param earcutInjection can be used to inject your own earcut reference
  24385. * @returns a new Mesh
  24386. */
  24387. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24388. /**
  24389. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24390. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24391. * @param name defines the name of the mesh to create
  24392. * @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
  24393. * @param depth defines the height of extrusion
  24394. * @param scene defines the hosting scene
  24395. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24396. * @param updatable defines if the mesh must be flagged as updatable
  24397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24398. * @param earcutInjection can be used to inject your own earcut reference
  24399. * @returns a new Mesh
  24400. */
  24401. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24402. /**
  24403. * Creates an extruded shape mesh.
  24404. * 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
  24405. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24406. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24407. * @param name defines the name of the mesh to create
  24408. * @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
  24409. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24410. * @param scale is the value to scale the shape
  24411. * @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
  24412. * @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
  24413. * @param scene defines the hosting scene
  24414. * @param updatable defines if the mesh must be flagged as updatable
  24415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24416. * @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)
  24417. * @returns a new Mesh
  24418. */
  24419. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24420. /**
  24421. * Creates an custom extruded shape mesh.
  24422. * The custom extrusion is a parametric shape.
  24423. * It has no predefined shape. Its final shape will depend on the input parameters.
  24424. * Please consider using the same method from the MeshBuilder class instead
  24425. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24426. * @param name defines the name of the mesh to create
  24427. * @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
  24428. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24429. * @param scaleFunction is a custom Javascript function called on each path point
  24430. * @param rotationFunction is a custom Javascript function called on each path point
  24431. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24432. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24433. * @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
  24434. * @param scene defines the hosting scene
  24435. * @param updatable defines if the mesh must be flagged as updatable
  24436. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24437. * @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)
  24438. * @returns a new Mesh
  24439. */
  24440. 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;
  24441. /**
  24442. * Creates lathe mesh.
  24443. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24444. * Please consider using the same method from the MeshBuilder class instead
  24445. * @param name defines the name of the mesh to create
  24446. * @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
  24447. * @param radius is the radius value of the lathe
  24448. * @param tessellation is the side number of the lathe.
  24449. * @param scene defines the hosting scene
  24450. * @param updatable defines if the mesh must be flagged as updatable
  24451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24452. * @returns a new Mesh
  24453. */
  24454. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24455. /**
  24456. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24457. * @param name defines the name of the mesh to create
  24458. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24459. * @param scene defines the hosting scene
  24460. * @param updatable defines if the mesh must be flagged as updatable
  24461. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24462. * @returns a new Mesh
  24463. */
  24464. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24465. /**
  24466. * Creates a ground mesh.
  24467. * Please consider using the same method from the MeshBuilder class instead
  24468. * @param name defines the name of the mesh to create
  24469. * @param width set the width of the ground
  24470. * @param height set the height of the ground
  24471. * @param subdivisions sets the number of subdivisions per side
  24472. * @param scene defines the hosting scene
  24473. * @param updatable defines if the mesh must be flagged as updatable
  24474. * @returns a new Mesh
  24475. */
  24476. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24477. /**
  24478. * Creates a tiled ground mesh.
  24479. * Please consider using the same method from the MeshBuilder class instead
  24480. * @param name defines the name of the mesh to create
  24481. * @param xmin set the ground minimum X coordinate
  24482. * @param zmin set the ground minimum Y coordinate
  24483. * @param xmax set the ground maximum X coordinate
  24484. * @param zmax set the ground maximum Z coordinate
  24485. * @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
  24486. * @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
  24487. * @param scene defines the hosting scene
  24488. * @param updatable defines if the mesh must be flagged as updatable
  24489. * @returns a new Mesh
  24490. */
  24491. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24492. w: number;
  24493. h: number;
  24494. }, precision: {
  24495. w: number;
  24496. h: number;
  24497. }, scene: Scene, updatable?: boolean): Mesh;
  24498. /**
  24499. * Creates a ground mesh from a height map.
  24500. * Please consider using the same method from the MeshBuilder class instead
  24501. * @see http://doc.babylonjs.com/babylon101/height_map
  24502. * @param name defines the name of the mesh to create
  24503. * @param url sets the URL of the height map image resource
  24504. * @param width set the ground width size
  24505. * @param height set the ground height size
  24506. * @param subdivisions sets the number of subdivision per side
  24507. * @param minHeight is the minimum altitude on the ground
  24508. * @param maxHeight is the maximum altitude on the ground
  24509. * @param scene defines the hosting scene
  24510. * @param updatable defines if the mesh must be flagged as updatable
  24511. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24512. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24513. * @returns a new Mesh
  24514. */
  24515. 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;
  24516. /**
  24517. * Creates a tube mesh.
  24518. * The tube is a parametric shape.
  24519. * It has no predefined shape. Its final shape will depend on the input parameters.
  24520. * Please consider using the same method from the MeshBuilder class instead
  24521. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24522. * @param name defines the name of the mesh to create
  24523. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24524. * @param radius sets the tube radius size
  24525. * @param tessellation is the number of sides on the tubular surface
  24526. * @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
  24527. * @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
  24528. * @param scene defines the hosting scene
  24529. * @param updatable defines if the mesh must be flagged as updatable
  24530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24531. * @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)
  24532. * @returns a new Mesh
  24533. */
  24534. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24535. (i: number, distance: number): number;
  24536. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24537. /**
  24538. * Creates a polyhedron mesh.
  24539. * Please consider using the same method from the MeshBuilder class instead.
  24540. * * 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
  24541. * * The parameter `size` (positive float, default 1) sets the polygon size
  24542. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24543. * * 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`
  24544. * * 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
  24545. * * 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)`)
  24546. * * 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
  24547. * * 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
  24548. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24549. * * 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
  24550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24551. * @param name defines the name of the mesh to create
  24552. * @param options defines the options used to create the mesh
  24553. * @param scene defines the hosting scene
  24554. * @returns a new Mesh
  24555. */
  24556. static CreatePolyhedron(name: string, options: {
  24557. type?: number;
  24558. size?: number;
  24559. sizeX?: number;
  24560. sizeY?: number;
  24561. sizeZ?: number;
  24562. custom?: any;
  24563. faceUV?: Vector4[];
  24564. faceColors?: Color4[];
  24565. updatable?: boolean;
  24566. sideOrientation?: number;
  24567. }, scene: Scene): Mesh;
  24568. /**
  24569. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24570. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24571. * * 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`)
  24572. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24573. * * 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
  24574. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24575. * * 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
  24576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24577. * @param name defines the name of the mesh
  24578. * @param options defines the options used to create the mesh
  24579. * @param scene defines the hosting scene
  24580. * @returns a new Mesh
  24581. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24582. */
  24583. static CreateIcoSphere(name: string, options: {
  24584. radius?: number;
  24585. flat?: boolean;
  24586. subdivisions?: number;
  24587. sideOrientation?: number;
  24588. updatable?: boolean;
  24589. }, scene: Scene): Mesh;
  24590. /**
  24591. * Creates a decal mesh.
  24592. * Please consider using the same method from the MeshBuilder class instead.
  24593. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24594. * @param name defines the name of the mesh
  24595. * @param sourceMesh defines the mesh receiving the decal
  24596. * @param position sets the position of the decal in world coordinates
  24597. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24598. * @param size sets the decal scaling
  24599. * @param angle sets the angle to rotate the decal
  24600. * @returns a new Mesh
  24601. */
  24602. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24603. /**
  24604. * Prepare internal position array for software CPU skinning
  24605. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24606. */
  24607. setPositionsForCPUSkinning(): Float32Array;
  24608. /**
  24609. * Prepare internal normal array for software CPU skinning
  24610. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24611. */
  24612. setNormalsForCPUSkinning(): Float32Array;
  24613. /**
  24614. * Updates the vertex buffer by applying transformation from the bones
  24615. * @param skeleton defines the skeleton to apply to current mesh
  24616. * @returns the current mesh
  24617. */
  24618. applySkeleton(skeleton: Skeleton): Mesh;
  24619. /**
  24620. * 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
  24621. * @param meshes defines the list of meshes to scan
  24622. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24623. */
  24624. static MinMax(meshes: AbstractMesh[]): {
  24625. min: Vector3;
  24626. max: Vector3;
  24627. };
  24628. /**
  24629. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24630. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24631. * @returns a vector3
  24632. */
  24633. static Center(meshesOrMinMaxVector: {
  24634. min: Vector3;
  24635. max: Vector3;
  24636. } | AbstractMesh[]): Vector3;
  24637. /**
  24638. * Merge the array of meshes into a single mesh for performance reasons.
  24639. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24640. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24641. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24642. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24643. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24644. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24645. * @returns a new mesh
  24646. */
  24647. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24648. /** @hidden */
  24649. addInstance(instance: InstancedMesh): void;
  24650. /** @hidden */
  24651. removeInstance(instance: InstancedMesh): void;
  24652. }
  24653. }
  24654. declare module BABYLON {
  24655. /**
  24656. * This is the base class of all the camera used in the application.
  24657. * @see http://doc.babylonjs.com/features/cameras
  24658. */
  24659. export class Camera extends Node {
  24660. /** @hidden */
  24661. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24662. /**
  24663. * This is the default projection mode used by the cameras.
  24664. * It helps recreating a feeling of perspective and better appreciate depth.
  24665. * This is the best way to simulate real life cameras.
  24666. */
  24667. static readonly PERSPECTIVE_CAMERA: number;
  24668. /**
  24669. * This helps creating camera with an orthographic mode.
  24670. * 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.
  24671. */
  24672. static readonly ORTHOGRAPHIC_CAMERA: number;
  24673. /**
  24674. * This is the default FOV mode for perspective cameras.
  24675. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24676. */
  24677. static readonly FOVMODE_VERTICAL_FIXED: number;
  24678. /**
  24679. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24680. */
  24681. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24682. /**
  24683. * This specifies ther is no need for a camera rig.
  24684. * Basically only one eye is rendered corresponding to the camera.
  24685. */
  24686. static readonly RIG_MODE_NONE: number;
  24687. /**
  24688. * Simulates a camera Rig with one blue eye and one red eye.
  24689. * This can be use with 3d blue and red glasses.
  24690. */
  24691. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24692. /**
  24693. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24694. */
  24695. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24696. /**
  24697. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24698. */
  24699. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24700. /**
  24701. * Defines that both eyes of the camera will be rendered over under each other.
  24702. */
  24703. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24704. /**
  24705. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24706. */
  24707. static readonly RIG_MODE_VR: number;
  24708. /**
  24709. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24710. */
  24711. static readonly RIG_MODE_WEBVR: number;
  24712. /**
  24713. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24714. */
  24715. static readonly RIG_MODE_CUSTOM: number;
  24716. /**
  24717. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24718. */
  24719. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24720. /**
  24721. * Define the input manager associated with the camera.
  24722. */
  24723. inputs: CameraInputsManager<Camera>;
  24724. /** @hidden */
  24725. _position: Vector3;
  24726. /**
  24727. * Define the current local position of the camera in the scene
  24728. */
  24729. position: Vector3;
  24730. /**
  24731. * The vector the camera should consider as up.
  24732. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24733. */
  24734. upVector: Vector3;
  24735. /**
  24736. * Define the current limit on the left side for an orthographic camera
  24737. * In scene unit
  24738. */
  24739. orthoLeft: Nullable<number>;
  24740. /**
  24741. * Define the current limit on the right side for an orthographic camera
  24742. * In scene unit
  24743. */
  24744. orthoRight: Nullable<number>;
  24745. /**
  24746. * Define the current limit on the bottom side for an orthographic camera
  24747. * In scene unit
  24748. */
  24749. orthoBottom: Nullable<number>;
  24750. /**
  24751. * Define the current limit on the top side for an orthographic camera
  24752. * In scene unit
  24753. */
  24754. orthoTop: Nullable<number>;
  24755. /**
  24756. * Field Of View is set in Radians. (default is 0.8)
  24757. */
  24758. fov: number;
  24759. /**
  24760. * Define the minimum distance the camera can see from.
  24761. * This is important to note that the depth buffer are not infinite and the closer it starts
  24762. * the more your scene might encounter depth fighting issue.
  24763. */
  24764. minZ: number;
  24765. /**
  24766. * Define the maximum distance the camera can see to.
  24767. * This is important to note that the depth buffer are not infinite and the further it end
  24768. * the more your scene might encounter depth fighting issue.
  24769. */
  24770. maxZ: number;
  24771. /**
  24772. * Define the default inertia of the camera.
  24773. * This helps giving a smooth feeling to the camera movement.
  24774. */
  24775. inertia: number;
  24776. /**
  24777. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24778. */
  24779. mode: number;
  24780. /**
  24781. * Define wether the camera is intermediate.
  24782. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24783. */
  24784. isIntermediate: boolean;
  24785. /**
  24786. * Define the viewport of the camera.
  24787. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24788. */
  24789. viewport: Viewport;
  24790. /**
  24791. * Restricts the camera to viewing objects with the same layerMask.
  24792. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24793. */
  24794. layerMask: number;
  24795. /**
  24796. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24797. */
  24798. fovMode: number;
  24799. /**
  24800. * Rig mode of the camera.
  24801. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24802. * This is normally controlled byt the camera themselves as internal use.
  24803. */
  24804. cameraRigMode: number;
  24805. /**
  24806. * Defines the distance between both "eyes" in case of a RIG
  24807. */
  24808. interaxialDistance: number;
  24809. /**
  24810. * Defines if stereoscopic rendering is done side by side or over under.
  24811. */
  24812. isStereoscopicSideBySide: boolean;
  24813. /**
  24814. * 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
  24815. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24816. * else in the scene. (Eg. security camera)
  24817. *
  24818. * 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)
  24819. */
  24820. customRenderTargets: RenderTargetTexture[];
  24821. /**
  24822. * When set, the camera will render to this render target instead of the default canvas
  24823. *
  24824. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24825. */
  24826. outputRenderTarget: Nullable<RenderTargetTexture>;
  24827. /**
  24828. * Observable triggered when the camera view matrix has changed.
  24829. */
  24830. onViewMatrixChangedObservable: Observable<Camera>;
  24831. /**
  24832. * Observable triggered when the camera Projection matrix has changed.
  24833. */
  24834. onProjectionMatrixChangedObservable: Observable<Camera>;
  24835. /**
  24836. * Observable triggered when the inputs have been processed.
  24837. */
  24838. onAfterCheckInputsObservable: Observable<Camera>;
  24839. /**
  24840. * Observable triggered when reset has been called and applied to the camera.
  24841. */
  24842. onRestoreStateObservable: Observable<Camera>;
  24843. /** @hidden */
  24844. _cameraRigParams: any;
  24845. /** @hidden */
  24846. _rigCameras: Camera[];
  24847. /** @hidden */
  24848. _rigPostProcess: Nullable<PostProcess>;
  24849. protected _webvrViewMatrix: Matrix;
  24850. /** @hidden */
  24851. _skipRendering: boolean;
  24852. /** @hidden */
  24853. _projectionMatrix: Matrix;
  24854. /** @hidden */
  24855. _postProcesses: Nullable<PostProcess>[];
  24856. /** @hidden */
  24857. _activeMeshes: SmartArray<AbstractMesh>;
  24858. protected _globalPosition: Vector3;
  24859. /** @hidden */
  24860. _computedViewMatrix: Matrix;
  24861. private _doNotComputeProjectionMatrix;
  24862. private _transformMatrix;
  24863. private _frustumPlanes;
  24864. private _refreshFrustumPlanes;
  24865. private _storedFov;
  24866. private _stateStored;
  24867. /**
  24868. * Instantiates a new camera object.
  24869. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24870. * @see http://doc.babylonjs.com/features/cameras
  24871. * @param name Defines the name of the camera in the scene
  24872. * @param position Defines the position of the camera
  24873. * @param scene Defines the scene the camera belongs too
  24874. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24875. */
  24876. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24877. /**
  24878. * Store current camera state (fov, position, etc..)
  24879. * @returns the camera
  24880. */
  24881. storeState(): Camera;
  24882. /**
  24883. * Restores the camera state values if it has been stored. You must call storeState() first
  24884. */
  24885. protected _restoreStateValues(): boolean;
  24886. /**
  24887. * Restored camera state. You must call storeState() first.
  24888. * @returns true if restored and false otherwise
  24889. */
  24890. restoreState(): boolean;
  24891. /**
  24892. * Gets the class name of the camera.
  24893. * @returns the class name
  24894. */
  24895. getClassName(): string;
  24896. /** @hidden */
  24897. readonly _isCamera: boolean;
  24898. /**
  24899. * Gets a string representation of the camera useful for debug purpose.
  24900. * @param fullDetails Defines that a more verboe level of logging is required
  24901. * @returns the string representation
  24902. */
  24903. toString(fullDetails?: boolean): string;
  24904. /**
  24905. * Gets the current world space position of the camera.
  24906. */
  24907. readonly globalPosition: Vector3;
  24908. /**
  24909. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24910. * @returns the active meshe list
  24911. */
  24912. getActiveMeshes(): SmartArray<AbstractMesh>;
  24913. /**
  24914. * Check wether a mesh is part of the current active mesh list of the camera
  24915. * @param mesh Defines the mesh to check
  24916. * @returns true if active, false otherwise
  24917. */
  24918. isActiveMesh(mesh: Mesh): boolean;
  24919. /**
  24920. * Is this camera ready to be used/rendered
  24921. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24922. * @return true if the camera is ready
  24923. */
  24924. isReady(completeCheck?: boolean): boolean;
  24925. /** @hidden */
  24926. _initCache(): void;
  24927. /** @hidden */
  24928. _updateCache(ignoreParentClass?: boolean): void;
  24929. /** @hidden */
  24930. _isSynchronized(): boolean;
  24931. /** @hidden */
  24932. _isSynchronizedViewMatrix(): boolean;
  24933. /** @hidden */
  24934. _isSynchronizedProjectionMatrix(): boolean;
  24935. /**
  24936. * Attach the input controls to a specific dom element to get the input from.
  24937. * @param element Defines the element the controls should be listened from
  24938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24939. */
  24940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24941. /**
  24942. * Detach the current controls from the specified dom element.
  24943. * @param element Defines the element to stop listening the inputs from
  24944. */
  24945. detachControl(element: HTMLElement): void;
  24946. /**
  24947. * Update the camera state according to the different inputs gathered during the frame.
  24948. */
  24949. update(): void;
  24950. /** @hidden */
  24951. _checkInputs(): void;
  24952. /** @hidden */
  24953. readonly rigCameras: Camera[];
  24954. /**
  24955. * Gets the post process used by the rig cameras
  24956. */
  24957. readonly rigPostProcess: Nullable<PostProcess>;
  24958. /**
  24959. * Internal, gets the first post proces.
  24960. * @returns the first post process to be run on this camera.
  24961. */
  24962. _getFirstPostProcess(): Nullable<PostProcess>;
  24963. private _cascadePostProcessesToRigCams;
  24964. /**
  24965. * Attach a post process to the camera.
  24966. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24967. * @param postProcess The post process to attach to the camera
  24968. * @param insertAt The position of the post process in case several of them are in use in the scene
  24969. * @returns the position the post process has been inserted at
  24970. */
  24971. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24972. /**
  24973. * Detach a post process to the camera.
  24974. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24975. * @param postProcess The post process to detach from the camera
  24976. */
  24977. detachPostProcess(postProcess: PostProcess): void;
  24978. /**
  24979. * Gets the current world matrix of the camera
  24980. */
  24981. getWorldMatrix(): Matrix;
  24982. /** @hidden */
  24983. _getViewMatrix(): Matrix;
  24984. /**
  24985. * Gets the current view matrix of the camera.
  24986. * @param force forces the camera to recompute the matrix without looking at the cached state
  24987. * @returns the view matrix
  24988. */
  24989. getViewMatrix(force?: boolean): Matrix;
  24990. /**
  24991. * Freeze the projection matrix.
  24992. * It will prevent the cache check of the camera projection compute and can speed up perf
  24993. * if no parameter of the camera are meant to change
  24994. * @param projection Defines manually a projection if necessary
  24995. */
  24996. freezeProjectionMatrix(projection?: Matrix): void;
  24997. /**
  24998. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24999. */
  25000. unfreezeProjectionMatrix(): void;
  25001. /**
  25002. * Gets the current projection matrix of the camera.
  25003. * @param force forces the camera to recompute the matrix without looking at the cached state
  25004. * @returns the projection matrix
  25005. */
  25006. getProjectionMatrix(force?: boolean): Matrix;
  25007. /**
  25008. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25009. * @returns a Matrix
  25010. */
  25011. getTransformationMatrix(): Matrix;
  25012. private _updateFrustumPlanes;
  25013. /**
  25014. * Checks if a cullable object (mesh...) is in the camera frustum
  25015. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25016. * @param target The object to check
  25017. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25018. * @returns true if the object is in frustum otherwise false
  25019. */
  25020. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25021. /**
  25022. * Checks if a cullable object (mesh...) is in the camera frustum
  25023. * Unlike isInFrustum this cheks the full bounding box
  25024. * @param target The object to check
  25025. * @returns true if the object is in frustum otherwise false
  25026. */
  25027. isCompletelyInFrustum(target: ICullable): boolean;
  25028. /**
  25029. * Gets a ray in the forward direction from the camera.
  25030. * @param length Defines the length of the ray to create
  25031. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25032. * @param origin Defines the start point of the ray which defaults to the camera position
  25033. * @returns the forward ray
  25034. */
  25035. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25036. /**
  25037. * Releases resources associated with this node.
  25038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25040. */
  25041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25042. /** @hidden */
  25043. _isLeftCamera: boolean;
  25044. /**
  25045. * Gets the left camera of a rig setup in case of Rigged Camera
  25046. */
  25047. readonly isLeftCamera: boolean;
  25048. /** @hidden */
  25049. _isRightCamera: boolean;
  25050. /**
  25051. * Gets the right camera of a rig setup in case of Rigged Camera
  25052. */
  25053. readonly isRightCamera: boolean;
  25054. /**
  25055. * Gets the left camera of a rig setup in case of Rigged Camera
  25056. */
  25057. readonly leftCamera: Nullable<FreeCamera>;
  25058. /**
  25059. * Gets the right camera of a rig setup in case of Rigged Camera
  25060. */
  25061. readonly rightCamera: Nullable<FreeCamera>;
  25062. /**
  25063. * Gets the left camera target of a rig setup in case of Rigged Camera
  25064. * @returns the target position
  25065. */
  25066. getLeftTarget(): Nullable<Vector3>;
  25067. /**
  25068. * Gets the right camera target of a rig setup in case of Rigged Camera
  25069. * @returns the target position
  25070. */
  25071. getRightTarget(): Nullable<Vector3>;
  25072. /**
  25073. * @hidden
  25074. */
  25075. setCameraRigMode(mode: number, rigParams: any): void;
  25076. /** @hidden */
  25077. static _setStereoscopicRigMode(camera: Camera): void;
  25078. /** @hidden */
  25079. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25080. /** @hidden */
  25081. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25082. /** @hidden */
  25083. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25084. /** @hidden */
  25085. _getVRProjectionMatrix(): Matrix;
  25086. protected _updateCameraRotationMatrix(): void;
  25087. protected _updateWebVRCameraRotationMatrix(): void;
  25088. /**
  25089. * This function MUST be overwritten by the different WebVR cameras available.
  25090. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25091. * @hidden
  25092. */
  25093. _getWebVRProjectionMatrix(): Matrix;
  25094. /**
  25095. * This function MUST be overwritten by the different WebVR cameras available.
  25096. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25097. * @hidden
  25098. */
  25099. _getWebVRViewMatrix(): Matrix;
  25100. /** @hidden */
  25101. setCameraRigParameter(name: string, value: any): void;
  25102. /**
  25103. * needs to be overridden by children so sub has required properties to be copied
  25104. * @hidden
  25105. */
  25106. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25107. /**
  25108. * May need to be overridden by children
  25109. * @hidden
  25110. */
  25111. _updateRigCameras(): void;
  25112. /** @hidden */
  25113. _setupInputs(): void;
  25114. /**
  25115. * Serialiaze the camera setup to a json represention
  25116. * @returns the JSON representation
  25117. */
  25118. serialize(): any;
  25119. /**
  25120. * Clones the current camera.
  25121. * @param name The cloned camera name
  25122. * @returns the cloned camera
  25123. */
  25124. clone(name: string): Camera;
  25125. /**
  25126. * Gets the direction of the camera relative to a given local axis.
  25127. * @param localAxis Defines the reference axis to provide a relative direction.
  25128. * @return the direction
  25129. */
  25130. getDirection(localAxis: Vector3): Vector3;
  25131. /**
  25132. * Returns the current camera absolute rotation
  25133. */
  25134. readonly absoluteRotation: Quaternion;
  25135. /**
  25136. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25137. * @param localAxis Defines the reference axis to provide a relative direction.
  25138. * @param result Defines the vector to store the result in
  25139. */
  25140. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25141. /**
  25142. * Gets a camera constructor for a given camera type
  25143. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25144. * @param name The name of the camera the result will be able to instantiate
  25145. * @param scene The scene the result will construct the camera in
  25146. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25147. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25148. * @returns a factory method to construc the camera
  25149. */
  25150. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25151. /**
  25152. * Compute the world matrix of the camera.
  25153. * @returns the camera workd matrix
  25154. */
  25155. computeWorldMatrix(): Matrix;
  25156. /**
  25157. * Parse a JSON and creates the camera from the parsed information
  25158. * @param parsedCamera The JSON to parse
  25159. * @param scene The scene to instantiate the camera in
  25160. * @returns the newly constructed camera
  25161. */
  25162. static Parse(parsedCamera: any, scene: Scene): Camera;
  25163. }
  25164. }
  25165. declare module BABYLON {
  25166. /**
  25167. * Class containing static functions to help procedurally build meshes
  25168. */
  25169. export class DiscBuilder {
  25170. /**
  25171. * Creates a plane polygonal mesh. By default, this is a disc
  25172. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25173. * * 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
  25174. * * 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
  25175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25176. * * 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
  25177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25178. * @param name defines the name of the mesh
  25179. * @param options defines the options used to create the mesh
  25180. * @param scene defines the hosting scene
  25181. * @returns the plane polygonal mesh
  25182. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25183. */
  25184. static CreateDisc(name: string, options: {
  25185. radius?: number;
  25186. tessellation?: number;
  25187. arc?: number;
  25188. updatable?: boolean;
  25189. sideOrientation?: number;
  25190. frontUVs?: Vector4;
  25191. backUVs?: Vector4;
  25192. }, scene?: Nullable<Scene>): Mesh;
  25193. }
  25194. }
  25195. declare module BABYLON {
  25196. /**
  25197. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25198. *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.
  25199. * The SPS is also a particle system. It provides some methods to manage the particles.
  25200. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25201. *
  25202. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25203. */
  25204. export class SolidParticleSystem implements IDisposable {
  25205. /**
  25206. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25207. * Example : var p = SPS.particles[i];
  25208. */
  25209. particles: SolidParticle[];
  25210. /**
  25211. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25212. */
  25213. nbParticles: number;
  25214. /**
  25215. * If the particles must ever face the camera (default false). Useful for planar particles.
  25216. */
  25217. billboard: boolean;
  25218. /**
  25219. * Recompute normals when adding a shape
  25220. */
  25221. recomputeNormals: boolean;
  25222. /**
  25223. * This a counter ofr your own usage. It's not set by any SPS functions.
  25224. */
  25225. counter: number;
  25226. /**
  25227. * The SPS name. This name is also given to the underlying mesh.
  25228. */
  25229. name: string;
  25230. /**
  25231. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25232. */
  25233. mesh: Mesh;
  25234. /**
  25235. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25236. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25237. */
  25238. vars: any;
  25239. /**
  25240. * This array is populated when the SPS is set as 'pickable'.
  25241. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25242. * Each element of this array is an object `{idx: int, faceId: int}`.
  25243. * `idx` is the picked particle index in the `SPS.particles` array
  25244. * `faceId` is the picked face index counted within this particle.
  25245. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25246. */
  25247. pickedParticles: {
  25248. idx: number;
  25249. faceId: number;
  25250. }[];
  25251. /**
  25252. * This array is populated when `enableDepthSort` is set to true.
  25253. * Each element of this array is an instance of the class DepthSortedParticle.
  25254. */
  25255. depthSortedParticles: DepthSortedParticle[];
  25256. /**
  25257. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25258. * @hidden
  25259. */
  25260. _bSphereOnly: boolean;
  25261. /**
  25262. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25263. * @hidden
  25264. */
  25265. _bSphereRadiusFactor: number;
  25266. private _scene;
  25267. private _positions;
  25268. private _indices;
  25269. private _normals;
  25270. private _colors;
  25271. private _uvs;
  25272. private _indices32;
  25273. private _positions32;
  25274. private _normals32;
  25275. private _fixedNormal32;
  25276. private _colors32;
  25277. private _uvs32;
  25278. private _index;
  25279. private _updatable;
  25280. private _pickable;
  25281. private _isVisibilityBoxLocked;
  25282. private _alwaysVisible;
  25283. private _depthSort;
  25284. private _shapeCounter;
  25285. private _copy;
  25286. private _color;
  25287. private _computeParticleColor;
  25288. private _computeParticleTexture;
  25289. private _computeParticleRotation;
  25290. private _computeParticleVertex;
  25291. private _computeBoundingBox;
  25292. private _depthSortParticles;
  25293. private _camera;
  25294. private _mustUnrotateFixedNormals;
  25295. private _particlesIntersect;
  25296. private _needs32Bits;
  25297. /**
  25298. * Creates a SPS (Solid Particle System) object.
  25299. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25300. * @param scene (Scene) is the scene in which the SPS is added.
  25301. * @param options defines the options of the sps e.g.
  25302. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25303. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25304. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25305. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25306. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25307. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25308. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25309. */
  25310. constructor(name: string, scene: Scene, options?: {
  25311. updatable?: boolean;
  25312. isPickable?: boolean;
  25313. enableDepthSort?: boolean;
  25314. particleIntersection?: boolean;
  25315. boundingSphereOnly?: boolean;
  25316. bSphereRadiusFactor?: number;
  25317. });
  25318. /**
  25319. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25320. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25321. * @returns the created mesh
  25322. */
  25323. buildMesh(): Mesh;
  25324. /**
  25325. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25326. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25327. * Thus the particles generated from `digest()` have their property `position` set yet.
  25328. * @param mesh ( Mesh ) is the mesh to be digested
  25329. * @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
  25330. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25331. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25332. * @returns the current SPS
  25333. */
  25334. digest(mesh: Mesh, options?: {
  25335. facetNb?: number;
  25336. number?: number;
  25337. delta?: number;
  25338. }): SolidParticleSystem;
  25339. private _unrotateFixedNormals;
  25340. private _resetCopy;
  25341. private _meshBuilder;
  25342. private _posToShape;
  25343. private _uvsToShapeUV;
  25344. private _addParticle;
  25345. /**
  25346. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25347. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25348. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25349. * @param nb (positive integer) the number of particles to be created from this model
  25350. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25351. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25352. * @returns the number of shapes in the system
  25353. */
  25354. addShape(mesh: Mesh, nb: number, options?: {
  25355. positionFunction?: any;
  25356. vertexFunction?: any;
  25357. }): number;
  25358. private _rebuildParticle;
  25359. /**
  25360. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25361. * @returns the SPS.
  25362. */
  25363. rebuildMesh(): SolidParticleSystem;
  25364. /**
  25365. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25366. * This method calls `updateParticle()` for each particle of the SPS.
  25367. * For an animated SPS, it is usually called within the render loop.
  25368. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25369. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25370. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25371. * @returns the SPS.
  25372. */
  25373. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25374. /**
  25375. * Disposes the SPS.
  25376. */
  25377. dispose(): void;
  25378. /**
  25379. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25380. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25381. * @returns the SPS.
  25382. */
  25383. refreshVisibleSize(): SolidParticleSystem;
  25384. /**
  25385. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25386. * @param size the size (float) of the visibility box
  25387. * note : this doesn't lock the SPS mesh bounding box.
  25388. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25389. */
  25390. setVisibilityBox(size: number): void;
  25391. /**
  25392. * Gets whether the SPS as always visible or not
  25393. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25394. */
  25395. /**
  25396. * Sets the SPS as always visible or not
  25397. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25398. */
  25399. isAlwaysVisible: boolean;
  25400. /**
  25401. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25402. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25403. */
  25404. /**
  25405. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25406. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25407. */
  25408. isVisibilityBoxLocked: boolean;
  25409. /**
  25410. * Tells to `setParticles()` to compute the particle rotations or not.
  25411. * Default value : true. The SPS is faster when it's set to false.
  25412. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25413. */
  25414. /**
  25415. * Gets if `setParticles()` computes the particle rotations or not.
  25416. * Default value : true. The SPS is faster when it's set to false.
  25417. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25418. */
  25419. computeParticleRotation: boolean;
  25420. /**
  25421. * Tells to `setParticles()` to compute the particle colors or not.
  25422. * Default value : true. The SPS is faster when it's set to false.
  25423. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25424. */
  25425. /**
  25426. * Gets if `setParticles()` computes the particle colors or not.
  25427. * Default value : true. The SPS is faster when it's set to false.
  25428. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25429. */
  25430. computeParticleColor: boolean;
  25431. /**
  25432. * Gets if `setParticles()` computes the particle textures or not.
  25433. * Default value : true. The SPS is faster when it's set to false.
  25434. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25435. */
  25436. computeParticleTexture: boolean;
  25437. /**
  25438. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25439. * Default value : false. The SPS is faster when it's set to false.
  25440. * Note : the particle custom vertex positions aren't stored values.
  25441. */
  25442. /**
  25443. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25444. * Default value : false. The SPS is faster when it's set to false.
  25445. * Note : the particle custom vertex positions aren't stored values.
  25446. */
  25447. computeParticleVertex: boolean;
  25448. /**
  25449. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25450. */
  25451. /**
  25452. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25453. */
  25454. computeBoundingBox: boolean;
  25455. /**
  25456. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25457. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25458. * Default : `true`
  25459. */
  25460. /**
  25461. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25462. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25463. * Default : `true`
  25464. */
  25465. depthSortParticles: boolean;
  25466. /**
  25467. * This function does nothing. It may be overwritten to set all the particle first values.
  25468. * The SPS doesn't call this function, you may have to call it by your own.
  25469. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25470. */
  25471. initParticles(): void;
  25472. /**
  25473. * This function does nothing. It may be overwritten to recycle a particle.
  25474. * The SPS doesn't call this function, you may have to call it by your own.
  25475. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25476. * @param particle The particle to recycle
  25477. * @returns the recycled particle
  25478. */
  25479. recycleParticle(particle: SolidParticle): SolidParticle;
  25480. /**
  25481. * Updates a particle : this function should be overwritten by the user.
  25482. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25483. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25484. * @example : just set a particle position or velocity and recycle conditions
  25485. * @param particle The particle to update
  25486. * @returns the updated particle
  25487. */
  25488. updateParticle(particle: SolidParticle): SolidParticle;
  25489. /**
  25490. * Updates a vertex of a particle : it can be overwritten by the user.
  25491. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25492. * @param particle the current particle
  25493. * @param vertex the current index of the current particle
  25494. * @param pt the index of the current vertex in the particle shape
  25495. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25496. * @example : just set a vertex particle position
  25497. * @returns the updated vertex
  25498. */
  25499. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25500. /**
  25501. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25502. * This does nothing and may be overwritten by the user.
  25503. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25504. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25505. * @param update the boolean update value actually passed to setParticles()
  25506. */
  25507. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25508. /**
  25509. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25510. * This will be passed three parameters.
  25511. * This does nothing and may be overwritten by the user.
  25512. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25513. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25514. * @param update the boolean update value actually passed to setParticles()
  25515. */
  25516. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25517. }
  25518. }
  25519. declare module BABYLON {
  25520. /**
  25521. * Represents one particle of a solid particle system.
  25522. */
  25523. export class SolidParticle {
  25524. /**
  25525. * particle global index
  25526. */
  25527. idx: number;
  25528. /**
  25529. * The color of the particle
  25530. */
  25531. color: Nullable<Color4>;
  25532. /**
  25533. * The world space position of the particle.
  25534. */
  25535. position: Vector3;
  25536. /**
  25537. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25538. */
  25539. rotation: Vector3;
  25540. /**
  25541. * The world space rotation quaternion of the particle.
  25542. */
  25543. rotationQuaternion: Nullable<Quaternion>;
  25544. /**
  25545. * The scaling of the particle.
  25546. */
  25547. scaling: Vector3;
  25548. /**
  25549. * The uvs of the particle.
  25550. */
  25551. uvs: Vector4;
  25552. /**
  25553. * The current speed of the particle.
  25554. */
  25555. velocity: Vector3;
  25556. /**
  25557. * The pivot point in the particle local space.
  25558. */
  25559. pivot: Vector3;
  25560. /**
  25561. * Must the particle be translated from its pivot point in its local space ?
  25562. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25563. * Default : false
  25564. */
  25565. translateFromPivot: boolean;
  25566. /**
  25567. * Is the particle active or not ?
  25568. */
  25569. alive: boolean;
  25570. /**
  25571. * Is the particle visible or not ?
  25572. */
  25573. isVisible: boolean;
  25574. /**
  25575. * Index of this particle in the global "positions" array (Internal use)
  25576. * @hidden
  25577. */
  25578. _pos: number;
  25579. /**
  25580. * @hidden Index of this particle in the global "indices" array (Internal use)
  25581. */
  25582. _ind: number;
  25583. /**
  25584. * @hidden ModelShape of this particle (Internal use)
  25585. */
  25586. _model: ModelShape;
  25587. /**
  25588. * ModelShape id of this particle
  25589. */
  25590. shapeId: number;
  25591. /**
  25592. * Index of the particle in its shape id
  25593. */
  25594. idxInShape: number;
  25595. /**
  25596. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25597. */
  25598. _modelBoundingInfo: BoundingInfo;
  25599. /**
  25600. * @hidden Particle BoundingInfo object (Internal use)
  25601. */
  25602. _boundingInfo: BoundingInfo;
  25603. /**
  25604. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25605. */
  25606. _sps: SolidParticleSystem;
  25607. /**
  25608. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25609. */
  25610. _stillInvisible: boolean;
  25611. /**
  25612. * @hidden Last computed particle rotation matrix
  25613. */
  25614. _rotationMatrix: number[];
  25615. /**
  25616. * Parent particle Id, if any.
  25617. * Default null.
  25618. */
  25619. parentId: Nullable<number>;
  25620. /**
  25621. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25622. * The possible values are :
  25623. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25624. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25625. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25626. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25627. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25628. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25629. * */
  25630. cullingStrategy: number;
  25631. /**
  25632. * @hidden Internal global position in the SPS.
  25633. */
  25634. _globalPosition: Vector3;
  25635. /**
  25636. * Creates a Solid Particle object.
  25637. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25638. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25639. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25640. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25641. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25642. * @param shapeId (integer) is the model shape identifier in the SPS.
  25643. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25644. * @param sps defines the sps it is associated to
  25645. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25646. */
  25647. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25648. /**
  25649. * Legacy support, changed scale to scaling
  25650. */
  25651. /**
  25652. * Legacy support, changed scale to scaling
  25653. */
  25654. scale: Vector3;
  25655. /**
  25656. * Legacy support, changed quaternion to rotationQuaternion
  25657. */
  25658. /**
  25659. * Legacy support, changed quaternion to rotationQuaternion
  25660. */
  25661. quaternion: Nullable<Quaternion>;
  25662. /**
  25663. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25664. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25665. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25666. * @returns true if it intersects
  25667. */
  25668. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25669. /**
  25670. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25671. * A particle is in the frustum if its bounding box intersects the frustum
  25672. * @param frustumPlanes defines the frustum to test
  25673. * @returns true if the particle is in the frustum planes
  25674. */
  25675. isInFrustum(frustumPlanes: Plane[]): boolean;
  25676. /**
  25677. * get the rotation matrix of the particle
  25678. * @hidden
  25679. */
  25680. getRotationMatrix(m: Matrix): void;
  25681. }
  25682. /**
  25683. * Represents the shape of the model used by one particle of a solid particle system.
  25684. * SPS internal tool, don't use it manually.
  25685. */
  25686. export class ModelShape {
  25687. /**
  25688. * The shape id
  25689. * @hidden
  25690. */
  25691. shapeID: number;
  25692. /**
  25693. * flat array of model positions (internal use)
  25694. * @hidden
  25695. */
  25696. _shape: Vector3[];
  25697. /**
  25698. * flat array of model UVs (internal use)
  25699. * @hidden
  25700. */
  25701. _shapeUV: number[];
  25702. /**
  25703. * length of the shape in the model indices array (internal use)
  25704. * @hidden
  25705. */
  25706. _indicesLength: number;
  25707. /**
  25708. * Custom position function (internal use)
  25709. * @hidden
  25710. */
  25711. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25712. /**
  25713. * Custom vertex function (internal use)
  25714. * @hidden
  25715. */
  25716. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25717. /**
  25718. * 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.
  25719. * SPS internal tool, don't use it manually.
  25720. * @hidden
  25721. */
  25722. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25723. }
  25724. /**
  25725. * Represents a Depth Sorted Particle in the solid particle system.
  25726. */
  25727. export class DepthSortedParticle {
  25728. /**
  25729. * Index of the particle in the "indices" array
  25730. */
  25731. ind: number;
  25732. /**
  25733. * Length of the particle shape in the "indices" array
  25734. */
  25735. indicesLength: number;
  25736. /**
  25737. * Squared distance from the particle to the camera
  25738. */
  25739. sqDistance: number;
  25740. }
  25741. }
  25742. declare module BABYLON {
  25743. /**
  25744. * @hidden
  25745. */
  25746. export class _MeshCollisionData {
  25747. _checkCollisions: boolean;
  25748. _collisionMask: number;
  25749. _collisionGroup: number;
  25750. _collider: Nullable<Collider>;
  25751. _oldPositionForCollisions: Vector3;
  25752. _diffPositionForCollisions: Vector3;
  25753. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25754. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25755. }
  25756. }
  25757. declare module BABYLON {
  25758. /** @hidden */
  25759. class _FacetDataStorage {
  25760. facetPositions: Vector3[];
  25761. facetNormals: Vector3[];
  25762. facetPartitioning: number[][];
  25763. facetNb: number;
  25764. partitioningSubdivisions: number;
  25765. partitioningBBoxRatio: number;
  25766. facetDataEnabled: boolean;
  25767. facetParameters: any;
  25768. bbSize: Vector3;
  25769. subDiv: {
  25770. max: number;
  25771. X: number;
  25772. Y: number;
  25773. Z: number;
  25774. };
  25775. facetDepthSort: boolean;
  25776. facetDepthSortEnabled: boolean;
  25777. depthSortedIndices: IndicesArray;
  25778. depthSortedFacets: {
  25779. ind: number;
  25780. sqDistance: number;
  25781. }[];
  25782. facetDepthSortFunction: (f1: {
  25783. ind: number;
  25784. sqDistance: number;
  25785. }, f2: {
  25786. ind: number;
  25787. sqDistance: number;
  25788. }) => number;
  25789. facetDepthSortFrom: Vector3;
  25790. facetDepthSortOrigin: Vector3;
  25791. invertedMatrix: Matrix;
  25792. }
  25793. /**
  25794. * @hidden
  25795. **/
  25796. class _InternalAbstractMeshDataInfo {
  25797. _hasVertexAlpha: boolean;
  25798. _useVertexColors: boolean;
  25799. _numBoneInfluencers: number;
  25800. _applyFog: boolean;
  25801. _receiveShadows: boolean;
  25802. _facetData: _FacetDataStorage;
  25803. _visibility: number;
  25804. _skeleton: Nullable<Skeleton>;
  25805. _layerMask: number;
  25806. _computeBonesUsingShaders: boolean;
  25807. _isActive: boolean;
  25808. _onlyForInstances: boolean;
  25809. _isActiveIntermediate: boolean;
  25810. _onlyForInstancesIntermediate: boolean;
  25811. }
  25812. /**
  25813. * Class used to store all common mesh properties
  25814. */
  25815. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25816. /** No occlusion */
  25817. static OCCLUSION_TYPE_NONE: number;
  25818. /** Occlusion set to optimisitic */
  25819. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25820. /** Occlusion set to strict */
  25821. static OCCLUSION_TYPE_STRICT: number;
  25822. /** Use an accurante occlusion algorithm */
  25823. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25824. /** Use a conservative occlusion algorithm */
  25825. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25826. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25827. * Test order :
  25828. * Is the bounding sphere outside the frustum ?
  25829. * If not, are the bounding box vertices outside the frustum ?
  25830. * It not, then the cullable object is in the frustum.
  25831. */
  25832. static readonly CULLINGSTRATEGY_STANDARD: number;
  25833. /** Culling strategy : Bounding Sphere Only.
  25834. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25835. * It's also less accurate than the standard because some not visible objects can still be selected.
  25836. * Test : is the bounding sphere outside the frustum ?
  25837. * If not, then the cullable object is in the frustum.
  25838. */
  25839. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25840. /** Culling strategy : Optimistic Inclusion.
  25841. * This in an inclusion test first, then the standard exclusion test.
  25842. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25843. * 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.
  25844. * Anyway, it's as accurate as the standard strategy.
  25845. * Test :
  25846. * Is the cullable object bounding sphere center in the frustum ?
  25847. * If not, apply the default culling strategy.
  25848. */
  25849. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25850. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25851. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25852. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25853. * 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.
  25854. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25855. * Test :
  25856. * Is the cullable object bounding sphere center in the frustum ?
  25857. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25858. */
  25859. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25860. /**
  25861. * No billboard
  25862. */
  25863. static readonly BILLBOARDMODE_NONE: number;
  25864. /** Billboard on X axis */
  25865. static readonly BILLBOARDMODE_X: number;
  25866. /** Billboard on Y axis */
  25867. static readonly BILLBOARDMODE_Y: number;
  25868. /** Billboard on Z axis */
  25869. static readonly BILLBOARDMODE_Z: number;
  25870. /** Billboard on all axes */
  25871. static readonly BILLBOARDMODE_ALL: number;
  25872. /** Billboard on using position instead of orientation */
  25873. static readonly BILLBOARDMODE_USE_POSITION: number;
  25874. /** @hidden */
  25875. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25876. /**
  25877. * The culling strategy to use to check whether the mesh must be rendered or not.
  25878. * This value can be changed at any time and will be used on the next render mesh selection.
  25879. * The possible values are :
  25880. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25881. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25882. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25883. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25884. * Please read each static variable documentation to get details about the culling process.
  25885. * */
  25886. cullingStrategy: number;
  25887. /**
  25888. * Gets the number of facets in the mesh
  25889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25890. */
  25891. readonly facetNb: number;
  25892. /**
  25893. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25895. */
  25896. partitioningSubdivisions: number;
  25897. /**
  25898. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25899. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25901. */
  25902. partitioningBBoxRatio: number;
  25903. /**
  25904. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25905. * Works only for updatable meshes.
  25906. * Doesn't work with multi-materials
  25907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25908. */
  25909. mustDepthSortFacets: boolean;
  25910. /**
  25911. * The location (Vector3) where the facet depth sort must be computed from.
  25912. * By default, the active camera position.
  25913. * Used only when facet depth sort is enabled
  25914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25915. */
  25916. facetDepthSortFrom: Vector3;
  25917. /**
  25918. * gets a boolean indicating if facetData is enabled
  25919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25920. */
  25921. readonly isFacetDataEnabled: boolean;
  25922. /** @hidden */
  25923. _updateNonUniformScalingState(value: boolean): boolean;
  25924. /**
  25925. * An event triggered when this mesh collides with another one
  25926. */
  25927. onCollideObservable: Observable<AbstractMesh>;
  25928. /** Set a function to call when this mesh collides with another one */
  25929. onCollide: () => void;
  25930. /**
  25931. * An event triggered when the collision's position changes
  25932. */
  25933. onCollisionPositionChangeObservable: Observable<Vector3>;
  25934. /** Set a function to call when the collision's position changes */
  25935. onCollisionPositionChange: () => void;
  25936. /**
  25937. * An event triggered when material is changed
  25938. */
  25939. onMaterialChangedObservable: Observable<AbstractMesh>;
  25940. /**
  25941. * Gets or sets the orientation for POV movement & rotation
  25942. */
  25943. definedFacingForward: boolean;
  25944. /** @hidden */
  25945. _occlusionQuery: Nullable<WebGLQuery>;
  25946. /** @hidden */
  25947. _renderingGroup: Nullable<RenderingGroup>;
  25948. /**
  25949. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25950. */
  25951. /**
  25952. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25953. */
  25954. visibility: number;
  25955. /** Gets or sets the alpha index used to sort transparent meshes
  25956. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25957. */
  25958. alphaIndex: number;
  25959. /**
  25960. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25961. */
  25962. isVisible: boolean;
  25963. /**
  25964. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25965. */
  25966. isPickable: boolean;
  25967. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25968. showSubMeshesBoundingBox: boolean;
  25969. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25971. */
  25972. isBlocker: boolean;
  25973. /**
  25974. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25975. */
  25976. enablePointerMoveEvents: boolean;
  25977. /**
  25978. * Specifies the rendering group id for this mesh (0 by default)
  25979. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25980. */
  25981. renderingGroupId: number;
  25982. private _material;
  25983. /** Gets or sets current material */
  25984. material: Nullable<Material>;
  25985. /**
  25986. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25987. * @see http://doc.babylonjs.com/babylon101/shadows
  25988. */
  25989. receiveShadows: boolean;
  25990. /** Defines color to use when rendering outline */
  25991. outlineColor: Color3;
  25992. /** Define width to use when rendering outline */
  25993. outlineWidth: number;
  25994. /** Defines color to use when rendering overlay */
  25995. overlayColor: Color3;
  25996. /** Defines alpha to use when rendering overlay */
  25997. overlayAlpha: number;
  25998. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25999. hasVertexAlpha: boolean;
  26000. /** 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) */
  26001. useVertexColors: boolean;
  26002. /**
  26003. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26004. */
  26005. computeBonesUsingShaders: boolean;
  26006. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26007. numBoneInfluencers: number;
  26008. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26009. applyFog: boolean;
  26010. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26011. useOctreeForRenderingSelection: boolean;
  26012. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26013. useOctreeForPicking: boolean;
  26014. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26015. useOctreeForCollisions: boolean;
  26016. /**
  26017. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26018. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26019. */
  26020. layerMask: number;
  26021. /**
  26022. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26023. */
  26024. alwaysSelectAsActiveMesh: boolean;
  26025. /**
  26026. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26027. */
  26028. doNotSyncBoundingInfo: boolean;
  26029. /**
  26030. * Gets or sets the current action manager
  26031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26032. */
  26033. actionManager: Nullable<AbstractActionManager>;
  26034. private _meshCollisionData;
  26035. /**
  26036. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26038. */
  26039. ellipsoid: Vector3;
  26040. /**
  26041. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26043. */
  26044. ellipsoidOffset: Vector3;
  26045. /**
  26046. * Gets or sets a collision mask used to mask collisions (default is -1).
  26047. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26048. */
  26049. collisionMask: number;
  26050. /**
  26051. * Gets or sets the current collision group mask (-1 by default).
  26052. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26053. */
  26054. collisionGroup: number;
  26055. /**
  26056. * Defines edge width used when edgesRenderer is enabled
  26057. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26058. */
  26059. edgesWidth: number;
  26060. /**
  26061. * Defines edge color used when edgesRenderer is enabled
  26062. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26063. */
  26064. edgesColor: Color4;
  26065. /** @hidden */
  26066. _edgesRenderer: Nullable<IEdgesRenderer>;
  26067. /** @hidden */
  26068. _masterMesh: Nullable<AbstractMesh>;
  26069. /** @hidden */
  26070. _boundingInfo: Nullable<BoundingInfo>;
  26071. /** @hidden */
  26072. _renderId: number;
  26073. /**
  26074. * Gets or sets the list of subMeshes
  26075. * @see http://doc.babylonjs.com/how_to/multi_materials
  26076. */
  26077. subMeshes: SubMesh[];
  26078. /** @hidden */
  26079. _intersectionsInProgress: AbstractMesh[];
  26080. /** @hidden */
  26081. _unIndexed: boolean;
  26082. /** @hidden */
  26083. _lightSources: Light[];
  26084. /** Gets the list of lights affecting that mesh */
  26085. readonly lightSources: Light[];
  26086. /** @hidden */
  26087. readonly _positions: Nullable<Vector3[]>;
  26088. /** @hidden */
  26089. _waitingData: {
  26090. lods: Nullable<any>;
  26091. actions: Nullable<any>;
  26092. freezeWorldMatrix: Nullable<boolean>;
  26093. };
  26094. /** @hidden */
  26095. _bonesTransformMatrices: Nullable<Float32Array>;
  26096. /** @hidden */
  26097. _transformMatrixTexture: Nullable<RawTexture>;
  26098. /**
  26099. * Gets or sets a skeleton to apply skining transformations
  26100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26101. */
  26102. skeleton: Nullable<Skeleton>;
  26103. /**
  26104. * An event triggered when the mesh is rebuilt.
  26105. */
  26106. onRebuildObservable: Observable<AbstractMesh>;
  26107. /**
  26108. * Creates a new AbstractMesh
  26109. * @param name defines the name of the mesh
  26110. * @param scene defines the hosting scene
  26111. */
  26112. constructor(name: string, scene?: Nullable<Scene>);
  26113. /**
  26114. * Returns the string "AbstractMesh"
  26115. * @returns "AbstractMesh"
  26116. */
  26117. getClassName(): string;
  26118. /**
  26119. * Gets a string representation of the current mesh
  26120. * @param fullDetails defines a boolean indicating if full details must be included
  26121. * @returns a string representation of the current mesh
  26122. */
  26123. toString(fullDetails?: boolean): string;
  26124. /**
  26125. * @hidden
  26126. */
  26127. protected _getEffectiveParent(): Nullable<Node>;
  26128. /** @hidden */
  26129. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26130. /** @hidden */
  26131. _rebuild(): void;
  26132. /** @hidden */
  26133. _resyncLightSources(): void;
  26134. /** @hidden */
  26135. _resyncLighSource(light: Light): void;
  26136. /** @hidden */
  26137. _unBindEffect(): void;
  26138. /** @hidden */
  26139. _removeLightSource(light: Light, dispose: boolean): void;
  26140. private _markSubMeshesAsDirty;
  26141. /** @hidden */
  26142. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26143. /** @hidden */
  26144. _markSubMeshesAsAttributesDirty(): void;
  26145. /** @hidden */
  26146. _markSubMeshesAsMiscDirty(): void;
  26147. /**
  26148. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26149. */
  26150. scaling: Vector3;
  26151. /**
  26152. * Returns true if the mesh is blocked. Implemented by child classes
  26153. */
  26154. readonly isBlocked: boolean;
  26155. /**
  26156. * Returns the mesh itself by default. Implemented by child classes
  26157. * @param camera defines the camera to use to pick the right LOD level
  26158. * @returns the currentAbstractMesh
  26159. */
  26160. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26161. /**
  26162. * Returns 0 by default. Implemented by child classes
  26163. * @returns an integer
  26164. */
  26165. getTotalVertices(): number;
  26166. /**
  26167. * Returns a positive integer : the total number of indices in this mesh geometry.
  26168. * @returns the numner of indices or zero if the mesh has no geometry.
  26169. */
  26170. getTotalIndices(): number;
  26171. /**
  26172. * Returns null by default. Implemented by child classes
  26173. * @returns null
  26174. */
  26175. getIndices(): Nullable<IndicesArray>;
  26176. /**
  26177. * Returns the array of the requested vertex data kind. Implemented by child classes
  26178. * @param kind defines the vertex data kind to use
  26179. * @returns null
  26180. */
  26181. getVerticesData(kind: string): Nullable<FloatArray>;
  26182. /**
  26183. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26184. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26185. * Note that a new underlying VertexBuffer object is created each call.
  26186. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26187. * @param kind defines vertex data kind:
  26188. * * VertexBuffer.PositionKind
  26189. * * VertexBuffer.UVKind
  26190. * * VertexBuffer.UV2Kind
  26191. * * VertexBuffer.UV3Kind
  26192. * * VertexBuffer.UV4Kind
  26193. * * VertexBuffer.UV5Kind
  26194. * * VertexBuffer.UV6Kind
  26195. * * VertexBuffer.ColorKind
  26196. * * VertexBuffer.MatricesIndicesKind
  26197. * * VertexBuffer.MatricesIndicesExtraKind
  26198. * * VertexBuffer.MatricesWeightsKind
  26199. * * VertexBuffer.MatricesWeightsExtraKind
  26200. * @param data defines the data source
  26201. * @param updatable defines if the data must be flagged as updatable (or static)
  26202. * @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
  26203. * @returns the current mesh
  26204. */
  26205. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26206. /**
  26207. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26208. * If the mesh has no geometry, it is simply returned as it is.
  26209. * @param kind defines vertex data kind:
  26210. * * VertexBuffer.PositionKind
  26211. * * VertexBuffer.UVKind
  26212. * * VertexBuffer.UV2Kind
  26213. * * VertexBuffer.UV3Kind
  26214. * * VertexBuffer.UV4Kind
  26215. * * VertexBuffer.UV5Kind
  26216. * * VertexBuffer.UV6Kind
  26217. * * VertexBuffer.ColorKind
  26218. * * VertexBuffer.MatricesIndicesKind
  26219. * * VertexBuffer.MatricesIndicesExtraKind
  26220. * * VertexBuffer.MatricesWeightsKind
  26221. * * VertexBuffer.MatricesWeightsExtraKind
  26222. * @param data defines the data source
  26223. * @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
  26224. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26225. * @returns the current mesh
  26226. */
  26227. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26228. /**
  26229. * Sets the mesh indices,
  26230. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26231. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26232. * @param totalVertices Defines the total number of vertices
  26233. * @returns the current mesh
  26234. */
  26235. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26236. /**
  26237. * Gets a boolean indicating if specific vertex data is present
  26238. * @param kind defines the vertex data kind to use
  26239. * @returns true is data kind is present
  26240. */
  26241. isVerticesDataPresent(kind: string): boolean;
  26242. /**
  26243. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26244. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26245. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26246. * @returns a BoundingInfo
  26247. */
  26248. getBoundingInfo(): BoundingInfo;
  26249. /**
  26250. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26251. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26252. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26253. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26254. * @returns the current mesh
  26255. */
  26256. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26257. /**
  26258. * Overwrite the current bounding info
  26259. * @param boundingInfo defines the new bounding info
  26260. * @returns the current mesh
  26261. */
  26262. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26263. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26264. readonly useBones: boolean;
  26265. /** @hidden */
  26266. _preActivate(): void;
  26267. /** @hidden */
  26268. _preActivateForIntermediateRendering(renderId: number): void;
  26269. /** @hidden */
  26270. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26271. /** @hidden */
  26272. _postActivate(): void;
  26273. /** @hidden */
  26274. _freeze(): void;
  26275. /** @hidden */
  26276. _unFreeze(): void;
  26277. /**
  26278. * Gets the current world matrix
  26279. * @returns a Matrix
  26280. */
  26281. getWorldMatrix(): Matrix;
  26282. /** @hidden */
  26283. _getWorldMatrixDeterminant(): number;
  26284. /**
  26285. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26286. */
  26287. readonly isAnInstance: boolean;
  26288. /**
  26289. * Gets a boolean indicating if this mesh has instances
  26290. */
  26291. readonly hasInstances: boolean;
  26292. /**
  26293. * Perform relative position change from the point of view of behind the front of the mesh.
  26294. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26295. * Supports definition of mesh facing forward or backward
  26296. * @param amountRight defines the distance on the right axis
  26297. * @param amountUp defines the distance on the up axis
  26298. * @param amountForward defines the distance on the forward axis
  26299. * @returns the current mesh
  26300. */
  26301. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26302. /**
  26303. * Calculate relative position change from the point of view of behind the front of the mesh.
  26304. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26305. * Supports definition of mesh facing forward or backward
  26306. * @param amountRight defines the distance on the right axis
  26307. * @param amountUp defines the distance on the up axis
  26308. * @param amountForward defines the distance on the forward axis
  26309. * @returns the new displacement vector
  26310. */
  26311. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26312. /**
  26313. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26314. * Supports definition of mesh facing forward or backward
  26315. * @param flipBack defines the flip
  26316. * @param twirlClockwise defines the twirl
  26317. * @param tiltRight defines the tilt
  26318. * @returns the current mesh
  26319. */
  26320. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26321. /**
  26322. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26323. * Supports definition of mesh facing forward or backward.
  26324. * @param flipBack defines the flip
  26325. * @param twirlClockwise defines the twirl
  26326. * @param tiltRight defines the tilt
  26327. * @returns the new rotation vector
  26328. */
  26329. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26330. /**
  26331. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26332. * This means the mesh underlying bounding box and sphere are recomputed.
  26333. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26334. * @returns the current mesh
  26335. */
  26336. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26337. /** @hidden */
  26338. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26339. /** @hidden */
  26340. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26341. /** @hidden */
  26342. _updateBoundingInfo(): AbstractMesh;
  26343. /** @hidden */
  26344. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26345. /** @hidden */
  26346. protected _afterComputeWorldMatrix(): void;
  26347. /** @hidden */
  26348. readonly _effectiveMesh: AbstractMesh;
  26349. /**
  26350. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26351. * A mesh is in the frustum if its bounding box intersects the frustum
  26352. * @param frustumPlanes defines the frustum to test
  26353. * @returns true if the mesh is in the frustum planes
  26354. */
  26355. isInFrustum(frustumPlanes: Plane[]): boolean;
  26356. /**
  26357. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26358. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26359. * @param frustumPlanes defines the frustum to test
  26360. * @returns true if the mesh is completely in the frustum planes
  26361. */
  26362. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26363. /**
  26364. * True if the mesh intersects another mesh or a SolidParticle object
  26365. * @param mesh defines a target mesh or SolidParticle to test
  26366. * @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)
  26367. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26368. * @returns true if there is an intersection
  26369. */
  26370. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26371. /**
  26372. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26373. * @param point defines the point to test
  26374. * @returns true if there is an intersection
  26375. */
  26376. intersectsPoint(point: Vector3): boolean;
  26377. /**
  26378. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26380. */
  26381. checkCollisions: boolean;
  26382. /**
  26383. * Gets Collider object used to compute collisions (not physics)
  26384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26385. */
  26386. readonly collider: Nullable<Collider>;
  26387. /**
  26388. * Move the mesh using collision engine
  26389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26390. * @param displacement defines the requested displacement vector
  26391. * @returns the current mesh
  26392. */
  26393. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26394. private _onCollisionPositionChange;
  26395. /** @hidden */
  26396. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26397. /** @hidden */
  26398. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26399. /** @hidden */
  26400. _checkCollision(collider: Collider): AbstractMesh;
  26401. /** @hidden */
  26402. _generatePointsArray(): boolean;
  26403. /**
  26404. * Checks if the passed Ray intersects with the mesh
  26405. * @param ray defines the ray to use
  26406. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26407. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26408. * @returns the picking info
  26409. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26410. */
  26411. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26412. /**
  26413. * Clones the current mesh
  26414. * @param name defines the mesh name
  26415. * @param newParent defines the new mesh parent
  26416. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26417. * @returns the new mesh
  26418. */
  26419. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26420. /**
  26421. * Disposes all the submeshes of the current meshnp
  26422. * @returns the current mesh
  26423. */
  26424. releaseSubMeshes(): AbstractMesh;
  26425. /**
  26426. * Releases resources associated with this abstract mesh.
  26427. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26428. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26429. */
  26430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26431. /**
  26432. * Adds the passed mesh as a child to the current mesh
  26433. * @param mesh defines the child mesh
  26434. * @returns the current mesh
  26435. */
  26436. addChild(mesh: AbstractMesh): AbstractMesh;
  26437. /**
  26438. * Removes the passed mesh from the current mesh children list
  26439. * @param mesh defines the child mesh
  26440. * @returns the current mesh
  26441. */
  26442. removeChild(mesh: AbstractMesh): AbstractMesh;
  26443. /** @hidden */
  26444. private _initFacetData;
  26445. /**
  26446. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26447. * This method can be called within the render loop.
  26448. * 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
  26449. * @returns the current mesh
  26450. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26451. */
  26452. updateFacetData(): AbstractMesh;
  26453. /**
  26454. * Returns the facetLocalNormals array.
  26455. * The normals are expressed in the mesh local spac
  26456. * @returns an array of Vector3
  26457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26458. */
  26459. getFacetLocalNormals(): Vector3[];
  26460. /**
  26461. * Returns the facetLocalPositions array.
  26462. * The facet positions are expressed in the mesh local space
  26463. * @returns an array of Vector3
  26464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26465. */
  26466. getFacetLocalPositions(): Vector3[];
  26467. /**
  26468. * Returns the facetLocalPartioning array
  26469. * @returns an array of array of numbers
  26470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26471. */
  26472. getFacetLocalPartitioning(): number[][];
  26473. /**
  26474. * Returns the i-th facet position in the world system.
  26475. * This method allocates a new Vector3 per call
  26476. * @param i defines the facet index
  26477. * @returns a new Vector3
  26478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26479. */
  26480. getFacetPosition(i: number): Vector3;
  26481. /**
  26482. * Sets the reference Vector3 with the i-th facet position in the world system
  26483. * @param i defines the facet index
  26484. * @param ref defines the target vector
  26485. * @returns the current mesh
  26486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26487. */
  26488. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26489. /**
  26490. * Returns the i-th facet normal in the world system.
  26491. * This method allocates a new Vector3 per call
  26492. * @param i defines the facet index
  26493. * @returns a new Vector3
  26494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26495. */
  26496. getFacetNormal(i: number): Vector3;
  26497. /**
  26498. * Sets the reference Vector3 with the i-th facet normal in the world system
  26499. * @param i defines the facet index
  26500. * @param ref defines the target vector
  26501. * @returns the current mesh
  26502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26503. */
  26504. getFacetNormalToRef(i: number, ref: Vector3): this;
  26505. /**
  26506. * 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)
  26507. * @param x defines x coordinate
  26508. * @param y defines y coordinate
  26509. * @param z defines z coordinate
  26510. * @returns the array of facet indexes
  26511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26512. */
  26513. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26514. /**
  26515. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26516. * @param projected sets as the (x,y,z) world projection on the facet
  26517. * @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
  26518. * @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
  26519. * @param x defines x coordinate
  26520. * @param y defines y coordinate
  26521. * @param z defines z coordinate
  26522. * @returns the face index if found (or null instead)
  26523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26524. */
  26525. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26526. /**
  26527. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26528. * @param projected sets as the (x,y,z) local projection on the facet
  26529. * @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
  26530. * @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
  26531. * @param x defines x coordinate
  26532. * @param y defines y coordinate
  26533. * @param z defines z coordinate
  26534. * @returns the face index if found (or null instead)
  26535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26536. */
  26537. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26538. /**
  26539. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26540. * @returns the parameters
  26541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26542. */
  26543. getFacetDataParameters(): any;
  26544. /**
  26545. * Disables the feature FacetData and frees the related memory
  26546. * @returns the current mesh
  26547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26548. */
  26549. disableFacetData(): AbstractMesh;
  26550. /**
  26551. * Updates the AbstractMesh indices array
  26552. * @param indices defines the data source
  26553. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26554. * @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)
  26555. * @returns the current mesh
  26556. */
  26557. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26558. /**
  26559. * Creates new normals data for the mesh
  26560. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26561. * @returns the current mesh
  26562. */
  26563. createNormals(updatable: boolean): AbstractMesh;
  26564. /**
  26565. * Align the mesh with a normal
  26566. * @param normal defines the normal to use
  26567. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26568. * @returns the current mesh
  26569. */
  26570. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26571. /** @hidden */
  26572. _checkOcclusionQuery(): boolean;
  26573. /**
  26574. * Disables the mesh edge rendering mode
  26575. * @returns the currentAbstractMesh
  26576. */
  26577. disableEdgesRendering(): AbstractMesh;
  26578. /**
  26579. * Enables the edge rendering mode on the mesh.
  26580. * This mode makes the mesh edges visible
  26581. * @param epsilon defines the maximal distance between two angles to detect a face
  26582. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26583. * @returns the currentAbstractMesh
  26584. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26585. */
  26586. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26587. }
  26588. }
  26589. declare module BABYLON {
  26590. /**
  26591. * Interface used to define ActionEvent
  26592. */
  26593. export interface IActionEvent {
  26594. /** The mesh or sprite that triggered the action */
  26595. source: any;
  26596. /** The X mouse cursor position at the time of the event */
  26597. pointerX: number;
  26598. /** The Y mouse cursor position at the time of the event */
  26599. pointerY: number;
  26600. /** The mesh that is currently pointed at (can be null) */
  26601. meshUnderPointer: Nullable<AbstractMesh>;
  26602. /** the original (browser) event that triggered the ActionEvent */
  26603. sourceEvent?: any;
  26604. /** additional data for the event */
  26605. additionalData?: any;
  26606. }
  26607. /**
  26608. * ActionEvent is the event being sent when an action is triggered.
  26609. */
  26610. export class ActionEvent implements IActionEvent {
  26611. /** The mesh or sprite that triggered the action */
  26612. source: any;
  26613. /** The X mouse cursor position at the time of the event */
  26614. pointerX: number;
  26615. /** The Y mouse cursor position at the time of the event */
  26616. pointerY: number;
  26617. /** The mesh that is currently pointed at (can be null) */
  26618. meshUnderPointer: Nullable<AbstractMesh>;
  26619. /** the original (browser) event that triggered the ActionEvent */
  26620. sourceEvent?: any;
  26621. /** additional data for the event */
  26622. additionalData?: any;
  26623. /**
  26624. * Creates a new ActionEvent
  26625. * @param source The mesh or sprite that triggered the action
  26626. * @param pointerX The X mouse cursor position at the time of the event
  26627. * @param pointerY The Y mouse cursor position at the time of the event
  26628. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26629. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26630. * @param additionalData additional data for the event
  26631. */
  26632. constructor(
  26633. /** The mesh or sprite that triggered the action */
  26634. source: any,
  26635. /** The X mouse cursor position at the time of the event */
  26636. pointerX: number,
  26637. /** The Y mouse cursor position at the time of the event */
  26638. pointerY: number,
  26639. /** The mesh that is currently pointed at (can be null) */
  26640. meshUnderPointer: Nullable<AbstractMesh>,
  26641. /** the original (browser) event that triggered the ActionEvent */
  26642. sourceEvent?: any,
  26643. /** additional data for the event */
  26644. additionalData?: any);
  26645. /**
  26646. * Helper function to auto-create an ActionEvent from a source mesh.
  26647. * @param source The source mesh that triggered the event
  26648. * @param evt The original (browser) event
  26649. * @param additionalData additional data for the event
  26650. * @returns the new ActionEvent
  26651. */
  26652. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26653. /**
  26654. * Helper function to auto-create an ActionEvent from a source sprite
  26655. * @param source The source sprite that triggered the event
  26656. * @param scene Scene associated with the sprite
  26657. * @param evt The original (browser) event
  26658. * @param additionalData additional data for the event
  26659. * @returns the new ActionEvent
  26660. */
  26661. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26662. /**
  26663. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26664. * @param scene the scene where the event occurred
  26665. * @param evt The original (browser) event
  26666. * @returns the new ActionEvent
  26667. */
  26668. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26669. /**
  26670. * Helper function to auto-create an ActionEvent from a primitive
  26671. * @param prim defines the target primitive
  26672. * @param pointerPos defines the pointer position
  26673. * @param evt The original (browser) event
  26674. * @param additionalData additional data for the event
  26675. * @returns the new ActionEvent
  26676. */
  26677. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26678. }
  26679. }
  26680. declare module BABYLON {
  26681. /**
  26682. * Abstract class used to decouple action Manager from scene and meshes.
  26683. * Do not instantiate.
  26684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26685. */
  26686. export abstract class AbstractActionManager implements IDisposable {
  26687. /** Gets the list of active triggers */
  26688. static Triggers: {
  26689. [key: string]: number;
  26690. };
  26691. /** Gets the cursor to use when hovering items */
  26692. hoverCursor: string;
  26693. /** Gets the list of actions */
  26694. actions: IAction[];
  26695. /**
  26696. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26697. */
  26698. isRecursive: boolean;
  26699. /**
  26700. * Releases all associated resources
  26701. */
  26702. abstract dispose(): void;
  26703. /**
  26704. * Does this action manager has pointer triggers
  26705. */
  26706. abstract readonly hasPointerTriggers: boolean;
  26707. /**
  26708. * Does this action manager has pick triggers
  26709. */
  26710. abstract readonly hasPickTriggers: boolean;
  26711. /**
  26712. * Process a specific trigger
  26713. * @param trigger defines the trigger to process
  26714. * @param evt defines the event details to be processed
  26715. */
  26716. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26717. /**
  26718. * Does this action manager handles actions of any of the given triggers
  26719. * @param triggers defines the triggers to be tested
  26720. * @return a boolean indicating whether one (or more) of the triggers is handled
  26721. */
  26722. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26723. /**
  26724. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26725. * speed.
  26726. * @param triggerA defines the trigger to be tested
  26727. * @param triggerB defines the trigger to be tested
  26728. * @return a boolean indicating whether one (or more) of the triggers is handled
  26729. */
  26730. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26731. /**
  26732. * Does this action manager handles actions of a given trigger
  26733. * @param trigger defines the trigger to be tested
  26734. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26735. * @return whether the trigger is handled
  26736. */
  26737. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26738. /**
  26739. * Serialize this manager to a JSON object
  26740. * @param name defines the property name to store this manager
  26741. * @returns a JSON representation of this manager
  26742. */
  26743. abstract serialize(name: string): any;
  26744. /**
  26745. * Registers an action to this action manager
  26746. * @param action defines the action to be registered
  26747. * @return the action amended (prepared) after registration
  26748. */
  26749. abstract registerAction(action: IAction): Nullable<IAction>;
  26750. /**
  26751. * Unregisters an action to this action manager
  26752. * @param action defines the action to be unregistered
  26753. * @return a boolean indicating whether the action has been unregistered
  26754. */
  26755. abstract unregisterAction(action: IAction): Boolean;
  26756. /**
  26757. * Does exist one action manager with at least one trigger
  26758. **/
  26759. static readonly HasTriggers: boolean;
  26760. /**
  26761. * Does exist one action manager with at least one pick trigger
  26762. **/
  26763. static readonly HasPickTriggers: boolean;
  26764. /**
  26765. * Does exist one action manager that handles actions of a given trigger
  26766. * @param trigger defines the trigger to be tested
  26767. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26768. **/
  26769. static HasSpecificTrigger(trigger: number): boolean;
  26770. }
  26771. }
  26772. declare module BABYLON {
  26773. /**
  26774. * Defines how a node can be built from a string name.
  26775. */
  26776. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26777. /**
  26778. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26779. */
  26780. export class Node implements IBehaviorAware<Node> {
  26781. /** @hidden */
  26782. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26783. private static _NodeConstructors;
  26784. /**
  26785. * Add a new node constructor
  26786. * @param type defines the type name of the node to construct
  26787. * @param constructorFunc defines the constructor function
  26788. */
  26789. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26790. /**
  26791. * Returns a node constructor based on type name
  26792. * @param type defines the type name
  26793. * @param name defines the new node name
  26794. * @param scene defines the hosting scene
  26795. * @param options defines optional options to transmit to constructors
  26796. * @returns the new constructor or null
  26797. */
  26798. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26799. /**
  26800. * Gets or sets the name of the node
  26801. */
  26802. name: string;
  26803. /**
  26804. * Gets or sets the id of the node
  26805. */
  26806. id: string;
  26807. /**
  26808. * Gets or sets the unique id of the node
  26809. */
  26810. uniqueId: number;
  26811. /**
  26812. * Gets or sets a string used to store user defined state for the node
  26813. */
  26814. state: string;
  26815. /**
  26816. * Gets or sets an object used to store user defined information for the node
  26817. */
  26818. metadata: any;
  26819. /**
  26820. * For internal use only. Please do not use.
  26821. */
  26822. reservedDataStore: any;
  26823. /**
  26824. * List of inspectable custom properties (used by the Inspector)
  26825. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26826. */
  26827. inspectableCustomProperties: IInspectable[];
  26828. /**
  26829. * Gets or sets a boolean used to define if the node must be serialized
  26830. */
  26831. doNotSerialize: boolean;
  26832. /** @hidden */
  26833. _isDisposed: boolean;
  26834. /**
  26835. * Gets a list of Animations associated with the node
  26836. */
  26837. animations: Animation[];
  26838. protected _ranges: {
  26839. [name: string]: Nullable<AnimationRange>;
  26840. };
  26841. /**
  26842. * Callback raised when the node is ready to be used
  26843. */
  26844. onReady: Nullable<(node: Node) => void>;
  26845. private _isEnabled;
  26846. private _isParentEnabled;
  26847. private _isReady;
  26848. /** @hidden */
  26849. _currentRenderId: number;
  26850. private _parentUpdateId;
  26851. /** @hidden */
  26852. _childUpdateId: number;
  26853. /** @hidden */
  26854. _waitingParentId: Nullable<string>;
  26855. /** @hidden */
  26856. _scene: Scene;
  26857. /** @hidden */
  26858. _cache: any;
  26859. private _parentNode;
  26860. private _children;
  26861. /** @hidden */
  26862. _worldMatrix: Matrix;
  26863. /** @hidden */
  26864. _worldMatrixDeterminant: number;
  26865. /** @hidden */
  26866. _worldMatrixDeterminantIsDirty: boolean;
  26867. /** @hidden */
  26868. private _sceneRootNodesIndex;
  26869. /**
  26870. * Gets a boolean indicating if the node has been disposed
  26871. * @returns true if the node was disposed
  26872. */
  26873. isDisposed(): boolean;
  26874. /**
  26875. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26876. * @see https://doc.babylonjs.com/how_to/parenting
  26877. */
  26878. parent: Nullable<Node>;
  26879. private addToSceneRootNodes;
  26880. private removeFromSceneRootNodes;
  26881. private _animationPropertiesOverride;
  26882. /**
  26883. * Gets or sets the animation properties override
  26884. */
  26885. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26886. /**
  26887. * Gets a string idenfifying the name of the class
  26888. * @returns "Node" string
  26889. */
  26890. getClassName(): string;
  26891. /** @hidden */
  26892. readonly _isNode: boolean;
  26893. /**
  26894. * An event triggered when the mesh is disposed
  26895. */
  26896. onDisposeObservable: Observable<Node>;
  26897. private _onDisposeObserver;
  26898. /**
  26899. * Sets a callback that will be raised when the node will be disposed
  26900. */
  26901. onDispose: () => void;
  26902. /**
  26903. * Creates a new Node
  26904. * @param name the name and id to be given to this node
  26905. * @param scene the scene this node will be added to
  26906. * @param addToRootNodes the node will be added to scene.rootNodes
  26907. */
  26908. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26909. /**
  26910. * Gets the scene of the node
  26911. * @returns a scene
  26912. */
  26913. getScene(): Scene;
  26914. /**
  26915. * Gets the engine of the node
  26916. * @returns a Engine
  26917. */
  26918. getEngine(): Engine;
  26919. private _behaviors;
  26920. /**
  26921. * Attach a behavior to the node
  26922. * @see http://doc.babylonjs.com/features/behaviour
  26923. * @param behavior defines the behavior to attach
  26924. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26925. * @returns the current Node
  26926. */
  26927. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26928. /**
  26929. * Remove an attached behavior
  26930. * @see http://doc.babylonjs.com/features/behaviour
  26931. * @param behavior defines the behavior to attach
  26932. * @returns the current Node
  26933. */
  26934. removeBehavior(behavior: Behavior<Node>): Node;
  26935. /**
  26936. * Gets the list of attached behaviors
  26937. * @see http://doc.babylonjs.com/features/behaviour
  26938. */
  26939. readonly behaviors: Behavior<Node>[];
  26940. /**
  26941. * Gets an attached behavior by name
  26942. * @param name defines the name of the behavior to look for
  26943. * @see http://doc.babylonjs.com/features/behaviour
  26944. * @returns null if behavior was not found else the requested behavior
  26945. */
  26946. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26947. /**
  26948. * Returns the latest update of the World matrix
  26949. * @returns a Matrix
  26950. */
  26951. getWorldMatrix(): Matrix;
  26952. /** @hidden */
  26953. _getWorldMatrixDeterminant(): number;
  26954. /**
  26955. * Returns directly the latest state of the mesh World matrix.
  26956. * A Matrix is returned.
  26957. */
  26958. readonly worldMatrixFromCache: Matrix;
  26959. /** @hidden */
  26960. _initCache(): void;
  26961. /** @hidden */
  26962. updateCache(force?: boolean): void;
  26963. /** @hidden */
  26964. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26965. /** @hidden */
  26966. _updateCache(ignoreParentClass?: boolean): void;
  26967. /** @hidden */
  26968. _isSynchronized(): boolean;
  26969. /** @hidden */
  26970. _markSyncedWithParent(): void;
  26971. /** @hidden */
  26972. isSynchronizedWithParent(): boolean;
  26973. /** @hidden */
  26974. isSynchronized(): boolean;
  26975. /**
  26976. * Is this node ready to be used/rendered
  26977. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26978. * @return true if the node is ready
  26979. */
  26980. isReady(completeCheck?: boolean): boolean;
  26981. /**
  26982. * Is this node enabled?
  26983. * 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
  26984. * @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
  26985. * @return whether this node (and its parent) is enabled
  26986. */
  26987. isEnabled(checkAncestors?: boolean): boolean;
  26988. /** @hidden */
  26989. protected _syncParentEnabledState(): void;
  26990. /**
  26991. * Set the enabled state of this node
  26992. * @param value defines the new enabled state
  26993. */
  26994. setEnabled(value: boolean): void;
  26995. /**
  26996. * Is this node a descendant of the given node?
  26997. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26998. * @param ancestor defines the parent node to inspect
  26999. * @returns a boolean indicating if this node is a descendant of the given node
  27000. */
  27001. isDescendantOf(ancestor: Node): boolean;
  27002. /** @hidden */
  27003. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27004. /**
  27005. * Will return all nodes that have this node as ascendant
  27006. * @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
  27007. * @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
  27008. * @return all children nodes of all types
  27009. */
  27010. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27011. /**
  27012. * Get all child-meshes of this node
  27013. * @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)
  27014. * @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
  27015. * @returns an array of AbstractMesh
  27016. */
  27017. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27018. /**
  27019. * Get all direct children of this node
  27020. * @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
  27021. * @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)
  27022. * @returns an array of Node
  27023. */
  27024. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27025. /** @hidden */
  27026. _setReady(state: boolean): void;
  27027. /**
  27028. * Get an animation by name
  27029. * @param name defines the name of the animation to look for
  27030. * @returns null if not found else the requested animation
  27031. */
  27032. getAnimationByName(name: string): Nullable<Animation>;
  27033. /**
  27034. * Creates an animation range for this node
  27035. * @param name defines the name of the range
  27036. * @param from defines the starting key
  27037. * @param to defines the end key
  27038. */
  27039. createAnimationRange(name: string, from: number, to: number): void;
  27040. /**
  27041. * Delete a specific animation range
  27042. * @param name defines the name of the range to delete
  27043. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27044. */
  27045. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27046. /**
  27047. * Get an animation range by name
  27048. * @param name defines the name of the animation range to look for
  27049. * @returns null if not found else the requested animation range
  27050. */
  27051. getAnimationRange(name: string): Nullable<AnimationRange>;
  27052. /**
  27053. * Gets the list of all animation ranges defined on this node
  27054. * @returns an array
  27055. */
  27056. getAnimationRanges(): Nullable<AnimationRange>[];
  27057. /**
  27058. * Will start the animation sequence
  27059. * @param name defines the range frames for animation sequence
  27060. * @param loop defines if the animation should loop (false by default)
  27061. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27062. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27063. * @returns the object created for this animation. If range does not exist, it will return null
  27064. */
  27065. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27066. /**
  27067. * Serialize animation ranges into a JSON compatible object
  27068. * @returns serialization object
  27069. */
  27070. serializeAnimationRanges(): any;
  27071. /**
  27072. * Computes the world matrix of the node
  27073. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27074. * @returns the world matrix
  27075. */
  27076. computeWorldMatrix(force?: boolean): Matrix;
  27077. /**
  27078. * Releases resources associated with this node.
  27079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27081. */
  27082. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27083. /**
  27084. * Parse animation range data from a serialization object and store them into a given node
  27085. * @param node defines where to store the animation ranges
  27086. * @param parsedNode defines the serialization object to read data from
  27087. * @param scene defines the hosting scene
  27088. */
  27089. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27090. /**
  27091. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27092. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27093. * @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
  27094. * @returns the new bounding vectors
  27095. */
  27096. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27097. min: Vector3;
  27098. max: Vector3;
  27099. };
  27100. }
  27101. }
  27102. declare module BABYLON {
  27103. /**
  27104. * @hidden
  27105. */
  27106. export class _IAnimationState {
  27107. key: number;
  27108. repeatCount: number;
  27109. workValue?: any;
  27110. loopMode?: number;
  27111. offsetValue?: any;
  27112. highLimitValue?: any;
  27113. }
  27114. /**
  27115. * Class used to store any kind of animation
  27116. */
  27117. export class Animation {
  27118. /**Name of the animation */
  27119. name: string;
  27120. /**Property to animate */
  27121. targetProperty: string;
  27122. /**The frames per second of the animation */
  27123. framePerSecond: number;
  27124. /**The data type of the animation */
  27125. dataType: number;
  27126. /**The loop mode of the animation */
  27127. loopMode?: number | undefined;
  27128. /**Specifies if blending should be enabled */
  27129. enableBlending?: boolean | undefined;
  27130. /**
  27131. * Use matrix interpolation instead of using direct key value when animating matrices
  27132. */
  27133. static AllowMatricesInterpolation: boolean;
  27134. /**
  27135. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27136. */
  27137. static AllowMatrixDecomposeForInterpolation: boolean;
  27138. /**
  27139. * Stores the key frames of the animation
  27140. */
  27141. private _keys;
  27142. /**
  27143. * Stores the easing function of the animation
  27144. */
  27145. private _easingFunction;
  27146. /**
  27147. * @hidden Internal use only
  27148. */
  27149. _runtimeAnimations: RuntimeAnimation[];
  27150. /**
  27151. * The set of event that will be linked to this animation
  27152. */
  27153. private _events;
  27154. /**
  27155. * Stores an array of target property paths
  27156. */
  27157. targetPropertyPath: string[];
  27158. /**
  27159. * Stores the blending speed of the animation
  27160. */
  27161. blendingSpeed: number;
  27162. /**
  27163. * Stores the animation ranges for the animation
  27164. */
  27165. private _ranges;
  27166. /**
  27167. * @hidden Internal use
  27168. */
  27169. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27170. /**
  27171. * Sets up an animation
  27172. * @param property The property to animate
  27173. * @param animationType The animation type to apply
  27174. * @param framePerSecond The frames per second of the animation
  27175. * @param easingFunction The easing function used in the animation
  27176. * @returns The created animation
  27177. */
  27178. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27179. /**
  27180. * Create and start an animation on a node
  27181. * @param name defines the name of the global animation that will be run on all nodes
  27182. * @param node defines the root node where the animation will take place
  27183. * @param targetProperty defines property to animate
  27184. * @param framePerSecond defines the number of frame per second yo use
  27185. * @param totalFrame defines the number of frames in total
  27186. * @param from defines the initial value
  27187. * @param to defines the final value
  27188. * @param loopMode defines which loop mode you want to use (off by default)
  27189. * @param easingFunction defines the easing function to use (linear by default)
  27190. * @param onAnimationEnd defines the callback to call when animation end
  27191. * @returns the animatable created for this animation
  27192. */
  27193. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27194. /**
  27195. * Create and start an animation on a node and its descendants
  27196. * @param name defines the name of the global animation that will be run on all nodes
  27197. * @param node defines the root node where the animation will take place
  27198. * @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
  27199. * @param targetProperty defines property to animate
  27200. * @param framePerSecond defines the number of frame per second to use
  27201. * @param totalFrame defines the number of frames in total
  27202. * @param from defines the initial value
  27203. * @param to defines the final value
  27204. * @param loopMode defines which loop mode you want to use (off by default)
  27205. * @param easingFunction defines the easing function to use (linear by default)
  27206. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27207. * @returns the list of animatables created for all nodes
  27208. * @example https://www.babylonjs-playground.com/#MH0VLI
  27209. */
  27210. 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[]>;
  27211. /**
  27212. * Creates a new animation, merges it with the existing animations and starts it
  27213. * @param name Name of the animation
  27214. * @param node Node which contains the scene that begins the animations
  27215. * @param targetProperty Specifies which property to animate
  27216. * @param framePerSecond The frames per second of the animation
  27217. * @param totalFrame The total number of frames
  27218. * @param from The frame at the beginning of the animation
  27219. * @param to The frame at the end of the animation
  27220. * @param loopMode Specifies the loop mode of the animation
  27221. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27222. * @param onAnimationEnd Callback to run once the animation is complete
  27223. * @returns Nullable animation
  27224. */
  27225. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27226. /**
  27227. * Transition property of an host to the target Value
  27228. * @param property The property to transition
  27229. * @param targetValue The target Value of the property
  27230. * @param host The object where the property to animate belongs
  27231. * @param scene Scene used to run the animation
  27232. * @param frameRate Framerate (in frame/s) to use
  27233. * @param transition The transition type we want to use
  27234. * @param duration The duration of the animation, in milliseconds
  27235. * @param onAnimationEnd Callback trigger at the end of the animation
  27236. * @returns Nullable animation
  27237. */
  27238. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27239. /**
  27240. * Return the array of runtime animations currently using this animation
  27241. */
  27242. readonly runtimeAnimations: RuntimeAnimation[];
  27243. /**
  27244. * Specifies if any of the runtime animations are currently running
  27245. */
  27246. readonly hasRunningRuntimeAnimations: boolean;
  27247. /**
  27248. * Initializes the animation
  27249. * @param name Name of the animation
  27250. * @param targetProperty Property to animate
  27251. * @param framePerSecond The frames per second of the animation
  27252. * @param dataType The data type of the animation
  27253. * @param loopMode The loop mode of the animation
  27254. * @param enableBlending Specifies if blending should be enabled
  27255. */
  27256. constructor(
  27257. /**Name of the animation */
  27258. name: string,
  27259. /**Property to animate */
  27260. targetProperty: string,
  27261. /**The frames per second of the animation */
  27262. framePerSecond: number,
  27263. /**The data type of the animation */
  27264. dataType: number,
  27265. /**The loop mode of the animation */
  27266. loopMode?: number | undefined,
  27267. /**Specifies if blending should be enabled */
  27268. enableBlending?: boolean | undefined);
  27269. /**
  27270. * Converts the animation to a string
  27271. * @param fullDetails support for multiple levels of logging within scene loading
  27272. * @returns String form of the animation
  27273. */
  27274. toString(fullDetails?: boolean): string;
  27275. /**
  27276. * Add an event to this animation
  27277. * @param event Event to add
  27278. */
  27279. addEvent(event: AnimationEvent): void;
  27280. /**
  27281. * Remove all events found at the given frame
  27282. * @param frame The frame to remove events from
  27283. */
  27284. removeEvents(frame: number): void;
  27285. /**
  27286. * Retrieves all the events from the animation
  27287. * @returns Events from the animation
  27288. */
  27289. getEvents(): AnimationEvent[];
  27290. /**
  27291. * Creates an animation range
  27292. * @param name Name of the animation range
  27293. * @param from Starting frame of the animation range
  27294. * @param to Ending frame of the animation
  27295. */
  27296. createRange(name: string, from: number, to: number): void;
  27297. /**
  27298. * Deletes an animation range by name
  27299. * @param name Name of the animation range to delete
  27300. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27301. */
  27302. deleteRange(name: string, deleteFrames?: boolean): void;
  27303. /**
  27304. * Gets the animation range by name, or null if not defined
  27305. * @param name Name of the animation range
  27306. * @returns Nullable animation range
  27307. */
  27308. getRange(name: string): Nullable<AnimationRange>;
  27309. /**
  27310. * Gets the key frames from the animation
  27311. * @returns The key frames of the animation
  27312. */
  27313. getKeys(): Array<IAnimationKey>;
  27314. /**
  27315. * Gets the highest frame rate of the animation
  27316. * @returns Highest frame rate of the animation
  27317. */
  27318. getHighestFrame(): number;
  27319. /**
  27320. * Gets the easing function of the animation
  27321. * @returns Easing function of the animation
  27322. */
  27323. getEasingFunction(): IEasingFunction;
  27324. /**
  27325. * Sets the easing function of the animation
  27326. * @param easingFunction A custom mathematical formula for animation
  27327. */
  27328. setEasingFunction(easingFunction: EasingFunction): void;
  27329. /**
  27330. * Interpolates a scalar linearly
  27331. * @param startValue Start value of the animation curve
  27332. * @param endValue End value of the animation curve
  27333. * @param gradient Scalar amount to interpolate
  27334. * @returns Interpolated scalar value
  27335. */
  27336. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27337. /**
  27338. * Interpolates a scalar cubically
  27339. * @param startValue Start value of the animation curve
  27340. * @param outTangent End tangent of the animation
  27341. * @param endValue End value of the animation curve
  27342. * @param inTangent Start tangent of the animation curve
  27343. * @param gradient Scalar amount to interpolate
  27344. * @returns Interpolated scalar value
  27345. */
  27346. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27347. /**
  27348. * Interpolates a quaternion using a spherical linear interpolation
  27349. * @param startValue Start value of the animation curve
  27350. * @param endValue End value of the animation curve
  27351. * @param gradient Scalar amount to interpolate
  27352. * @returns Interpolated quaternion value
  27353. */
  27354. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27355. /**
  27356. * Interpolates a quaternion cubically
  27357. * @param startValue Start value of the animation curve
  27358. * @param outTangent End tangent of the animation curve
  27359. * @param endValue End value of the animation curve
  27360. * @param inTangent Start tangent of the animation curve
  27361. * @param gradient Scalar amount to interpolate
  27362. * @returns Interpolated quaternion value
  27363. */
  27364. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27365. /**
  27366. * Interpolates a Vector3 linearl
  27367. * @param startValue Start value of the animation curve
  27368. * @param endValue End value of the animation curve
  27369. * @param gradient Scalar amount to interpolate
  27370. * @returns Interpolated scalar value
  27371. */
  27372. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27373. /**
  27374. * Interpolates a Vector3 cubically
  27375. * @param startValue Start value of the animation curve
  27376. * @param outTangent End tangent of the animation
  27377. * @param endValue End value of the animation curve
  27378. * @param inTangent Start tangent of the animation curve
  27379. * @param gradient Scalar amount to interpolate
  27380. * @returns InterpolatedVector3 value
  27381. */
  27382. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27383. /**
  27384. * Interpolates a Vector2 linearly
  27385. * @param startValue Start value of the animation curve
  27386. * @param endValue End value of the animation curve
  27387. * @param gradient Scalar amount to interpolate
  27388. * @returns Interpolated Vector2 value
  27389. */
  27390. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27391. /**
  27392. * Interpolates a Vector2 cubically
  27393. * @param startValue Start value of the animation curve
  27394. * @param outTangent End tangent of the animation
  27395. * @param endValue End value of the animation curve
  27396. * @param inTangent Start tangent of the animation curve
  27397. * @param gradient Scalar amount to interpolate
  27398. * @returns Interpolated Vector2 value
  27399. */
  27400. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27401. /**
  27402. * Interpolates a size linearly
  27403. * @param startValue Start value of the animation curve
  27404. * @param endValue End value of the animation curve
  27405. * @param gradient Scalar amount to interpolate
  27406. * @returns Interpolated Size value
  27407. */
  27408. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27409. /**
  27410. * Interpolates a Color3 linearly
  27411. * @param startValue Start value of the animation curve
  27412. * @param endValue End value of the animation curve
  27413. * @param gradient Scalar amount to interpolate
  27414. * @returns Interpolated Color3 value
  27415. */
  27416. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27417. /**
  27418. * @hidden Internal use only
  27419. */
  27420. _getKeyValue(value: any): any;
  27421. /**
  27422. * @hidden Internal use only
  27423. */
  27424. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27425. /**
  27426. * Defines the function to use to interpolate matrices
  27427. * @param startValue defines the start matrix
  27428. * @param endValue defines the end matrix
  27429. * @param gradient defines the gradient between both matrices
  27430. * @param result defines an optional target matrix where to store the interpolation
  27431. * @returns the interpolated matrix
  27432. */
  27433. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27434. /**
  27435. * Makes a copy of the animation
  27436. * @returns Cloned animation
  27437. */
  27438. clone(): Animation;
  27439. /**
  27440. * Sets the key frames of the animation
  27441. * @param values The animation key frames to set
  27442. */
  27443. setKeys(values: Array<IAnimationKey>): void;
  27444. /**
  27445. * Serializes the animation to an object
  27446. * @returns Serialized object
  27447. */
  27448. serialize(): any;
  27449. /**
  27450. * Float animation type
  27451. */
  27452. private static _ANIMATIONTYPE_FLOAT;
  27453. /**
  27454. * Vector3 animation type
  27455. */
  27456. private static _ANIMATIONTYPE_VECTOR3;
  27457. /**
  27458. * Quaternion animation type
  27459. */
  27460. private static _ANIMATIONTYPE_QUATERNION;
  27461. /**
  27462. * Matrix animation type
  27463. */
  27464. private static _ANIMATIONTYPE_MATRIX;
  27465. /**
  27466. * Color3 animation type
  27467. */
  27468. private static _ANIMATIONTYPE_COLOR3;
  27469. /**
  27470. * Vector2 animation type
  27471. */
  27472. private static _ANIMATIONTYPE_VECTOR2;
  27473. /**
  27474. * Size animation type
  27475. */
  27476. private static _ANIMATIONTYPE_SIZE;
  27477. /**
  27478. * Relative Loop Mode
  27479. */
  27480. private static _ANIMATIONLOOPMODE_RELATIVE;
  27481. /**
  27482. * Cycle Loop Mode
  27483. */
  27484. private static _ANIMATIONLOOPMODE_CYCLE;
  27485. /**
  27486. * Constant Loop Mode
  27487. */
  27488. private static _ANIMATIONLOOPMODE_CONSTANT;
  27489. /**
  27490. * Get the float animation type
  27491. */
  27492. static readonly ANIMATIONTYPE_FLOAT: number;
  27493. /**
  27494. * Get the Vector3 animation type
  27495. */
  27496. static readonly ANIMATIONTYPE_VECTOR3: number;
  27497. /**
  27498. * Get the Vector2 animation type
  27499. */
  27500. static readonly ANIMATIONTYPE_VECTOR2: number;
  27501. /**
  27502. * Get the Size animation type
  27503. */
  27504. static readonly ANIMATIONTYPE_SIZE: number;
  27505. /**
  27506. * Get the Quaternion animation type
  27507. */
  27508. static readonly ANIMATIONTYPE_QUATERNION: number;
  27509. /**
  27510. * Get the Matrix animation type
  27511. */
  27512. static readonly ANIMATIONTYPE_MATRIX: number;
  27513. /**
  27514. * Get the Color3 animation type
  27515. */
  27516. static readonly ANIMATIONTYPE_COLOR3: number;
  27517. /**
  27518. * Get the Relative Loop Mode
  27519. */
  27520. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27521. /**
  27522. * Get the Cycle Loop Mode
  27523. */
  27524. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27525. /**
  27526. * Get the Constant Loop Mode
  27527. */
  27528. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27529. /** @hidden */
  27530. static _UniversalLerp(left: any, right: any, amount: number): any;
  27531. /**
  27532. * Parses an animation object and creates an animation
  27533. * @param parsedAnimation Parsed animation object
  27534. * @returns Animation object
  27535. */
  27536. static Parse(parsedAnimation: any): Animation;
  27537. /**
  27538. * Appends the serialized animations from the source animations
  27539. * @param source Source containing the animations
  27540. * @param destination Target to store the animations
  27541. */
  27542. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27543. }
  27544. }
  27545. declare module BABYLON {
  27546. /**
  27547. * Interface containing an array of animations
  27548. */
  27549. export interface IAnimatable {
  27550. /**
  27551. * Array of animations
  27552. */
  27553. animations: Nullable<Array<Animation>>;
  27554. }
  27555. }
  27556. declare module BABYLON {
  27557. /**
  27558. * This represents all the required information to add a fresnel effect on a material:
  27559. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27560. */
  27561. export class FresnelParameters {
  27562. private _isEnabled;
  27563. /**
  27564. * Define if the fresnel effect is enable or not.
  27565. */
  27566. isEnabled: boolean;
  27567. /**
  27568. * Define the color used on edges (grazing angle)
  27569. */
  27570. leftColor: Color3;
  27571. /**
  27572. * Define the color used on center
  27573. */
  27574. rightColor: Color3;
  27575. /**
  27576. * Define bias applied to computed fresnel term
  27577. */
  27578. bias: number;
  27579. /**
  27580. * Defined the power exponent applied to fresnel term
  27581. */
  27582. power: number;
  27583. /**
  27584. * Clones the current fresnel and its valuues
  27585. * @returns a clone fresnel configuration
  27586. */
  27587. clone(): FresnelParameters;
  27588. /**
  27589. * Serializes the current fresnel parameters to a JSON representation.
  27590. * @return the JSON serialization
  27591. */
  27592. serialize(): any;
  27593. /**
  27594. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27595. * @param parsedFresnelParameters Define the JSON representation
  27596. * @returns the parsed parameters
  27597. */
  27598. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27599. }
  27600. }
  27601. declare module BABYLON {
  27602. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27603. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27604. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27605. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27606. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27607. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27608. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27609. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27610. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27611. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27612. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27613. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27614. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27615. /**
  27616. * Decorator used to define property that can be serialized as reference to a camera
  27617. * @param sourceName defines the name of the property to decorate
  27618. */
  27619. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27620. /**
  27621. * Class used to help serialization objects
  27622. */
  27623. export class SerializationHelper {
  27624. /** @hidden */
  27625. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27626. /** @hidden */
  27627. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27628. /** @hidden */
  27629. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27630. /** @hidden */
  27631. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27632. /**
  27633. * Appends the serialized animations from the source animations
  27634. * @param source Source containing the animations
  27635. * @param destination Target to store the animations
  27636. */
  27637. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27638. /**
  27639. * Static function used to serialized a specific entity
  27640. * @param entity defines the entity to serialize
  27641. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27642. * @returns a JSON compatible object representing the serialization of the entity
  27643. */
  27644. static Serialize<T>(entity: T, serializationObject?: any): any;
  27645. /**
  27646. * Creates a new entity from a serialization data object
  27647. * @param creationFunction defines a function used to instanciated the new entity
  27648. * @param source defines the source serialization data
  27649. * @param scene defines the hosting scene
  27650. * @param rootUrl defines the root url for resources
  27651. * @returns a new entity
  27652. */
  27653. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27654. /**
  27655. * Clones an object
  27656. * @param creationFunction defines the function used to instanciate the new object
  27657. * @param source defines the source object
  27658. * @returns the cloned object
  27659. */
  27660. static Clone<T>(creationFunction: () => T, source: T): T;
  27661. /**
  27662. * Instanciates a new object based on a source one (some data will be shared between both object)
  27663. * @param creationFunction defines the function used to instanciate the new object
  27664. * @param source defines the source object
  27665. * @returns the new object
  27666. */
  27667. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27668. }
  27669. }
  27670. declare module BABYLON {
  27671. /**
  27672. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27673. */
  27674. export interface CubeMapInfo {
  27675. /**
  27676. * The pixel array for the front face.
  27677. * This is stored in format, left to right, up to down format.
  27678. */
  27679. front: Nullable<ArrayBufferView>;
  27680. /**
  27681. * The pixel array for the back face.
  27682. * This is stored in format, left to right, up to down format.
  27683. */
  27684. back: Nullable<ArrayBufferView>;
  27685. /**
  27686. * The pixel array for the left face.
  27687. * This is stored in format, left to right, up to down format.
  27688. */
  27689. left: Nullable<ArrayBufferView>;
  27690. /**
  27691. * The pixel array for the right face.
  27692. * This is stored in format, left to right, up to down format.
  27693. */
  27694. right: Nullable<ArrayBufferView>;
  27695. /**
  27696. * The pixel array for the up face.
  27697. * This is stored in format, left to right, up to down format.
  27698. */
  27699. up: Nullable<ArrayBufferView>;
  27700. /**
  27701. * The pixel array for the down face.
  27702. * This is stored in format, left to right, up to down format.
  27703. */
  27704. down: Nullable<ArrayBufferView>;
  27705. /**
  27706. * The size of the cubemap stored.
  27707. *
  27708. * Each faces will be size * size pixels.
  27709. */
  27710. size: number;
  27711. /**
  27712. * The format of the texture.
  27713. *
  27714. * RGBA, RGB.
  27715. */
  27716. format: number;
  27717. /**
  27718. * The type of the texture data.
  27719. *
  27720. * UNSIGNED_INT, FLOAT.
  27721. */
  27722. type: number;
  27723. /**
  27724. * Specifies whether the texture is in gamma space.
  27725. */
  27726. gammaSpace: boolean;
  27727. }
  27728. /**
  27729. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27730. */
  27731. export class PanoramaToCubeMapTools {
  27732. private static FACE_FRONT;
  27733. private static FACE_BACK;
  27734. private static FACE_RIGHT;
  27735. private static FACE_LEFT;
  27736. private static FACE_DOWN;
  27737. private static FACE_UP;
  27738. /**
  27739. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27740. *
  27741. * @param float32Array The source data.
  27742. * @param inputWidth The width of the input panorama.
  27743. * @param inputHeight The height of the input panorama.
  27744. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27745. * @return The cubemap data
  27746. */
  27747. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27748. private static CreateCubemapTexture;
  27749. private static CalcProjectionSpherical;
  27750. }
  27751. }
  27752. declare module BABYLON {
  27753. /**
  27754. * Helper class dealing with the extraction of spherical polynomial dataArray
  27755. * from a cube map.
  27756. */
  27757. export class CubeMapToSphericalPolynomialTools {
  27758. private static FileFaces;
  27759. /**
  27760. * Converts a texture to the according Spherical Polynomial data.
  27761. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27762. *
  27763. * @param texture The texture to extract the information from.
  27764. * @return The Spherical Polynomial data.
  27765. */
  27766. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27767. /**
  27768. * Converts a cubemap to the according Spherical Polynomial data.
  27769. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27770. *
  27771. * @param cubeInfo The Cube map to extract the information from.
  27772. * @return The Spherical Polynomial data.
  27773. */
  27774. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27775. }
  27776. }
  27777. declare module BABYLON {
  27778. /**
  27779. * Class used to manipulate GUIDs
  27780. */
  27781. export class GUID {
  27782. /**
  27783. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27784. * Be aware Math.random() could cause collisions, but:
  27785. * "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"
  27786. * @returns a pseudo random id
  27787. */
  27788. static RandomId(): string;
  27789. }
  27790. }
  27791. declare module BABYLON {
  27792. /**
  27793. * Base class of all the textures in babylon.
  27794. * It groups all the common properties the materials, post process, lights... might need
  27795. * in order to make a correct use of the texture.
  27796. */
  27797. export class BaseTexture implements IAnimatable {
  27798. /**
  27799. * Default anisotropic filtering level for the application.
  27800. * It is set to 4 as a good tradeoff between perf and quality.
  27801. */
  27802. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27803. /**
  27804. * Gets or sets the unique id of the texture
  27805. */
  27806. uniqueId: number;
  27807. /**
  27808. * Define the name of the texture.
  27809. */
  27810. name: string;
  27811. /**
  27812. * Gets or sets an object used to store user defined information.
  27813. */
  27814. metadata: any;
  27815. /**
  27816. * For internal use only. Please do not use.
  27817. */
  27818. reservedDataStore: any;
  27819. private _hasAlpha;
  27820. /**
  27821. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27822. */
  27823. hasAlpha: boolean;
  27824. /**
  27825. * Defines if the alpha value should be determined via the rgb values.
  27826. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27827. */
  27828. getAlphaFromRGB: boolean;
  27829. /**
  27830. * Intensity or strength of the texture.
  27831. * It is commonly used by materials to fine tune the intensity of the texture
  27832. */
  27833. level: number;
  27834. /**
  27835. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27836. * This is part of the texture as textures usually maps to one uv set.
  27837. */
  27838. coordinatesIndex: number;
  27839. private _coordinatesMode;
  27840. /**
  27841. * How a texture is mapped.
  27842. *
  27843. * | Value | Type | Description |
  27844. * | ----- | ----------------------------------- | ----------- |
  27845. * | 0 | EXPLICIT_MODE | |
  27846. * | 1 | SPHERICAL_MODE | |
  27847. * | 2 | PLANAR_MODE | |
  27848. * | 3 | CUBIC_MODE | |
  27849. * | 4 | PROJECTION_MODE | |
  27850. * | 5 | SKYBOX_MODE | |
  27851. * | 6 | INVCUBIC_MODE | |
  27852. * | 7 | EQUIRECTANGULAR_MODE | |
  27853. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27854. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27855. */
  27856. coordinatesMode: number;
  27857. /**
  27858. * | Value | Type | Description |
  27859. * | ----- | ------------------ | ----------- |
  27860. * | 0 | CLAMP_ADDRESSMODE | |
  27861. * | 1 | WRAP_ADDRESSMODE | |
  27862. * | 2 | MIRROR_ADDRESSMODE | |
  27863. */
  27864. wrapU: number;
  27865. /**
  27866. * | Value | Type | Description |
  27867. * | ----- | ------------------ | ----------- |
  27868. * | 0 | CLAMP_ADDRESSMODE | |
  27869. * | 1 | WRAP_ADDRESSMODE | |
  27870. * | 2 | MIRROR_ADDRESSMODE | |
  27871. */
  27872. wrapV: number;
  27873. /**
  27874. * | Value | Type | Description |
  27875. * | ----- | ------------------ | ----------- |
  27876. * | 0 | CLAMP_ADDRESSMODE | |
  27877. * | 1 | WRAP_ADDRESSMODE | |
  27878. * | 2 | MIRROR_ADDRESSMODE | |
  27879. */
  27880. wrapR: number;
  27881. /**
  27882. * With compliant hardware and browser (supporting anisotropic filtering)
  27883. * this defines the level of anisotropic filtering in the texture.
  27884. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27885. */
  27886. anisotropicFilteringLevel: number;
  27887. /**
  27888. * Define if the texture is a cube texture or if false a 2d texture.
  27889. */
  27890. isCube: boolean;
  27891. /**
  27892. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27893. */
  27894. is3D: boolean;
  27895. /**
  27896. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27897. * HDR texture are usually stored in linear space.
  27898. * This only impacts the PBR and Background materials
  27899. */
  27900. gammaSpace: boolean;
  27901. /**
  27902. * Gets or sets whether or not the texture contains RGBD data.
  27903. */
  27904. isRGBD: boolean;
  27905. /**
  27906. * Is Z inverted in the texture (useful in a cube texture).
  27907. */
  27908. invertZ: boolean;
  27909. /**
  27910. * Are mip maps generated for this texture or not.
  27911. */
  27912. readonly noMipmap: boolean;
  27913. /**
  27914. * @hidden
  27915. */
  27916. lodLevelInAlpha: boolean;
  27917. /**
  27918. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27919. */
  27920. lodGenerationOffset: number;
  27921. /**
  27922. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27923. */
  27924. lodGenerationScale: number;
  27925. /**
  27926. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27927. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27928. * average roughness values.
  27929. */
  27930. linearSpecularLOD: boolean;
  27931. /**
  27932. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27933. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27934. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27935. */
  27936. irradianceTexture: Nullable<BaseTexture>;
  27937. /**
  27938. * Define if the texture is a render target.
  27939. */
  27940. isRenderTarget: boolean;
  27941. /**
  27942. * Define the unique id of the texture in the scene.
  27943. */
  27944. readonly uid: string;
  27945. /**
  27946. * Return a string representation of the texture.
  27947. * @returns the texture as a string
  27948. */
  27949. toString(): string;
  27950. /**
  27951. * Get the class name of the texture.
  27952. * @returns "BaseTexture"
  27953. */
  27954. getClassName(): string;
  27955. /**
  27956. * Define the list of animation attached to the texture.
  27957. */
  27958. animations: Animation[];
  27959. /**
  27960. * An event triggered when the texture is disposed.
  27961. */
  27962. onDisposeObservable: Observable<BaseTexture>;
  27963. private _onDisposeObserver;
  27964. /**
  27965. * Callback triggered when the texture has been disposed.
  27966. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27967. */
  27968. onDispose: () => void;
  27969. /**
  27970. * Define the current state of the loading sequence when in delayed load mode.
  27971. */
  27972. delayLoadState: number;
  27973. private _scene;
  27974. /** @hidden */
  27975. _texture: Nullable<InternalTexture>;
  27976. private _uid;
  27977. /**
  27978. * Define if the texture is preventinga material to render or not.
  27979. * If not and the texture is not ready, the engine will use a default black texture instead.
  27980. */
  27981. readonly isBlocking: boolean;
  27982. /**
  27983. * Instantiates a new BaseTexture.
  27984. * Base class of all the textures in babylon.
  27985. * It groups all the common properties the materials, post process, lights... might need
  27986. * in order to make a correct use of the texture.
  27987. * @param scene Define the scene the texture blongs to
  27988. */
  27989. constructor(scene: Nullable<Scene>);
  27990. /**
  27991. * Get the scene the texture belongs to.
  27992. * @returns the scene or null if undefined
  27993. */
  27994. getScene(): Nullable<Scene>;
  27995. /**
  27996. * Get the texture transform matrix used to offset tile the texture for istance.
  27997. * @returns the transformation matrix
  27998. */
  27999. getTextureMatrix(): Matrix;
  28000. /**
  28001. * Get the texture reflection matrix used to rotate/transform the reflection.
  28002. * @returns the reflection matrix
  28003. */
  28004. getReflectionTextureMatrix(): Matrix;
  28005. /**
  28006. * Get the underlying lower level texture from Babylon.
  28007. * @returns the insternal texture
  28008. */
  28009. getInternalTexture(): Nullable<InternalTexture>;
  28010. /**
  28011. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28012. * @returns true if ready or not blocking
  28013. */
  28014. isReadyOrNotBlocking(): boolean;
  28015. /**
  28016. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28017. * @returns true if fully ready
  28018. */
  28019. isReady(): boolean;
  28020. private _cachedSize;
  28021. /**
  28022. * Get the size of the texture.
  28023. * @returns the texture size.
  28024. */
  28025. getSize(): ISize;
  28026. /**
  28027. * Get the base size of the texture.
  28028. * It can be different from the size if the texture has been resized for POT for instance
  28029. * @returns the base size
  28030. */
  28031. getBaseSize(): ISize;
  28032. /**
  28033. * Update the sampling mode of the texture.
  28034. * Default is Trilinear mode.
  28035. *
  28036. * | Value | Type | Description |
  28037. * | ----- | ------------------ | ----------- |
  28038. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28039. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28040. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28041. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28042. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28043. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28044. * | 7 | NEAREST_LINEAR | |
  28045. * | 8 | NEAREST_NEAREST | |
  28046. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28047. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28048. * | 11 | LINEAR_LINEAR | |
  28049. * | 12 | LINEAR_NEAREST | |
  28050. *
  28051. * > _mag_: magnification filter (close to the viewer)
  28052. * > _min_: minification filter (far from the viewer)
  28053. * > _mip_: filter used between mip map levels
  28054. *@param samplingMode Define the new sampling mode of the texture
  28055. */
  28056. updateSamplingMode(samplingMode: number): void;
  28057. /**
  28058. * Scales the texture if is `canRescale()`
  28059. * @param ratio the resize factor we want to use to rescale
  28060. */
  28061. scale(ratio: number): void;
  28062. /**
  28063. * Get if the texture can rescale.
  28064. */
  28065. readonly canRescale: boolean;
  28066. /** @hidden */
  28067. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28068. /** @hidden */
  28069. _rebuild(): void;
  28070. /**
  28071. * Triggers the load sequence in delayed load mode.
  28072. */
  28073. delayLoad(): void;
  28074. /**
  28075. * Clones the texture.
  28076. * @returns the cloned texture
  28077. */
  28078. clone(): Nullable<BaseTexture>;
  28079. /**
  28080. * Get the texture underlying type (INT, FLOAT...)
  28081. */
  28082. readonly textureType: number;
  28083. /**
  28084. * Get the texture underlying format (RGB, RGBA...)
  28085. */
  28086. readonly textureFormat: number;
  28087. /**
  28088. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28089. * This will returns an RGBA array buffer containing either in values (0-255) or
  28090. * float values (0-1) depending of the underlying buffer type.
  28091. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28092. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28093. * @param buffer defines a user defined buffer to fill with data (can be null)
  28094. * @returns The Array buffer containing the pixels data.
  28095. */
  28096. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28097. /**
  28098. * Release and destroy the underlying lower level texture aka internalTexture.
  28099. */
  28100. releaseInternalTexture(): void;
  28101. /**
  28102. * Get the polynomial representation of the texture data.
  28103. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28104. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28105. */
  28106. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28107. /** @hidden */
  28108. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28109. /** @hidden */
  28110. readonly _lodTextureMid: Nullable<BaseTexture>;
  28111. /** @hidden */
  28112. readonly _lodTextureLow: Nullable<BaseTexture>;
  28113. /**
  28114. * Dispose the texture and release its associated resources.
  28115. */
  28116. dispose(): void;
  28117. /**
  28118. * Serialize the texture into a JSON representation that can be parsed later on.
  28119. * @returns the JSON representation of the texture
  28120. */
  28121. serialize(): any;
  28122. /**
  28123. * Helper function to be called back once a list of texture contains only ready textures.
  28124. * @param textures Define the list of textures to wait for
  28125. * @param callback Define the callback triggered once the entire list will be ready
  28126. */
  28127. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28128. }
  28129. }
  28130. declare module BABYLON {
  28131. /**
  28132. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28133. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28134. */
  28135. export class EffectFallbacks {
  28136. private _defines;
  28137. private _currentRank;
  28138. private _maxRank;
  28139. private _mesh;
  28140. /**
  28141. * Removes the fallback from the bound mesh.
  28142. */
  28143. unBindMesh(): void;
  28144. /**
  28145. * Adds a fallback on the specified property.
  28146. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28147. * @param define The name of the define in the shader
  28148. */
  28149. addFallback(rank: number, define: string): void;
  28150. /**
  28151. * Sets the mesh to use CPU skinning when needing to fallback.
  28152. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28153. * @param mesh The mesh to use the fallbacks.
  28154. */
  28155. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28156. /**
  28157. * Checks to see if more fallbacks are still availible.
  28158. */
  28159. readonly hasMoreFallbacks: boolean;
  28160. /**
  28161. * Removes the defines that should be removed when falling back.
  28162. * @param currentDefines defines the current define statements for the shader.
  28163. * @param effect defines the current effect we try to compile
  28164. * @returns The resulting defines with defines of the current rank removed.
  28165. */
  28166. reduce(currentDefines: string, effect: Effect): string;
  28167. }
  28168. /**
  28169. * Options to be used when creating an effect.
  28170. */
  28171. export class EffectCreationOptions {
  28172. /**
  28173. * Atrributes that will be used in the shader.
  28174. */
  28175. attributes: string[];
  28176. /**
  28177. * Uniform varible names that will be set in the shader.
  28178. */
  28179. uniformsNames: string[];
  28180. /**
  28181. * Uniform buffer varible names that will be set in the shader.
  28182. */
  28183. uniformBuffersNames: string[];
  28184. /**
  28185. * Sampler texture variable names that will be set in the shader.
  28186. */
  28187. samplers: string[];
  28188. /**
  28189. * Define statements that will be set in the shader.
  28190. */
  28191. defines: any;
  28192. /**
  28193. * Possible fallbacks for this effect to improve performance when needed.
  28194. */
  28195. fallbacks: Nullable<EffectFallbacks>;
  28196. /**
  28197. * Callback that will be called when the shader is compiled.
  28198. */
  28199. onCompiled: Nullable<(effect: Effect) => void>;
  28200. /**
  28201. * Callback that will be called if an error occurs during shader compilation.
  28202. */
  28203. onError: Nullable<(effect: Effect, errors: string) => void>;
  28204. /**
  28205. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28206. */
  28207. indexParameters: any;
  28208. /**
  28209. * Max number of lights that can be used in the shader.
  28210. */
  28211. maxSimultaneousLights: number;
  28212. /**
  28213. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28214. */
  28215. transformFeedbackVaryings: Nullable<string[]>;
  28216. }
  28217. /**
  28218. * Effect containing vertex and fragment shader that can be executed on an object.
  28219. */
  28220. export class Effect implements IDisposable {
  28221. /**
  28222. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28223. */
  28224. static ShadersRepository: string;
  28225. /**
  28226. * Name of the effect.
  28227. */
  28228. name: any;
  28229. /**
  28230. * String container all the define statements that should be set on the shader.
  28231. */
  28232. defines: string;
  28233. /**
  28234. * Callback that will be called when the shader is compiled.
  28235. */
  28236. onCompiled: Nullable<(effect: Effect) => void>;
  28237. /**
  28238. * Callback that will be called if an error occurs during shader compilation.
  28239. */
  28240. onError: Nullable<(effect: Effect, errors: string) => void>;
  28241. /**
  28242. * Callback that will be called when effect is bound.
  28243. */
  28244. onBind: Nullable<(effect: Effect) => void>;
  28245. /**
  28246. * Unique ID of the effect.
  28247. */
  28248. uniqueId: number;
  28249. /**
  28250. * Observable that will be called when the shader is compiled.
  28251. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28252. */
  28253. onCompileObservable: Observable<Effect>;
  28254. /**
  28255. * Observable that will be called if an error occurs during shader compilation.
  28256. */
  28257. onErrorObservable: Observable<Effect>;
  28258. /** @hidden */
  28259. _onBindObservable: Nullable<Observable<Effect>>;
  28260. /**
  28261. * Observable that will be called when effect is bound.
  28262. */
  28263. readonly onBindObservable: Observable<Effect>;
  28264. /** @hidden */
  28265. _bonesComputationForcedToCPU: boolean;
  28266. private static _uniqueIdSeed;
  28267. private _engine;
  28268. private _uniformBuffersNames;
  28269. private _uniformsNames;
  28270. private _samplerList;
  28271. private _samplers;
  28272. private _isReady;
  28273. private _compilationError;
  28274. private _attributesNames;
  28275. private _attributes;
  28276. private _uniforms;
  28277. /**
  28278. * Key for the effect.
  28279. * @hidden
  28280. */
  28281. _key: string;
  28282. private _indexParameters;
  28283. private _fallbacks;
  28284. private _vertexSourceCode;
  28285. private _fragmentSourceCode;
  28286. private _vertexSourceCodeOverride;
  28287. private _fragmentSourceCodeOverride;
  28288. private _transformFeedbackVaryings;
  28289. /**
  28290. * Compiled shader to webGL program.
  28291. * @hidden
  28292. */
  28293. _pipelineContext: Nullable<IPipelineContext>;
  28294. private _valueCache;
  28295. private static _baseCache;
  28296. /**
  28297. * Instantiates an effect.
  28298. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28299. * @param baseName Name of the effect.
  28300. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28301. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28302. * @param samplers List of sampler variables that will be passed to the shader.
  28303. * @param engine Engine to be used to render the effect
  28304. * @param defines Define statements to be added to the shader.
  28305. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28306. * @param onCompiled Callback that will be called when the shader is compiled.
  28307. * @param onError Callback that will be called if an error occurs during shader compilation.
  28308. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28309. */
  28310. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | BaseEngine, samplers?: Nullable<string[]>, engine?: BaseEngine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28311. private _useFinalCode;
  28312. /**
  28313. * Unique key for this effect
  28314. */
  28315. readonly key: string;
  28316. /**
  28317. * If the effect has been compiled and prepared.
  28318. * @returns if the effect is compiled and prepared.
  28319. */
  28320. isReady(): boolean;
  28321. private _isReadyInternal;
  28322. /**
  28323. * The engine the effect was initialized with.
  28324. * @returns the engine.
  28325. */
  28326. getEngine(): Engine;
  28327. /**
  28328. * The pipeline context for this effect
  28329. * @returns the associated pipeline context
  28330. */
  28331. getPipelineContext(): Nullable<IPipelineContext>;
  28332. /**
  28333. * The set of names of attribute variables for the shader.
  28334. * @returns An array of attribute names.
  28335. */
  28336. getAttributesNames(): string[];
  28337. /**
  28338. * Returns the attribute at the given index.
  28339. * @param index The index of the attribute.
  28340. * @returns The location of the attribute.
  28341. */
  28342. getAttributeLocation(index: number): number;
  28343. /**
  28344. * Returns the attribute based on the name of the variable.
  28345. * @param name of the attribute to look up.
  28346. * @returns the attribute location.
  28347. */
  28348. getAttributeLocationByName(name: string): number;
  28349. /**
  28350. * The number of attributes.
  28351. * @returns the numnber of attributes.
  28352. */
  28353. getAttributesCount(): number;
  28354. /**
  28355. * Gets the index of a uniform variable.
  28356. * @param uniformName of the uniform to look up.
  28357. * @returns the index.
  28358. */
  28359. getUniformIndex(uniformName: string): number;
  28360. /**
  28361. * Returns the attribute based on the name of the variable.
  28362. * @param uniformName of the uniform to look up.
  28363. * @returns the location of the uniform.
  28364. */
  28365. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28366. /**
  28367. * Returns an array of sampler variable names
  28368. * @returns The array of sampler variable neames.
  28369. */
  28370. getSamplers(): string[];
  28371. /**
  28372. * The error from the last compilation.
  28373. * @returns the error string.
  28374. */
  28375. getCompilationError(): string;
  28376. /**
  28377. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28378. * @param func The callback to be used.
  28379. */
  28380. executeWhenCompiled(func: (effect: Effect) => void): void;
  28381. private _checkIsReady;
  28382. /** @hidden */
  28383. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28384. /** @hidden */
  28385. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28386. /** @hidden */
  28387. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28388. /**
  28389. * Recompiles the webGL program
  28390. * @param vertexSourceCode The source code for the vertex shader.
  28391. * @param fragmentSourceCode The source code for the fragment shader.
  28392. * @param onCompiled Callback called when completed.
  28393. * @param onError Callback called on error.
  28394. * @hidden
  28395. */
  28396. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28397. /**
  28398. * Prepares the effect
  28399. * @hidden
  28400. */
  28401. _prepareEffect(): void;
  28402. private _processCompilationErrors;
  28403. /**
  28404. * Checks if the effect is supported. (Must be called after compilation)
  28405. */
  28406. readonly isSupported: boolean;
  28407. /**
  28408. * Binds a texture to the engine to be used as output of the shader.
  28409. * @param channel Name of the output variable.
  28410. * @param texture Texture to bind.
  28411. * @hidden
  28412. */
  28413. _bindTexture(channel: string, texture: InternalTexture): void;
  28414. /**
  28415. * Sets a texture on the engine to be used in the shader.
  28416. * @param channel Name of the sampler variable.
  28417. * @param texture Texture to set.
  28418. */
  28419. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28420. /**
  28421. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28422. * @param channel Name of the sampler variable.
  28423. * @param texture Texture to set.
  28424. */
  28425. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28426. /**
  28427. * Sets an array of textures on the engine to be used in the shader.
  28428. * @param channel Name of the variable.
  28429. * @param textures Textures to set.
  28430. */
  28431. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28432. /**
  28433. * 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)
  28434. * @param channel Name of the sampler variable.
  28435. * @param postProcess Post process to get the input texture from.
  28436. */
  28437. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28438. /**
  28439. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28440. * 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)
  28441. * @param channel Name of the sampler variable.
  28442. * @param postProcess Post process to get the output texture from.
  28443. */
  28444. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28445. /** @hidden */
  28446. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28447. /** @hidden */
  28448. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28449. /** @hidden */
  28450. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28451. /** @hidden */
  28452. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28453. /**
  28454. * Binds a buffer to a uniform.
  28455. * @param buffer Buffer to bind.
  28456. * @param name Name of the uniform variable to bind to.
  28457. */
  28458. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28459. /**
  28460. * Binds block to a uniform.
  28461. * @param blockName Name of the block to bind.
  28462. * @param index Index to bind.
  28463. */
  28464. bindUniformBlock(blockName: string, index: number): void;
  28465. /**
  28466. * Sets an interger value on a uniform variable.
  28467. * @param uniformName Name of the variable.
  28468. * @param value Value to be set.
  28469. * @returns this effect.
  28470. */
  28471. setInt(uniformName: string, value: number): Effect;
  28472. /**
  28473. * Sets an int array on a uniform variable.
  28474. * @param uniformName Name of the variable.
  28475. * @param array array to be set.
  28476. * @returns this effect.
  28477. */
  28478. setIntArray(uniformName: string, array: Int32Array): Effect;
  28479. /**
  28480. * 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)
  28481. * @param uniformName Name of the variable.
  28482. * @param array array to be set.
  28483. * @returns this effect.
  28484. */
  28485. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28486. /**
  28487. * 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)
  28488. * @param uniformName Name of the variable.
  28489. * @param array array to be set.
  28490. * @returns this effect.
  28491. */
  28492. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28493. /**
  28494. * 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)
  28495. * @param uniformName Name of the variable.
  28496. * @param array array to be set.
  28497. * @returns this effect.
  28498. */
  28499. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28500. /**
  28501. * Sets an float array on a uniform variable.
  28502. * @param uniformName Name of the variable.
  28503. * @param array array to be set.
  28504. * @returns this effect.
  28505. */
  28506. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28507. /**
  28508. * 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)
  28509. * @param uniformName Name of the variable.
  28510. * @param array array to be set.
  28511. * @returns this effect.
  28512. */
  28513. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28514. /**
  28515. * 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)
  28516. * @param uniformName Name of the variable.
  28517. * @param array array to be set.
  28518. * @returns this effect.
  28519. */
  28520. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28521. /**
  28522. * 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)
  28523. * @param uniformName Name of the variable.
  28524. * @param array array to be set.
  28525. * @returns this effect.
  28526. */
  28527. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28528. /**
  28529. * Sets an array on a uniform variable.
  28530. * @param uniformName Name of the variable.
  28531. * @param array array to be set.
  28532. * @returns this effect.
  28533. */
  28534. setArray(uniformName: string, array: number[]): Effect;
  28535. /**
  28536. * 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)
  28537. * @param uniformName Name of the variable.
  28538. * @param array array to be set.
  28539. * @returns this effect.
  28540. */
  28541. setArray2(uniformName: string, array: number[]): Effect;
  28542. /**
  28543. * 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)
  28544. * @param uniformName Name of the variable.
  28545. * @param array array to be set.
  28546. * @returns this effect.
  28547. */
  28548. setArray3(uniformName: string, array: number[]): Effect;
  28549. /**
  28550. * 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)
  28551. * @param uniformName Name of the variable.
  28552. * @param array array to be set.
  28553. * @returns this effect.
  28554. */
  28555. setArray4(uniformName: string, array: number[]): Effect;
  28556. /**
  28557. * Sets matrices on a uniform variable.
  28558. * @param uniformName Name of the variable.
  28559. * @param matrices matrices to be set.
  28560. * @returns this effect.
  28561. */
  28562. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28563. /**
  28564. * Sets matrix on a uniform variable.
  28565. * @param uniformName Name of the variable.
  28566. * @param matrix matrix to be set.
  28567. * @returns this effect.
  28568. */
  28569. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28570. /**
  28571. * 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)
  28572. * @param uniformName Name of the variable.
  28573. * @param matrix matrix to be set.
  28574. * @returns this effect.
  28575. */
  28576. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28577. /**
  28578. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28579. * @param uniformName Name of the variable.
  28580. * @param matrix matrix to be set.
  28581. * @returns this effect.
  28582. */
  28583. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28584. /**
  28585. * Sets a float on a uniform variable.
  28586. * @param uniformName Name of the variable.
  28587. * @param value value to be set.
  28588. * @returns this effect.
  28589. */
  28590. setFloat(uniformName: string, value: number): Effect;
  28591. /**
  28592. * Sets a boolean on a uniform variable.
  28593. * @param uniformName Name of the variable.
  28594. * @param bool value to be set.
  28595. * @returns this effect.
  28596. */
  28597. setBool(uniformName: string, bool: boolean): Effect;
  28598. /**
  28599. * Sets a Vector2 on a uniform variable.
  28600. * @param uniformName Name of the variable.
  28601. * @param vector2 vector2 to be set.
  28602. * @returns this effect.
  28603. */
  28604. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28605. /**
  28606. * Sets a float2 on a uniform variable.
  28607. * @param uniformName Name of the variable.
  28608. * @param x First float in float2.
  28609. * @param y Second float in float2.
  28610. * @returns this effect.
  28611. */
  28612. setFloat2(uniformName: string, x: number, y: number): Effect;
  28613. /**
  28614. * Sets a Vector3 on a uniform variable.
  28615. * @param uniformName Name of the variable.
  28616. * @param vector3 Value to be set.
  28617. * @returns this effect.
  28618. */
  28619. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28620. /**
  28621. * Sets a float3 on a uniform variable.
  28622. * @param uniformName Name of the variable.
  28623. * @param x First float in float3.
  28624. * @param y Second float in float3.
  28625. * @param z Third float in float3.
  28626. * @returns this effect.
  28627. */
  28628. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28629. /**
  28630. * Sets a Vector4 on a uniform variable.
  28631. * @param uniformName Name of the variable.
  28632. * @param vector4 Value to be set.
  28633. * @returns this effect.
  28634. */
  28635. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28636. /**
  28637. * Sets a float4 on a uniform variable.
  28638. * @param uniformName Name of the variable.
  28639. * @param x First float in float4.
  28640. * @param y Second float in float4.
  28641. * @param z Third float in float4.
  28642. * @param w Fourth float in float4.
  28643. * @returns this effect.
  28644. */
  28645. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28646. /**
  28647. * Sets a Color3 on a uniform variable.
  28648. * @param uniformName Name of the variable.
  28649. * @param color3 Value to be set.
  28650. * @returns this effect.
  28651. */
  28652. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28653. /**
  28654. * Sets a Color4 on a uniform variable.
  28655. * @param uniformName Name of the variable.
  28656. * @param color3 Value to be set.
  28657. * @param alpha Alpha value to be set.
  28658. * @returns this effect.
  28659. */
  28660. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28661. /**
  28662. * Sets a Color4 on a uniform variable
  28663. * @param uniformName defines the name of the variable
  28664. * @param color4 defines the value to be set
  28665. * @returns this effect.
  28666. */
  28667. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28668. /** Release all associated resources */
  28669. dispose(): void;
  28670. /**
  28671. * This function will add a new shader to the shader store
  28672. * @param name the name of the shader
  28673. * @param pixelShader optional pixel shader content
  28674. * @param vertexShader optional vertex shader content
  28675. */
  28676. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28677. /**
  28678. * Store of each shader (The can be looked up using effect.key)
  28679. */
  28680. static ShadersStore: {
  28681. [key: string]: string;
  28682. };
  28683. /**
  28684. * Store of each included file for a shader (The can be looked up using effect.key)
  28685. */
  28686. static IncludesShadersStore: {
  28687. [key: string]: string;
  28688. };
  28689. /**
  28690. * Resets the cache of effects.
  28691. */
  28692. static ResetCache(): void;
  28693. }
  28694. }
  28695. declare module BABYLON {
  28696. /**
  28697. * Class used to describe the capabilities of the engine relatively to the current browser
  28698. */
  28699. export class EngineCapabilities {
  28700. /** Maximum textures units per fragment shader */
  28701. maxTexturesImageUnits: number;
  28702. /** Maximum texture units per vertex shader */
  28703. maxVertexTextureImageUnits: number;
  28704. /** Maximum textures units in the entire pipeline */
  28705. maxCombinedTexturesImageUnits: number;
  28706. /** Maximum texture size */
  28707. maxTextureSize: number;
  28708. /** Maximum cube texture size */
  28709. maxCubemapTextureSize: number;
  28710. /** Maximum render texture size */
  28711. maxRenderTextureSize: number;
  28712. /** Maximum number of vertex attributes */
  28713. maxVertexAttribs: number;
  28714. /** Maximum number of varyings */
  28715. maxVaryingVectors: number;
  28716. /** Maximum number of uniforms per vertex shader */
  28717. maxVertexUniformVectors: number;
  28718. /** Maximum number of uniforms per fragment shader */
  28719. maxFragmentUniformVectors: number;
  28720. /** Defines if standard derivates (dx/dy) are supported */
  28721. standardDerivatives: boolean;
  28722. /** Defines if s3tc texture compression is supported */
  28723. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28724. /** Defines if pvrtc texture compression is supported */
  28725. pvrtc: any;
  28726. /** Defines if etc1 texture compression is supported */
  28727. etc1: any;
  28728. /** Defines if etc2 texture compression is supported */
  28729. etc2: any;
  28730. /** Defines if astc texture compression is supported */
  28731. astc: any;
  28732. /** Defines if float textures are supported */
  28733. textureFloat: boolean;
  28734. /** Defines if vertex array objects are supported */
  28735. vertexArrayObject: boolean;
  28736. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28737. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28738. /** Gets the maximum level of anisotropy supported */
  28739. maxAnisotropy: number;
  28740. /** Defines if instancing is supported */
  28741. instancedArrays: boolean;
  28742. /** Defines if 32 bits indices are supported */
  28743. uintIndices: boolean;
  28744. /** Defines if high precision shaders are supported */
  28745. highPrecisionShaderSupported: boolean;
  28746. /** Defines if depth reading in the fragment shader is supported */
  28747. fragmentDepthSupported: boolean;
  28748. /** Defines if float texture linear filtering is supported*/
  28749. textureFloatLinearFiltering: boolean;
  28750. /** Defines if rendering to float textures is supported */
  28751. textureFloatRender: boolean;
  28752. /** Defines if half float textures are supported*/
  28753. textureHalfFloat: boolean;
  28754. /** Defines if half float texture linear filtering is supported*/
  28755. textureHalfFloatLinearFiltering: boolean;
  28756. /** Defines if rendering to half float textures is supported */
  28757. textureHalfFloatRender: boolean;
  28758. /** Defines if textureLOD shader command is supported */
  28759. textureLOD: boolean;
  28760. /** Defines if draw buffers extension is supported */
  28761. drawBuffersExtension: boolean;
  28762. /** Defines if depth textures are supported */
  28763. depthTextureExtension: boolean;
  28764. /** Defines if float color buffer are supported */
  28765. colorBufferFloat: boolean;
  28766. /** Gets disjoint timer query extension (null if not supported) */
  28767. timerQuery: EXT_disjoint_timer_query;
  28768. /** Defines if timestamp can be used with timer query */
  28769. canUseTimestampForTimerQuery: boolean;
  28770. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28771. multiview: any;
  28772. /** Function used to let the system compiles shaders in background */
  28773. parallelShaderCompile: {
  28774. COMPLETION_STATUS_KHR: number;
  28775. };
  28776. /** Max number of texture samples for MSAA */
  28777. maxMSAASamples: number;
  28778. /** Defines if the blend min max extension is supported */
  28779. blendMinMax: boolean;
  28780. }
  28781. }
  28782. declare module BABYLON {
  28783. /**
  28784. * This class is used to track a performance counter which is number based.
  28785. * The user has access to many properties which give statistics of different nature.
  28786. *
  28787. * The implementer can track two kinds of Performance Counter: time and count.
  28788. * 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.
  28789. * 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.
  28790. */
  28791. export class PerfCounter {
  28792. /**
  28793. * Gets or sets a global boolean to turn on and off all the counters
  28794. */
  28795. static Enabled: boolean;
  28796. /**
  28797. * Returns the smallest value ever
  28798. */
  28799. readonly min: number;
  28800. /**
  28801. * Returns the biggest value ever
  28802. */
  28803. readonly max: number;
  28804. /**
  28805. * Returns the average value since the performance counter is running
  28806. */
  28807. readonly average: number;
  28808. /**
  28809. * Returns the average value of the last second the counter was monitored
  28810. */
  28811. readonly lastSecAverage: number;
  28812. /**
  28813. * Returns the current value
  28814. */
  28815. readonly current: number;
  28816. /**
  28817. * Gets the accumulated total
  28818. */
  28819. readonly total: number;
  28820. /**
  28821. * Gets the total value count
  28822. */
  28823. readonly count: number;
  28824. /**
  28825. * Creates a new counter
  28826. */
  28827. constructor();
  28828. /**
  28829. * Call this method to start monitoring a new frame.
  28830. * 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.
  28831. */
  28832. fetchNewFrame(): void;
  28833. /**
  28834. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28835. * @param newCount the count value to add to the monitored count
  28836. * @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.
  28837. */
  28838. addCount(newCount: number, fetchResult: boolean): void;
  28839. /**
  28840. * Start monitoring this performance counter
  28841. */
  28842. beginMonitoring(): void;
  28843. /**
  28844. * Compute the time lapsed since the previous beginMonitoring() call.
  28845. * @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
  28846. */
  28847. endMonitoring(newFrame?: boolean): void;
  28848. private _fetchResult;
  28849. private _startMonitoringTime;
  28850. private _min;
  28851. private _max;
  28852. private _average;
  28853. private _current;
  28854. private _totalValueCount;
  28855. private _totalAccumulated;
  28856. private _lastSecAverage;
  28857. private _lastSecAccumulated;
  28858. private _lastSecTime;
  28859. private _lastSecValueCount;
  28860. }
  28861. }
  28862. declare module BABYLON {
  28863. /** @hidden */
  28864. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28865. attributeProcessor(attribute: string): string;
  28866. varyingProcessor(varying: string, isFragment: boolean): string;
  28867. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28868. }
  28869. }
  28870. declare module BABYLON {
  28871. /** @hidden */
  28872. export class WebGLDataBuffer extends DataBuffer {
  28873. private _buffer;
  28874. constructor(resource: WebGLBuffer);
  28875. readonly underlyingResource: any;
  28876. }
  28877. }
  28878. declare module BABYLON {
  28879. /** @hidden */
  28880. export class WebGLPipelineContext implements IPipelineContext {
  28881. engine: BaseEngine;
  28882. program: Nullable<WebGLProgram>;
  28883. context?: WebGLRenderingContext;
  28884. vertexShader?: WebGLShader;
  28885. fragmentShader?: WebGLShader;
  28886. isParallelCompiled: boolean;
  28887. onCompiled?: () => void;
  28888. transformFeedback?: WebGLTransformFeedback | null;
  28889. readonly isAsync: boolean;
  28890. readonly isReady: boolean;
  28891. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  28892. }
  28893. }
  28894. declare module BABYLON {
  28895. /**
  28896. * Interface for attribute information associated with buffer instanciation
  28897. */
  28898. export class InstancingAttributeInfo {
  28899. /**
  28900. * Index/offset of the attribute in the vertex shader
  28901. */
  28902. index: number;
  28903. /**
  28904. * size of the attribute, 1, 2, 3 or 4
  28905. */
  28906. attributeSize: number;
  28907. /**
  28908. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28909. * default is FLOAT
  28910. */
  28911. attribyteType: number;
  28912. /**
  28913. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28914. */
  28915. normalized: boolean;
  28916. /**
  28917. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28918. */
  28919. offset: number;
  28920. /**
  28921. * Name of the GLSL attribute, for debugging purpose only
  28922. */
  28923. attributeName: string;
  28924. }
  28925. }
  28926. declare module BABYLON {
  28927. /**
  28928. * Settings for finer control over video usage
  28929. */
  28930. export interface VideoTextureSettings {
  28931. /**
  28932. * Applies `autoplay` to video, if specified
  28933. */
  28934. autoPlay?: boolean;
  28935. /**
  28936. * Applies `loop` to video, if specified
  28937. */
  28938. loop?: boolean;
  28939. /**
  28940. * Automatically updates internal texture from video at every frame in the render loop
  28941. */
  28942. autoUpdateTexture: boolean;
  28943. /**
  28944. * Image src displayed during the video loading or until the user interacts with the video.
  28945. */
  28946. poster?: string;
  28947. }
  28948. /**
  28949. * If you want to display a video in your scene, this is the special texture for that.
  28950. * This special texture works similar to other textures, with the exception of a few parameters.
  28951. * @see https://doc.babylonjs.com/how_to/video_texture
  28952. */
  28953. export class VideoTexture extends Texture {
  28954. /**
  28955. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28956. */
  28957. readonly autoUpdateTexture: boolean;
  28958. /**
  28959. * The video instance used by the texture internally
  28960. */
  28961. readonly video: HTMLVideoElement;
  28962. private _onUserActionRequestedObservable;
  28963. /**
  28964. * Event triggerd when a dom action is required by the user to play the video.
  28965. * This happens due to recent changes in browser policies preventing video to auto start.
  28966. */
  28967. readonly onUserActionRequestedObservable: Observable<Texture>;
  28968. private _generateMipMaps;
  28969. private _engine;
  28970. private _stillImageCaptured;
  28971. private _displayingPosterTexture;
  28972. private _settings;
  28973. private _createInternalTextureOnEvent;
  28974. private _frameId;
  28975. /**
  28976. * Creates a video texture.
  28977. * If you want to display a video in your scene, this is the special texture for that.
  28978. * This special texture works similar to other textures, with the exception of a few parameters.
  28979. * @see https://doc.babylonjs.com/how_to/video_texture
  28980. * @param name optional name, will detect from video source, if not defined
  28981. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28982. * @param scene is obviously the current scene.
  28983. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28984. * @param invertY is false by default but can be used to invert video on Y axis
  28985. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28986. * @param settings allows finer control over video usage
  28987. */
  28988. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28989. private _getName;
  28990. private _getVideo;
  28991. private _createInternalTexture;
  28992. private reset;
  28993. /**
  28994. * @hidden Internal method to initiate `update`.
  28995. */
  28996. _rebuild(): void;
  28997. /**
  28998. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28999. */
  29000. update(): void;
  29001. /**
  29002. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29003. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29004. */
  29005. updateTexture(isVisible: boolean): void;
  29006. protected _updateInternalTexture: () => void;
  29007. /**
  29008. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29009. * @param url New url.
  29010. */
  29011. updateURL(url: string): void;
  29012. /**
  29013. * Dispose the texture and release its associated resources.
  29014. */
  29015. dispose(): void;
  29016. /**
  29017. * Creates a video texture straight from a stream.
  29018. * @param scene Define the scene the texture should be created in
  29019. * @param stream Define the stream the texture should be created from
  29020. * @returns The created video texture as a promise
  29021. */
  29022. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29023. /**
  29024. * Creates a video texture straight from your WebCam video feed.
  29025. * @param scene Define the scene the texture should be created in
  29026. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29027. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29028. * @returns The created video texture as a promise
  29029. */
  29030. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29031. minWidth: number;
  29032. maxWidth: number;
  29033. minHeight: number;
  29034. maxHeight: number;
  29035. deviceId: string;
  29036. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29037. /**
  29038. * Creates a video texture straight from your WebCam video feed.
  29039. * @param scene Define the scene the texture should be created in
  29040. * @param onReady Define a callback to triggered once the texture will be ready
  29041. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29042. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29043. */
  29044. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29045. minWidth: number;
  29046. maxWidth: number;
  29047. minHeight: number;
  29048. maxHeight: number;
  29049. deviceId: string;
  29050. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29051. }
  29052. }
  29053. declare module BABYLON {
  29054. /**
  29055. * Defines the interface used by objects containing a viewport (like a camera)
  29056. */
  29057. interface IViewportOwnerLike {
  29058. /**
  29059. * Gets or sets the viewport
  29060. */
  29061. viewport: IViewportLike;
  29062. }
  29063. /**
  29064. * Defines the interface used by objects working like Scene
  29065. * @hidden
  29066. */
  29067. interface ISceneLike {
  29068. _addPendingData(data: any): void;
  29069. _removePendingData(data: any): void;
  29070. offlineProvider: IOfflineProvider;
  29071. }
  29072. /** Interface defining initialization parameters for Engine class */
  29073. export interface EngineOptions extends WebGLContextAttributes {
  29074. /**
  29075. * Defines if the engine should no exceed a specified device ratio
  29076. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29077. */
  29078. limitDeviceRatio?: number;
  29079. /**
  29080. * Defines if webvr should be enabled automatically
  29081. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29082. */
  29083. autoEnableWebVR?: boolean;
  29084. /**
  29085. * Defines if webgl2 should be turned off even if supported
  29086. * @see http://doc.babylonjs.com/features/webgl2
  29087. */
  29088. disableWebGL2Support?: boolean;
  29089. /**
  29090. * Defines if webaudio should be initialized as well
  29091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29092. */
  29093. audioEngine?: boolean;
  29094. /**
  29095. * Defines if animations should run using a deterministic lock step
  29096. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29097. */
  29098. deterministicLockstep?: boolean;
  29099. /** Defines the maximum steps to use with deterministic lock step mode */
  29100. lockstepMaxSteps?: number;
  29101. /**
  29102. * Defines that engine should ignore context lost events
  29103. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29104. */
  29105. doNotHandleContextLost?: boolean;
  29106. /**
  29107. * Defines that engine should ignore modifying touch action attribute and style
  29108. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29109. */
  29110. doNotHandleTouchAction?: boolean;
  29111. /**
  29112. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29113. */
  29114. useHighPrecisionFloats?: boolean;
  29115. }
  29116. /**
  29117. * The base engine class (root of all engines)
  29118. */
  29119. export class BaseEngine {
  29120. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29121. static ExceptionList: ({
  29122. key: string;
  29123. capture: string;
  29124. captureConstraint: number;
  29125. targets: string[];
  29126. } | {
  29127. key: string;
  29128. capture: null;
  29129. captureConstraint: null;
  29130. targets: string[];
  29131. })[];
  29132. /** @hidden */
  29133. static _TextureLoaders: IInternalTextureLoader[];
  29134. /**
  29135. * Returns the current npm package of the sdk
  29136. */
  29137. static readonly NpmPackage: string;
  29138. /**
  29139. * Returns the current version of the framework
  29140. */
  29141. static readonly Version: string;
  29142. /**
  29143. * Returns a string describing the current engine
  29144. */
  29145. readonly description: string;
  29146. /**
  29147. * Gets or sets the epsilon value used by collision engine
  29148. */
  29149. static CollisionsEpsilon: number;
  29150. /**
  29151. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29152. */
  29153. static ShadersRepository: string;
  29154. /** @hidden */
  29155. _shaderProcessor: IShaderProcessor;
  29156. /**
  29157. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29158. */
  29159. forcePOTTextures: boolean;
  29160. /**
  29161. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29162. */
  29163. isFullscreen: boolean;
  29164. /**
  29165. * Gets a boolean indicating if the pointer is currently locked
  29166. */
  29167. isPointerLock: boolean;
  29168. /**
  29169. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29170. */
  29171. cullBackFaces: boolean;
  29172. /**
  29173. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29174. */
  29175. renderEvenInBackground: boolean;
  29176. /**
  29177. * Gets or sets a boolean indicating that cache can be kept between frames
  29178. */
  29179. preventCacheWipeBetweenFrames: boolean;
  29180. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29181. validateShaderPrograms: boolean;
  29182. /**
  29183. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29184. */
  29185. disableUniformBuffers: boolean;
  29186. /** @hidden */
  29187. _uniformBuffers: UniformBuffer[];
  29188. /**
  29189. * Gets a boolean indicating that the engine supports uniform buffers
  29190. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29191. */
  29192. readonly supportsUniformBuffers: boolean;
  29193. /** @hidden */
  29194. _gl: WebGLRenderingContext;
  29195. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29196. protected _windowIsBackground: boolean;
  29197. protected _webGLVersion: number;
  29198. protected _highPrecisionShadersAllowed: boolean;
  29199. /** @hidden */
  29200. readonly _shouldUseHighPrecisionShader: boolean;
  29201. /**
  29202. * Gets a boolean indicating that only power of 2 textures are supported
  29203. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29204. */
  29205. readonly needPOTTextures: boolean;
  29206. /** @hidden */
  29207. _badOS: boolean;
  29208. /** @hidden */
  29209. _badDesktopOS: boolean;
  29210. private _hardwareScalingLevel;
  29211. /** @hidden */
  29212. _caps: EngineCapabilities;
  29213. private _isStencilEnable;
  29214. protected _colorWrite: boolean;
  29215. /** @hidden */
  29216. _drawCalls: PerfCounter;
  29217. private _glVersion;
  29218. private _glRenderer;
  29219. private _glVendor;
  29220. private _videoTextureSupported;
  29221. protected _renderingQueueLaunched: boolean;
  29222. protected _activeRenderLoops: (() => void)[];
  29223. private _deterministicLockstep;
  29224. private _lockstepMaxSteps;
  29225. /**
  29226. * Observable signaled when a context lost event is raised
  29227. */
  29228. onContextLostObservable: Observable<BaseEngine>;
  29229. /**
  29230. * Observable signaled when a context restored event is raised
  29231. */
  29232. onContextRestoredObservable: Observable<BaseEngine>;
  29233. private _onContextLost;
  29234. private _onContextRestored;
  29235. protected _contextWasLost: boolean;
  29236. /** @hidden */
  29237. _doNotHandleContextLost: boolean;
  29238. /**
  29239. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29240. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29241. */
  29242. doNotHandleContextLost: boolean;
  29243. /**
  29244. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29245. */
  29246. disableVertexArrayObjects: boolean;
  29247. /** @hidden */
  29248. protected _depthCullingState: _DepthCullingState;
  29249. /** @hidden */
  29250. protected _stencilState: _StencilState;
  29251. /** @hidden */
  29252. protected _alphaState: _AlphaState;
  29253. /** @hidden */
  29254. protected _alphaMode: number;
  29255. /** @hidden */
  29256. protected _alphaEquation: number;
  29257. /** @hidden */
  29258. _internalTexturesCache: InternalTexture[];
  29259. /** @hidden */
  29260. protected _activeChannel: number;
  29261. private _currentTextureChannel;
  29262. /** @hidden */
  29263. protected _boundTexturesCache: {
  29264. [key: string]: Nullable<InternalTexture>;
  29265. };
  29266. /** @hidden */
  29267. protected _currentEffect: Nullable<Effect>;
  29268. /** @hidden */
  29269. protected _currentProgram: Nullable<WebGLProgram>;
  29270. private _compiledEffects;
  29271. private _vertexAttribArraysEnabled;
  29272. /** @hidden */
  29273. protected _cachedViewport: Nullable<IViewportLike>;
  29274. private _cachedVertexArrayObject;
  29275. /** @hidden */
  29276. protected _cachedVertexBuffers: any;
  29277. /** @hidden */
  29278. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29279. /** @hidden */
  29280. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29281. /** @hidden */
  29282. _currentRenderTarget: Nullable<InternalTexture>;
  29283. private _uintIndicesCurrentlySet;
  29284. private _currentBoundBuffer;
  29285. /** @hidden */
  29286. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29287. private _currentBufferPointers;
  29288. private _currentInstanceLocations;
  29289. private _currentInstanceBuffers;
  29290. private _textureUnits;
  29291. /** @hidden */
  29292. _workingCanvas: Nullable<HTMLCanvasElement>;
  29293. /** @hidden */
  29294. _workingContext: Nullable<CanvasRenderingContext2D>;
  29295. /** @hidden */
  29296. _bindedRenderFunction: any;
  29297. private _vaoRecordInProgress;
  29298. private _mustWipeVertexAttributes;
  29299. private _emptyTexture;
  29300. private _emptyCubeTexture;
  29301. private _emptyTexture3D;
  29302. /** @hidden */
  29303. _frameHandler: number;
  29304. private _nextFreeTextureSlots;
  29305. private _maxSimultaneousTextures;
  29306. private _activeRequests;
  29307. private _texturesSupported;
  29308. /** @hidden */
  29309. _textureFormatInUse: Nullable<string>;
  29310. protected readonly _supportsHardwareTextureRescaling: boolean;
  29311. /**
  29312. * Gets the list of texture formats supported
  29313. */
  29314. readonly texturesSupported: Array<string>;
  29315. /**
  29316. * Gets the list of texture formats in use
  29317. */
  29318. readonly textureFormatInUse: Nullable<string>;
  29319. /**
  29320. * Gets the current viewport
  29321. */
  29322. readonly currentViewport: Nullable<IViewportLike>;
  29323. /**
  29324. * Gets the default empty texture
  29325. */
  29326. readonly emptyTexture: InternalTexture;
  29327. /**
  29328. * Gets the default empty 3D texture
  29329. */
  29330. readonly emptyTexture3D: InternalTexture;
  29331. /**
  29332. * Gets the default empty cube texture
  29333. */
  29334. readonly emptyCubeTexture: InternalTexture;
  29335. /**
  29336. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29337. */
  29338. readonly premultipliedAlpha: boolean;
  29339. /**
  29340. * Creates a new engine
  29341. * @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
  29342. * @param antialias defines enable antialiasing (default: false)
  29343. * @param options defines further options to be sent to the getContext() function
  29344. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29345. */
  29346. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29347. private _disableTouchAction;
  29348. private _rebuildInternalTextures;
  29349. private _rebuildEffects;
  29350. /**
  29351. * Gets a boolean indicating if all created effects are ready
  29352. * @returns true if all effects are ready
  29353. */
  29354. areAllEffectsReady(): boolean;
  29355. protected _rebuildBuffers(): void;
  29356. private _initGLContext;
  29357. /**
  29358. * Gets version of the current webGL context
  29359. */
  29360. readonly webGLVersion: number;
  29361. /**
  29362. * Gets a string idenfifying the name of the class
  29363. * @returns "Engine" string
  29364. */
  29365. getClassName(): string;
  29366. /**
  29367. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29368. */
  29369. readonly isStencilEnable: boolean;
  29370. /** @hidden */
  29371. _prepareWorkingCanvas(): void;
  29372. /**
  29373. * Reset the texture cache to empty state
  29374. */
  29375. resetTextureCache(): void;
  29376. /**
  29377. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29378. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29379. * @returns true if engine is in deterministic lock step mode
  29380. */
  29381. isDeterministicLockStep(): boolean;
  29382. /**
  29383. * Gets the max steps when engine is running in deterministic lock step
  29384. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29385. * @returns the max steps
  29386. */
  29387. getLockstepMaxSteps(): number;
  29388. /**
  29389. * Gets an object containing information about the current webGL context
  29390. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29391. */
  29392. getGlInfo(): {
  29393. vendor: string;
  29394. renderer: string;
  29395. version: string;
  29396. };
  29397. /**
  29398. * Gets current aspect ratio
  29399. * @param viewportOwner defines the camera to use to get the aspect ratio
  29400. * @param useScreen defines if screen size must be used (or the current render target if any)
  29401. * @returns a number defining the aspect ratio
  29402. */
  29403. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  29404. /**
  29405. * Gets current screen aspect ratio
  29406. * @returns a number defining the aspect ratio
  29407. */
  29408. getScreenAspectRatio(): number;
  29409. /**
  29410. * Gets the current render width
  29411. * @param useScreen defines if screen size must be used (or the current render target if any)
  29412. * @returns a number defining the current render width
  29413. */
  29414. getRenderWidth(useScreen?: boolean): number;
  29415. /**
  29416. * Gets the current render height
  29417. * @param useScreen defines if screen size must be used (or the current render target if any)
  29418. * @returns a number defining the current render height
  29419. */
  29420. getRenderHeight(useScreen?: boolean): number;
  29421. /**
  29422. * Gets the HTML canvas attached with the current webGL context
  29423. * @returns a HTML canvas
  29424. */
  29425. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29426. /**
  29427. * Gets host window
  29428. * @returns the host window object
  29429. */
  29430. getHostWindow(): Window;
  29431. /**
  29432. * Gets host document
  29433. * @returns the host document object
  29434. */
  29435. getHostDocument(): Document;
  29436. /**
  29437. * Gets the client rect of the HTML canvas attached with the current webGL context
  29438. * @returns a client rectanglee
  29439. */
  29440. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  29441. /**
  29442. * Defines the hardware scaling level.
  29443. * By default the hardware scaling level is computed from the window device ratio.
  29444. * 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.
  29445. * @param level defines the level to use
  29446. */
  29447. setHardwareScalingLevel(level: number): void;
  29448. /**
  29449. * Gets the current hardware scaling level.
  29450. * By default the hardware scaling level is computed from the window device ratio.
  29451. * 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.
  29452. * @returns a number indicating the current hardware scaling level
  29453. */
  29454. getHardwareScalingLevel(): number;
  29455. /**
  29456. * Gets the list of loaded textures
  29457. * @returns an array containing all loaded textures
  29458. */
  29459. getLoadedTexturesCache(): InternalTexture[];
  29460. /**
  29461. * Gets the object containing all engine capabilities
  29462. * @returns the EngineCapabilities object
  29463. */
  29464. getCaps(): EngineCapabilities;
  29465. /**
  29466. * Gets the current depth function
  29467. * @returns a number defining the depth function
  29468. */
  29469. getDepthFunction(): Nullable<number>;
  29470. /**
  29471. * Sets the current depth function
  29472. * @param depthFunc defines the function to use
  29473. */
  29474. setDepthFunction(depthFunc: number): void;
  29475. /**
  29476. * Sets the current depth function to GREATER
  29477. */
  29478. setDepthFunctionToGreater(): void;
  29479. /**
  29480. * Sets the current depth function to GEQUAL
  29481. */
  29482. setDepthFunctionToGreaterOrEqual(): void;
  29483. /**
  29484. * Sets the current depth function to LESS
  29485. */
  29486. setDepthFunctionToLess(): void;
  29487. private _cachedStencilBuffer;
  29488. private _cachedStencilFunction;
  29489. private _cachedStencilMask;
  29490. private _cachedStencilOperationPass;
  29491. private _cachedStencilOperationFail;
  29492. private _cachedStencilOperationDepthFail;
  29493. private _cachedStencilReference;
  29494. /**
  29495. * Caches the the state of the stencil buffer
  29496. */
  29497. cacheStencilState(): void;
  29498. /**
  29499. * Restores the state of the stencil buffer
  29500. */
  29501. restoreStencilState(): void;
  29502. /**
  29503. * Sets the current depth function to LEQUAL
  29504. */
  29505. setDepthFunctionToLessOrEqual(): void;
  29506. /**
  29507. * Gets a boolean indicating if stencil buffer is enabled
  29508. * @returns the current stencil buffer state
  29509. */
  29510. getStencilBuffer(): boolean;
  29511. /**
  29512. * Enable or disable the stencil buffer
  29513. * @param enable defines if the stencil buffer must be enabled or disabled
  29514. */
  29515. setStencilBuffer(enable: boolean): void;
  29516. /**
  29517. * Gets the current stencil mask
  29518. * @returns a number defining the new stencil mask to use
  29519. */
  29520. getStencilMask(): number;
  29521. /**
  29522. * Sets the current stencil mask
  29523. * @param mask defines the new stencil mask to use
  29524. */
  29525. setStencilMask(mask: number): void;
  29526. /**
  29527. * Gets the current stencil function
  29528. * @returns a number defining the stencil function to use
  29529. */
  29530. getStencilFunction(): number;
  29531. /**
  29532. * Gets the current stencil reference value
  29533. * @returns a number defining the stencil reference value to use
  29534. */
  29535. getStencilFunctionReference(): number;
  29536. /**
  29537. * Gets the current stencil mask
  29538. * @returns a number defining the stencil mask to use
  29539. */
  29540. getStencilFunctionMask(): number;
  29541. /**
  29542. * Sets the current stencil function
  29543. * @param stencilFunc defines the new stencil function to use
  29544. */
  29545. setStencilFunction(stencilFunc: number): void;
  29546. /**
  29547. * Sets the current stencil reference
  29548. * @param reference defines the new stencil reference to use
  29549. */
  29550. setStencilFunctionReference(reference: number): void;
  29551. /**
  29552. * Sets the current stencil mask
  29553. * @param mask defines the new stencil mask to use
  29554. */
  29555. setStencilFunctionMask(mask: number): void;
  29556. /**
  29557. * Gets the current stencil operation when stencil fails
  29558. * @returns a number defining stencil operation to use when stencil fails
  29559. */
  29560. getStencilOperationFail(): number;
  29561. /**
  29562. * Gets the current stencil operation when depth fails
  29563. * @returns a number defining stencil operation to use when depth fails
  29564. */
  29565. getStencilOperationDepthFail(): number;
  29566. /**
  29567. * Gets the current stencil operation when stencil passes
  29568. * @returns a number defining stencil operation to use when stencil passes
  29569. */
  29570. getStencilOperationPass(): number;
  29571. /**
  29572. * Sets the stencil operation to use when stencil fails
  29573. * @param operation defines the stencil operation to use when stencil fails
  29574. */
  29575. setStencilOperationFail(operation: number): void;
  29576. /**
  29577. * Sets the stencil operation to use when depth fails
  29578. * @param operation defines the stencil operation to use when depth fails
  29579. */
  29580. setStencilOperationDepthFail(operation: number): void;
  29581. /**
  29582. * Sets the stencil operation to use when stencil passes
  29583. * @param operation defines the stencil operation to use when stencil passes
  29584. */
  29585. setStencilOperationPass(operation: number): void;
  29586. /**
  29587. * Sets a boolean indicating if the dithering state is enabled or disabled
  29588. * @param value defines the dithering state
  29589. */
  29590. setDitheringState(value: boolean): void;
  29591. /**
  29592. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29593. * @param value defines the rasterizer state
  29594. */
  29595. setRasterizerState(value: boolean): void;
  29596. /**
  29597. * stop executing a render loop function and remove it from the execution array
  29598. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29599. */
  29600. stopRenderLoop(renderFunction?: () => void): void;
  29601. /** @hidden */
  29602. _renderLoop(): void;
  29603. /**
  29604. * Can be used to override the current requestAnimationFrame requester.
  29605. * @hidden
  29606. */
  29607. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29608. /**
  29609. * Register and execute a render loop. The engine can have more than one render function
  29610. * @param renderFunction defines the function to continuously execute
  29611. */
  29612. runRenderLoop(renderFunction: () => void): void;
  29613. /**
  29614. * Clear the current render buffer or the current render target (if any is set up)
  29615. * @param color defines the color to use
  29616. * @param backBuffer defines if the back buffer must be cleared
  29617. * @param depth defines if the depth buffer must be cleared
  29618. * @param stencil defines if the stencil buffer must be cleared
  29619. */
  29620. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29621. /**
  29622. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29623. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29624. * @param y defines the y-coordinate of the corner of the clear rectangle
  29625. * @param width defines the width of the clear rectangle
  29626. * @param height defines the height of the clear rectangle
  29627. * @param clearColor defines the clear color
  29628. */
  29629. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  29630. /**
  29631. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29632. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29633. * @param y defines the y-coordinate of the corner of the clear rectangle
  29634. * @param width defines the width of the clear rectangle
  29635. * @param height defines the height of the clear rectangle
  29636. */
  29637. enableScissor(x: number, y: number, width: number, height: number): void;
  29638. /**
  29639. * Disable previously set scissor test rectangle
  29640. */
  29641. disableScissor(): void;
  29642. private _viewportCached;
  29643. /** @hidden */
  29644. _viewport(x: number, y: number, width: number, height: number): void;
  29645. /**
  29646. * Set the WebGL's viewport
  29647. * @param viewport defines the viewport element to be used
  29648. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29649. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29650. */
  29651. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29652. /**
  29653. * Directly set the WebGL Viewport
  29654. * @param x defines the x coordinate of the viewport (in screen space)
  29655. * @param y defines the y coordinate of the viewport (in screen space)
  29656. * @param width defines the width of the viewport (in screen space)
  29657. * @param height defines the height of the viewport (in screen space)
  29658. * @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
  29659. */
  29660. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  29661. /**
  29662. * Begin a new frame
  29663. */
  29664. beginFrame(): void;
  29665. /**
  29666. * Enf the current frame
  29667. */
  29668. endFrame(): void;
  29669. /**
  29670. * Resize the view according to the canvas' size
  29671. */
  29672. resize(): void;
  29673. /**
  29674. * Force a specific size of the canvas
  29675. * @param width defines the new canvas' width
  29676. * @param height defines the new canvas' height
  29677. */
  29678. setSize(width: number, height: number): void;
  29679. /**
  29680. * Binds the frame buffer to the specified texture.
  29681. * @param texture The texture to render to or null for the default canvas
  29682. * @param faceIndex The face of the texture to render to in case of cube texture
  29683. * @param requiredWidth The width of the target to render to
  29684. * @param requiredHeight The height of the target to render to
  29685. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29686. * @param depthStencilTexture The depth stencil texture to use to render
  29687. * @param lodLevel defines le lod level to bind to the frame buffer
  29688. */
  29689. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29690. /** @hidden */
  29691. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29692. /**
  29693. * Unbind the current render target texture from the webGL context
  29694. * @param texture defines the render target texture to unbind
  29695. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29696. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29697. */
  29698. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29699. /**
  29700. * Force the mipmap generation for the given render target texture
  29701. * @param texture defines the render target texture to use
  29702. */
  29703. generateMipMapsForCubemap(texture: InternalTexture): void;
  29704. /**
  29705. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29706. */
  29707. flushFramebuffer(): void;
  29708. /**
  29709. * Unbind the current render target and bind the default framebuffer
  29710. */
  29711. restoreDefaultFramebuffer(): void;
  29712. /**
  29713. * Create an uniform buffer
  29714. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29715. * @param elements defines the content of the uniform buffer
  29716. * @returns the webGL uniform buffer
  29717. */
  29718. createUniformBuffer(elements: FloatArray): DataBuffer;
  29719. /**
  29720. * Create a dynamic uniform buffer
  29721. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29722. * @param elements defines the content of the uniform buffer
  29723. * @returns the webGL uniform buffer
  29724. */
  29725. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29726. /**
  29727. * Update an existing uniform buffer
  29728. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29729. * @param uniformBuffer defines the target uniform buffer
  29730. * @param elements defines the content to update
  29731. * @param offset defines the offset in the uniform buffer where update should start
  29732. * @param count defines the size of the data to update
  29733. */
  29734. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29735. private _resetVertexBufferBinding;
  29736. /**
  29737. * Creates a vertex buffer
  29738. * @param data the data for the vertex buffer
  29739. * @returns the new WebGL static buffer
  29740. */
  29741. createVertexBuffer(data: DataArray): DataBuffer;
  29742. private _createVertexBuffer;
  29743. /**
  29744. * Creates a dynamic vertex buffer
  29745. * @param data the data for the dynamic vertex buffer
  29746. * @returns the new WebGL dynamic buffer
  29747. */
  29748. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29749. /**
  29750. * Update a dynamic index buffer
  29751. * @param indexBuffer defines the target index buffer
  29752. * @param indices defines the data to update
  29753. * @param offset defines the offset in the target index buffer where update should start
  29754. */
  29755. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29756. /**
  29757. * Updates a dynamic vertex buffer.
  29758. * @param vertexBuffer the vertex buffer to update
  29759. * @param data the data used to update the vertex buffer
  29760. * @param byteOffset the byte offset of the data
  29761. * @param byteLength the byte length of the data
  29762. */
  29763. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29764. private _resetIndexBufferBinding;
  29765. /**
  29766. * Creates a new index buffer
  29767. * @param indices defines the content of the index buffer
  29768. * @param updatable defines if the index buffer must be updatable
  29769. * @returns a new webGL buffer
  29770. */
  29771. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29772. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29773. /**
  29774. * Bind a webGL buffer to the webGL context
  29775. * @param buffer defines the buffer to bind
  29776. */
  29777. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29778. /**
  29779. * Bind an uniform buffer to the current webGL context
  29780. * @param buffer defines the buffer to bind
  29781. */
  29782. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29783. /**
  29784. * Bind a buffer to the current webGL context at a given location
  29785. * @param buffer defines the buffer to bind
  29786. * @param location defines the index where to bind the buffer
  29787. */
  29788. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29789. /**
  29790. * Bind a specific block at a given index in a specific shader program
  29791. * @param pipelineContext defines the pipeline context to use
  29792. * @param blockName defines the block name
  29793. * @param index defines the index where to bind the block
  29794. */
  29795. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29796. private bindIndexBuffer;
  29797. private bindBuffer;
  29798. /**
  29799. * update the bound buffer with the given data
  29800. * @param data defines the data to update
  29801. */
  29802. updateArrayBuffer(data: Float32Array): void;
  29803. private _vertexAttribPointer;
  29804. private _bindIndexBufferWithCache;
  29805. private _bindVertexBuffersAttributes;
  29806. /**
  29807. * Records a vertex array object
  29808. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29809. * @param vertexBuffers defines the list of vertex buffers to store
  29810. * @param indexBuffer defines the index buffer to store
  29811. * @param effect defines the effect to store
  29812. * @returns the new vertex array object
  29813. */
  29814. recordVertexArrayObject(vertexBuffers: {
  29815. [key: string]: VertexBuffer;
  29816. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29817. /**
  29818. * Bind a specific vertex array object
  29819. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29820. * @param vertexArrayObject defines the vertex array object to bind
  29821. * @param indexBuffer defines the index buffer to bind
  29822. */
  29823. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29824. /**
  29825. * Bind webGl buffers directly to the webGL context
  29826. * @param vertexBuffer defines the vertex buffer to bind
  29827. * @param indexBuffer defines the index buffer to bind
  29828. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29829. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29830. * @param effect defines the effect associated with the vertex buffer
  29831. */
  29832. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29833. private _unbindVertexArrayObject;
  29834. /**
  29835. * Bind a list of vertex buffers to the webGL context
  29836. * @param vertexBuffers defines the list of vertex buffers to bind
  29837. * @param indexBuffer defines the index buffer to bind
  29838. * @param effect defines the effect associated with the vertex buffers
  29839. */
  29840. bindBuffers(vertexBuffers: {
  29841. [key: string]: Nullable<VertexBuffer>;
  29842. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29843. /**
  29844. * Unbind all instance attributes
  29845. */
  29846. unbindInstanceAttributes(): void;
  29847. /**
  29848. * Release and free the memory of a vertex array object
  29849. * @param vao defines the vertex array object to delete
  29850. */
  29851. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29852. /** @hidden */
  29853. _releaseBuffer(buffer: DataBuffer): boolean;
  29854. protected _deleteBuffer(buffer: DataBuffer): void;
  29855. /**
  29856. * Creates a webGL buffer to use with instanciation
  29857. * @param capacity defines the size of the buffer
  29858. * @returns the webGL buffer
  29859. */
  29860. createInstancesBuffer(capacity: number): DataBuffer;
  29861. /**
  29862. * Delete a webGL buffer used with instanciation
  29863. * @param buffer defines the webGL buffer to delete
  29864. */
  29865. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29866. /**
  29867. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29868. * @param instancesBuffer defines the webGL buffer to update and bind
  29869. * @param data defines the data to store in the buffer
  29870. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29871. */
  29872. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29873. /**
  29874. * Apply all cached states (depth, culling, stencil and alpha)
  29875. */
  29876. applyStates(): void;
  29877. /**
  29878. * Send a draw order
  29879. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29880. * @param indexStart defines the starting index
  29881. * @param indexCount defines the number of index to draw
  29882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29883. */
  29884. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29885. /**
  29886. * Draw a list of points
  29887. * @param verticesStart defines the index of first vertex to draw
  29888. * @param verticesCount defines the count of vertices to draw
  29889. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29890. */
  29891. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29892. /**
  29893. * Draw a list of unindexed primitives
  29894. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29895. * @param verticesStart defines the index of first vertex to draw
  29896. * @param verticesCount defines the count of vertices to draw
  29897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29898. */
  29899. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29900. /**
  29901. * Draw a list of indexed primitives
  29902. * @param fillMode defines the primitive to use
  29903. * @param indexStart defines the starting index
  29904. * @param indexCount defines the number of index to draw
  29905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29906. */
  29907. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29908. /**
  29909. * Draw a list of unindexed primitives
  29910. * @param fillMode defines the primitive to use
  29911. * @param verticesStart defines the index of first vertex to draw
  29912. * @param verticesCount defines the count of vertices to draw
  29913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29914. */
  29915. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29916. private _drawMode;
  29917. /** @hidden */
  29918. _releaseEffect(effect: Effect): void;
  29919. /** @hidden */
  29920. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29921. /**
  29922. * Create a new effect (used to store vertex/fragment shaders)
  29923. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29924. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29925. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29926. * @param samplers defines an array of string used to represent textures
  29927. * @param defines defines the string containing the defines to use to compile the shaders
  29928. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29929. * @param onCompiled defines a function to call when the effect creation is successful
  29930. * @param onError defines a function to call when the effect creation has failed
  29931. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29932. * @returns the new Effect
  29933. */
  29934. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | BaseEngine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29935. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29936. private _compileShader;
  29937. private _compileRawShader;
  29938. /**
  29939. * Directly creates a webGL program
  29940. * @param pipelineContext defines the pipeline context to attach to
  29941. * @param vertexCode defines the vertex shader code to use
  29942. * @param fragmentCode defines the fragment shader code to use
  29943. * @param context defines the webGL context to use (if not set, the current one will be used)
  29944. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29945. * @returns the new webGL program
  29946. */
  29947. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29948. /**
  29949. * Creates a webGL program
  29950. * @param pipelineContext defines the pipeline context to attach to
  29951. * @param vertexCode defines the vertex shader code to use
  29952. * @param fragmentCode defines the fragment shader code to use
  29953. * @param defines defines the string containing the defines to use to compile the shaders
  29954. * @param context defines the webGL context to use (if not set, the current one will be used)
  29955. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29956. * @returns the new webGL program
  29957. */
  29958. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29959. /**
  29960. * Creates a new pipeline context
  29961. * @returns the new pipeline
  29962. */
  29963. createPipelineContext(): IPipelineContext;
  29964. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29965. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29966. /** @hidden */
  29967. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29968. /** @hidden */
  29969. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29970. /** @hidden */
  29971. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29972. /**
  29973. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29974. * @param pipelineContext defines the pipeline context to use
  29975. * @param uniformsNames defines the list of uniform names
  29976. * @returns an array of webGL uniform locations
  29977. */
  29978. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29979. /**
  29980. * Gets the lsit of active attributes for a given webGL program
  29981. * @param pipelineContext defines the pipeline context to use
  29982. * @param attributesNames defines the list of attribute names to get
  29983. * @returns an array of indices indicating the offset of each attribute
  29984. */
  29985. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29986. /**
  29987. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29988. * @param effect defines the effect to activate
  29989. */
  29990. enableEffect(effect: Nullable<Effect>): void;
  29991. /**
  29992. * Set the value of an uniform to an array of int32
  29993. * @param uniform defines the webGL uniform location where to store the value
  29994. * @param array defines the array of int32 to store
  29995. */
  29996. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29997. /**
  29998. * Set the value of an uniform to an array of int32 (stored as vec2)
  29999. * @param uniform defines the webGL uniform location where to store the value
  30000. * @param array defines the array of int32 to store
  30001. */
  30002. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30003. /**
  30004. * Set the value of an uniform to an array of int32 (stored as vec3)
  30005. * @param uniform defines the webGL uniform location where to store the value
  30006. * @param array defines the array of int32 to store
  30007. */
  30008. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30009. /**
  30010. * Set the value of an uniform to an array of int32 (stored as vec4)
  30011. * @param uniform defines the webGL uniform location where to store the value
  30012. * @param array defines the array of int32 to store
  30013. */
  30014. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30015. /**
  30016. * Set the value of an uniform to an array of float32
  30017. * @param uniform defines the webGL uniform location where to store the value
  30018. * @param array defines the array of float32 to store
  30019. */
  30020. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30021. /**
  30022. * Set the value of an uniform to an array of float32 (stored as vec2)
  30023. * @param uniform defines the webGL uniform location where to store the value
  30024. * @param array defines the array of float32 to store
  30025. */
  30026. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30027. /**
  30028. * Set the value of an uniform to an array of float32 (stored as vec3)
  30029. * @param uniform defines the webGL uniform location where to store the value
  30030. * @param array defines the array of float32 to store
  30031. */
  30032. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30033. /**
  30034. * Set the value of an uniform to an array of float32 (stored as vec4)
  30035. * @param uniform defines the webGL uniform location where to store the value
  30036. * @param array defines the array of float32 to store
  30037. */
  30038. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30039. /**
  30040. * Set the value of an uniform to an array of number
  30041. * @param uniform defines the webGL uniform location where to store the value
  30042. * @param array defines the array of number to store
  30043. */
  30044. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30045. /**
  30046. * Set the value of an uniform to an array of number (stored as vec2)
  30047. * @param uniform defines the webGL uniform location where to store the value
  30048. * @param array defines the array of number to store
  30049. */
  30050. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30051. /**
  30052. * Set the value of an uniform to an array of number (stored as vec3)
  30053. * @param uniform defines the webGL uniform location where to store the value
  30054. * @param array defines the array of number to store
  30055. */
  30056. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30057. /**
  30058. * Set the value of an uniform to an array of number (stored as vec4)
  30059. * @param uniform defines the webGL uniform location where to store the value
  30060. * @param array defines the array of number to store
  30061. */
  30062. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30063. /**
  30064. * Set the value of an uniform to an array of float32 (stored as matrices)
  30065. * @param uniform defines the webGL uniform location where to store the value
  30066. * @param matrices defines the array of float32 to store
  30067. */
  30068. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30069. /**
  30070. * Set the value of an uniform to a matrix (3x3)
  30071. * @param uniform defines the webGL uniform location where to store the value
  30072. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30073. */
  30074. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30075. /**
  30076. * Set the value of an uniform to a matrix (2x2)
  30077. * @param uniform defines the webGL uniform location where to store the value
  30078. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30079. */
  30080. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30081. /**
  30082. * Set the value of an uniform to a number (int)
  30083. * @param uniform defines the webGL uniform location where to store the value
  30084. * @param value defines the int number to store
  30085. */
  30086. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30087. /**
  30088. * Set the value of an uniform to a number (float)
  30089. * @param uniform defines the webGL uniform location where to store the value
  30090. * @param value defines the float number to store
  30091. */
  30092. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30093. /**
  30094. * Set the value of an uniform to a vec2
  30095. * @param uniform defines the webGL uniform location where to store the value
  30096. * @param x defines the 1st component of the value
  30097. * @param y defines the 2nd component of the value
  30098. */
  30099. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30100. /**
  30101. * Set the value of an uniform to a vec3
  30102. * @param uniform defines the webGL uniform location where to store the value
  30103. * @param x defines the 1st component of the value
  30104. * @param y defines the 2nd component of the value
  30105. * @param z defines the 3rd component of the value
  30106. */
  30107. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30108. /**
  30109. * Set the value of an uniform to a boolean
  30110. * @param uniform defines the webGL uniform location where to store the value
  30111. * @param bool defines the boolean to store
  30112. */
  30113. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30114. /**
  30115. * Set the value of an uniform to a vec4
  30116. * @param uniform defines the webGL uniform location where to store the value
  30117. * @param x defines the 1st component of the value
  30118. * @param y defines the 2nd component of the value
  30119. * @param z defines the 3rd component of the value
  30120. * @param w defines the 4th component of the value
  30121. */
  30122. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30123. /**
  30124. * Sets a Color4 on a uniform variable
  30125. * @param uniform defines the uniform location
  30126. * @param color4 defines the value to be set
  30127. */
  30128. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30129. /**
  30130. * Set various states to the webGL context
  30131. * @param culling defines backface culling state
  30132. * @param zOffset defines the value to apply to zOffset (0 by default)
  30133. * @param force defines if states must be applied even if cache is up to date
  30134. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30135. */
  30136. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30137. /**
  30138. * Set the z offset to apply to current rendering
  30139. * @param value defines the offset to apply
  30140. */
  30141. setZOffset(value: number): void;
  30142. /**
  30143. * Gets the current value of the zOffset
  30144. * @returns the current zOffset state
  30145. */
  30146. getZOffset(): number;
  30147. /**
  30148. * Enable or disable depth buffering
  30149. * @param enable defines the state to set
  30150. */
  30151. setDepthBuffer(enable: boolean): void;
  30152. /**
  30153. * Gets a boolean indicating if depth writing is enabled
  30154. * @returns the current depth writing state
  30155. */
  30156. getDepthWrite(): boolean;
  30157. /**
  30158. * Enable or disable depth writing
  30159. * @param enable defines the state to set
  30160. */
  30161. setDepthWrite(enable: boolean): void;
  30162. /**
  30163. * Enable or disable color writing
  30164. * @param enable defines the state to set
  30165. */
  30166. setColorWrite(enable: boolean): void;
  30167. /**
  30168. * Gets a boolean indicating if color writing is enabled
  30169. * @returns the current color writing state
  30170. */
  30171. getColorWrite(): boolean;
  30172. /**
  30173. * Sets alpha constants used by some alpha blending modes
  30174. * @param r defines the red component
  30175. * @param g defines the green component
  30176. * @param b defines the blue component
  30177. * @param a defines the alpha component
  30178. */
  30179. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30180. /**
  30181. * Sets the current alpha mode
  30182. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30183. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30184. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30185. */
  30186. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30187. /**
  30188. * Gets the current alpha mode
  30189. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30190. * @returns the current alpha mode
  30191. */
  30192. getAlphaMode(): number;
  30193. /**
  30194. * Sets the current alpha equation
  30195. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  30196. */
  30197. setAlphaEquation(equation: number): void;
  30198. /**
  30199. * Gets the current alpha equation.
  30200. * @returns the current alpha equation
  30201. */
  30202. getAlphaEquation(): number;
  30203. /**
  30204. * Clears the list of texture accessible through engine.
  30205. * This can help preventing texture load conflict due to name collision.
  30206. */
  30207. clearInternalTexturesCache(): void;
  30208. /**
  30209. * Force the entire cache to be cleared
  30210. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30211. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30212. */
  30213. wipeCaches(bruteForce?: boolean): void;
  30214. /**
  30215. * Set the compressed texture format to use, based on the formats you have, and the formats
  30216. * supported by the hardware / browser.
  30217. *
  30218. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30219. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30220. * to API arguments needed to compressed textures. This puts the burden on the container
  30221. * generator to house the arcane code for determining these for current & future formats.
  30222. *
  30223. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30224. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30225. *
  30226. * Note: The result of this call is not taken into account when a texture is base64.
  30227. *
  30228. * @param formatsAvailable defines the list of those format families you have created
  30229. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30230. *
  30231. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30232. * @returns The extension selected.
  30233. */
  30234. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  30235. /** @hidden */
  30236. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30237. min: number;
  30238. mag: number;
  30239. };
  30240. /** @hidden */
  30241. _createTexture(): WebGLTexture;
  30242. /**
  30243. * Usually called from Texture.ts.
  30244. * Passed information to create a WebGLTexture
  30245. * @param urlArg defines a value which contains one of the following:
  30246. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30247. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30248. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30249. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30250. * @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)
  30251. * @param scene needed for loading to the correct scene
  30252. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30253. * @param onLoad optional callback to be called upon successful completion
  30254. * @param onError optional callback to be called upon failure
  30255. * @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
  30256. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30257. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30258. * @param forcedExtension defines the extension to use to pick the right loader
  30259. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30260. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30261. */
  30262. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30263. /**
  30264. * @hidden
  30265. */
  30266. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30267. private _unpackFlipYCached;
  30268. /**
  30269. * In case you are sharing the context with other applications, it might
  30270. * be interested to not cache the unpack flip y state to ensure a consistent
  30271. * value would be set.
  30272. */
  30273. enableUnpackFlipYCached: boolean;
  30274. /** @hidden */
  30275. _unpackFlipY(value: boolean): void;
  30276. /** @hidden */
  30277. _getUnpackAlignement(): number;
  30278. /**
  30279. * Creates a dynamic texture
  30280. * @param width defines the width of the texture
  30281. * @param height defines the height of the texture
  30282. * @param generateMipMaps defines if the engine should generate the mip levels
  30283. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30284. * @returns the dynamic texture inside an InternalTexture
  30285. */
  30286. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  30287. /**
  30288. * Update the sampling mode of a given texture
  30289. * @param samplingMode defines the required sampling mode
  30290. * @param texture defines the texture to update
  30291. */
  30292. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30293. /**
  30294. * Update the content of a dynamic texture
  30295. * @param texture defines the texture to update
  30296. * @param canvas defines the canvas containing the source
  30297. * @param invertY defines if data must be stored with Y axis inverted
  30298. * @param premulAlpha defines if alpha is stored as premultiplied
  30299. * @param format defines the format of the data
  30300. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30301. */
  30302. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  30303. /**
  30304. * Update a video texture
  30305. * @param texture defines the texture to update
  30306. * @param video defines the video element to use
  30307. * @param invertY defines if data must be stored with Y axis inverted
  30308. */
  30309. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30310. /**
  30311. * Updates a depth texture Comparison Mode and Function.
  30312. * If the comparison Function is equal to 0, the mode will be set to none.
  30313. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30314. * @param texture The texture to set the comparison function for
  30315. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30316. */
  30317. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30318. /** @hidden */
  30319. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30320. width: number;
  30321. height: number;
  30322. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30323. /**
  30324. * Creates a depth stencil texture.
  30325. * This is only available in WebGL 2 or with the depth texture extension available.
  30326. * @param size The size of face edge in the texture.
  30327. * @param options The options defining the texture.
  30328. * @returns The texture
  30329. */
  30330. createDepthStencilTexture(size: number | {
  30331. width: number;
  30332. height: number;
  30333. }, options: DepthTextureCreationOptions): InternalTexture;
  30334. /**
  30335. * Creates a depth stencil texture.
  30336. * This is only available in WebGL 2 or with the depth texture extension available.
  30337. * @param size The size of face edge in the texture.
  30338. * @param options The options defining the texture.
  30339. * @returns The texture
  30340. */
  30341. private _createDepthStencilTexture;
  30342. /**
  30343. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30344. * @param renderTarget The render target to set the frame buffer for
  30345. */
  30346. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30347. /**
  30348. * Creates a new render target texture
  30349. * @param size defines the size of the texture
  30350. * @param options defines the options used to create the texture
  30351. * @returns a new render target texture stored in an InternalTexture
  30352. */
  30353. createRenderTargetTexture(size: number | {
  30354. width: number;
  30355. height: number;
  30356. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  30357. /** @hidden */
  30358. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30359. /**
  30360. * Updates the sample count of a render target texture
  30361. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30362. * @param texture defines the texture to update
  30363. * @param samples defines the sample count to set
  30364. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30365. */
  30366. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  30367. /** @hidden */
  30368. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30369. /** @hidden */
  30370. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30371. /** @hidden */
  30372. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30373. /** @hidden */
  30374. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30375. /**
  30376. * @hidden
  30377. */
  30378. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30379. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30380. private _prepareWebGLTexture;
  30381. /** @hidden */
  30382. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  30383. /** @hidden */
  30384. _releaseFramebufferObjects(texture: InternalTexture): void;
  30385. /** @hidden */
  30386. _releaseTexture(texture: InternalTexture): void;
  30387. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30388. protected _setProgram(program: WebGLProgram): void;
  30389. protected _boundUniforms: {
  30390. [key: number]: WebGLUniformLocation;
  30391. };
  30392. /**
  30393. * Binds an effect to the webGL context
  30394. * @param effect defines the effect to bind
  30395. */
  30396. bindSamplers(effect: Effect): void;
  30397. private _activateCurrentTexture;
  30398. /** @hidden */
  30399. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30400. /** @hidden */
  30401. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30402. /**
  30403. * Sets a texture to the webGL context from a postprocess
  30404. * @param channel defines the channel to use
  30405. * @param postProcess defines the source postprocess
  30406. */
  30407. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  30408. /**
  30409. * Binds the output of the passed in post process to the texture channel specified
  30410. * @param channel The channel the texture should be bound to
  30411. * @param postProcess The post process which's output should be bound
  30412. */
  30413. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  30414. /**
  30415. * Unbind all textures from the webGL context
  30416. */
  30417. unbindAllTextures(): void;
  30418. /**
  30419. * Sets a texture to the according uniform.
  30420. * @param channel The texture channel
  30421. * @param uniform The uniform to set
  30422. * @param texture The texture to apply
  30423. */
  30424. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30425. /**
  30426. * Sets a depth stencil texture from a render target to the according uniform.
  30427. * @param channel The texture channel
  30428. * @param uniform The uniform to set
  30429. * @param texture The render target texture containing the depth stencil texture to apply
  30430. */
  30431. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  30432. private _bindSamplerUniformToChannel;
  30433. private _getTextureWrapMode;
  30434. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30435. /**
  30436. * Sets an array of texture to the webGL context
  30437. * @param channel defines the channel where the texture array must be set
  30438. * @param uniform defines the associated uniform location
  30439. * @param textures defines the array of textures to bind
  30440. */
  30441. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30442. /** @hidden */
  30443. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30444. private _setTextureParameterFloat;
  30445. private _setTextureParameterInteger;
  30446. /**
  30447. * Reads pixels from the current frame buffer. Please note that this function can be slow
  30448. * @param x defines the x coordinate of the rectangle where pixels must be read
  30449. * @param y defines the y coordinate of the rectangle where pixels must be read
  30450. * @param width defines the width of the rectangle where pixels must be read
  30451. * @param height defines the height of the rectangle where pixels must be read
  30452. * @returns a Uint8Array containing RGBA colors
  30453. */
  30454. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  30455. /**
  30456. * Unbind all vertex attributes from the webGL context
  30457. */
  30458. unbindAllAttributes(): void;
  30459. /**
  30460. * 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
  30461. */
  30462. releaseEffects(): void;
  30463. /**
  30464. * Dispose and release all associated resources
  30465. */
  30466. dispose(): void;
  30467. /**
  30468. * Attach a new callback raised when context lost event is fired
  30469. * @param callback defines the callback to call
  30470. */
  30471. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30472. /**
  30473. * Attach a new callback raised when context restored event is fired
  30474. * @param callback defines the callback to call
  30475. */
  30476. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30477. /**
  30478. * Gets the source code of the vertex shader associated with a specific webGL program
  30479. * @param program defines the program to use
  30480. * @returns a string containing the source code of the vertex shader associated with the program
  30481. */
  30482. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30483. /**
  30484. * Gets the source code of the fragment shader associated with a specific webGL program
  30485. * @param program defines the program to use
  30486. * @returns a string containing the source code of the fragment shader associated with the program
  30487. */
  30488. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30489. /**
  30490. * Get the current error code of the webGL context
  30491. * @returns the error code
  30492. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30493. */
  30494. getError(): number;
  30495. private _canRenderToFloatFramebuffer;
  30496. private _canRenderToHalfFloatFramebuffer;
  30497. private _canRenderToFramebuffer;
  30498. /** @hidden */
  30499. _getWebGLTextureType(type: number): number;
  30500. /** @hidden */
  30501. _getInternalFormat(format: number): number;
  30502. /** @hidden */
  30503. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30504. /** @hidden */
  30505. _getRGBAMultiSampleBufferFormat(type: number): number;
  30506. /** @hidden */
  30507. _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;
  30508. /** @hidden */
  30509. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30510. /**
  30511. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30512. * @returns true if the engine can be created
  30513. * @ignorenaming
  30514. */
  30515. static isSupported(): boolean;
  30516. /**
  30517. * Find the next highest power of two.
  30518. * @param x Number to start search from.
  30519. * @return Next highest power of two.
  30520. */
  30521. static CeilingPOT(x: number): number;
  30522. /**
  30523. * Find the next lowest power of two.
  30524. * @param x Number to start search from.
  30525. * @return Next lowest power of two.
  30526. */
  30527. static FloorPOT(x: number): number;
  30528. /**
  30529. * Find the nearest power of two.
  30530. * @param x Number to start search from.
  30531. * @return Next nearest power of two.
  30532. */
  30533. static NearestPOT(x: number): number;
  30534. /**
  30535. * Get the closest exponent of two
  30536. * @param value defines the value to approximate
  30537. * @param max defines the maximum value to return
  30538. * @param mode defines how to define the closest value
  30539. * @returns closest exponent of two of the given value
  30540. */
  30541. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30542. /**
  30543. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30544. * @param func - the function to be called
  30545. * @param requester - the object that will request the next frame. Falls back to window.
  30546. * @returns frame number
  30547. */
  30548. static QueueNewFrame(func: () => void, requester?: any): number;
  30549. /**
  30550. * Ask the browser to promote the current element to pointerlock mode
  30551. * @param element defines the DOM element to promote
  30552. */
  30553. static _RequestPointerlock(element: HTMLElement): void;
  30554. /**
  30555. * Asks the browser to exit pointerlock mode
  30556. */
  30557. static _ExitPointerlock(): void;
  30558. /**
  30559. * Ask the browser to promote the current element to fullscreen rendering mode
  30560. * @param element defines the DOM element to promote
  30561. */
  30562. static _RequestFullscreen(element: HTMLElement): void;
  30563. /**
  30564. * Asks the browser to exit fullscreen mode
  30565. */
  30566. static _ExitFullscreen(): void;
  30567. }
  30568. }
  30569. declare module BABYLON {
  30570. /**
  30571. * Class used to store data associated with WebGL texture data for the engine
  30572. * This class should not be used directly
  30573. */
  30574. export class InternalTexture {
  30575. /** @hidden */
  30576. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30577. /**
  30578. * The source of the texture data is unknown
  30579. */
  30580. static DATASOURCE_UNKNOWN: number;
  30581. /**
  30582. * Texture data comes from an URL
  30583. */
  30584. static DATASOURCE_URL: number;
  30585. /**
  30586. * Texture data is only used for temporary storage
  30587. */
  30588. static DATASOURCE_TEMP: number;
  30589. /**
  30590. * Texture data comes from raw data (ArrayBuffer)
  30591. */
  30592. static DATASOURCE_RAW: number;
  30593. /**
  30594. * Texture content is dynamic (video or dynamic texture)
  30595. */
  30596. static DATASOURCE_DYNAMIC: number;
  30597. /**
  30598. * Texture content is generated by rendering to it
  30599. */
  30600. static DATASOURCE_RENDERTARGET: number;
  30601. /**
  30602. * Texture content is part of a multi render target process
  30603. */
  30604. static DATASOURCE_MULTIRENDERTARGET: number;
  30605. /**
  30606. * Texture data comes from a cube data file
  30607. */
  30608. static DATASOURCE_CUBE: number;
  30609. /**
  30610. * Texture data comes from a raw cube data
  30611. */
  30612. static DATASOURCE_CUBERAW: number;
  30613. /**
  30614. * Texture data come from a prefiltered cube data file
  30615. */
  30616. static DATASOURCE_CUBEPREFILTERED: number;
  30617. /**
  30618. * Texture content is raw 3D data
  30619. */
  30620. static DATASOURCE_RAW3D: number;
  30621. /**
  30622. * Texture content is a depth texture
  30623. */
  30624. static DATASOURCE_DEPTHTEXTURE: number;
  30625. /**
  30626. * Texture data comes from a raw cube data encoded with RGBD
  30627. */
  30628. static DATASOURCE_CUBERAW_RGBD: number;
  30629. /**
  30630. * Defines if the texture is ready
  30631. */
  30632. isReady: boolean;
  30633. /**
  30634. * Defines if the texture is a cube texture
  30635. */
  30636. isCube: boolean;
  30637. /**
  30638. * Defines if the texture contains 3D data
  30639. */
  30640. is3D: boolean;
  30641. /**
  30642. * Defines if the texture contains multiview data
  30643. */
  30644. isMultiview: boolean;
  30645. /**
  30646. * Gets the URL used to load this texture
  30647. */
  30648. url: string;
  30649. /**
  30650. * Gets the sampling mode of the texture
  30651. */
  30652. samplingMode: number;
  30653. /**
  30654. * Gets a boolean indicating if the texture needs mipmaps generation
  30655. */
  30656. generateMipMaps: boolean;
  30657. /**
  30658. * Gets the number of samples used by the texture (WebGL2+ only)
  30659. */
  30660. samples: number;
  30661. /**
  30662. * Gets the type of the texture (int, float...)
  30663. */
  30664. type: number;
  30665. /**
  30666. * Gets the format of the texture (RGB, RGBA...)
  30667. */
  30668. format: number;
  30669. /**
  30670. * Observable called when the texture is loaded
  30671. */
  30672. onLoadedObservable: Observable<InternalTexture>;
  30673. /**
  30674. * Gets the width of the texture
  30675. */
  30676. width: number;
  30677. /**
  30678. * Gets the height of the texture
  30679. */
  30680. height: number;
  30681. /**
  30682. * Gets the depth of the texture
  30683. */
  30684. depth: number;
  30685. /**
  30686. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30687. */
  30688. baseWidth: number;
  30689. /**
  30690. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30691. */
  30692. baseHeight: number;
  30693. /**
  30694. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30695. */
  30696. baseDepth: number;
  30697. /**
  30698. * Gets a boolean indicating if the texture is inverted on Y axis
  30699. */
  30700. invertY: boolean;
  30701. /** @hidden */
  30702. _invertVScale: boolean;
  30703. /** @hidden */
  30704. _associatedChannel: number;
  30705. /** @hidden */
  30706. _dataSource: number;
  30707. /** @hidden */
  30708. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30709. /** @hidden */
  30710. _bufferView: Nullable<ArrayBufferView>;
  30711. /** @hidden */
  30712. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30713. /** @hidden */
  30714. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30715. /** @hidden */
  30716. _size: number;
  30717. /** @hidden */
  30718. _extension: string;
  30719. /** @hidden */
  30720. _files: Nullable<string[]>;
  30721. /** @hidden */
  30722. _workingCanvas: Nullable<HTMLCanvasElement>;
  30723. /** @hidden */
  30724. _workingContext: Nullable<CanvasRenderingContext2D>;
  30725. /** @hidden */
  30726. _framebuffer: Nullable<WebGLFramebuffer>;
  30727. /** @hidden */
  30728. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30729. /** @hidden */
  30730. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30731. /** @hidden */
  30732. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30733. /** @hidden */
  30734. _attachments: Nullable<number[]>;
  30735. /** @hidden */
  30736. _cachedCoordinatesMode: Nullable<number>;
  30737. /** @hidden */
  30738. _cachedWrapU: Nullable<number>;
  30739. /** @hidden */
  30740. _cachedWrapV: Nullable<number>;
  30741. /** @hidden */
  30742. _cachedWrapR: Nullable<number>;
  30743. /** @hidden */
  30744. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30745. /** @hidden */
  30746. _isDisabled: boolean;
  30747. /** @hidden */
  30748. _compression: Nullable<string>;
  30749. /** @hidden */
  30750. _generateStencilBuffer: boolean;
  30751. /** @hidden */
  30752. _generateDepthBuffer: boolean;
  30753. /** @hidden */
  30754. _comparisonFunction: number;
  30755. /** @hidden */
  30756. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30757. /** @hidden */
  30758. _lodGenerationScale: number;
  30759. /** @hidden */
  30760. _lodGenerationOffset: number;
  30761. /** @hidden */
  30762. _colorTextureArray: Nullable<WebGLTexture>;
  30763. /** @hidden */
  30764. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30765. /** @hidden */
  30766. _lodTextureHigh: Nullable<BaseTexture>;
  30767. /** @hidden */
  30768. _lodTextureMid: Nullable<BaseTexture>;
  30769. /** @hidden */
  30770. _lodTextureLow: Nullable<BaseTexture>;
  30771. /** @hidden */
  30772. _isRGBD: boolean;
  30773. /** @hidden */
  30774. _linearSpecularLOD: boolean;
  30775. /** @hidden */
  30776. _irradianceTexture: Nullable<BaseTexture>;
  30777. /** @hidden */
  30778. _webGLTexture: Nullable<WebGLTexture>;
  30779. /** @hidden */
  30780. _references: number;
  30781. private _engine;
  30782. /**
  30783. * Gets the Engine the texture belongs to.
  30784. * @returns The babylon engine
  30785. */
  30786. getEngine(): BaseEngine;
  30787. /**
  30788. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  30789. */
  30790. readonly dataSource: number;
  30791. /**
  30792. * Creates a new InternalTexture
  30793. * @param engine defines the engine to use
  30794. * @param dataSource defines the type of data that will be used
  30795. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30796. */
  30797. constructor(engine: BaseEngine, dataSource: number, delayAllocation?: boolean);
  30798. /**
  30799. * Increments the number of references (ie. the number of Texture that point to it)
  30800. */
  30801. incrementReferences(): void;
  30802. /**
  30803. * Change the size of the texture (not the size of the content)
  30804. * @param width defines the new width
  30805. * @param height defines the new height
  30806. * @param depth defines the new depth (1 by default)
  30807. */
  30808. updateSize(width: int, height: int, depth?: int): void;
  30809. /** @hidden */
  30810. _rebuild(): void;
  30811. /** @hidden */
  30812. _swapAndDie(target: InternalTexture): void;
  30813. /**
  30814. * Dispose the current allocated resources
  30815. */
  30816. dispose(): void;
  30817. }
  30818. }
  30819. declare module BABYLON {
  30820. /**
  30821. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30823. */
  30824. export class Analyser {
  30825. /**
  30826. * Gets or sets the smoothing
  30827. * @ignorenaming
  30828. */
  30829. SMOOTHING: number;
  30830. /**
  30831. * Gets or sets the FFT table size
  30832. * @ignorenaming
  30833. */
  30834. FFT_SIZE: number;
  30835. /**
  30836. * Gets or sets the bar graph amplitude
  30837. * @ignorenaming
  30838. */
  30839. BARGRAPHAMPLITUDE: number;
  30840. /**
  30841. * Gets or sets the position of the debug canvas
  30842. * @ignorenaming
  30843. */
  30844. DEBUGCANVASPOS: {
  30845. x: number;
  30846. y: number;
  30847. };
  30848. /**
  30849. * Gets or sets the debug canvas size
  30850. * @ignorenaming
  30851. */
  30852. DEBUGCANVASSIZE: {
  30853. width: number;
  30854. height: number;
  30855. };
  30856. private _byteFreqs;
  30857. private _byteTime;
  30858. private _floatFreqs;
  30859. private _webAudioAnalyser;
  30860. private _debugCanvas;
  30861. private _debugCanvasContext;
  30862. private _scene;
  30863. private _registerFunc;
  30864. private _audioEngine;
  30865. /**
  30866. * Creates a new analyser
  30867. * @param scene defines hosting scene
  30868. */
  30869. constructor(scene: Scene);
  30870. /**
  30871. * Get the number of data values you will have to play with for the visualization
  30872. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30873. * @returns a number
  30874. */
  30875. getFrequencyBinCount(): number;
  30876. /**
  30877. * Gets the current frequency data as a byte array
  30878. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30879. * @returns a Uint8Array
  30880. */
  30881. getByteFrequencyData(): Uint8Array;
  30882. /**
  30883. * Gets the current waveform as a byte array
  30884. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30885. * @returns a Uint8Array
  30886. */
  30887. getByteTimeDomainData(): Uint8Array;
  30888. /**
  30889. * Gets the current frequency data as a float array
  30890. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30891. * @returns a Float32Array
  30892. */
  30893. getFloatFrequencyData(): Float32Array;
  30894. /**
  30895. * Renders the debug canvas
  30896. */
  30897. drawDebugCanvas(): void;
  30898. /**
  30899. * Stops rendering the debug canvas and removes it
  30900. */
  30901. stopDebugCanvas(): void;
  30902. /**
  30903. * Connects two audio nodes
  30904. * @param inputAudioNode defines first node to connect
  30905. * @param outputAudioNode defines second node to connect
  30906. */
  30907. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30908. /**
  30909. * Releases all associated resources
  30910. */
  30911. dispose(): void;
  30912. }
  30913. }
  30914. declare module BABYLON {
  30915. /**
  30916. * This represents an audio engine and it is responsible
  30917. * to play, synchronize and analyse sounds throughout the application.
  30918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30919. */
  30920. export interface IAudioEngine extends IDisposable {
  30921. /**
  30922. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30923. */
  30924. readonly canUseWebAudio: boolean;
  30925. /**
  30926. * Gets the current AudioContext if available.
  30927. */
  30928. readonly audioContext: Nullable<AudioContext>;
  30929. /**
  30930. * The master gain node defines the global audio volume of your audio engine.
  30931. */
  30932. readonly masterGain: GainNode;
  30933. /**
  30934. * Gets whether or not mp3 are supported by your browser.
  30935. */
  30936. readonly isMP3supported: boolean;
  30937. /**
  30938. * Gets whether or not ogg are supported by your browser.
  30939. */
  30940. readonly isOGGsupported: boolean;
  30941. /**
  30942. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30943. * @ignoreNaming
  30944. */
  30945. WarnedWebAudioUnsupported: boolean;
  30946. /**
  30947. * Defines if the audio engine relies on a custom unlocked button.
  30948. * In this case, the embedded button will not be displayed.
  30949. */
  30950. useCustomUnlockedButton: boolean;
  30951. /**
  30952. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30953. */
  30954. readonly unlocked: boolean;
  30955. /**
  30956. * Event raised when audio has been unlocked on the browser.
  30957. */
  30958. onAudioUnlockedObservable: Observable<AudioEngine>;
  30959. /**
  30960. * Event raised when audio has been locked on the browser.
  30961. */
  30962. onAudioLockedObservable: Observable<AudioEngine>;
  30963. /**
  30964. * Flags the audio engine in Locked state.
  30965. * This happens due to new browser policies preventing audio to autoplay.
  30966. */
  30967. lock(): void;
  30968. /**
  30969. * Unlocks the audio engine once a user action has been done on the dom.
  30970. * This is helpful to resume play once browser policies have been satisfied.
  30971. */
  30972. unlock(): void;
  30973. }
  30974. /**
  30975. * This represents the default audio engine used in babylon.
  30976. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30978. */
  30979. export class AudioEngine implements IAudioEngine {
  30980. private _audioContext;
  30981. private _audioContextInitialized;
  30982. private _muteButton;
  30983. private _hostElement;
  30984. /**
  30985. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30986. */
  30987. canUseWebAudio: boolean;
  30988. /**
  30989. * The master gain node defines the global audio volume of your audio engine.
  30990. */
  30991. masterGain: GainNode;
  30992. /**
  30993. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30994. * @ignoreNaming
  30995. */
  30996. WarnedWebAudioUnsupported: boolean;
  30997. /**
  30998. * Gets whether or not mp3 are supported by your browser.
  30999. */
  31000. isMP3supported: boolean;
  31001. /**
  31002. * Gets whether or not ogg are supported by your browser.
  31003. */
  31004. isOGGsupported: boolean;
  31005. /**
  31006. * Gets whether audio has been unlocked on the device.
  31007. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31008. * a user interaction has happened.
  31009. */
  31010. unlocked: boolean;
  31011. /**
  31012. * Defines if the audio engine relies on a custom unlocked button.
  31013. * In this case, the embedded button will not be displayed.
  31014. */
  31015. useCustomUnlockedButton: boolean;
  31016. /**
  31017. * Event raised when audio has been unlocked on the browser.
  31018. */
  31019. onAudioUnlockedObservable: Observable<AudioEngine>;
  31020. /**
  31021. * Event raised when audio has been locked on the browser.
  31022. */
  31023. onAudioLockedObservable: Observable<AudioEngine>;
  31024. /**
  31025. * Gets the current AudioContext if available.
  31026. */
  31027. readonly audioContext: Nullable<AudioContext>;
  31028. private _connectedAnalyser;
  31029. /**
  31030. * Instantiates a new audio engine.
  31031. *
  31032. * There should be only one per page as some browsers restrict the number
  31033. * of audio contexts you can create.
  31034. * @param hostElement defines the host element where to display the mute icon if necessary
  31035. */
  31036. constructor(hostElement?: Nullable<HTMLElement>);
  31037. /**
  31038. * Flags the audio engine in Locked state.
  31039. * This happens due to new browser policies preventing audio to autoplay.
  31040. */
  31041. lock(): void;
  31042. /**
  31043. * Unlocks the audio engine once a user action has been done on the dom.
  31044. * This is helpful to resume play once browser policies have been satisfied.
  31045. */
  31046. unlock(): void;
  31047. private _resumeAudioContext;
  31048. private _initializeAudioContext;
  31049. private _tryToRun;
  31050. private _triggerRunningState;
  31051. private _triggerSuspendedState;
  31052. private _displayMuteButton;
  31053. private _moveButtonToTopLeft;
  31054. private _onResize;
  31055. private _hideMuteButton;
  31056. /**
  31057. * Destroy and release the resources associated with the audio ccontext.
  31058. */
  31059. dispose(): void;
  31060. /**
  31061. * Gets the global volume sets on the master gain.
  31062. * @returns the global volume if set or -1 otherwise
  31063. */
  31064. getGlobalVolume(): number;
  31065. /**
  31066. * Sets the global volume of your experience (sets on the master gain).
  31067. * @param newVolume Defines the new global volume of the application
  31068. */
  31069. setGlobalVolume(newVolume: number): void;
  31070. /**
  31071. * Connect the audio engine to an audio analyser allowing some amazing
  31072. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31074. * @param analyser The analyser to connect to the engine
  31075. */
  31076. connectToAnalyser(analyser: Analyser): void;
  31077. }
  31078. }
  31079. declare module BABYLON {
  31080. /**
  31081. * Interface used to present a loading screen while loading a scene
  31082. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31083. */
  31084. export interface ILoadingScreen {
  31085. /**
  31086. * Function called to display the loading screen
  31087. */
  31088. displayLoadingUI: () => void;
  31089. /**
  31090. * Function called to hide the loading screen
  31091. */
  31092. hideLoadingUI: () => void;
  31093. /**
  31094. * Gets or sets the color to use for the background
  31095. */
  31096. loadingUIBackgroundColor: string;
  31097. /**
  31098. * Gets or sets the text to display while loading
  31099. */
  31100. loadingUIText: string;
  31101. }
  31102. /**
  31103. * Class used for the default loading screen
  31104. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31105. */
  31106. export class DefaultLoadingScreen implements ILoadingScreen {
  31107. private _renderingCanvas;
  31108. private _loadingText;
  31109. private _loadingDivBackgroundColor;
  31110. private _loadingDiv;
  31111. private _loadingTextDiv;
  31112. /** Gets or sets the logo url to use for the default loading screen */
  31113. static DefaultLogoUrl: string;
  31114. /** Gets or sets the spinner url to use for the default loading screen */
  31115. static DefaultSpinnerUrl: string;
  31116. /**
  31117. * Creates a new default loading screen
  31118. * @param _renderingCanvas defines the canvas used to render the scene
  31119. * @param _loadingText defines the default text to display
  31120. * @param _loadingDivBackgroundColor defines the default background color
  31121. */
  31122. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31123. /**
  31124. * Function called to display the loading screen
  31125. */
  31126. displayLoadingUI(): void;
  31127. /**
  31128. * Function called to hide the loading screen
  31129. */
  31130. hideLoadingUI(): void;
  31131. /**
  31132. * Gets or sets the text to display while loading
  31133. */
  31134. loadingUIText: string;
  31135. /**
  31136. * Gets or sets the color to use for the background
  31137. */
  31138. loadingUIBackgroundColor: string;
  31139. private _resizeLoadingUI;
  31140. }
  31141. }
  31142. declare module BABYLON {
  31143. /**
  31144. * Interface for any object that can request an animation frame
  31145. */
  31146. export interface ICustomAnimationFrameRequester {
  31147. /**
  31148. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31149. */
  31150. renderFunction?: Function;
  31151. /**
  31152. * Called to request the next frame to render to
  31153. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31154. */
  31155. requestAnimationFrame: Function;
  31156. /**
  31157. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31158. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31159. */
  31160. requestID?: number;
  31161. }
  31162. }
  31163. declare module BABYLON {
  31164. /**
  31165. * Interface for performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31166. */
  31167. export interface IPerformanceMonitor {
  31168. /**
  31169. * Enables contributions to the sliding window sample set
  31170. */
  31171. enable(): void;
  31172. /**
  31173. * Disables contributions to the sliding window sample set
  31174. * Samples will not be interpolated over the disabled period
  31175. */
  31176. disable(): void;
  31177. /**
  31178. * Samples current frame
  31179. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31180. */
  31181. sampleFrame(timeMs?: number): void;
  31182. /**
  31183. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31184. */
  31185. averageFrameTime: number;
  31186. /**
  31187. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31188. */
  31189. averageFrameTimeVariance: number;
  31190. /**
  31191. * Returns the frame time of the most recent frame
  31192. */
  31193. instantaneousFrameTime: number;
  31194. /**
  31195. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31196. */
  31197. averageFPS: number;
  31198. /**
  31199. * Returns the average framerate in frames per second using the most recent frame time
  31200. */
  31201. instantaneousFPS: number;
  31202. }
  31203. }
  31204. declare module BABYLON {
  31205. /**
  31206. * Defines the interface used by display changed events
  31207. */
  31208. export interface IDisplayChangedEventArgs {
  31209. /** Gets the vrDisplay object (if any) */
  31210. vrDisplay: Nullable<any>;
  31211. /** Gets a boolean indicating if webVR is supported */
  31212. vrSupported: boolean;
  31213. }
  31214. /**
  31215. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31216. */
  31217. export class Engine extends BaseEngine {
  31218. /**
  31219. * Returns the current npm package of the sdk
  31220. */
  31221. static readonly NpmPackage: string;
  31222. /**
  31223. * Returns the current version of the framework
  31224. */
  31225. static readonly Version: string;
  31226. /** Gets the list of created engines */
  31227. static readonly Instances: Engine[];
  31228. /**
  31229. * Gets the latest created engine
  31230. */
  31231. static readonly LastCreatedEngine: Nullable<Engine>;
  31232. /**
  31233. * Gets the latest created scene
  31234. */
  31235. static readonly LastCreatedScene: Nullable<Scene>;
  31236. /**
  31237. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31238. * @param flag defines which part of the materials must be marked as dirty
  31239. * @param predicate defines a predicate used to filter which materials should be affected
  31240. */
  31241. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31242. /**
  31243. * Factory used to create the performance monitor
  31244. * @returns a new PerformanceMonitor
  31245. */
  31246. static DefaultPerformanceMonitorFactory(): IPerformanceMonitor;
  31247. /**
  31248. * Method called to create the default loading screen.
  31249. * This can be overriden in your own app.
  31250. * @param canvas The rendering canvas element
  31251. * @returns The loading screen
  31252. */
  31253. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31254. /**
  31255. * Method called to create the default rescale post process on each engine.
  31256. */
  31257. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31258. /**
  31259. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31260. **/
  31261. enableOfflineSupport: boolean;
  31262. /**
  31263. * 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)
  31264. **/
  31265. disableManifestCheck: boolean;
  31266. /**
  31267. * Gets the list of created scenes
  31268. */
  31269. scenes: Scene[];
  31270. /**
  31271. * Event raised when a new scene is created
  31272. */
  31273. onNewSceneAddedObservable: Observable<Scene>;
  31274. /**
  31275. * Gets the list of created postprocesses
  31276. */
  31277. postProcesses: PostProcess[];
  31278. /**
  31279. * Observable event triggered each time the rendering canvas is resized
  31280. */
  31281. onResizeObservable: Observable<Engine>;
  31282. /**
  31283. * Observable event triggered each time the canvas loses focus
  31284. */
  31285. onCanvasBlurObservable: Observable<Engine>;
  31286. /**
  31287. * Observable event triggered each time the canvas gains focus
  31288. */
  31289. onCanvasFocusObservable: Observable<Engine>;
  31290. /**
  31291. * Observable event triggered each time the canvas receives pointerout event
  31292. */
  31293. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31294. /**
  31295. * Observable event triggered before each texture is initialized
  31296. */
  31297. onBeforeTextureInitObservable: Observable<Texture>;
  31298. /**
  31299. * Observable raised when the engine begins a new frame
  31300. */
  31301. onBeginFrameObservable: Observable<Engine>;
  31302. /**
  31303. * If set, will be used to request the next animation frame for the render loop
  31304. */
  31305. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31306. /**
  31307. * Observable raised when the engine ends the current frame
  31308. */
  31309. onEndFrameObservable: Observable<Engine>;
  31310. /**
  31311. * Observable raised when the engine is about to compile a shader
  31312. */
  31313. onBeforeShaderCompilationObservable: Observable<Engine>;
  31314. /**
  31315. * Observable raised when the engine has jsut compiled a shader
  31316. */
  31317. onAfterShaderCompilationObservable: Observable<Engine>;
  31318. /**
  31319. * Gets the audio engine
  31320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31321. * @ignorenaming
  31322. */
  31323. static audioEngine: IAudioEngine;
  31324. /**
  31325. * Default AudioEngine factory responsible of creating the Audio Engine.
  31326. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31327. */
  31328. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31329. /**
  31330. * Default offline support factory responsible of creating a tool used to store data locally.
  31331. * By default, this will create a Database object if the workload has been embedded.
  31332. */
  31333. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31334. private _loadingScreen;
  31335. private _pointerLockRequested;
  31336. private _dummyFramebuffer;
  31337. private _rescalePostProcess;
  31338. protected readonly _supportsHardwareTextureRescaling: boolean;
  31339. private _fps;
  31340. private _deltaTime;
  31341. /**
  31342. * Turn this value on if you want to pause FPS computation when in background
  31343. */
  31344. disablePerformanceMonitorInBackground: boolean;
  31345. private _performanceMonitor;
  31346. /**
  31347. * Gets the performance monitor attached to this engine
  31348. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31349. */
  31350. readonly performanceMonitor: IPerformanceMonitor;
  31351. private _onFocus;
  31352. private _onBlur;
  31353. private _onCanvasPointerOut;
  31354. private _onCanvasBlur;
  31355. private _onCanvasFocus;
  31356. private _onFullscreenChange;
  31357. private _onPointerLockChange;
  31358. /**
  31359. * Creates a new engine
  31360. * @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
  31361. * @param antialias defines enable antialiasing (default: false)
  31362. * @param options defines further options to be sent to the getContext() function
  31363. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31364. */
  31365. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31366. /**
  31367. * Initializes a webVR display and starts listening to display change events
  31368. * The onVRDisplayChangedObservable will be notified upon these changes
  31369. * @returns The onVRDisplayChangedObservable
  31370. */
  31371. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31372. /** @hidden */
  31373. _prepareVRComponent(): void;
  31374. /** @hidden */
  31375. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31376. /** @hidden */
  31377. _submitVRFrame(): void;
  31378. /**
  31379. * Call this function to leave webVR mode
  31380. * Will do nothing if webVR is not supported or if there is no webVR device
  31381. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31382. */
  31383. disableVR(): void;
  31384. /**
  31385. * Gets a boolean indicating that the system is in VR mode and is presenting
  31386. * @returns true if VR mode is engaged
  31387. */
  31388. isVRPresenting(): boolean;
  31389. /** @hidden */
  31390. _requestVRFrame(): void;
  31391. protected _rebuildBuffers(): void;
  31392. _renderLoop(): void;
  31393. /**
  31394. * Toggle full screen mode
  31395. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31396. */
  31397. switchFullscreen(requestPointerLock: boolean): void;
  31398. /**
  31399. * Enters full screen mode
  31400. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31401. */
  31402. enterFullscreen(requestPointerLock: boolean): void;
  31403. /**
  31404. * Exits full screen mode
  31405. */
  31406. exitFullscreen(): void;
  31407. /**
  31408. * Enters Pointerlock mode
  31409. */
  31410. enterPointerlock(): void;
  31411. /**
  31412. * Exits Pointerlock mode
  31413. */
  31414. exitPointerlock(): void;
  31415. /**
  31416. * Begin a new frame
  31417. */
  31418. beginFrame(): void;
  31419. /**
  31420. * Enf the current frame
  31421. */
  31422. endFrame(): void;
  31423. resize(): void;
  31424. /**
  31425. * Force a specific size of the canvas
  31426. * @param width defines the new canvas' width
  31427. * @param height defines the new canvas' height
  31428. */
  31429. setSize(width: number, height: number): void;
  31430. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31431. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31432. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31433. _releaseTexture(texture: InternalTexture): void;
  31434. /**
  31435. * @hidden
  31436. * Rescales a texture
  31437. * @param source input texutre
  31438. * @param destination destination texture
  31439. * @param scene scene to use to render the resize
  31440. * @param internalFormat format to use when resizing
  31441. * @param onComplete callback to be called when resize has completed
  31442. */
  31443. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31444. /**
  31445. * Gets the current framerate
  31446. * @returns a number representing the framerate
  31447. */
  31448. getFps(): number;
  31449. /**
  31450. * Gets the time spent between current and previous frame
  31451. * @returns a number representing the delta time in ms
  31452. */
  31453. getDeltaTime(): number;
  31454. private _measureFps;
  31455. /** @hidden */
  31456. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31457. dispose(): void;
  31458. /**
  31459. * Display the loading screen
  31460. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31461. */
  31462. displayLoadingUI(): void;
  31463. /**
  31464. * Hide the loading screen
  31465. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31466. */
  31467. hideLoadingUI(): void;
  31468. /**
  31469. * Gets the current loading screen object
  31470. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31471. */
  31472. /**
  31473. * Sets the current loading screen object
  31474. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31475. */
  31476. loadingScreen: ILoadingScreen;
  31477. /**
  31478. * Sets the current loading screen text
  31479. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31480. */
  31481. loadingUIText: string;
  31482. /**
  31483. * Sets the current loading screen background color
  31484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31485. */
  31486. loadingUIBackgroundColor: string;
  31487. }
  31488. }
  31489. declare module BABYLON {
  31490. /**
  31491. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31492. * during the life time of the application.
  31493. */
  31494. export class EngineStore {
  31495. /** Gets the list of created engines */
  31496. static Instances: Engine[];
  31497. /** @hidden */
  31498. static _LastCreatedScene: Nullable<Scene>;
  31499. /**
  31500. * Gets the latest created engine
  31501. */
  31502. static readonly LastCreatedEngine: Nullable<Engine>;
  31503. /**
  31504. * Gets the latest created scene
  31505. */
  31506. static readonly LastCreatedScene: Nullable<Scene>;
  31507. /**
  31508. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31509. * @ignorenaming
  31510. */
  31511. static UseFallbackTexture: boolean;
  31512. /**
  31513. * Texture content used if a texture cannot loaded
  31514. * @ignorenaming
  31515. */
  31516. static FallbackTexture: string;
  31517. }
  31518. }
  31519. declare module BABYLON {
  31520. /**
  31521. * Helper class that provides a small promise polyfill
  31522. */
  31523. export class PromisePolyfill {
  31524. /**
  31525. * Static function used to check if the polyfill is required
  31526. * If this is the case then the function will inject the polyfill to window.Promise
  31527. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31528. */
  31529. static Apply(force?: boolean): void;
  31530. }
  31531. }
  31532. declare module BABYLON {
  31533. /**
  31534. * Interface for screenshot methods with describe argument called `size` as object with options
  31535. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31536. */
  31537. export interface IScreenshotSize {
  31538. /**
  31539. * number in pixels for canvas height
  31540. */
  31541. height?: number;
  31542. /**
  31543. * multiplier allowing render at a higher or lower resolution
  31544. * If value is defined then height and width will be ignored and taken from camera
  31545. */
  31546. precision?: number;
  31547. /**
  31548. * number in pixels for canvas width
  31549. */
  31550. width?: number;
  31551. }
  31552. }
  31553. declare module BABYLON {
  31554. interface IColor4Like {
  31555. r: float;
  31556. g: float;
  31557. b: float;
  31558. a: float;
  31559. }
  31560. /**
  31561. * Class containing a set of static utilities functions
  31562. */
  31563. export class Tools {
  31564. /**
  31565. * Gets or sets the base URL to use to load assets
  31566. */
  31567. static BaseUrl: string;
  31568. /**
  31569. * Enable/Disable Custom HTTP Request Headers globally.
  31570. * default = false
  31571. * @see CustomRequestHeaders
  31572. */
  31573. static UseCustomRequestHeaders: boolean;
  31574. /**
  31575. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31576. * i.e. when loading files, where the server/service expects an Authorization header
  31577. */
  31578. static CustomRequestHeaders: {
  31579. [key: string]: string;
  31580. };
  31581. /**
  31582. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31583. */
  31584. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31585. /**
  31586. * Default behaviour for cors in the application.
  31587. * It can be a string if the expected behavior is identical in the entire app.
  31588. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31589. */
  31590. static CorsBehavior: string | ((url: string | string[]) => string);
  31591. /**
  31592. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31593. * @ignorenaming
  31594. */
  31595. static UseFallbackTexture: boolean;
  31596. /**
  31597. * Use this object to register external classes like custom textures or material
  31598. * to allow the laoders to instantiate them
  31599. */
  31600. static RegisteredExternalClasses: {
  31601. [key: string]: Object;
  31602. };
  31603. /**
  31604. * Texture content used if a texture cannot loaded
  31605. * @ignorenaming
  31606. */
  31607. static fallbackTexture: string;
  31608. /**
  31609. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31610. * @param u defines the coordinate on X axis
  31611. * @param v defines the coordinate on Y axis
  31612. * @param width defines the width of the source data
  31613. * @param height defines the height of the source data
  31614. * @param pixels defines the source byte array
  31615. * @param color defines the output color
  31616. */
  31617. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31618. /**
  31619. * Interpolates between a and b via alpha
  31620. * @param a The lower value (returned when alpha = 0)
  31621. * @param b The upper value (returned when alpha = 1)
  31622. * @param alpha The interpolation-factor
  31623. * @return The mixed value
  31624. */
  31625. static Mix(a: number, b: number, alpha: number): number;
  31626. /**
  31627. * Tries to instantiate a new object from a given class name
  31628. * @param className defines the class name to instantiate
  31629. * @returns the new object or null if the system was not able to do the instantiation
  31630. */
  31631. static Instantiate(className: string): any;
  31632. /**
  31633. * Provides a slice function that will work even on IE
  31634. * @param data defines the array to slice
  31635. * @param start defines the start of the data (optional)
  31636. * @param end defines the end of the data (optional)
  31637. * @returns the new sliced array
  31638. */
  31639. static Slice<T>(data: T, start?: number, end?: number): T;
  31640. /**
  31641. * Polyfill for setImmediate
  31642. * @param action defines the action to execute after the current execution block
  31643. */
  31644. static SetImmediate(action: () => void): void;
  31645. /**
  31646. * Function indicating if a number is an exponent of 2
  31647. * @param value defines the value to test
  31648. * @returns true if the value is an exponent of 2
  31649. */
  31650. static IsExponentOfTwo(value: number): boolean;
  31651. private static _tmpFloatArray;
  31652. /**
  31653. * Returns the nearest 32-bit single precision float representation of a Number
  31654. * @param value A Number. If the parameter is of a different type, it will get converted
  31655. * to a number or to NaN if it cannot be converted
  31656. * @returns number
  31657. */
  31658. static FloatRound(value: number): number;
  31659. /**
  31660. * Extracts the filename from a path
  31661. * @param path defines the path to use
  31662. * @returns the filename
  31663. */
  31664. static GetFilename(path: string): string;
  31665. /**
  31666. * Extracts the "folder" part of a path (everything before the filename).
  31667. * @param uri The URI to extract the info from
  31668. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31669. * @returns The "folder" part of the path
  31670. */
  31671. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31672. /**
  31673. * Extracts text content from a DOM element hierarchy
  31674. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31675. */
  31676. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31677. /**
  31678. * Convert an angle in radians to degrees
  31679. * @param angle defines the angle to convert
  31680. * @returns the angle in degrees
  31681. */
  31682. static ToDegrees(angle: number): number;
  31683. /**
  31684. * Convert an angle in degrees to radians
  31685. * @param angle defines the angle to convert
  31686. * @returns the angle in radians
  31687. */
  31688. static ToRadians(angle: number): number;
  31689. /**
  31690. * Encode a buffer to a base64 string
  31691. * @param buffer defines the buffer to encode
  31692. * @returns the encoded string
  31693. */
  31694. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31695. /**
  31696. * Returns an array if obj is not an array
  31697. * @param obj defines the object to evaluate as an array
  31698. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31699. * @returns either obj directly if obj is an array or a new array containing obj
  31700. */
  31701. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31702. /**
  31703. * Gets the pointer prefix to use
  31704. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31705. */
  31706. static GetPointerPrefix(): string;
  31707. /**
  31708. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31709. * @param url define the url we are trying
  31710. * @param element define the dom element where to configure the cors policy
  31711. */
  31712. static SetCorsBehavior(url: string | string[], element: {
  31713. crossOrigin: string | null;
  31714. }): void;
  31715. /**
  31716. * Removes unwanted characters from an url
  31717. * @param url defines the url to clean
  31718. * @returns the cleaned url
  31719. */
  31720. static CleanUrl(url: string): string;
  31721. /**
  31722. * Gets or sets a function used to pre-process url before using them to load assets
  31723. */
  31724. static PreprocessUrl: (url: string) => string;
  31725. /**
  31726. * Loads an image as an HTMLImageElement.
  31727. * @param input url string, ArrayBuffer, or Blob to load
  31728. * @param onLoad callback called when the image successfully loads
  31729. * @param onError callback called when the image fails to load
  31730. * @param offlineProvider offline provider for caching
  31731. * @returns the HTMLImageElement of the loaded image
  31732. */
  31733. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31734. /**
  31735. * Loads a file
  31736. * @param url url string, ArrayBuffer, or Blob to load
  31737. * @param onSuccess callback called when the file successfully loads
  31738. * @param onProgress callback called while file is loading (if the server supports this mode)
  31739. * @param offlineProvider defines the offline provider for caching
  31740. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31741. * @param onError callback called when the file fails to load
  31742. * @returns a file request object
  31743. */
  31744. 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;
  31745. /**
  31746. * Loads a file from a url
  31747. * @param url the file url to load
  31748. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31749. */
  31750. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31751. /**
  31752. * Load a script (identified by an url). When the url returns, the
  31753. * content of this file is added into a new script element, attached to the DOM (body element)
  31754. * @param scriptUrl defines the url of the script to laod
  31755. * @param onSuccess defines the callback called when the script is loaded
  31756. * @param onError defines the callback to call if an error occurs
  31757. * @param scriptId defines the id of the script element
  31758. */
  31759. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31760. /**
  31761. * Load an asynchronous script (identified by an url). When the url returns, the
  31762. * content of this file is added into a new script element, attached to the DOM (body element)
  31763. * @param scriptUrl defines the url of the script to laod
  31764. * @param scriptId defines the id of the script element
  31765. * @returns a promise request object
  31766. */
  31767. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31768. /**
  31769. * Loads a file from a blob
  31770. * @param fileToLoad defines the blob to use
  31771. * @param callback defines the callback to call when data is loaded
  31772. * @param progressCallback defines the callback to call during loading process
  31773. * @returns a file request object
  31774. */
  31775. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31776. /**
  31777. * Loads a file
  31778. * @param fileToLoad defines the file to load
  31779. * @param callback defines the callback to call when data is loaded
  31780. * @param progressCallBack defines the callback to call during loading process
  31781. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31782. * @returns a file request object
  31783. */
  31784. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31785. /**
  31786. * Creates a data url from a given string content
  31787. * @param content defines the content to convert
  31788. * @returns the new data url link
  31789. */
  31790. static FileAsURL(content: string): string;
  31791. /**
  31792. * Format the given number to a specific decimal format
  31793. * @param value defines the number to format
  31794. * @param decimals defines the number of decimals to use
  31795. * @returns the formatted string
  31796. */
  31797. static Format(value: number, decimals?: number): string;
  31798. /**
  31799. * Tries to copy an object by duplicating every property
  31800. * @param source defines the source object
  31801. * @param destination defines the target object
  31802. * @param doNotCopyList defines a list of properties to avoid
  31803. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31804. */
  31805. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31806. /**
  31807. * Gets a boolean indicating if the given object has no own property
  31808. * @param obj defines the object to test
  31809. * @returns true if object has no own property
  31810. */
  31811. static IsEmpty(obj: any): boolean;
  31812. /**
  31813. * Function used to register events at window level
  31814. * @param windowElement defines the Window object to use
  31815. * @param events defines the events to register
  31816. */
  31817. static RegisterTopRootEvents(windowElement: Window, events: {
  31818. name: string;
  31819. handler: Nullable<(e: FocusEvent) => any>;
  31820. }[]): void;
  31821. /**
  31822. * Function used to unregister events from window level
  31823. * @param windowElement defines the Window object to use
  31824. * @param events defines the events to unregister
  31825. */
  31826. static UnregisterTopRootEvents(windowElement: Window, events: {
  31827. name: string;
  31828. handler: Nullable<(e: FocusEvent) => any>;
  31829. }[]): void;
  31830. /**
  31831. * @ignore
  31832. */
  31833. static _ScreenshotCanvas: HTMLCanvasElement;
  31834. /**
  31835. * Dumps the current bound framebuffer
  31836. * @param width defines the rendering width
  31837. * @param height defines the rendering height
  31838. * @param engine defines the hosting engine
  31839. * @param successCallback defines the callback triggered once the data are available
  31840. * @param mimeType defines the mime type of the result
  31841. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31842. */
  31843. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31844. /**
  31845. * Converts the canvas data to blob.
  31846. * This acts as a polyfill for browsers not supporting the to blob function.
  31847. * @param canvas Defines the canvas to extract the data from
  31848. * @param successCallback Defines the callback triggered once the data are available
  31849. * @param mimeType Defines the mime type of the result
  31850. */
  31851. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31852. /**
  31853. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31854. * @param successCallback defines the callback triggered once the data are available
  31855. * @param mimeType defines the mime type of the result
  31856. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31857. */
  31858. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31859. /**
  31860. * Downloads a blob in the browser
  31861. * @param blob defines the blob to download
  31862. * @param fileName defines the name of the downloaded file
  31863. */
  31864. static Download(blob: Blob, fileName: string): void;
  31865. /**
  31866. * Captures a screenshot of the current rendering
  31867. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31868. * @param engine defines the rendering engine
  31869. * @param camera defines the source camera
  31870. * @param size This parameter can be set to a single number or to an object with the
  31871. * following (optional) properties: precision, width, height. If a single number is passed,
  31872. * it will be used for both width and height. If an object is passed, the screenshot size
  31873. * will be derived from the parameters. The precision property is a multiplier allowing
  31874. * rendering at a higher or lower resolution
  31875. * @param successCallback defines the callback receives a single parameter which contains the
  31876. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31877. * src parameter of an <img> to display it
  31878. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31879. * Check your browser for supported MIME types
  31880. */
  31881. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31882. /**
  31883. * Captures a screenshot of the current rendering
  31884. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31885. * @param engine defines the rendering engine
  31886. * @param camera defines the source camera
  31887. * @param size This parameter can be set to a single number or to an object with the
  31888. * following (optional) properties: precision, width, height. If a single number is passed,
  31889. * it will be used for both width and height. If an object is passed, the screenshot size
  31890. * will be derived from the parameters. The precision property is a multiplier allowing
  31891. * rendering at a higher or lower resolution
  31892. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31893. * Check your browser for supported MIME types
  31894. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31895. * to the src parameter of an <img> to display it
  31896. */
  31897. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31898. /**
  31899. * Generates an image screenshot from the specified camera.
  31900. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31901. * @param engine The engine to use for rendering
  31902. * @param camera The camera to use for rendering
  31903. * @param size This parameter can be set to a single number or to an object with the
  31904. * following (optional) properties: precision, width, height. If a single number is passed,
  31905. * it will be used for both width and height. If an object is passed, the screenshot size
  31906. * will be derived from the parameters. The precision property is a multiplier allowing
  31907. * rendering at a higher or lower resolution
  31908. * @param successCallback The callback receives a single parameter which contains the
  31909. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31910. * src parameter of an <img> to display it
  31911. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31912. * Check your browser for supported MIME types
  31913. * @param samples Texture samples (default: 1)
  31914. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31915. * @param fileName A name for for the downloaded file.
  31916. */
  31917. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31918. /**
  31919. * Generates an image screenshot from the specified camera.
  31920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31921. * @param engine The engine to use for rendering
  31922. * @param camera The camera to use for rendering
  31923. * @param size This parameter can be set to a single number or to an object with the
  31924. * following (optional) properties: precision, width, height. If a single number is passed,
  31925. * it will be used for both width and height. If an object is passed, the screenshot size
  31926. * will be derived from the parameters. The precision property is a multiplier allowing
  31927. * rendering at a higher or lower resolution
  31928. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31929. * Check your browser for supported MIME types
  31930. * @param samples Texture samples (default: 1)
  31931. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31932. * @param fileName A name for for the downloaded file.
  31933. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31934. * to the src parameter of an <img> to display it
  31935. */
  31936. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31937. /**
  31938. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31939. * Be aware Math.random() could cause collisions, but:
  31940. * "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"
  31941. * @returns a pseudo random id
  31942. */
  31943. static RandomId(): string;
  31944. /**
  31945. * Test if the given uri is a base64 string
  31946. * @param uri The uri to test
  31947. * @return True if the uri is a base64 string or false otherwise
  31948. */
  31949. static IsBase64(uri: string): boolean;
  31950. /**
  31951. * Decode the given base64 uri.
  31952. * @param uri The uri to decode
  31953. * @return The decoded base64 data.
  31954. */
  31955. static DecodeBase64(uri: string): ArrayBuffer;
  31956. /**
  31957. * Gets the absolute url.
  31958. * @param url the input url
  31959. * @return the absolute url
  31960. */
  31961. static GetAbsoluteUrl(url: string): string;
  31962. /**
  31963. * No log
  31964. */
  31965. static readonly NoneLogLevel: number;
  31966. /**
  31967. * Only message logs
  31968. */
  31969. static readonly MessageLogLevel: number;
  31970. /**
  31971. * Only warning logs
  31972. */
  31973. static readonly WarningLogLevel: number;
  31974. /**
  31975. * Only error logs
  31976. */
  31977. static readonly ErrorLogLevel: number;
  31978. /**
  31979. * All logs
  31980. */
  31981. static readonly AllLogLevel: number;
  31982. /**
  31983. * Gets a value indicating the number of loading errors
  31984. * @ignorenaming
  31985. */
  31986. static readonly errorsCount: number;
  31987. /**
  31988. * Callback called when a new log is added
  31989. */
  31990. static OnNewCacheEntry: (entry: string) => void;
  31991. /**
  31992. * Log a message to the console
  31993. * @param message defines the message to log
  31994. */
  31995. static Log(message: string): void;
  31996. /**
  31997. * Write a warning message to the console
  31998. * @param message defines the message to log
  31999. */
  32000. static Warn(message: string): void;
  32001. /**
  32002. * Write an error message to the console
  32003. * @param message defines the message to log
  32004. */
  32005. static Error(message: string): void;
  32006. /**
  32007. * Gets current log cache (list of logs)
  32008. */
  32009. static readonly LogCache: string;
  32010. /**
  32011. * Clears the log cache
  32012. */
  32013. static ClearLogCache(): void;
  32014. /**
  32015. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32016. */
  32017. static LogLevels: number;
  32018. /**
  32019. * Checks if the window object exists
  32020. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32021. */
  32022. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32023. /**
  32024. * No performance log
  32025. */
  32026. static readonly PerformanceNoneLogLevel: number;
  32027. /**
  32028. * Use user marks to log performance
  32029. */
  32030. static readonly PerformanceUserMarkLogLevel: number;
  32031. /**
  32032. * Log performance to the console
  32033. */
  32034. static readonly PerformanceConsoleLogLevel: number;
  32035. private static _performance;
  32036. /**
  32037. * Sets the current performance log level
  32038. */
  32039. static PerformanceLogLevel: number;
  32040. private static _StartPerformanceCounterDisabled;
  32041. private static _EndPerformanceCounterDisabled;
  32042. private static _StartUserMark;
  32043. private static _EndUserMark;
  32044. private static _StartPerformanceConsole;
  32045. private static _EndPerformanceConsole;
  32046. /**
  32047. * Starts a performance counter
  32048. */
  32049. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32050. /**
  32051. * Ends a specific performance coutner
  32052. */
  32053. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32054. /**
  32055. * Gets either window.performance.now() if supported or Date.now() else
  32056. */
  32057. static readonly Now: number;
  32058. /**
  32059. * This method will return the name of the class used to create the instance of the given object.
  32060. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32061. * @param object the object to get the class name from
  32062. * @param isType defines if the object is actually a type
  32063. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32064. */
  32065. static GetClassName(object: any, isType?: boolean): string;
  32066. /**
  32067. * Gets the first element of an array satisfying a given predicate
  32068. * @param array defines the array to browse
  32069. * @param predicate defines the predicate to use
  32070. * @returns null if not found or the element
  32071. */
  32072. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32073. /**
  32074. * This method will return the name of the full name of the class, including its owning module (if any).
  32075. * 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).
  32076. * @param object the object to get the class name from
  32077. * @param isType defines if the object is actually a type
  32078. * @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.
  32079. * @ignorenaming
  32080. */
  32081. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32082. /**
  32083. * Returns a promise that resolves after the given amount of time.
  32084. * @param delay Number of milliseconds to delay
  32085. * @returns Promise that resolves after the given amount of time
  32086. */
  32087. static DelayAsync(delay: number): Promise<void>;
  32088. }
  32089. /**
  32090. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32091. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32092. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32093. * @param name The name of the class, case should be preserved
  32094. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32095. */
  32096. export function className(name: string, module?: string): (target: Object) => void;
  32097. /**
  32098. * An implementation of a loop for asynchronous functions.
  32099. */
  32100. export class AsyncLoop {
  32101. /**
  32102. * Defines the number of iterations for the loop
  32103. */
  32104. iterations: number;
  32105. /**
  32106. * Defines the current index of the loop.
  32107. */
  32108. index: number;
  32109. private _done;
  32110. private _fn;
  32111. private _successCallback;
  32112. /**
  32113. * Constructor.
  32114. * @param iterations the number of iterations.
  32115. * @param func the function to run each iteration
  32116. * @param successCallback the callback that will be called upon succesful execution
  32117. * @param offset starting offset.
  32118. */
  32119. constructor(
  32120. /**
  32121. * Defines the number of iterations for the loop
  32122. */
  32123. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32124. /**
  32125. * Execute the next iteration. Must be called after the last iteration was finished.
  32126. */
  32127. executeNext(): void;
  32128. /**
  32129. * Break the loop and run the success callback.
  32130. */
  32131. breakLoop(): void;
  32132. /**
  32133. * Create and run an async loop.
  32134. * @param iterations the number of iterations.
  32135. * @param fn the function to run each iteration
  32136. * @param successCallback the callback that will be called upon succesful execution
  32137. * @param offset starting offset.
  32138. * @returns the created async loop object
  32139. */
  32140. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32141. /**
  32142. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32143. * @param iterations total number of iterations
  32144. * @param syncedIterations number of synchronous iterations in each async iteration.
  32145. * @param fn the function to call each iteration.
  32146. * @param callback a success call back that will be called when iterating stops.
  32147. * @param breakFunction a break condition (optional)
  32148. * @param timeout timeout settings for the setTimeout function. default - 0.
  32149. * @returns the created async loop object
  32150. */
  32151. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32152. }
  32153. }
  32154. declare module BABYLON {
  32155. /**
  32156. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32157. * The underlying implementation relies on an associative array to ensure the best performances.
  32158. * The value can be anything including 'null' but except 'undefined'
  32159. */
  32160. export class StringDictionary<T> {
  32161. /**
  32162. * This will clear this dictionary and copy the content from the 'source' one.
  32163. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32164. * @param source the dictionary to take the content from and copy to this dictionary
  32165. */
  32166. copyFrom(source: StringDictionary<T>): void;
  32167. /**
  32168. * Get a value based from its key
  32169. * @param key the given key to get the matching value from
  32170. * @return the value if found, otherwise undefined is returned
  32171. */
  32172. get(key: string): T | undefined;
  32173. /**
  32174. * Get a value from its key or add it if it doesn't exist.
  32175. * This method will ensure you that a given key/data will be present in the dictionary.
  32176. * @param key the given key to get the matching value from
  32177. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32178. * The factory will only be invoked if there's no data for the given key.
  32179. * @return the value corresponding to the key.
  32180. */
  32181. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32182. /**
  32183. * Get a value from its key if present in the dictionary otherwise add it
  32184. * @param key the key to get the value from
  32185. * @param val if there's no such key/value pair in the dictionary add it with this value
  32186. * @return the value corresponding to the key
  32187. */
  32188. getOrAdd(key: string, val: T): T;
  32189. /**
  32190. * Check if there's a given key in the dictionary
  32191. * @param key the key to check for
  32192. * @return true if the key is present, false otherwise
  32193. */
  32194. contains(key: string): boolean;
  32195. /**
  32196. * Add a new key and its corresponding value
  32197. * @param key the key to add
  32198. * @param value the value corresponding to the key
  32199. * @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
  32200. */
  32201. add(key: string, value: T): boolean;
  32202. /**
  32203. * Update a specific value associated to a key
  32204. * @param key defines the key to use
  32205. * @param value defines the value to store
  32206. * @returns true if the value was updated (or false if the key was not found)
  32207. */
  32208. set(key: string, value: T): boolean;
  32209. /**
  32210. * Get the element of the given key and remove it from the dictionary
  32211. * @param key defines the key to search
  32212. * @returns the value associated with the key or null if not found
  32213. */
  32214. getAndRemove(key: string): Nullable<T>;
  32215. /**
  32216. * Remove a key/value from the dictionary.
  32217. * @param key the key to remove
  32218. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32219. */
  32220. remove(key: string): boolean;
  32221. /**
  32222. * Clear the whole content of the dictionary
  32223. */
  32224. clear(): void;
  32225. /**
  32226. * Gets the current count
  32227. */
  32228. readonly count: number;
  32229. /**
  32230. * Execute a callback on each key/val of the dictionary.
  32231. * Note that you can remove any element in this dictionary in the callback implementation
  32232. * @param callback the callback to execute on a given key/value pair
  32233. */
  32234. forEach(callback: (key: string, val: T) => void): void;
  32235. /**
  32236. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32237. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32238. * Note that you can remove any element in this dictionary in the callback implementation
  32239. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32240. * @returns the first item
  32241. */
  32242. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32243. private _count;
  32244. private _data;
  32245. }
  32246. }
  32247. declare module BABYLON {
  32248. /** @hidden */
  32249. export interface ICollisionCoordinator {
  32250. createCollider(): Collider;
  32251. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32252. init(scene: Scene): void;
  32253. }
  32254. /** @hidden */
  32255. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32256. private _scene;
  32257. private _scaledPosition;
  32258. private _scaledVelocity;
  32259. private _finalPosition;
  32260. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32261. createCollider(): Collider;
  32262. init(scene: Scene): void;
  32263. private _collideWithWorld;
  32264. }
  32265. }
  32266. declare module BABYLON {
  32267. /**
  32268. * Class used to manage all inputs for the scene.
  32269. */
  32270. export class InputManager {
  32271. /** The distance in pixel that you have to move to prevent some events */
  32272. static DragMovementThreshold: number;
  32273. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32274. static LongPressDelay: number;
  32275. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32276. static DoubleClickDelay: number;
  32277. /** If you need to check double click without raising a single click at first click, enable this flag */
  32278. static ExclusiveDoubleClickMode: boolean;
  32279. private _wheelEventName;
  32280. private _onPointerMove;
  32281. private _onPointerDown;
  32282. private _onPointerUp;
  32283. private _initClickEvent;
  32284. private _initActionManager;
  32285. private _delayedSimpleClick;
  32286. private _delayedSimpleClickTimeout;
  32287. private _previousDelayedSimpleClickTimeout;
  32288. private _meshPickProceed;
  32289. private _previousButtonPressed;
  32290. private _currentPickResult;
  32291. private _previousPickResult;
  32292. private _totalPointersPressed;
  32293. private _doubleClickOccured;
  32294. private _pointerOverMesh;
  32295. private _pickedDownMesh;
  32296. private _pickedUpMesh;
  32297. private _pointerX;
  32298. private _pointerY;
  32299. private _unTranslatedPointerX;
  32300. private _unTranslatedPointerY;
  32301. private _startingPointerPosition;
  32302. private _previousStartingPointerPosition;
  32303. private _startingPointerTime;
  32304. private _previousStartingPointerTime;
  32305. private _pointerCaptures;
  32306. private _onKeyDown;
  32307. private _onKeyUp;
  32308. private _onCanvasFocusObserver;
  32309. private _onCanvasBlurObserver;
  32310. private _scene;
  32311. /**
  32312. * Creates a new InputManager
  32313. * @param scene defines the hosting scene
  32314. */
  32315. constructor(scene: Scene);
  32316. /**
  32317. * Gets the mesh that is currently under the pointer
  32318. */
  32319. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32320. /**
  32321. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32322. */
  32323. readonly unTranslatedPointer: Vector2;
  32324. /**
  32325. * Gets or sets the current on-screen X position of the pointer
  32326. */
  32327. pointerX: number;
  32328. /**
  32329. * Gets or sets the current on-screen Y position of the pointer
  32330. */
  32331. pointerY: number;
  32332. private _updatePointerPosition;
  32333. private _processPointerMove;
  32334. private _setRayOnPointerInfo;
  32335. private _checkPrePointerObservable;
  32336. /**
  32337. * Use this method to simulate a pointer move on a mesh
  32338. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32339. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32340. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32341. */
  32342. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32343. /**
  32344. * Use this method to simulate a pointer down on a mesh
  32345. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32346. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32347. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32348. */
  32349. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32350. private _processPointerDown;
  32351. /** @hidden */
  32352. _isPointerSwiping(): boolean;
  32353. /**
  32354. * Use this method to simulate a pointer up on a mesh
  32355. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32356. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32357. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32358. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32359. */
  32360. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32361. private _processPointerUp;
  32362. /**
  32363. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32364. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32365. * @returns true if the pointer was captured
  32366. */
  32367. isPointerCaptured(pointerId?: number): boolean;
  32368. /**
  32369. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32370. * @param attachUp defines if you want to attach events to pointerup
  32371. * @param attachDown defines if you want to attach events to pointerdown
  32372. * @param attachMove defines if you want to attach events to pointermove
  32373. */
  32374. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32375. /**
  32376. * Detaches all event handlers
  32377. */
  32378. detachControl(): void;
  32379. /**
  32380. * Force the value of meshUnderPointer
  32381. * @param mesh defines the mesh to use
  32382. */
  32383. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32384. /**
  32385. * Gets the mesh under the pointer
  32386. * @returns a Mesh or null if no mesh is under the pointer
  32387. */
  32388. getPointerOverMesh(): Nullable<AbstractMesh>;
  32389. }
  32390. }
  32391. declare module BABYLON {
  32392. /**
  32393. * Helper class used to generate session unique ID
  32394. */
  32395. export class UniqueIdGenerator {
  32396. private static _UniqueIdCounter;
  32397. /**
  32398. * Gets an unique (relatively to the current scene) Id
  32399. */
  32400. static readonly UniqueId: number;
  32401. }
  32402. }
  32403. declare module BABYLON {
  32404. /**
  32405. * This class defines the direct association between an animation and a target
  32406. */
  32407. export class TargetedAnimation {
  32408. /**
  32409. * Animation to perform
  32410. */
  32411. animation: Animation;
  32412. /**
  32413. * Target to animate
  32414. */
  32415. target: any;
  32416. /**
  32417. * Serialize the object
  32418. * @returns the JSON object representing the current entity
  32419. */
  32420. serialize(): any;
  32421. }
  32422. /**
  32423. * Use this class to create coordinated animations on multiple targets
  32424. */
  32425. export class AnimationGroup implements IDisposable {
  32426. /** The name of the animation group */
  32427. name: string;
  32428. private _scene;
  32429. private _targetedAnimations;
  32430. private _animatables;
  32431. private _from;
  32432. private _to;
  32433. private _isStarted;
  32434. private _isPaused;
  32435. private _speedRatio;
  32436. private _loopAnimation;
  32437. /**
  32438. * Gets or sets the unique id of the node
  32439. */
  32440. uniqueId: number;
  32441. /**
  32442. * This observable will notify when one animation have ended
  32443. */
  32444. onAnimationEndObservable: Observable<TargetedAnimation>;
  32445. /**
  32446. * Observer raised when one animation loops
  32447. */
  32448. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32449. /**
  32450. * This observable will notify when all animations have ended.
  32451. */
  32452. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32453. /**
  32454. * This observable will notify when all animations have paused.
  32455. */
  32456. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32457. /**
  32458. * This observable will notify when all animations are playing.
  32459. */
  32460. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32461. /**
  32462. * Gets the first frame
  32463. */
  32464. readonly from: number;
  32465. /**
  32466. * Gets the last frame
  32467. */
  32468. readonly to: number;
  32469. /**
  32470. * Define if the animations are started
  32471. */
  32472. readonly isStarted: boolean;
  32473. /**
  32474. * Gets a value indicating that the current group is playing
  32475. */
  32476. readonly isPlaying: boolean;
  32477. /**
  32478. * Gets or sets the speed ratio to use for all animations
  32479. */
  32480. /**
  32481. * Gets or sets the speed ratio to use for all animations
  32482. */
  32483. speedRatio: number;
  32484. /**
  32485. * Gets or sets if all animations should loop or not
  32486. */
  32487. loopAnimation: boolean;
  32488. /**
  32489. * Gets the targeted animations for this animation group
  32490. */
  32491. readonly targetedAnimations: Array<TargetedAnimation>;
  32492. /**
  32493. * returning the list of animatables controlled by this animation group.
  32494. */
  32495. readonly animatables: Array<Animatable>;
  32496. /**
  32497. * Instantiates a new Animation Group.
  32498. * This helps managing several animations at once.
  32499. * @see http://doc.babylonjs.com/how_to/group
  32500. * @param name Defines the name of the group
  32501. * @param scene Defines the scene the group belongs to
  32502. */
  32503. constructor(
  32504. /** The name of the animation group */
  32505. name: string, scene?: Nullable<Scene>);
  32506. /**
  32507. * Add an animation (with its target) in the group
  32508. * @param animation defines the animation we want to add
  32509. * @param target defines the target of the animation
  32510. * @returns the TargetedAnimation object
  32511. */
  32512. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32513. /**
  32514. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32515. * It can add constant keys at begin or end
  32516. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32517. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32518. * @returns the animation group
  32519. */
  32520. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32521. /**
  32522. * Start all animations on given targets
  32523. * @param loop defines if animations must loop
  32524. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32525. * @param from defines the from key (optional)
  32526. * @param to defines the to key (optional)
  32527. * @returns the current animation group
  32528. */
  32529. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32530. /**
  32531. * Pause all animations
  32532. * @returns the animation group
  32533. */
  32534. pause(): AnimationGroup;
  32535. /**
  32536. * Play all animations to initial state
  32537. * This function will start() the animations if they were not started or will restart() them if they were paused
  32538. * @param loop defines if animations must loop
  32539. * @returns the animation group
  32540. */
  32541. play(loop?: boolean): AnimationGroup;
  32542. /**
  32543. * Reset all animations to initial state
  32544. * @returns the animation group
  32545. */
  32546. reset(): AnimationGroup;
  32547. /**
  32548. * Restart animations from key 0
  32549. * @returns the animation group
  32550. */
  32551. restart(): AnimationGroup;
  32552. /**
  32553. * Stop all animations
  32554. * @returns the animation group
  32555. */
  32556. stop(): AnimationGroup;
  32557. /**
  32558. * Set animation weight for all animatables
  32559. * @param weight defines the weight to use
  32560. * @return the animationGroup
  32561. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32562. */
  32563. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32564. /**
  32565. * Synchronize and normalize all animatables with a source animatable
  32566. * @param root defines the root animatable to synchronize with
  32567. * @return the animationGroup
  32568. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32569. */
  32570. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32571. /**
  32572. * Goes to a specific frame in this animation group
  32573. * @param frame the frame number to go to
  32574. * @return the animationGroup
  32575. */
  32576. goToFrame(frame: number): AnimationGroup;
  32577. /**
  32578. * Dispose all associated resources
  32579. */
  32580. dispose(): void;
  32581. private _checkAnimationGroupEnded;
  32582. /**
  32583. * Clone the current animation group and returns a copy
  32584. * @param newName defines the name of the new group
  32585. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32586. * @returns the new aniamtion group
  32587. */
  32588. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32589. /**
  32590. * Serializes the animationGroup to an object
  32591. * @returns Serialized object
  32592. */
  32593. serialize(): any;
  32594. /**
  32595. * Returns a new AnimationGroup object parsed from the source provided.
  32596. * @param parsedAnimationGroup defines the source
  32597. * @param scene defines the scene that will receive the animationGroup
  32598. * @returns a new AnimationGroup
  32599. */
  32600. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32601. /**
  32602. * Returns the string "AnimationGroup"
  32603. * @returns "AnimationGroup"
  32604. */
  32605. getClassName(): string;
  32606. /**
  32607. * Creates a detailled string about the object
  32608. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32609. * @returns a string representing the object
  32610. */
  32611. toString(fullDetails?: boolean): string;
  32612. }
  32613. }
  32614. declare module BABYLON {
  32615. /**
  32616. * Define an interface for all classes that will hold resources
  32617. */
  32618. export interface IDisposable {
  32619. /**
  32620. * Releases all held resources
  32621. */
  32622. dispose(): void;
  32623. }
  32624. /** Interface defining initialization parameters for Scene class */
  32625. export interface SceneOptions {
  32626. /**
  32627. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32628. * It will improve performance when the number of geometries becomes important.
  32629. */
  32630. useGeometryUniqueIdsMap?: boolean;
  32631. /**
  32632. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32633. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32634. */
  32635. useMaterialMeshMap?: boolean;
  32636. /**
  32637. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32638. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32639. */
  32640. useClonedMeshhMap?: boolean;
  32641. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32642. virtual?: boolean;
  32643. }
  32644. /**
  32645. * Represents a scene to be rendered by the engine.
  32646. * @see http://doc.babylonjs.com/features/scene
  32647. */
  32648. export class Scene extends AbstractScene implements IAnimatable {
  32649. /** The fog is deactivated */
  32650. static readonly FOGMODE_NONE: number;
  32651. /** The fog density is following an exponential function */
  32652. static readonly FOGMODE_EXP: number;
  32653. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32654. static readonly FOGMODE_EXP2: number;
  32655. /** The fog density is following a linear function. */
  32656. static readonly FOGMODE_LINEAR: number;
  32657. /**
  32658. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32659. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32660. */
  32661. static MinDeltaTime: number;
  32662. /**
  32663. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32665. */
  32666. static MaxDeltaTime: number;
  32667. /**
  32668. * Factory used to create the default material.
  32669. * @param name The name of the material to create
  32670. * @param scene The scene to create the material for
  32671. * @returns The default material
  32672. */
  32673. static DefaultMaterialFactory(scene: Scene): Material;
  32674. /**
  32675. * Factory used to create the a collision coordinator.
  32676. * @returns The collision coordinator
  32677. */
  32678. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32679. /** @hidden */
  32680. _inputManager: InputManager;
  32681. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32682. cameraToUseForPointers: Nullable<Camera>;
  32683. /** @hidden */
  32684. readonly _isScene: boolean;
  32685. /**
  32686. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32687. */
  32688. autoClear: boolean;
  32689. /**
  32690. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32691. */
  32692. autoClearDepthAndStencil: boolean;
  32693. /**
  32694. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32695. */
  32696. clearColor: Color4;
  32697. /**
  32698. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32699. */
  32700. ambientColor: Color3;
  32701. /**
  32702. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32703. * It should only be one of the following (if not the default embedded one):
  32704. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32705. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32706. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32707. * The material properties need to be setup according to the type of texture in use.
  32708. */
  32709. environmentBRDFTexture: BaseTexture;
  32710. /** @hidden */
  32711. protected _environmentTexture: Nullable<BaseTexture>;
  32712. /**
  32713. * Texture used in all pbr material as the reflection texture.
  32714. * As in the majority of the scene they are the same (exception for multi room and so on),
  32715. * this is easier to reference from here than from all the materials.
  32716. */
  32717. /**
  32718. * Texture used in all pbr material as the reflection texture.
  32719. * As in the majority of the scene they are the same (exception for multi room and so on),
  32720. * this is easier to set here than in all the materials.
  32721. */
  32722. environmentTexture: Nullable<BaseTexture>;
  32723. /** @hidden */
  32724. protected _environmentIntensity: number;
  32725. /**
  32726. * Intensity of the environment in all pbr material.
  32727. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32728. * As in the majority of the scene they are the same (exception for multi room and so on),
  32729. * this is easier to reference from here than from all the materials.
  32730. */
  32731. /**
  32732. * Intensity of the environment in all pbr material.
  32733. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32734. * As in the majority of the scene they are the same (exception for multi room and so on),
  32735. * this is easier to set here than in all the materials.
  32736. */
  32737. environmentIntensity: number;
  32738. /** @hidden */
  32739. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32740. /**
  32741. * Default image processing configuration used either in the rendering
  32742. * Forward main pass or through the imageProcessingPostProcess if present.
  32743. * As in the majority of the scene they are the same (exception for multi camera),
  32744. * this is easier to reference from here than from all the materials and post process.
  32745. *
  32746. * No setter as we it is a shared configuration, you can set the values instead.
  32747. */
  32748. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32749. private _forceWireframe;
  32750. /**
  32751. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32752. */
  32753. forceWireframe: boolean;
  32754. private _forcePointsCloud;
  32755. /**
  32756. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32757. */
  32758. forcePointsCloud: boolean;
  32759. /**
  32760. * Gets or sets the active clipplane 1
  32761. */
  32762. clipPlane: Nullable<Plane>;
  32763. /**
  32764. * Gets or sets the active clipplane 2
  32765. */
  32766. clipPlane2: Nullable<Plane>;
  32767. /**
  32768. * Gets or sets the active clipplane 3
  32769. */
  32770. clipPlane3: Nullable<Plane>;
  32771. /**
  32772. * Gets or sets the active clipplane 4
  32773. */
  32774. clipPlane4: Nullable<Plane>;
  32775. /**
  32776. * Gets or sets a boolean indicating if animations are enabled
  32777. */
  32778. animationsEnabled: boolean;
  32779. private _animationPropertiesOverride;
  32780. /**
  32781. * Gets or sets the animation properties override
  32782. */
  32783. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32784. /**
  32785. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32786. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32787. */
  32788. useConstantAnimationDeltaTime: boolean;
  32789. /**
  32790. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32791. * Please note that it requires to run a ray cast through the scene on every frame
  32792. */
  32793. constantlyUpdateMeshUnderPointer: boolean;
  32794. /**
  32795. * Defines the HTML cursor to use when hovering over interactive elements
  32796. */
  32797. hoverCursor: string;
  32798. /**
  32799. * Defines the HTML default cursor to use (empty by default)
  32800. */
  32801. defaultCursor: string;
  32802. /**
  32803. * This is used to call preventDefault() on pointer down
  32804. * in order to block unwanted artifacts like system double clicks
  32805. */
  32806. preventDefaultOnPointerDown: boolean;
  32807. /**
  32808. * This is used to call preventDefault() on pointer up
  32809. * in order to block unwanted artifacts like system double clicks
  32810. */
  32811. preventDefaultOnPointerUp: boolean;
  32812. /**
  32813. * Gets or sets user defined metadata
  32814. */
  32815. metadata: any;
  32816. /**
  32817. * For internal use only. Please do not use.
  32818. */
  32819. reservedDataStore: any;
  32820. /**
  32821. * Gets the name of the plugin used to load this scene (null by default)
  32822. */
  32823. loadingPluginName: string;
  32824. /**
  32825. * Use this array to add regular expressions used to disable offline support for specific urls
  32826. */
  32827. disableOfflineSupportExceptionRules: RegExp[];
  32828. /**
  32829. * An event triggered when the scene is disposed.
  32830. */
  32831. onDisposeObservable: Observable<Scene>;
  32832. private _onDisposeObserver;
  32833. /** Sets a function to be executed when this scene is disposed. */
  32834. onDispose: () => void;
  32835. /**
  32836. * An event triggered before rendering the scene (right after animations and physics)
  32837. */
  32838. onBeforeRenderObservable: Observable<Scene>;
  32839. private _onBeforeRenderObserver;
  32840. /** Sets a function to be executed before rendering this scene */
  32841. beforeRender: Nullable<() => void>;
  32842. /**
  32843. * An event triggered after rendering the scene
  32844. */
  32845. onAfterRenderObservable: Observable<Scene>;
  32846. /**
  32847. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32848. */
  32849. onAfterRenderCameraObservable: Observable<Camera>;
  32850. private _onAfterRenderObserver;
  32851. /** Sets a function to be executed after rendering this scene */
  32852. afterRender: Nullable<() => void>;
  32853. /**
  32854. * An event triggered before animating the scene
  32855. */
  32856. onBeforeAnimationsObservable: Observable<Scene>;
  32857. /**
  32858. * An event triggered after animations processing
  32859. */
  32860. onAfterAnimationsObservable: Observable<Scene>;
  32861. /**
  32862. * An event triggered before draw calls are ready to be sent
  32863. */
  32864. onBeforeDrawPhaseObservable: Observable<Scene>;
  32865. /**
  32866. * An event triggered after draw calls have been sent
  32867. */
  32868. onAfterDrawPhaseObservable: Observable<Scene>;
  32869. /**
  32870. * An event triggered when the scene is ready
  32871. */
  32872. onReadyObservable: Observable<Scene>;
  32873. /**
  32874. * An event triggered before rendering a camera
  32875. */
  32876. onBeforeCameraRenderObservable: Observable<Camera>;
  32877. private _onBeforeCameraRenderObserver;
  32878. /** Sets a function to be executed before rendering a camera*/
  32879. beforeCameraRender: () => void;
  32880. /**
  32881. * An event triggered after rendering a camera
  32882. */
  32883. onAfterCameraRenderObservable: Observable<Camera>;
  32884. private _onAfterCameraRenderObserver;
  32885. /** Sets a function to be executed after rendering a camera*/
  32886. afterCameraRender: () => void;
  32887. /**
  32888. * An event triggered when active meshes evaluation is about to start
  32889. */
  32890. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32891. /**
  32892. * An event triggered when active meshes evaluation is done
  32893. */
  32894. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32895. /**
  32896. * An event triggered when particles rendering is about to start
  32897. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32898. */
  32899. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32900. /**
  32901. * An event triggered when particles rendering is done
  32902. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32903. */
  32904. onAfterParticlesRenderingObservable: Observable<Scene>;
  32905. /**
  32906. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32907. */
  32908. onDataLoadedObservable: Observable<Scene>;
  32909. /**
  32910. * An event triggered when a camera is created
  32911. */
  32912. onNewCameraAddedObservable: Observable<Camera>;
  32913. /**
  32914. * An event triggered when a camera is removed
  32915. */
  32916. onCameraRemovedObservable: Observable<Camera>;
  32917. /**
  32918. * An event triggered when a light is created
  32919. */
  32920. onNewLightAddedObservable: Observable<Light>;
  32921. /**
  32922. * An event triggered when a light is removed
  32923. */
  32924. onLightRemovedObservable: Observable<Light>;
  32925. /**
  32926. * An event triggered when a geometry is created
  32927. */
  32928. onNewGeometryAddedObservable: Observable<Geometry>;
  32929. /**
  32930. * An event triggered when a geometry is removed
  32931. */
  32932. onGeometryRemovedObservable: Observable<Geometry>;
  32933. /**
  32934. * An event triggered when a transform node is created
  32935. */
  32936. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32937. /**
  32938. * An event triggered when a transform node is removed
  32939. */
  32940. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32941. /**
  32942. * An event triggered when a mesh is created
  32943. */
  32944. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32945. /**
  32946. * An event triggered when a mesh is removed
  32947. */
  32948. onMeshRemovedObservable: Observable<AbstractMesh>;
  32949. /**
  32950. * An event triggered when a skeleton is created
  32951. */
  32952. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32953. /**
  32954. * An event triggered when a skeleton is removed
  32955. */
  32956. onSkeletonRemovedObservable: Observable<Skeleton>;
  32957. /**
  32958. * An event triggered when a material is created
  32959. */
  32960. onNewMaterialAddedObservable: Observable<Material>;
  32961. /**
  32962. * An event triggered when a material is removed
  32963. */
  32964. onMaterialRemovedObservable: Observable<Material>;
  32965. /**
  32966. * An event triggered when a texture is created
  32967. */
  32968. onNewTextureAddedObservable: Observable<BaseTexture>;
  32969. /**
  32970. * An event triggered when a texture is removed
  32971. */
  32972. onTextureRemovedObservable: Observable<BaseTexture>;
  32973. /**
  32974. * An event triggered when render targets are about to be rendered
  32975. * Can happen multiple times per frame.
  32976. */
  32977. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32978. /**
  32979. * An event triggered when render targets were rendered.
  32980. * Can happen multiple times per frame.
  32981. */
  32982. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32983. /**
  32984. * An event triggered before calculating deterministic simulation step
  32985. */
  32986. onBeforeStepObservable: Observable<Scene>;
  32987. /**
  32988. * An event triggered after calculating deterministic simulation step
  32989. */
  32990. onAfterStepObservable: Observable<Scene>;
  32991. /**
  32992. * An event triggered when the activeCamera property is updated
  32993. */
  32994. onActiveCameraChanged: Observable<Scene>;
  32995. /**
  32996. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32997. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32998. * 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)
  32999. */
  33000. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33001. /**
  33002. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33003. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33004. * 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)
  33005. */
  33006. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33007. /**
  33008. * This Observable will when a mesh has been imported into the scene.
  33009. */
  33010. onMeshImportedObservable: Observable<AbstractMesh>;
  33011. /**
  33012. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33013. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33014. */
  33015. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33016. /** @hidden */
  33017. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33018. /**
  33019. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33020. */
  33021. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33022. /**
  33023. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33024. */
  33025. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33026. /**
  33027. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33028. */
  33029. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33030. /** Callback called when a pointer move is detected */
  33031. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33032. /** Callback called when a pointer down is detected */
  33033. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33034. /** Callback called when a pointer up is detected */
  33035. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33036. /** Callback called when a pointer pick is detected */
  33037. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33038. /**
  33039. * 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).
  33040. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33041. */
  33042. onPrePointerObservable: Observable<PointerInfoPre>;
  33043. /**
  33044. * Observable event triggered each time an input event is received from the rendering canvas
  33045. */
  33046. onPointerObservable: Observable<PointerInfo>;
  33047. /**
  33048. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33049. */
  33050. readonly unTranslatedPointer: Vector2;
  33051. /**
  33052. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33053. */
  33054. static DragMovementThreshold: number;
  33055. /**
  33056. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33057. */
  33058. static LongPressDelay: number;
  33059. /**
  33060. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33061. */
  33062. static DoubleClickDelay: number;
  33063. /** If you need to check double click without raising a single click at first click, enable this flag */
  33064. static ExclusiveDoubleClickMode: boolean;
  33065. /** @hidden */
  33066. _mirroredCameraPosition: Nullable<Vector3>;
  33067. /**
  33068. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33069. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33070. */
  33071. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33072. /**
  33073. * Observable event triggered each time an keyboard event is received from the hosting window
  33074. */
  33075. onKeyboardObservable: Observable<KeyboardInfo>;
  33076. private _useRightHandedSystem;
  33077. /**
  33078. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33079. */
  33080. useRightHandedSystem: boolean;
  33081. private _timeAccumulator;
  33082. private _currentStepId;
  33083. private _currentInternalStep;
  33084. /**
  33085. * Sets the step Id used by deterministic lock step
  33086. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33087. * @param newStepId defines the step Id
  33088. */
  33089. setStepId(newStepId: number): void;
  33090. /**
  33091. * Gets the step Id used by deterministic lock step
  33092. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33093. * @returns the step Id
  33094. */
  33095. getStepId(): number;
  33096. /**
  33097. * Gets the internal step used by deterministic lock step
  33098. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33099. * @returns the internal step
  33100. */
  33101. getInternalStep(): number;
  33102. private _fogEnabled;
  33103. /**
  33104. * Gets or sets a boolean indicating if fog is enabled on this scene
  33105. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33106. * (Default is true)
  33107. */
  33108. fogEnabled: boolean;
  33109. private _fogMode;
  33110. /**
  33111. * Gets or sets the fog mode to use
  33112. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33113. * | mode | value |
  33114. * | --- | --- |
  33115. * | FOGMODE_NONE | 0 |
  33116. * | FOGMODE_EXP | 1 |
  33117. * | FOGMODE_EXP2 | 2 |
  33118. * | FOGMODE_LINEAR | 3 |
  33119. */
  33120. fogMode: number;
  33121. /**
  33122. * Gets or sets the fog color to use
  33123. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33124. * (Default is Color3(0.2, 0.2, 0.3))
  33125. */
  33126. fogColor: Color3;
  33127. /**
  33128. * Gets or sets the fog density to use
  33129. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33130. * (Default is 0.1)
  33131. */
  33132. fogDensity: number;
  33133. /**
  33134. * Gets or sets the fog start distance to use
  33135. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33136. * (Default is 0)
  33137. */
  33138. fogStart: number;
  33139. /**
  33140. * Gets or sets the fog end distance to use
  33141. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33142. * (Default is 1000)
  33143. */
  33144. fogEnd: number;
  33145. private _shadowsEnabled;
  33146. /**
  33147. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33148. */
  33149. shadowsEnabled: boolean;
  33150. private _lightsEnabled;
  33151. /**
  33152. * Gets or sets a boolean indicating if lights are enabled on this scene
  33153. */
  33154. lightsEnabled: boolean;
  33155. /** All of the active cameras added to this scene. */
  33156. activeCameras: Camera[];
  33157. /** @hidden */
  33158. _activeCamera: Nullable<Camera>;
  33159. /** Gets or sets the current active camera */
  33160. activeCamera: Nullable<Camera>;
  33161. private _defaultMaterial;
  33162. /** The default material used on meshes when no material is affected */
  33163. /** The default material used on meshes when no material is affected */
  33164. defaultMaterial: Material;
  33165. private _texturesEnabled;
  33166. /**
  33167. * Gets or sets a boolean indicating if textures are enabled on this scene
  33168. */
  33169. texturesEnabled: boolean;
  33170. /**
  33171. * Gets or sets a boolean indicating if particles are enabled on this scene
  33172. */
  33173. particlesEnabled: boolean;
  33174. /**
  33175. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33176. */
  33177. spritesEnabled: boolean;
  33178. private _skeletonsEnabled;
  33179. /**
  33180. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33181. */
  33182. skeletonsEnabled: boolean;
  33183. /**
  33184. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33185. */
  33186. lensFlaresEnabled: boolean;
  33187. /**
  33188. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33190. */
  33191. collisionsEnabled: boolean;
  33192. private _collisionCoordinator;
  33193. /** @hidden */
  33194. readonly collisionCoordinator: ICollisionCoordinator;
  33195. /**
  33196. * Defines the gravity applied to this scene (used only for collisions)
  33197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33198. */
  33199. gravity: Vector3;
  33200. /**
  33201. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33202. */
  33203. postProcessesEnabled: boolean;
  33204. /**
  33205. * The list of postprocesses added to the scene
  33206. */
  33207. postProcesses: PostProcess[];
  33208. /**
  33209. * Gets the current postprocess manager
  33210. */
  33211. postProcessManager: PostProcessManager;
  33212. /**
  33213. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33214. */
  33215. renderTargetsEnabled: boolean;
  33216. /**
  33217. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33218. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33219. */
  33220. dumpNextRenderTargets: boolean;
  33221. /**
  33222. * The list of user defined render targets added to the scene
  33223. */
  33224. customRenderTargets: RenderTargetTexture[];
  33225. /**
  33226. * Defines if texture loading must be delayed
  33227. * If true, textures will only be loaded when they need to be rendered
  33228. */
  33229. useDelayedTextureLoading: boolean;
  33230. /**
  33231. * Gets the list of meshes imported to the scene through SceneLoader
  33232. */
  33233. importedMeshesFiles: String[];
  33234. /**
  33235. * Gets or sets a boolean indicating if probes are enabled on this scene
  33236. */
  33237. probesEnabled: boolean;
  33238. /**
  33239. * Gets or sets the current offline provider to use to store scene data
  33240. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33241. */
  33242. offlineProvider: IOfflineProvider;
  33243. /**
  33244. * Gets or sets the action manager associated with the scene
  33245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33246. */
  33247. actionManager: AbstractActionManager;
  33248. private _meshesForIntersections;
  33249. /**
  33250. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33251. */
  33252. proceduralTexturesEnabled: boolean;
  33253. private _engine;
  33254. private _totalVertices;
  33255. /** @hidden */
  33256. _activeIndices: PerfCounter;
  33257. /** @hidden */
  33258. _activeParticles: PerfCounter;
  33259. /** @hidden */
  33260. _activeBones: PerfCounter;
  33261. private _animationRatio;
  33262. /** @hidden */
  33263. _animationTimeLast: number;
  33264. /** @hidden */
  33265. _animationTime: number;
  33266. /**
  33267. * Gets or sets a general scale for animation speed
  33268. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33269. */
  33270. animationTimeScale: number;
  33271. /** @hidden */
  33272. _cachedMaterial: Nullable<Material>;
  33273. /** @hidden */
  33274. _cachedEffect: Nullable<Effect>;
  33275. /** @hidden */
  33276. _cachedVisibility: Nullable<number>;
  33277. private _renderId;
  33278. private _frameId;
  33279. private _executeWhenReadyTimeoutId;
  33280. private _intermediateRendering;
  33281. private _viewUpdateFlag;
  33282. private _projectionUpdateFlag;
  33283. /** @hidden */
  33284. _toBeDisposed: Nullable<IDisposable>[];
  33285. private _activeRequests;
  33286. /** @hidden */
  33287. _pendingData: any[];
  33288. private _isDisposed;
  33289. /**
  33290. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33291. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33292. */
  33293. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33294. private _activeMeshes;
  33295. private _processedMaterials;
  33296. private _renderTargets;
  33297. /** @hidden */
  33298. _activeParticleSystems: SmartArray<IParticleSystem>;
  33299. private _activeSkeletons;
  33300. private _softwareSkinnedMeshes;
  33301. private _renderingManager;
  33302. /** @hidden */
  33303. _activeAnimatables: Animatable[];
  33304. private _transformMatrix;
  33305. private _sceneUbo;
  33306. /** @hidden */
  33307. _viewMatrix: Matrix;
  33308. private _projectionMatrix;
  33309. /** @hidden */
  33310. _forcedViewPosition: Nullable<Vector3>;
  33311. /** @hidden */
  33312. _frustumPlanes: Plane[];
  33313. /**
  33314. * Gets the list of frustum planes (built from the active camera)
  33315. */
  33316. readonly frustumPlanes: Plane[];
  33317. /**
  33318. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33319. * This is useful if there are more lights that the maximum simulteanous authorized
  33320. */
  33321. requireLightSorting: boolean;
  33322. /** @hidden */
  33323. readonly useMaterialMeshMap: boolean;
  33324. /** @hidden */
  33325. readonly useClonedMeshhMap: boolean;
  33326. private _externalData;
  33327. private _uid;
  33328. /**
  33329. * @hidden
  33330. * Backing store of defined scene components.
  33331. */
  33332. _components: ISceneComponent[];
  33333. /**
  33334. * @hidden
  33335. * Backing store of defined scene components.
  33336. */
  33337. _serializableComponents: ISceneSerializableComponent[];
  33338. /**
  33339. * List of components to register on the next registration step.
  33340. */
  33341. private _transientComponents;
  33342. /**
  33343. * Registers the transient components if needed.
  33344. */
  33345. private _registerTransientComponents;
  33346. /**
  33347. * @hidden
  33348. * Add a component to the scene.
  33349. * Note that the ccomponent could be registered on th next frame if this is called after
  33350. * the register component stage.
  33351. * @param component Defines the component to add to the scene
  33352. */
  33353. _addComponent(component: ISceneComponent): void;
  33354. /**
  33355. * @hidden
  33356. * Gets a component from the scene.
  33357. * @param name defines the name of the component to retrieve
  33358. * @returns the component or null if not present
  33359. */
  33360. _getComponent(name: string): Nullable<ISceneComponent>;
  33361. /**
  33362. * @hidden
  33363. * Defines the actions happening before camera updates.
  33364. */
  33365. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33366. /**
  33367. * @hidden
  33368. * Defines the actions happening before clear the canvas.
  33369. */
  33370. _beforeClearStage: Stage<SimpleStageAction>;
  33371. /**
  33372. * @hidden
  33373. * Defines the actions when collecting render targets for the frame.
  33374. */
  33375. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33376. /**
  33377. * @hidden
  33378. * Defines the actions happening for one camera in the frame.
  33379. */
  33380. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33381. /**
  33382. * @hidden
  33383. * Defines the actions happening during the per mesh ready checks.
  33384. */
  33385. _isReadyForMeshStage: Stage<MeshStageAction>;
  33386. /**
  33387. * @hidden
  33388. * Defines the actions happening before evaluate active mesh checks.
  33389. */
  33390. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33391. /**
  33392. * @hidden
  33393. * Defines the actions happening during the evaluate sub mesh checks.
  33394. */
  33395. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33396. /**
  33397. * @hidden
  33398. * Defines the actions happening during the active mesh stage.
  33399. */
  33400. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33401. /**
  33402. * @hidden
  33403. * Defines the actions happening during the per camera render target step.
  33404. */
  33405. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33406. /**
  33407. * @hidden
  33408. * Defines the actions happening just before the active camera is drawing.
  33409. */
  33410. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33411. /**
  33412. * @hidden
  33413. * Defines the actions happening just before a render target is drawing.
  33414. */
  33415. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33416. /**
  33417. * @hidden
  33418. * Defines the actions happening just before a rendering group is drawing.
  33419. */
  33420. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33421. /**
  33422. * @hidden
  33423. * Defines the actions happening just before a mesh is drawing.
  33424. */
  33425. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33426. /**
  33427. * @hidden
  33428. * Defines the actions happening just after a mesh has been drawn.
  33429. */
  33430. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33431. /**
  33432. * @hidden
  33433. * Defines the actions happening just after a rendering group has been drawn.
  33434. */
  33435. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33436. /**
  33437. * @hidden
  33438. * Defines the actions happening just after the active camera has been drawn.
  33439. */
  33440. _afterCameraDrawStage: Stage<CameraStageAction>;
  33441. /**
  33442. * @hidden
  33443. * Defines the actions happening just after a render target has been drawn.
  33444. */
  33445. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33446. /**
  33447. * @hidden
  33448. * Defines the actions happening just after rendering all cameras and computing intersections.
  33449. */
  33450. _afterRenderStage: Stage<SimpleStageAction>;
  33451. /**
  33452. * @hidden
  33453. * Defines the actions happening when a pointer move event happens.
  33454. */
  33455. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33456. /**
  33457. * @hidden
  33458. * Defines the actions happening when a pointer down event happens.
  33459. */
  33460. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33461. /**
  33462. * @hidden
  33463. * Defines the actions happening when a pointer up event happens.
  33464. */
  33465. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33466. /**
  33467. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33468. */
  33469. private geometriesByUniqueId;
  33470. /**
  33471. * Creates a new Scene
  33472. * @param engine defines the engine to use to render this scene
  33473. * @param options defines the scene options
  33474. */
  33475. constructor(engine: Engine, options?: SceneOptions);
  33476. /**
  33477. * Gets a string idenfifying the name of the class
  33478. * @returns "Scene" string
  33479. */
  33480. getClassName(): string;
  33481. private _defaultMeshCandidates;
  33482. /**
  33483. * @hidden
  33484. */
  33485. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33486. private _defaultSubMeshCandidates;
  33487. /**
  33488. * @hidden
  33489. */
  33490. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33491. /**
  33492. * Sets the default candidate providers for the scene.
  33493. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33494. * and getCollidingSubMeshCandidates to their default function
  33495. */
  33496. setDefaultCandidateProviders(): void;
  33497. /**
  33498. * Gets the mesh that is currently under the pointer
  33499. */
  33500. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33501. /**
  33502. * Gets or sets the current on-screen X position of the pointer
  33503. */
  33504. pointerX: number;
  33505. /**
  33506. * Gets or sets the current on-screen Y position of the pointer
  33507. */
  33508. pointerY: number;
  33509. /**
  33510. * Gets the cached material (ie. the latest rendered one)
  33511. * @returns the cached material
  33512. */
  33513. getCachedMaterial(): Nullable<Material>;
  33514. /**
  33515. * Gets the cached effect (ie. the latest rendered one)
  33516. * @returns the cached effect
  33517. */
  33518. getCachedEffect(): Nullable<Effect>;
  33519. /**
  33520. * Gets the cached visibility state (ie. the latest rendered one)
  33521. * @returns the cached visibility state
  33522. */
  33523. getCachedVisibility(): Nullable<number>;
  33524. /**
  33525. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33526. * @param material defines the current material
  33527. * @param effect defines the current effect
  33528. * @param visibility defines the current visibility state
  33529. * @returns true if one parameter is not cached
  33530. */
  33531. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33532. /**
  33533. * Gets the engine associated with the scene
  33534. * @returns an Engine
  33535. */
  33536. getEngine(): Engine;
  33537. /**
  33538. * Gets the total number of vertices rendered per frame
  33539. * @returns the total number of vertices rendered per frame
  33540. */
  33541. getTotalVertices(): number;
  33542. /**
  33543. * Gets the performance counter for total vertices
  33544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33545. */
  33546. readonly totalVerticesPerfCounter: PerfCounter;
  33547. /**
  33548. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33549. * @returns the total number of active indices rendered per frame
  33550. */
  33551. getActiveIndices(): number;
  33552. /**
  33553. * Gets the performance counter for active indices
  33554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33555. */
  33556. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33557. /**
  33558. * Gets the total number of active particles rendered per frame
  33559. * @returns the total number of active particles rendered per frame
  33560. */
  33561. getActiveParticles(): number;
  33562. /**
  33563. * Gets the performance counter for active particles
  33564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33565. */
  33566. readonly activeParticlesPerfCounter: PerfCounter;
  33567. /**
  33568. * Gets the total number of active bones rendered per frame
  33569. * @returns the total number of active bones rendered per frame
  33570. */
  33571. getActiveBones(): number;
  33572. /**
  33573. * Gets the performance counter for active bones
  33574. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33575. */
  33576. readonly activeBonesPerfCounter: PerfCounter;
  33577. /**
  33578. * Gets the array of active meshes
  33579. * @returns an array of AbstractMesh
  33580. */
  33581. getActiveMeshes(): SmartArray<AbstractMesh>;
  33582. /**
  33583. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33584. * @returns a number
  33585. */
  33586. getAnimationRatio(): number;
  33587. /**
  33588. * Gets an unique Id for the current render phase
  33589. * @returns a number
  33590. */
  33591. getRenderId(): number;
  33592. /**
  33593. * Gets an unique Id for the current frame
  33594. * @returns a number
  33595. */
  33596. getFrameId(): number;
  33597. /** Call this function if you want to manually increment the render Id*/
  33598. incrementRenderId(): void;
  33599. private _createUbo;
  33600. /**
  33601. * Use this method to simulate a pointer move on a mesh
  33602. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33603. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33604. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33605. * @returns the current scene
  33606. */
  33607. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33608. /**
  33609. * Use this method to simulate a pointer down on a mesh
  33610. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33611. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33612. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33613. * @returns the current scene
  33614. */
  33615. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33616. /**
  33617. * Use this method to simulate a pointer up on a mesh
  33618. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33619. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33620. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33621. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33622. * @returns the current scene
  33623. */
  33624. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33625. /**
  33626. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33627. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33628. * @returns true if the pointer was captured
  33629. */
  33630. isPointerCaptured(pointerId?: number): boolean;
  33631. /**
  33632. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33633. * @param attachUp defines if you want to attach events to pointerup
  33634. * @param attachDown defines if you want to attach events to pointerdown
  33635. * @param attachMove defines if you want to attach events to pointermove
  33636. */
  33637. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33638. /** Detaches all event handlers*/
  33639. detachControl(): void;
  33640. /**
  33641. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33642. * Delay loaded resources are not taking in account
  33643. * @return true if all required resources are ready
  33644. */
  33645. isReady(): boolean;
  33646. /** Resets all cached information relative to material (including effect and visibility) */
  33647. resetCachedMaterial(): void;
  33648. /**
  33649. * Registers a function to be called before every frame render
  33650. * @param func defines the function to register
  33651. */
  33652. registerBeforeRender(func: () => void): void;
  33653. /**
  33654. * Unregisters a function called before every frame render
  33655. * @param func defines the function to unregister
  33656. */
  33657. unregisterBeforeRender(func: () => void): void;
  33658. /**
  33659. * Registers a function to be called after every frame render
  33660. * @param func defines the function to register
  33661. */
  33662. registerAfterRender(func: () => void): void;
  33663. /**
  33664. * Unregisters a function called after every frame render
  33665. * @param func defines the function to unregister
  33666. */
  33667. unregisterAfterRender(func: () => void): void;
  33668. private _executeOnceBeforeRender;
  33669. /**
  33670. * The provided function will run before render once and will be disposed afterwards.
  33671. * A timeout delay can be provided so that the function will be executed in N ms.
  33672. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33673. * @param func The function to be executed.
  33674. * @param timeout optional delay in ms
  33675. */
  33676. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33677. /** @hidden */
  33678. _addPendingData(data: any): void;
  33679. /** @hidden */
  33680. _removePendingData(data: any): void;
  33681. /**
  33682. * Returns the number of items waiting to be loaded
  33683. * @returns the number of items waiting to be loaded
  33684. */
  33685. getWaitingItemsCount(): number;
  33686. /**
  33687. * Returns a boolean indicating if the scene is still loading data
  33688. */
  33689. readonly isLoading: boolean;
  33690. /**
  33691. * Registers a function to be executed when the scene is ready
  33692. * @param {Function} func - the function to be executed
  33693. */
  33694. executeWhenReady(func: () => void): void;
  33695. /**
  33696. * Returns a promise that resolves when the scene is ready
  33697. * @returns A promise that resolves when the scene is ready
  33698. */
  33699. whenReadyAsync(): Promise<void>;
  33700. /** @hidden */
  33701. _checkIsReady(): void;
  33702. /**
  33703. * Gets all animatable attached to the scene
  33704. */
  33705. readonly animatables: Animatable[];
  33706. /**
  33707. * Resets the last animation time frame.
  33708. * Useful to override when animations start running when loading a scene for the first time.
  33709. */
  33710. resetLastAnimationTimeFrame(): void;
  33711. /**
  33712. * Gets the current view matrix
  33713. * @returns a Matrix
  33714. */
  33715. getViewMatrix(): Matrix;
  33716. /**
  33717. * Gets the current projection matrix
  33718. * @returns a Matrix
  33719. */
  33720. getProjectionMatrix(): Matrix;
  33721. /**
  33722. * Gets the current transform matrix
  33723. * @returns a Matrix made of View * Projection
  33724. */
  33725. getTransformMatrix(): Matrix;
  33726. /**
  33727. * Sets the current transform matrix
  33728. * @param viewL defines the View matrix to use
  33729. * @param projectionL defines the Projection matrix to use
  33730. * @param viewR defines the right View matrix to use (if provided)
  33731. * @param projectionR defines the right Projection matrix to use (if provided)
  33732. */
  33733. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33734. /**
  33735. * Gets the uniform buffer used to store scene data
  33736. * @returns a UniformBuffer
  33737. */
  33738. getSceneUniformBuffer(): UniformBuffer;
  33739. /**
  33740. * Gets an unique (relatively to the current scene) Id
  33741. * @returns an unique number for the scene
  33742. */
  33743. getUniqueId(): number;
  33744. /**
  33745. * Add a mesh to the list of scene's meshes
  33746. * @param newMesh defines the mesh to add
  33747. * @param recursive if all child meshes should also be added to the scene
  33748. */
  33749. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33750. /**
  33751. * Remove a mesh for the list of scene's meshes
  33752. * @param toRemove defines the mesh to remove
  33753. * @param recursive if all child meshes should also be removed from the scene
  33754. * @returns the index where the mesh was in the mesh list
  33755. */
  33756. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33757. /**
  33758. * Add a transform node to the list of scene's transform nodes
  33759. * @param newTransformNode defines the transform node to add
  33760. */
  33761. addTransformNode(newTransformNode: TransformNode): void;
  33762. /**
  33763. * Remove a transform node for the list of scene's transform nodes
  33764. * @param toRemove defines the transform node to remove
  33765. * @returns the index where the transform node was in the transform node list
  33766. */
  33767. removeTransformNode(toRemove: TransformNode): number;
  33768. /**
  33769. * Remove a skeleton for the list of scene's skeletons
  33770. * @param toRemove defines the skeleton to remove
  33771. * @returns the index where the skeleton was in the skeleton list
  33772. */
  33773. removeSkeleton(toRemove: Skeleton): number;
  33774. /**
  33775. * Remove a morph target for the list of scene's morph targets
  33776. * @param toRemove defines the morph target to remove
  33777. * @returns the index where the morph target was in the morph target list
  33778. */
  33779. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33780. /**
  33781. * Remove a light for the list of scene's lights
  33782. * @param toRemove defines the light to remove
  33783. * @returns the index where the light was in the light list
  33784. */
  33785. removeLight(toRemove: Light): number;
  33786. /**
  33787. * Remove a camera for the list of scene's cameras
  33788. * @param toRemove defines the camera to remove
  33789. * @returns the index where the camera was in the camera list
  33790. */
  33791. removeCamera(toRemove: Camera): number;
  33792. /**
  33793. * Remove a particle system for the list of scene's particle systems
  33794. * @param toRemove defines the particle system to remove
  33795. * @returns the index where the particle system was in the particle system list
  33796. */
  33797. removeParticleSystem(toRemove: IParticleSystem): number;
  33798. /**
  33799. * Remove a animation for the list of scene's animations
  33800. * @param toRemove defines the animation to remove
  33801. * @returns the index where the animation was in the animation list
  33802. */
  33803. removeAnimation(toRemove: Animation): number;
  33804. /**
  33805. * Will stop the animation of the given target
  33806. * @param target - the target
  33807. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33808. * @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)
  33809. */
  33810. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33811. /**
  33812. * Removes the given animation group from this scene.
  33813. * @param toRemove The animation group to remove
  33814. * @returns The index of the removed animation group
  33815. */
  33816. removeAnimationGroup(toRemove: AnimationGroup): number;
  33817. /**
  33818. * Removes the given multi-material from this scene.
  33819. * @param toRemove The multi-material to remove
  33820. * @returns The index of the removed multi-material
  33821. */
  33822. removeMultiMaterial(toRemove: MultiMaterial): number;
  33823. /**
  33824. * Removes the given material from this scene.
  33825. * @param toRemove The material to remove
  33826. * @returns The index of the removed material
  33827. */
  33828. removeMaterial(toRemove: Material): number;
  33829. /**
  33830. * Removes the given action manager from this scene.
  33831. * @param toRemove The action manager to remove
  33832. * @returns The index of the removed action manager
  33833. */
  33834. removeActionManager(toRemove: AbstractActionManager): number;
  33835. /**
  33836. * Removes the given texture from this scene.
  33837. * @param toRemove The texture to remove
  33838. * @returns The index of the removed texture
  33839. */
  33840. removeTexture(toRemove: BaseTexture): number;
  33841. /**
  33842. * Adds the given light to this scene
  33843. * @param newLight The light to add
  33844. */
  33845. addLight(newLight: Light): void;
  33846. /**
  33847. * Sorts the list list based on light priorities
  33848. */
  33849. sortLightsByPriority(): void;
  33850. /**
  33851. * Adds the given camera to this scene
  33852. * @param newCamera The camera to add
  33853. */
  33854. addCamera(newCamera: Camera): void;
  33855. /**
  33856. * Adds the given skeleton to this scene
  33857. * @param newSkeleton The skeleton to add
  33858. */
  33859. addSkeleton(newSkeleton: Skeleton): void;
  33860. /**
  33861. * Adds the given particle system to this scene
  33862. * @param newParticleSystem The particle system to add
  33863. */
  33864. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33865. /**
  33866. * Adds the given animation to this scene
  33867. * @param newAnimation The animation to add
  33868. */
  33869. addAnimation(newAnimation: Animation): void;
  33870. /**
  33871. * Adds the given animation group to this scene.
  33872. * @param newAnimationGroup The animation group to add
  33873. */
  33874. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33875. /**
  33876. * Adds the given multi-material to this scene
  33877. * @param newMultiMaterial The multi-material to add
  33878. */
  33879. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33880. /**
  33881. * Adds the given material to this scene
  33882. * @param newMaterial The material to add
  33883. */
  33884. addMaterial(newMaterial: Material): void;
  33885. /**
  33886. * Adds the given morph target to this scene
  33887. * @param newMorphTargetManager The morph target to add
  33888. */
  33889. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33890. /**
  33891. * Adds the given geometry to this scene
  33892. * @param newGeometry The geometry to add
  33893. */
  33894. addGeometry(newGeometry: Geometry): void;
  33895. /**
  33896. * Adds the given action manager to this scene
  33897. * @param newActionManager The action manager to add
  33898. */
  33899. addActionManager(newActionManager: AbstractActionManager): void;
  33900. /**
  33901. * Adds the given texture to this scene.
  33902. * @param newTexture The texture to add
  33903. */
  33904. addTexture(newTexture: BaseTexture): void;
  33905. /**
  33906. * Switch active camera
  33907. * @param newCamera defines the new active camera
  33908. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33909. */
  33910. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33911. /**
  33912. * sets the active camera of the scene using its ID
  33913. * @param id defines the camera's ID
  33914. * @return the new active camera or null if none found.
  33915. */
  33916. setActiveCameraByID(id: string): Nullable<Camera>;
  33917. /**
  33918. * sets the active camera of the scene using its name
  33919. * @param name defines the camera's name
  33920. * @returns the new active camera or null if none found.
  33921. */
  33922. setActiveCameraByName(name: string): Nullable<Camera>;
  33923. /**
  33924. * get an animation group using its name
  33925. * @param name defines the material's name
  33926. * @return the animation group or null if none found.
  33927. */
  33928. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33929. /**
  33930. * Get a material using its unique id
  33931. * @param uniqueId defines the material's unique id
  33932. * @return the material or null if none found.
  33933. */
  33934. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33935. /**
  33936. * get a material using its id
  33937. * @param id defines the material's ID
  33938. * @return the material or null if none found.
  33939. */
  33940. getMaterialByID(id: string): Nullable<Material>;
  33941. /**
  33942. * Gets a the last added material using a given id
  33943. * @param id defines the material's ID
  33944. * @return the last material with the given id or null if none found.
  33945. */
  33946. getLastMaterialByID(id: string): Nullable<Material>;
  33947. /**
  33948. * Gets a material using its name
  33949. * @param name defines the material's name
  33950. * @return the material or null if none found.
  33951. */
  33952. getMaterialByName(name: string): Nullable<Material>;
  33953. /**
  33954. * Get a texture using its unique id
  33955. * @param uniqueId defines the texture's unique id
  33956. * @return the texture or null if none found.
  33957. */
  33958. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33959. /**
  33960. * Gets a camera using its id
  33961. * @param id defines the id to look for
  33962. * @returns the camera or null if not found
  33963. */
  33964. getCameraByID(id: string): Nullable<Camera>;
  33965. /**
  33966. * Gets a camera using its unique id
  33967. * @param uniqueId defines the unique id to look for
  33968. * @returns the camera or null if not found
  33969. */
  33970. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33971. /**
  33972. * Gets a camera using its name
  33973. * @param name defines the camera's name
  33974. * @return the camera or null if none found.
  33975. */
  33976. getCameraByName(name: string): Nullable<Camera>;
  33977. /**
  33978. * Gets a bone using its id
  33979. * @param id defines the bone's id
  33980. * @return the bone or null if not found
  33981. */
  33982. getBoneByID(id: string): Nullable<Bone>;
  33983. /**
  33984. * Gets a bone using its id
  33985. * @param name defines the bone's name
  33986. * @return the bone or null if not found
  33987. */
  33988. getBoneByName(name: string): Nullable<Bone>;
  33989. /**
  33990. * Gets a light node using its name
  33991. * @param name defines the the light's name
  33992. * @return the light or null if none found.
  33993. */
  33994. getLightByName(name: string): Nullable<Light>;
  33995. /**
  33996. * Gets a light node using its id
  33997. * @param id defines the light's id
  33998. * @return the light or null if none found.
  33999. */
  34000. getLightByID(id: string): Nullable<Light>;
  34001. /**
  34002. * Gets a light node using its scene-generated unique ID
  34003. * @param uniqueId defines the light's unique id
  34004. * @return the light or null if none found.
  34005. */
  34006. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34007. /**
  34008. * Gets a particle system by id
  34009. * @param id defines the particle system id
  34010. * @return the corresponding system or null if none found
  34011. */
  34012. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34013. /**
  34014. * Gets a geometry using its ID
  34015. * @param id defines the geometry's id
  34016. * @return the geometry or null if none found.
  34017. */
  34018. getGeometryByID(id: string): Nullable<Geometry>;
  34019. private _getGeometryByUniqueID;
  34020. /**
  34021. * Add a new geometry to this scene
  34022. * @param geometry defines the geometry to be added to the scene.
  34023. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34024. * @return a boolean defining if the geometry was added or not
  34025. */
  34026. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34027. /**
  34028. * Removes an existing geometry
  34029. * @param geometry defines the geometry to be removed from the scene
  34030. * @return a boolean defining if the geometry was removed or not
  34031. */
  34032. removeGeometry(geometry: Geometry): boolean;
  34033. /**
  34034. * Gets the list of geometries attached to the scene
  34035. * @returns an array of Geometry
  34036. */
  34037. getGeometries(): Geometry[];
  34038. /**
  34039. * Gets the first added mesh found of a given ID
  34040. * @param id defines the id to search for
  34041. * @return the mesh found or null if not found at all
  34042. */
  34043. getMeshByID(id: string): Nullable<AbstractMesh>;
  34044. /**
  34045. * Gets a list of meshes using their id
  34046. * @param id defines the id to search for
  34047. * @returns a list of meshes
  34048. */
  34049. getMeshesByID(id: string): Array<AbstractMesh>;
  34050. /**
  34051. * Gets the first added transform node found of a given ID
  34052. * @param id defines the id to search for
  34053. * @return the found transform node or null if not found at all.
  34054. */
  34055. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34056. /**
  34057. * Gets a transform node with its auto-generated unique id
  34058. * @param uniqueId efines the unique id to search for
  34059. * @return the found transform node or null if not found at all.
  34060. */
  34061. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34062. /**
  34063. * Gets a list of transform nodes using their id
  34064. * @param id defines the id to search for
  34065. * @returns a list of transform nodes
  34066. */
  34067. getTransformNodesByID(id: string): Array<TransformNode>;
  34068. /**
  34069. * Gets a mesh with its auto-generated unique id
  34070. * @param uniqueId defines the unique id to search for
  34071. * @return the found mesh or null if not found at all.
  34072. */
  34073. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34074. /**
  34075. * Gets a the last added mesh using a given id
  34076. * @param id defines the id to search for
  34077. * @return the found mesh or null if not found at all.
  34078. */
  34079. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34080. /**
  34081. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34082. * @param id defines the id to search for
  34083. * @return the found node or null if not found at all
  34084. */
  34085. getLastEntryByID(id: string): Nullable<Node>;
  34086. /**
  34087. * Gets a node (Mesh, Camera, Light) using a given id
  34088. * @param id defines the id to search for
  34089. * @return the found node or null if not found at all
  34090. */
  34091. getNodeByID(id: string): Nullable<Node>;
  34092. /**
  34093. * Gets a node (Mesh, Camera, Light) using a given name
  34094. * @param name defines the name to search for
  34095. * @return the found node or null if not found at all.
  34096. */
  34097. getNodeByName(name: string): Nullable<Node>;
  34098. /**
  34099. * Gets a mesh using a given name
  34100. * @param name defines the name to search for
  34101. * @return the found mesh or null if not found at all.
  34102. */
  34103. getMeshByName(name: string): Nullable<AbstractMesh>;
  34104. /**
  34105. * Gets a transform node using a given name
  34106. * @param name defines the name to search for
  34107. * @return the found transform node or null if not found at all.
  34108. */
  34109. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34110. /**
  34111. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34112. * @param id defines the id to search for
  34113. * @return the found skeleton or null if not found at all.
  34114. */
  34115. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34116. /**
  34117. * Gets a skeleton using a given auto generated unique id
  34118. * @param uniqueId defines the unique id to search for
  34119. * @return the found skeleton or null if not found at all.
  34120. */
  34121. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34122. /**
  34123. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34124. * @param id defines the id to search for
  34125. * @return the found skeleton or null if not found at all.
  34126. */
  34127. getSkeletonById(id: string): Nullable<Skeleton>;
  34128. /**
  34129. * Gets a skeleton using a given name
  34130. * @param name defines the name to search for
  34131. * @return the found skeleton or null if not found at all.
  34132. */
  34133. getSkeletonByName(name: string): Nullable<Skeleton>;
  34134. /**
  34135. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34136. * @param id defines the id to search for
  34137. * @return the found morph target manager or null if not found at all.
  34138. */
  34139. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34140. /**
  34141. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34142. * @param id defines the id to search for
  34143. * @return the found morph target or null if not found at all.
  34144. */
  34145. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34146. /**
  34147. * Gets a boolean indicating if the given mesh is active
  34148. * @param mesh defines the mesh to look for
  34149. * @returns true if the mesh is in the active list
  34150. */
  34151. isActiveMesh(mesh: AbstractMesh): boolean;
  34152. /**
  34153. * Return a unique id as a string which can serve as an identifier for the scene
  34154. */
  34155. readonly uid: string;
  34156. /**
  34157. * Add an externaly attached data from its key.
  34158. * This method call will fail and return false, if such key already exists.
  34159. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34160. * @param key the unique key that identifies the data
  34161. * @param data the data object to associate to the key for this Engine instance
  34162. * @return true if no such key were already present and the data was added successfully, false otherwise
  34163. */
  34164. addExternalData<T>(key: string, data: T): boolean;
  34165. /**
  34166. * Get an externaly attached data from its key
  34167. * @param key the unique key that identifies the data
  34168. * @return the associated data, if present (can be null), or undefined if not present
  34169. */
  34170. getExternalData<T>(key: string): Nullable<T>;
  34171. /**
  34172. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34173. * @param key the unique key that identifies the data
  34174. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34175. * @return the associated data, can be null if the factory returned null.
  34176. */
  34177. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34178. /**
  34179. * Remove an externaly attached data from the Engine instance
  34180. * @param key the unique key that identifies the data
  34181. * @return true if the data was successfully removed, false if it doesn't exist
  34182. */
  34183. removeExternalData(key: string): boolean;
  34184. private _evaluateSubMesh;
  34185. /**
  34186. * Clear the processed materials smart array preventing retention point in material dispose.
  34187. */
  34188. freeProcessedMaterials(): void;
  34189. private _preventFreeActiveMeshesAndRenderingGroups;
  34190. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34191. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34192. * when disposing several meshes in a row or a hierarchy of meshes.
  34193. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34194. */
  34195. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34196. /**
  34197. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34198. */
  34199. freeActiveMeshes(): void;
  34200. /**
  34201. * Clear the info related to rendering groups preventing retention points during dispose.
  34202. */
  34203. freeRenderingGroups(): void;
  34204. /** @hidden */
  34205. _isInIntermediateRendering(): boolean;
  34206. /**
  34207. * Lambda returning the list of potentially active meshes.
  34208. */
  34209. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34210. /**
  34211. * Lambda returning the list of potentially active sub meshes.
  34212. */
  34213. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34214. /**
  34215. * Lambda returning the list of potentially intersecting sub meshes.
  34216. */
  34217. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34218. /**
  34219. * Lambda returning the list of potentially colliding sub meshes.
  34220. */
  34221. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34222. private _activeMeshesFrozen;
  34223. /**
  34224. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34225. * @returns the current scene
  34226. */
  34227. freezeActiveMeshes(): Scene;
  34228. /**
  34229. * Use this function to restart evaluating active meshes on every frame
  34230. * @returns the current scene
  34231. */
  34232. unfreezeActiveMeshes(): Scene;
  34233. private _evaluateActiveMeshes;
  34234. private _activeMesh;
  34235. /**
  34236. * Update the transform matrix to update from the current active camera
  34237. * @param force defines a boolean used to force the update even if cache is up to date
  34238. */
  34239. updateTransformMatrix(force?: boolean): void;
  34240. private _bindFrameBuffer;
  34241. /** @hidden */
  34242. _allowPostProcessClearColor: boolean;
  34243. /** @hidden */
  34244. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34245. private _processSubCameras;
  34246. private _checkIntersections;
  34247. /** @hidden */
  34248. _advancePhysicsEngineStep(step: number): void;
  34249. /**
  34250. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34251. */
  34252. getDeterministicFrameTime: () => number;
  34253. /** @hidden */
  34254. _animate(): void;
  34255. /** Execute all animations (for a frame) */
  34256. animate(): void;
  34257. /**
  34258. * Render the scene
  34259. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34260. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34261. */
  34262. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34263. /**
  34264. * Freeze all materials
  34265. * A frozen material will not be updatable but should be faster to render
  34266. */
  34267. freezeMaterials(): void;
  34268. /**
  34269. * Unfreeze all materials
  34270. * A frozen material will not be updatable but should be faster to render
  34271. */
  34272. unfreezeMaterials(): void;
  34273. /**
  34274. * Releases all held ressources
  34275. */
  34276. dispose(): void;
  34277. /**
  34278. * Gets if the scene is already disposed
  34279. */
  34280. readonly isDisposed: boolean;
  34281. /**
  34282. * Call this function to reduce memory footprint of the scene.
  34283. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34284. */
  34285. clearCachedVertexData(): void;
  34286. /**
  34287. * This function will remove the local cached buffer data from texture.
  34288. * It will save memory but will prevent the texture from being rebuilt
  34289. */
  34290. cleanCachedTextureBuffer(): void;
  34291. /**
  34292. * Get the world extend vectors with an optional filter
  34293. *
  34294. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34295. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34296. */
  34297. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34298. min: Vector3;
  34299. max: Vector3;
  34300. };
  34301. /**
  34302. * Creates a ray that can be used to pick in the scene
  34303. * @param x defines the x coordinate of the origin (on-screen)
  34304. * @param y defines the y coordinate of the origin (on-screen)
  34305. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34306. * @param camera defines the camera to use for the picking
  34307. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34308. * @returns a Ray
  34309. */
  34310. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34311. /**
  34312. * Creates a ray that can be used to pick in the scene
  34313. * @param x defines the x coordinate of the origin (on-screen)
  34314. * @param y defines the y coordinate of the origin (on-screen)
  34315. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34316. * @param result defines the ray where to store the picking ray
  34317. * @param camera defines the camera to use for the picking
  34318. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34319. * @returns the current scene
  34320. */
  34321. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34322. /**
  34323. * Creates a ray that can be used to pick in the scene
  34324. * @param x defines the x coordinate of the origin (on-screen)
  34325. * @param y defines the y coordinate of the origin (on-screen)
  34326. * @param camera defines the camera to use for the picking
  34327. * @returns a Ray
  34328. */
  34329. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34330. /**
  34331. * Creates a ray that can be used to pick in the scene
  34332. * @param x defines the x coordinate of the origin (on-screen)
  34333. * @param y defines the y coordinate of the origin (on-screen)
  34334. * @param result defines the ray where to store the picking ray
  34335. * @param camera defines the camera to use for the picking
  34336. * @returns the current scene
  34337. */
  34338. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34339. /** Launch a ray to try to pick a mesh in the scene
  34340. * @param x position on screen
  34341. * @param y position on screen
  34342. * @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
  34343. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34344. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34345. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34346. * @returns a PickingInfo
  34347. */
  34348. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34349. /** Use the given ray to pick a mesh in the scene
  34350. * @param ray The ray to use to pick meshes
  34351. * @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
  34352. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34353. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34354. * @returns a PickingInfo
  34355. */
  34356. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34357. /**
  34358. * Launch a ray to try to pick a mesh in the scene
  34359. * @param x X position on screen
  34360. * @param y Y position on screen
  34361. * @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
  34362. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34363. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34364. * @returns an array of PickingInfo
  34365. */
  34366. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34367. /**
  34368. * Launch a ray to try to pick a mesh in the scene
  34369. * @param ray Ray to use
  34370. * @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
  34371. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34372. * @returns an array of PickingInfo
  34373. */
  34374. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34375. /**
  34376. * Force the value of meshUnderPointer
  34377. * @param mesh defines the mesh to use
  34378. */
  34379. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34380. /**
  34381. * Gets the mesh under the pointer
  34382. * @returns a Mesh or null if no mesh is under the pointer
  34383. */
  34384. getPointerOverMesh(): Nullable<AbstractMesh>;
  34385. /** @hidden */
  34386. _rebuildGeometries(): void;
  34387. /** @hidden */
  34388. _rebuildTextures(): void;
  34389. private _getByTags;
  34390. /**
  34391. * Get a list of meshes by tags
  34392. * @param tagsQuery defines the tags query to use
  34393. * @param forEach defines a predicate used to filter results
  34394. * @returns an array of Mesh
  34395. */
  34396. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34397. /**
  34398. * Get a list of cameras by tags
  34399. * @param tagsQuery defines the tags query to use
  34400. * @param forEach defines a predicate used to filter results
  34401. * @returns an array of Camera
  34402. */
  34403. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34404. /**
  34405. * Get a list of lights by tags
  34406. * @param tagsQuery defines the tags query to use
  34407. * @param forEach defines a predicate used to filter results
  34408. * @returns an array of Light
  34409. */
  34410. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34411. /**
  34412. * Get a list of materials by tags
  34413. * @param tagsQuery defines the tags query to use
  34414. * @param forEach defines a predicate used to filter results
  34415. * @returns an array of Material
  34416. */
  34417. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34418. /**
  34419. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34420. * This allowed control for front to back rendering or reversly depending of the special needs.
  34421. *
  34422. * @param renderingGroupId The rendering group id corresponding to its index
  34423. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34424. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34425. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34426. */
  34427. 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;
  34428. /**
  34429. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34430. *
  34431. * @param renderingGroupId The rendering group id corresponding to its index
  34432. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34433. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34434. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34435. */
  34436. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34437. /**
  34438. * Gets the current auto clear configuration for one rendering group of the rendering
  34439. * manager.
  34440. * @param index the rendering group index to get the information for
  34441. * @returns The auto clear setup for the requested rendering group
  34442. */
  34443. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34444. private _blockMaterialDirtyMechanism;
  34445. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34446. blockMaterialDirtyMechanism: boolean;
  34447. /**
  34448. * Will flag all materials as dirty to trigger new shader compilation
  34449. * @param flag defines the flag used to specify which material part must be marked as dirty
  34450. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34451. */
  34452. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34453. /** @hidden */
  34454. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34455. /** @hidden */
  34456. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34457. }
  34458. }
  34459. declare module BABYLON {
  34460. /**
  34461. * Set of assets to keep when moving a scene into an asset container.
  34462. */
  34463. export class KeepAssets extends AbstractScene {
  34464. }
  34465. /**
  34466. * Container with a set of assets that can be added or removed from a scene.
  34467. */
  34468. export class AssetContainer extends AbstractScene {
  34469. /**
  34470. * The scene the AssetContainer belongs to.
  34471. */
  34472. scene: Scene;
  34473. /**
  34474. * Instantiates an AssetContainer.
  34475. * @param scene The scene the AssetContainer belongs to.
  34476. */
  34477. constructor(scene: Scene);
  34478. /**
  34479. * Adds all the assets from the container to the scene.
  34480. */
  34481. addAllToScene(): void;
  34482. /**
  34483. * Removes all the assets in the container from the scene
  34484. */
  34485. removeAllFromScene(): void;
  34486. /**
  34487. * Disposes all the assets in the container
  34488. */
  34489. dispose(): void;
  34490. private _moveAssets;
  34491. /**
  34492. * Removes all the assets contained in the scene and adds them to the container.
  34493. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34494. */
  34495. moveAllFromScene(keepAssets?: KeepAssets): void;
  34496. /**
  34497. * 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.
  34498. * @returns the root mesh
  34499. */
  34500. createRootMesh(): Mesh;
  34501. }
  34502. }
  34503. declare module BABYLON {
  34504. /**
  34505. * Defines how the parser contract is defined.
  34506. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34507. */
  34508. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34509. /**
  34510. * Defines how the individual parser contract is defined.
  34511. * These parser can parse an individual asset
  34512. */
  34513. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34514. /**
  34515. * Base class of the scene acting as a container for the different elements composing a scene.
  34516. * This class is dynamically extended by the different components of the scene increasing
  34517. * flexibility and reducing coupling
  34518. */
  34519. export abstract class AbstractScene {
  34520. /**
  34521. * Stores the list of available parsers in the application.
  34522. */
  34523. private static _BabylonFileParsers;
  34524. /**
  34525. * Stores the list of available individual parsers in the application.
  34526. */
  34527. private static _IndividualBabylonFileParsers;
  34528. /**
  34529. * Adds a parser in the list of available ones
  34530. * @param name Defines the name of the parser
  34531. * @param parser Defines the parser to add
  34532. */
  34533. static AddParser(name: string, parser: BabylonFileParser): void;
  34534. /**
  34535. * Gets a general parser from the list of avaialble ones
  34536. * @param name Defines the name of the parser
  34537. * @returns the requested parser or null
  34538. */
  34539. static GetParser(name: string): Nullable<BabylonFileParser>;
  34540. /**
  34541. * Adds n individual parser in the list of available ones
  34542. * @param name Defines the name of the parser
  34543. * @param parser Defines the parser to add
  34544. */
  34545. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34546. /**
  34547. * Gets an individual parser from the list of avaialble ones
  34548. * @param name Defines the name of the parser
  34549. * @returns the requested parser or null
  34550. */
  34551. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34552. /**
  34553. * Parser json data and populate both a scene and its associated container object
  34554. * @param jsonData Defines the data to parse
  34555. * @param scene Defines the scene to parse the data for
  34556. * @param container Defines the container attached to the parsing sequence
  34557. * @param rootUrl Defines the root url of the data
  34558. */
  34559. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34560. /**
  34561. * Gets the list of root nodes (ie. nodes with no parent)
  34562. */
  34563. rootNodes: Node[];
  34564. /** All of the cameras added to this scene
  34565. * @see http://doc.babylonjs.com/babylon101/cameras
  34566. */
  34567. cameras: Camera[];
  34568. /**
  34569. * All of the lights added to this scene
  34570. * @see http://doc.babylonjs.com/babylon101/lights
  34571. */
  34572. lights: Light[];
  34573. /**
  34574. * All of the (abstract) meshes added to this scene
  34575. */
  34576. meshes: AbstractMesh[];
  34577. /**
  34578. * The list of skeletons added to the scene
  34579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34580. */
  34581. skeletons: Skeleton[];
  34582. /**
  34583. * All of the particle systems added to this scene
  34584. * @see http://doc.babylonjs.com/babylon101/particles
  34585. */
  34586. particleSystems: IParticleSystem[];
  34587. /**
  34588. * Gets a list of Animations associated with the scene
  34589. */
  34590. animations: Animation[];
  34591. /**
  34592. * All of the animation groups added to this scene
  34593. * @see http://doc.babylonjs.com/how_to/group
  34594. */
  34595. animationGroups: AnimationGroup[];
  34596. /**
  34597. * All of the multi-materials added to this scene
  34598. * @see http://doc.babylonjs.com/how_to/multi_materials
  34599. */
  34600. multiMaterials: MultiMaterial[];
  34601. /**
  34602. * All of the materials added to this scene
  34603. * In the context of a Scene, it is not supposed to be modified manually.
  34604. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34605. * Note also that the order of the Material wihin the array is not significant and might change.
  34606. * @see http://doc.babylonjs.com/babylon101/materials
  34607. */
  34608. materials: Material[];
  34609. /**
  34610. * The list of morph target managers added to the scene
  34611. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34612. */
  34613. morphTargetManagers: MorphTargetManager[];
  34614. /**
  34615. * The list of geometries used in the scene.
  34616. */
  34617. geometries: Geometry[];
  34618. /**
  34619. * All of the tranform nodes added to this scene
  34620. * In the context of a Scene, it is not supposed to be modified manually.
  34621. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34622. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34623. * @see http://doc.babylonjs.com/how_to/transformnode
  34624. */
  34625. transformNodes: TransformNode[];
  34626. /**
  34627. * ActionManagers available on the scene.
  34628. */
  34629. actionManagers: AbstractActionManager[];
  34630. /**
  34631. * Textures to keep.
  34632. */
  34633. textures: BaseTexture[];
  34634. /**
  34635. * Environment texture for the scene
  34636. */
  34637. environmentTexture: Nullable<BaseTexture>;
  34638. }
  34639. }
  34640. declare module BABYLON {
  34641. /**
  34642. * Interface used to define options for Sound class
  34643. */
  34644. export interface ISoundOptions {
  34645. /**
  34646. * Does the sound autoplay once loaded.
  34647. */
  34648. autoplay?: boolean;
  34649. /**
  34650. * Does the sound loop after it finishes playing once.
  34651. */
  34652. loop?: boolean;
  34653. /**
  34654. * Sound's volume
  34655. */
  34656. volume?: number;
  34657. /**
  34658. * Is it a spatial sound?
  34659. */
  34660. spatialSound?: boolean;
  34661. /**
  34662. * Maximum distance to hear that sound
  34663. */
  34664. maxDistance?: number;
  34665. /**
  34666. * Uses user defined attenuation function
  34667. */
  34668. useCustomAttenuation?: boolean;
  34669. /**
  34670. * Define the roll off factor of spatial sounds.
  34671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34672. */
  34673. rolloffFactor?: number;
  34674. /**
  34675. * Define the reference distance the sound should be heard perfectly.
  34676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34677. */
  34678. refDistance?: number;
  34679. /**
  34680. * Define the distance attenuation model the sound will follow.
  34681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34682. */
  34683. distanceModel?: string;
  34684. /**
  34685. * Defines the playback speed (1 by default)
  34686. */
  34687. playbackRate?: number;
  34688. /**
  34689. * Defines if the sound is from a streaming source
  34690. */
  34691. streaming?: boolean;
  34692. /**
  34693. * Defines an optional length (in seconds) inside the sound file
  34694. */
  34695. length?: number;
  34696. /**
  34697. * Defines an optional offset (in seconds) inside the sound file
  34698. */
  34699. offset?: number;
  34700. /**
  34701. * If true, URLs will not be required to state the audio file codec to use.
  34702. */
  34703. skipCodecCheck?: boolean;
  34704. }
  34705. /**
  34706. * Defines a sound that can be played in the application.
  34707. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34709. */
  34710. export class Sound {
  34711. /**
  34712. * The name of the sound in the scene.
  34713. */
  34714. name: string;
  34715. /**
  34716. * Does the sound autoplay once loaded.
  34717. */
  34718. autoplay: boolean;
  34719. /**
  34720. * Does the sound loop after it finishes playing once.
  34721. */
  34722. loop: boolean;
  34723. /**
  34724. * Does the sound use a custom attenuation curve to simulate the falloff
  34725. * happening when the source gets further away from the camera.
  34726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34727. */
  34728. useCustomAttenuation: boolean;
  34729. /**
  34730. * The sound track id this sound belongs to.
  34731. */
  34732. soundTrackId: number;
  34733. /**
  34734. * Is this sound currently played.
  34735. */
  34736. isPlaying: boolean;
  34737. /**
  34738. * Is this sound currently paused.
  34739. */
  34740. isPaused: boolean;
  34741. /**
  34742. * Does this sound enables spatial sound.
  34743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34744. */
  34745. spatialSound: boolean;
  34746. /**
  34747. * Define the reference distance the sound should be heard perfectly.
  34748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34749. */
  34750. refDistance: number;
  34751. /**
  34752. * Define the roll off factor of spatial sounds.
  34753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34754. */
  34755. rolloffFactor: number;
  34756. /**
  34757. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34759. */
  34760. maxDistance: number;
  34761. /**
  34762. * Define the distance attenuation model the sound will follow.
  34763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34764. */
  34765. distanceModel: string;
  34766. /**
  34767. * @hidden
  34768. * Back Compat
  34769. **/
  34770. onended: () => any;
  34771. /**
  34772. * Observable event when the current playing sound finishes.
  34773. */
  34774. onEndedObservable: Observable<Sound>;
  34775. private _panningModel;
  34776. private _playbackRate;
  34777. private _streaming;
  34778. private _startTime;
  34779. private _startOffset;
  34780. private _position;
  34781. /** @hidden */
  34782. _positionInEmitterSpace: boolean;
  34783. private _localDirection;
  34784. private _volume;
  34785. private _isReadyToPlay;
  34786. private _isDirectional;
  34787. private _readyToPlayCallback;
  34788. private _audioBuffer;
  34789. private _soundSource;
  34790. private _streamingSource;
  34791. private _soundPanner;
  34792. private _soundGain;
  34793. private _inputAudioNode;
  34794. private _outputAudioNode;
  34795. private _coneInnerAngle;
  34796. private _coneOuterAngle;
  34797. private _coneOuterGain;
  34798. private _scene;
  34799. private _connectedTransformNode;
  34800. private _customAttenuationFunction;
  34801. private _registerFunc;
  34802. private _isOutputConnected;
  34803. private _htmlAudioElement;
  34804. private _urlType;
  34805. private _length?;
  34806. private _offset?;
  34807. /** @hidden */
  34808. static _SceneComponentInitialization: (scene: Scene) => void;
  34809. /**
  34810. * Create a sound and attach it to a scene
  34811. * @param name Name of your sound
  34812. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34813. * @param scene defines the scene the sound belongs to
  34814. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34815. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34816. */
  34817. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34818. /**
  34819. * Release the sound and its associated resources
  34820. */
  34821. dispose(): void;
  34822. /**
  34823. * Gets if the sounds is ready to be played or not.
  34824. * @returns true if ready, otherwise false
  34825. */
  34826. isReady(): boolean;
  34827. private _soundLoaded;
  34828. /**
  34829. * Sets the data of the sound from an audiobuffer
  34830. * @param audioBuffer The audioBuffer containing the data
  34831. */
  34832. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34833. /**
  34834. * Updates the current sounds options such as maxdistance, loop...
  34835. * @param options A JSON object containing values named as the object properties
  34836. */
  34837. updateOptions(options: ISoundOptions): void;
  34838. private _createSpatialParameters;
  34839. private _updateSpatialParameters;
  34840. /**
  34841. * Switch the panning model to HRTF:
  34842. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34844. */
  34845. switchPanningModelToHRTF(): void;
  34846. /**
  34847. * Switch the panning model to Equal Power:
  34848. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34850. */
  34851. switchPanningModelToEqualPower(): void;
  34852. private _switchPanningModel;
  34853. /**
  34854. * Connect this sound to a sound track audio node like gain...
  34855. * @param soundTrackAudioNode the sound track audio node to connect to
  34856. */
  34857. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34858. /**
  34859. * Transform this sound into a directional source
  34860. * @param coneInnerAngle Size of the inner cone in degree
  34861. * @param coneOuterAngle Size of the outer cone in degree
  34862. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34863. */
  34864. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34865. /**
  34866. * Gets or sets the inner angle for the directional cone.
  34867. */
  34868. /**
  34869. * Gets or sets the inner angle for the directional cone.
  34870. */
  34871. directionalConeInnerAngle: number;
  34872. /**
  34873. * Gets or sets the outer angle for the directional cone.
  34874. */
  34875. /**
  34876. * Gets or sets the outer angle for the directional cone.
  34877. */
  34878. directionalConeOuterAngle: number;
  34879. /**
  34880. * Sets the position of the emitter if spatial sound is enabled
  34881. * @param newPosition Defines the new posisiton
  34882. */
  34883. setPosition(newPosition: Vector3): void;
  34884. /**
  34885. * Sets the local direction of the emitter if spatial sound is enabled
  34886. * @param newLocalDirection Defines the new local direction
  34887. */
  34888. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34889. private _updateDirection;
  34890. /** @hidden */
  34891. updateDistanceFromListener(): void;
  34892. /**
  34893. * Sets a new custom attenuation function for the sound.
  34894. * @param callback Defines the function used for the attenuation
  34895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34896. */
  34897. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34898. /**
  34899. * Play the sound
  34900. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34901. * @param offset (optional) Start the sound at a specific time in seconds
  34902. * @param length (optional) Sound duration (in seconds)
  34903. */
  34904. play(time?: number, offset?: number, length?: number): void;
  34905. private _onended;
  34906. /**
  34907. * Stop the sound
  34908. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34909. */
  34910. stop(time?: number): void;
  34911. /**
  34912. * Put the sound in pause
  34913. */
  34914. pause(): void;
  34915. /**
  34916. * Sets a dedicated volume for this sounds
  34917. * @param newVolume Define the new volume of the sound
  34918. * @param time Define time for gradual change to new volume
  34919. */
  34920. setVolume(newVolume: number, time?: number): void;
  34921. /**
  34922. * Set the sound play back rate
  34923. * @param newPlaybackRate Define the playback rate the sound should be played at
  34924. */
  34925. setPlaybackRate(newPlaybackRate: number): void;
  34926. /**
  34927. * Gets the volume of the sound.
  34928. * @returns the volume of the sound
  34929. */
  34930. getVolume(): number;
  34931. /**
  34932. * Attach the sound to a dedicated mesh
  34933. * @param transformNode The transform node to connect the sound with
  34934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34935. */
  34936. attachToMesh(transformNode: TransformNode): void;
  34937. /**
  34938. * Detach the sound from the previously attached mesh
  34939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34940. */
  34941. detachFromMesh(): void;
  34942. private _onRegisterAfterWorldMatrixUpdate;
  34943. /**
  34944. * Clone the current sound in the scene.
  34945. * @returns the new sound clone
  34946. */
  34947. clone(): Nullable<Sound>;
  34948. /**
  34949. * Gets the current underlying audio buffer containing the data
  34950. * @returns the audio buffer
  34951. */
  34952. getAudioBuffer(): Nullable<AudioBuffer>;
  34953. /**
  34954. * Serializes the Sound in a JSON representation
  34955. * @returns the JSON representation of the sound
  34956. */
  34957. serialize(): any;
  34958. /**
  34959. * Parse a JSON representation of a sound to innstantiate in a given scene
  34960. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34961. * @param scene Define the scene the new parsed sound should be created in
  34962. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34963. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34964. * @returns the newly parsed sound
  34965. */
  34966. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34967. }
  34968. }
  34969. declare module BABYLON {
  34970. /**
  34971. * This defines an action helpful to play a defined sound on a triggered action.
  34972. */
  34973. export class PlaySoundAction extends Action {
  34974. private _sound;
  34975. /**
  34976. * Instantiate the action
  34977. * @param triggerOptions defines the trigger options
  34978. * @param sound defines the sound to play
  34979. * @param condition defines the trigger related conditions
  34980. */
  34981. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34982. /** @hidden */
  34983. _prepare(): void;
  34984. /**
  34985. * Execute the action and play the sound.
  34986. */
  34987. execute(): void;
  34988. /**
  34989. * Serializes the actions and its related information.
  34990. * @param parent defines the object to serialize in
  34991. * @returns the serialized object
  34992. */
  34993. serialize(parent: any): any;
  34994. }
  34995. /**
  34996. * This defines an action helpful to stop a defined sound on a triggered action.
  34997. */
  34998. export class StopSoundAction extends Action {
  34999. private _sound;
  35000. /**
  35001. * Instantiate the action
  35002. * @param triggerOptions defines the trigger options
  35003. * @param sound defines the sound to stop
  35004. * @param condition defines the trigger related conditions
  35005. */
  35006. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35007. /** @hidden */
  35008. _prepare(): void;
  35009. /**
  35010. * Execute the action and stop the sound.
  35011. */
  35012. execute(): void;
  35013. /**
  35014. * Serializes the actions and its related information.
  35015. * @param parent defines the object to serialize in
  35016. * @returns the serialized object
  35017. */
  35018. serialize(parent: any): any;
  35019. }
  35020. }
  35021. declare module BABYLON {
  35022. /**
  35023. * This defines an action responsible to change the value of a property
  35024. * by interpolating between its current value and the newly set one once triggered.
  35025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35026. */
  35027. export class InterpolateValueAction extends Action {
  35028. /**
  35029. * Defines the path of the property where the value should be interpolated
  35030. */
  35031. propertyPath: string;
  35032. /**
  35033. * Defines the target value at the end of the interpolation.
  35034. */
  35035. value: any;
  35036. /**
  35037. * Defines the time it will take for the property to interpolate to the value.
  35038. */
  35039. duration: number;
  35040. /**
  35041. * Defines if the other scene animations should be stopped when the action has been triggered
  35042. */
  35043. stopOtherAnimations?: boolean;
  35044. /**
  35045. * Defines a callback raised once the interpolation animation has been done.
  35046. */
  35047. onInterpolationDone?: () => void;
  35048. /**
  35049. * Observable triggered once the interpolation animation has been done.
  35050. */
  35051. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35052. private _target;
  35053. private _effectiveTarget;
  35054. private _property;
  35055. /**
  35056. * Instantiate the action
  35057. * @param triggerOptions defines the trigger options
  35058. * @param target defines the object containing the value to interpolate
  35059. * @param propertyPath defines the path to the property in the target object
  35060. * @param value defines the target value at the end of the interpolation
  35061. * @param duration deines the time it will take for the property to interpolate to the value.
  35062. * @param condition defines the trigger related conditions
  35063. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35064. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35065. */
  35066. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35067. /** @hidden */
  35068. _prepare(): void;
  35069. /**
  35070. * Execute the action starts the value interpolation.
  35071. */
  35072. execute(): void;
  35073. /**
  35074. * Serializes the actions and its related information.
  35075. * @param parent defines the object to serialize in
  35076. * @returns the serialized object
  35077. */
  35078. serialize(parent: any): any;
  35079. }
  35080. }
  35081. declare module BABYLON {
  35082. /**
  35083. * Options allowed during the creation of a sound track.
  35084. */
  35085. export interface ISoundTrackOptions {
  35086. /**
  35087. * The volume the sound track should take during creation
  35088. */
  35089. volume?: number;
  35090. /**
  35091. * Define if the sound track is the main sound track of the scene
  35092. */
  35093. mainTrack?: boolean;
  35094. }
  35095. /**
  35096. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35097. * It will be also used in a future release to apply effects on a specific track.
  35098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35099. */
  35100. export class SoundTrack {
  35101. /**
  35102. * The unique identifier of the sound track in the scene.
  35103. */
  35104. id: number;
  35105. /**
  35106. * The list of sounds included in the sound track.
  35107. */
  35108. soundCollection: Array<Sound>;
  35109. private _outputAudioNode;
  35110. private _scene;
  35111. private _isMainTrack;
  35112. private _connectedAnalyser;
  35113. private _options;
  35114. private _isInitialized;
  35115. /**
  35116. * Creates a new sound track.
  35117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35118. * @param scene Define the scene the sound track belongs to
  35119. * @param options
  35120. */
  35121. constructor(scene: Scene, options?: ISoundTrackOptions);
  35122. private _initializeSoundTrackAudioGraph;
  35123. /**
  35124. * Release the sound track and its associated resources
  35125. */
  35126. dispose(): void;
  35127. /**
  35128. * Adds a sound to this sound track
  35129. * @param sound define the cound to add
  35130. * @ignoreNaming
  35131. */
  35132. AddSound(sound: Sound): void;
  35133. /**
  35134. * Removes a sound to this sound track
  35135. * @param sound define the cound to remove
  35136. * @ignoreNaming
  35137. */
  35138. RemoveSound(sound: Sound): void;
  35139. /**
  35140. * Set a global volume for the full sound track.
  35141. * @param newVolume Define the new volume of the sound track
  35142. */
  35143. setVolume(newVolume: number): void;
  35144. /**
  35145. * Switch the panning model to HRTF:
  35146. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35148. */
  35149. switchPanningModelToHRTF(): void;
  35150. /**
  35151. * Switch the panning model to Equal Power:
  35152. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35154. */
  35155. switchPanningModelToEqualPower(): void;
  35156. /**
  35157. * Connect the sound track to an audio analyser allowing some amazing
  35158. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35160. * @param analyser The analyser to connect to the engine
  35161. */
  35162. connectToAnalyser(analyser: Analyser): void;
  35163. }
  35164. }
  35165. declare module BABYLON {
  35166. interface AbstractScene {
  35167. /**
  35168. * The list of sounds used in the scene.
  35169. */
  35170. sounds: Nullable<Array<Sound>>;
  35171. }
  35172. interface Scene {
  35173. /**
  35174. * @hidden
  35175. * Backing field
  35176. */
  35177. _mainSoundTrack: SoundTrack;
  35178. /**
  35179. * The main sound track played by the scene.
  35180. * It cotains your primary collection of sounds.
  35181. */
  35182. mainSoundTrack: SoundTrack;
  35183. /**
  35184. * The list of sound tracks added to the scene
  35185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35186. */
  35187. soundTracks: Nullable<Array<SoundTrack>>;
  35188. /**
  35189. * Gets a sound using a given name
  35190. * @param name defines the name to search for
  35191. * @return the found sound or null if not found at all.
  35192. */
  35193. getSoundByName(name: string): Nullable<Sound>;
  35194. /**
  35195. * Gets or sets if audio support is enabled
  35196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35197. */
  35198. audioEnabled: boolean;
  35199. /**
  35200. * Gets or sets if audio will be output to headphones
  35201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35202. */
  35203. headphone: boolean;
  35204. /**
  35205. * Gets or sets custom audio listener position provider
  35206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35207. */
  35208. audioListenerPositionProvider: Nullable<() => Vector3>;
  35209. }
  35210. /**
  35211. * Defines the sound scene component responsible to manage any sounds
  35212. * in a given scene.
  35213. */
  35214. export class AudioSceneComponent implements ISceneSerializableComponent {
  35215. /**
  35216. * The component name helpfull to identify the component in the list of scene components.
  35217. */
  35218. readonly name: string;
  35219. /**
  35220. * The scene the component belongs to.
  35221. */
  35222. scene: Scene;
  35223. private _audioEnabled;
  35224. /**
  35225. * Gets whether audio is enabled or not.
  35226. * Please use related enable/disable method to switch state.
  35227. */
  35228. readonly audioEnabled: boolean;
  35229. private _headphone;
  35230. /**
  35231. * Gets whether audio is outputing to headphone or not.
  35232. * Please use the according Switch methods to change output.
  35233. */
  35234. readonly headphone: boolean;
  35235. private _audioListenerPositionProvider;
  35236. /**
  35237. * Gets the current audio listener position provider
  35238. */
  35239. /**
  35240. * Sets a custom listener position for all sounds in the scene
  35241. * By default, this is the position of the first active camera
  35242. */
  35243. audioListenerPositionProvider: Nullable<() => Vector3>;
  35244. /**
  35245. * Creates a new instance of the component for the given scene
  35246. * @param scene Defines the scene to register the component in
  35247. */
  35248. constructor(scene: Scene);
  35249. /**
  35250. * Registers the component in a given scene
  35251. */
  35252. register(): void;
  35253. /**
  35254. * Rebuilds the elements related to this component in case of
  35255. * context lost for instance.
  35256. */
  35257. rebuild(): void;
  35258. /**
  35259. * Serializes the component data to the specified json object
  35260. * @param serializationObject The object to serialize to
  35261. */
  35262. serialize(serializationObject: any): void;
  35263. /**
  35264. * Adds all the elements from the container to the scene
  35265. * @param container the container holding the elements
  35266. */
  35267. addFromContainer(container: AbstractScene): void;
  35268. /**
  35269. * Removes all the elements in the container from the scene
  35270. * @param container contains the elements to remove
  35271. * @param dispose if the removed element should be disposed (default: false)
  35272. */
  35273. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35274. /**
  35275. * Disposes the component and the associated ressources.
  35276. */
  35277. dispose(): void;
  35278. /**
  35279. * Disables audio in the associated scene.
  35280. */
  35281. disableAudio(): void;
  35282. /**
  35283. * Enables audio in the associated scene.
  35284. */
  35285. enableAudio(): void;
  35286. /**
  35287. * Switch audio to headphone output.
  35288. */
  35289. switchAudioModeForHeadphones(): void;
  35290. /**
  35291. * Switch audio to normal speakers.
  35292. */
  35293. switchAudioModeForNormalSpeakers(): void;
  35294. private _afterRender;
  35295. }
  35296. }
  35297. declare module BABYLON {
  35298. /**
  35299. * Wraps one or more Sound objects and selects one with random weight for playback.
  35300. */
  35301. export class WeightedSound {
  35302. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35303. loop: boolean;
  35304. private _coneInnerAngle;
  35305. private _coneOuterAngle;
  35306. private _volume;
  35307. /** A Sound is currently playing. */
  35308. isPlaying: boolean;
  35309. /** A Sound is currently paused. */
  35310. isPaused: boolean;
  35311. private _sounds;
  35312. private _weights;
  35313. private _currentIndex?;
  35314. /**
  35315. * Creates a new WeightedSound from the list of sounds given.
  35316. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35317. * @param sounds Array of Sounds that will be selected from.
  35318. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35319. */
  35320. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35321. /**
  35322. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35323. */
  35324. /**
  35325. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35326. */
  35327. directionalConeInnerAngle: number;
  35328. /**
  35329. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35330. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35331. */
  35332. /**
  35333. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35334. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35335. */
  35336. directionalConeOuterAngle: number;
  35337. /**
  35338. * Playback volume.
  35339. */
  35340. /**
  35341. * Playback volume.
  35342. */
  35343. volume: number;
  35344. private _onended;
  35345. /**
  35346. * Suspend playback
  35347. */
  35348. pause(): void;
  35349. /**
  35350. * Stop playback
  35351. */
  35352. stop(): void;
  35353. /**
  35354. * Start playback.
  35355. * @param startOffset Position the clip head at a specific time in seconds.
  35356. */
  35357. play(startOffset?: number): void;
  35358. }
  35359. }
  35360. declare module BABYLON {
  35361. /**
  35362. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35363. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35364. */
  35365. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35366. /**
  35367. * Gets the name of the behavior.
  35368. */
  35369. readonly name: string;
  35370. /**
  35371. * The easing function used by animations
  35372. */
  35373. static EasingFunction: BackEase;
  35374. /**
  35375. * The easing mode used by animations
  35376. */
  35377. static EasingMode: number;
  35378. /**
  35379. * The duration of the animation, in milliseconds
  35380. */
  35381. transitionDuration: number;
  35382. /**
  35383. * Length of the distance animated by the transition when lower radius is reached
  35384. */
  35385. lowerRadiusTransitionRange: number;
  35386. /**
  35387. * Length of the distance animated by the transition when upper radius is reached
  35388. */
  35389. upperRadiusTransitionRange: number;
  35390. private _autoTransitionRange;
  35391. /**
  35392. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35393. */
  35394. /**
  35395. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35396. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35397. */
  35398. autoTransitionRange: boolean;
  35399. private _attachedCamera;
  35400. private _onAfterCheckInputsObserver;
  35401. private _onMeshTargetChangedObserver;
  35402. /**
  35403. * Initializes the behavior.
  35404. */
  35405. init(): void;
  35406. /**
  35407. * Attaches the behavior to its arc rotate camera.
  35408. * @param camera Defines the camera to attach the behavior to
  35409. */
  35410. attach(camera: ArcRotateCamera): void;
  35411. /**
  35412. * Detaches the behavior from its current arc rotate camera.
  35413. */
  35414. detach(): void;
  35415. private _radiusIsAnimating;
  35416. private _radiusBounceTransition;
  35417. private _animatables;
  35418. private _cachedWheelPrecision;
  35419. /**
  35420. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35421. * @param radiusLimit The limit to check against.
  35422. * @return Bool to indicate if at limit.
  35423. */
  35424. private _isRadiusAtLimit;
  35425. /**
  35426. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35427. * @param radiusDelta The delta by which to animate to. Can be negative.
  35428. */
  35429. private _applyBoundRadiusAnimation;
  35430. /**
  35431. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35432. */
  35433. protected _clearAnimationLocks(): void;
  35434. /**
  35435. * Stops and removes all animations that have been applied to the camera
  35436. */
  35437. stopAllAnimations(): void;
  35438. }
  35439. }
  35440. declare module BABYLON {
  35441. /**
  35442. * 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.
  35443. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35444. */
  35445. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35446. /**
  35447. * Gets the name of the behavior.
  35448. */
  35449. readonly name: string;
  35450. private _mode;
  35451. private _radiusScale;
  35452. private _positionScale;
  35453. private _defaultElevation;
  35454. private _elevationReturnTime;
  35455. private _elevationReturnWaitTime;
  35456. private _zoomStopsAnimation;
  35457. private _framingTime;
  35458. /**
  35459. * The easing function used by animations
  35460. */
  35461. static EasingFunction: ExponentialEase;
  35462. /**
  35463. * The easing mode used by animations
  35464. */
  35465. static EasingMode: number;
  35466. /**
  35467. * Sets the current mode used by the behavior
  35468. */
  35469. /**
  35470. * Gets current mode used by the behavior.
  35471. */
  35472. mode: number;
  35473. /**
  35474. * Sets the scale applied to the radius (1 by default)
  35475. */
  35476. /**
  35477. * Gets the scale applied to the radius
  35478. */
  35479. radiusScale: number;
  35480. /**
  35481. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35482. */
  35483. /**
  35484. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35485. */
  35486. positionScale: number;
  35487. /**
  35488. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35489. * behaviour is triggered, in radians.
  35490. */
  35491. /**
  35492. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35493. * behaviour is triggered, in radians.
  35494. */
  35495. defaultElevation: number;
  35496. /**
  35497. * Sets the time (in milliseconds) taken to return to the default beta position.
  35498. * Negative value indicates camera should not return to default.
  35499. */
  35500. /**
  35501. * Gets the time (in milliseconds) taken to return to the default beta position.
  35502. * Negative value indicates camera should not return to default.
  35503. */
  35504. elevationReturnTime: number;
  35505. /**
  35506. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35507. */
  35508. /**
  35509. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35510. */
  35511. elevationReturnWaitTime: number;
  35512. /**
  35513. * Sets the flag that indicates if user zooming should stop animation.
  35514. */
  35515. /**
  35516. * Gets the flag that indicates if user zooming should stop animation.
  35517. */
  35518. zoomStopsAnimation: boolean;
  35519. /**
  35520. * Sets the transition time when framing the mesh, in milliseconds
  35521. */
  35522. /**
  35523. * Gets the transition time when framing the mesh, in milliseconds
  35524. */
  35525. framingTime: number;
  35526. /**
  35527. * Define if the behavior should automatically change the configured
  35528. * camera limits and sensibilities.
  35529. */
  35530. autoCorrectCameraLimitsAndSensibility: boolean;
  35531. private _onPrePointerObservableObserver;
  35532. private _onAfterCheckInputsObserver;
  35533. private _onMeshTargetChangedObserver;
  35534. private _attachedCamera;
  35535. private _isPointerDown;
  35536. private _lastInteractionTime;
  35537. /**
  35538. * Initializes the behavior.
  35539. */
  35540. init(): void;
  35541. /**
  35542. * Attaches the behavior to its arc rotate camera.
  35543. * @param camera Defines the camera to attach the behavior to
  35544. */
  35545. attach(camera: ArcRotateCamera): void;
  35546. /**
  35547. * Detaches the behavior from its current arc rotate camera.
  35548. */
  35549. detach(): void;
  35550. private _animatables;
  35551. private _betaIsAnimating;
  35552. private _betaTransition;
  35553. private _radiusTransition;
  35554. private _vectorTransition;
  35555. /**
  35556. * Targets the given mesh and updates zoom level accordingly.
  35557. * @param mesh The mesh to target.
  35558. * @param radius Optional. If a cached radius position already exists, overrides default.
  35559. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35560. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35561. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35562. */
  35563. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35564. /**
  35565. * Targets the given mesh with its children and updates zoom level accordingly.
  35566. * @param mesh The mesh to target.
  35567. * @param radius Optional. If a cached radius position already exists, overrides default.
  35568. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35569. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35570. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35571. */
  35572. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35573. /**
  35574. * Targets the given meshes with their children and updates zoom level accordingly.
  35575. * @param meshes The mesh to target.
  35576. * @param radius Optional. If a cached radius position already exists, overrides default.
  35577. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35578. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35579. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35580. */
  35581. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35582. /**
  35583. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35584. * @param minimumWorld Determines the smaller position of the bounding box extend
  35585. * @param maximumWorld Determines the bigger position of the bounding box extend
  35586. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35587. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35588. */
  35589. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35590. /**
  35591. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35592. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35593. * frustum width.
  35594. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35595. * to fully enclose the mesh in the viewing frustum.
  35596. */
  35597. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35598. /**
  35599. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35600. * is automatically returned to its default position (expected to be above ground plane).
  35601. */
  35602. private _maintainCameraAboveGround;
  35603. /**
  35604. * Returns the frustum slope based on the canvas ratio and camera FOV
  35605. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35606. */
  35607. private _getFrustumSlope;
  35608. /**
  35609. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35610. */
  35611. private _clearAnimationLocks;
  35612. /**
  35613. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35614. */
  35615. private _applyUserInteraction;
  35616. /**
  35617. * Stops and removes all animations that have been applied to the camera
  35618. */
  35619. stopAllAnimations(): void;
  35620. /**
  35621. * Gets a value indicating if the user is moving the camera
  35622. */
  35623. readonly isUserIsMoving: boolean;
  35624. /**
  35625. * The camera can move all the way towards the mesh.
  35626. */
  35627. static IgnoreBoundsSizeMode: number;
  35628. /**
  35629. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35630. */
  35631. static FitFrustumSidesMode: number;
  35632. }
  35633. }
  35634. declare module BABYLON {
  35635. /**
  35636. * Base class for Camera Pointer Inputs.
  35637. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35638. * for example usage.
  35639. */
  35640. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35641. /**
  35642. * Defines the camera the input is attached to.
  35643. */
  35644. abstract camera: Camera;
  35645. /**
  35646. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35647. */
  35648. protected _altKey: boolean;
  35649. protected _ctrlKey: boolean;
  35650. protected _metaKey: boolean;
  35651. protected _shiftKey: boolean;
  35652. /**
  35653. * Which mouse buttons were pressed at time of last mouse event.
  35654. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35655. */
  35656. protected _buttonsPressed: number;
  35657. /**
  35658. * Defines the buttons associated with the input to handle camera move.
  35659. */
  35660. buttons: number[];
  35661. /**
  35662. * Attach the input controls to a specific dom element to get the input from.
  35663. * @param element Defines the element the controls should be listened from
  35664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35665. */
  35666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35667. /**
  35668. * Detach the current controls from the specified dom element.
  35669. * @param element Defines the element to stop listening the inputs from
  35670. */
  35671. detachControl(element: Nullable<HTMLElement>): void;
  35672. /**
  35673. * Gets the class name of the current input.
  35674. * @returns the class name
  35675. */
  35676. getClassName(): string;
  35677. /**
  35678. * Get the friendly name associated with the input class.
  35679. * @returns the input friendly name
  35680. */
  35681. getSimpleName(): string;
  35682. /**
  35683. * Called on pointer POINTERDOUBLETAP event.
  35684. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35685. */
  35686. protected onDoubleTap(type: string): void;
  35687. /**
  35688. * Called on pointer POINTERMOVE event if only a single touch is active.
  35689. * Override this method to provide functionality.
  35690. */
  35691. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35692. /**
  35693. * Called on pointer POINTERMOVE event if multiple touches are active.
  35694. * Override this method to provide functionality.
  35695. */
  35696. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35697. /**
  35698. * Called on JS contextmenu event.
  35699. * Override this method to provide functionality.
  35700. */
  35701. protected onContextMenu(evt: PointerEvent): void;
  35702. /**
  35703. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35704. * press.
  35705. * Override this method to provide functionality.
  35706. */
  35707. protected onButtonDown(evt: PointerEvent): void;
  35708. /**
  35709. * Called each time a new POINTERUP event occurs. Ie, for each button
  35710. * release.
  35711. * Override this method to provide functionality.
  35712. */
  35713. protected onButtonUp(evt: PointerEvent): void;
  35714. /**
  35715. * Called when window becomes inactive.
  35716. * Override this method to provide functionality.
  35717. */
  35718. protected onLostFocus(): void;
  35719. private _pointerInput;
  35720. private _observer;
  35721. private _onLostFocus;
  35722. private pointA;
  35723. private pointB;
  35724. }
  35725. }
  35726. declare module BABYLON {
  35727. /**
  35728. * Manage the pointers inputs to control an arc rotate camera.
  35729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35730. */
  35731. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35732. /**
  35733. * Defines the camera the input is attached to.
  35734. */
  35735. camera: ArcRotateCamera;
  35736. /**
  35737. * Gets the class name of the current input.
  35738. * @returns the class name
  35739. */
  35740. getClassName(): string;
  35741. /**
  35742. * Defines the buttons associated with the input to handle camera move.
  35743. */
  35744. buttons: number[];
  35745. /**
  35746. * Defines the pointer angular sensibility along the X axis or how fast is
  35747. * the camera rotating.
  35748. */
  35749. angularSensibilityX: number;
  35750. /**
  35751. * Defines the pointer angular sensibility along the Y axis or how fast is
  35752. * the camera rotating.
  35753. */
  35754. angularSensibilityY: number;
  35755. /**
  35756. * Defines the pointer pinch precision or how fast is the camera zooming.
  35757. */
  35758. pinchPrecision: number;
  35759. /**
  35760. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35761. * from 0.
  35762. * It defines the percentage of current camera.radius to use as delta when
  35763. * pinch zoom is used.
  35764. */
  35765. pinchDeltaPercentage: number;
  35766. /**
  35767. * Defines the pointer panning sensibility or how fast is the camera moving.
  35768. */
  35769. panningSensibility: number;
  35770. /**
  35771. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35772. */
  35773. multiTouchPanning: boolean;
  35774. /**
  35775. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35776. * zoom (pinch) through multitouch.
  35777. */
  35778. multiTouchPanAndZoom: boolean;
  35779. /**
  35780. * Revers pinch action direction.
  35781. */
  35782. pinchInwards: boolean;
  35783. private _isPanClick;
  35784. private _twoFingerActivityCount;
  35785. private _isPinching;
  35786. /**
  35787. * Called on pointer POINTERMOVE event if only a single touch is active.
  35788. */
  35789. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35790. /**
  35791. * Called on pointer POINTERDOUBLETAP event.
  35792. */
  35793. protected onDoubleTap(type: string): void;
  35794. /**
  35795. * Called on pointer POINTERMOVE event if multiple touches are active.
  35796. */
  35797. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35798. /**
  35799. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35800. * press.
  35801. */
  35802. protected onButtonDown(evt: PointerEvent): void;
  35803. /**
  35804. * Called each time a new POINTERUP event occurs. Ie, for each button
  35805. * release.
  35806. */
  35807. protected onButtonUp(evt: PointerEvent): void;
  35808. /**
  35809. * Called when window becomes inactive.
  35810. */
  35811. protected onLostFocus(): void;
  35812. }
  35813. }
  35814. declare module BABYLON {
  35815. /**
  35816. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35818. */
  35819. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35820. /**
  35821. * Defines the camera the input is attached to.
  35822. */
  35823. camera: ArcRotateCamera;
  35824. /**
  35825. * Defines the list of key codes associated with the up action (increase alpha)
  35826. */
  35827. keysUp: number[];
  35828. /**
  35829. * Defines the list of key codes associated with the down action (decrease alpha)
  35830. */
  35831. keysDown: number[];
  35832. /**
  35833. * Defines the list of key codes associated with the left action (increase beta)
  35834. */
  35835. keysLeft: number[];
  35836. /**
  35837. * Defines the list of key codes associated with the right action (decrease beta)
  35838. */
  35839. keysRight: number[];
  35840. /**
  35841. * Defines the list of key codes associated with the reset action.
  35842. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35843. */
  35844. keysReset: number[];
  35845. /**
  35846. * Defines the panning sensibility of the inputs.
  35847. * (How fast is the camera paning)
  35848. */
  35849. panningSensibility: number;
  35850. /**
  35851. * Defines the zooming sensibility of the inputs.
  35852. * (How fast is the camera zooming)
  35853. */
  35854. zoomingSensibility: number;
  35855. /**
  35856. * Defines wether maintaining the alt key down switch the movement mode from
  35857. * orientation to zoom.
  35858. */
  35859. useAltToZoom: boolean;
  35860. /**
  35861. * Rotation speed of the camera
  35862. */
  35863. angularSpeed: number;
  35864. private _keys;
  35865. private _ctrlPressed;
  35866. private _altPressed;
  35867. private _onCanvasBlurObserver;
  35868. private _onKeyboardObserver;
  35869. private _engine;
  35870. private _scene;
  35871. /**
  35872. * Attach the input controls to a specific dom element to get the input from.
  35873. * @param element Defines the element the controls should be listened from
  35874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35875. */
  35876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35877. /**
  35878. * Detach the current controls from the specified dom element.
  35879. * @param element Defines the element to stop listening the inputs from
  35880. */
  35881. detachControl(element: Nullable<HTMLElement>): void;
  35882. /**
  35883. * Update the current camera state depending on the inputs that have been used this frame.
  35884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35885. */
  35886. checkInputs(): void;
  35887. /**
  35888. * Gets the class name of the current intput.
  35889. * @returns the class name
  35890. */
  35891. getClassName(): string;
  35892. /**
  35893. * Get the friendly name associated with the input class.
  35894. * @returns the input friendly name
  35895. */
  35896. getSimpleName(): string;
  35897. }
  35898. }
  35899. declare module BABYLON {
  35900. /**
  35901. * Manage the mouse wheel inputs to control an arc rotate camera.
  35902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35903. */
  35904. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35905. /**
  35906. * Defines the camera the input is attached to.
  35907. */
  35908. camera: ArcRotateCamera;
  35909. /**
  35910. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35911. */
  35912. wheelPrecision: number;
  35913. /**
  35914. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35915. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35916. */
  35917. wheelDeltaPercentage: number;
  35918. private _wheel;
  35919. private _observer;
  35920. private computeDeltaFromMouseWheelLegacyEvent;
  35921. /**
  35922. * Attach the input controls to a specific dom element to get the input from.
  35923. * @param element Defines the element the controls should be listened from
  35924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35925. */
  35926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35927. /**
  35928. * Detach the current controls from the specified dom element.
  35929. * @param element Defines the element to stop listening the inputs from
  35930. */
  35931. detachControl(element: Nullable<HTMLElement>): void;
  35932. /**
  35933. * Gets the class name of the current intput.
  35934. * @returns the class name
  35935. */
  35936. getClassName(): string;
  35937. /**
  35938. * Get the friendly name associated with the input class.
  35939. * @returns the input friendly name
  35940. */
  35941. getSimpleName(): string;
  35942. }
  35943. }
  35944. declare module BABYLON {
  35945. /**
  35946. * Default Inputs manager for the ArcRotateCamera.
  35947. * It groups all the default supported inputs for ease of use.
  35948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35949. */
  35950. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35951. /**
  35952. * Instantiates a new ArcRotateCameraInputsManager.
  35953. * @param camera Defines the camera the inputs belong to
  35954. */
  35955. constructor(camera: ArcRotateCamera);
  35956. /**
  35957. * Add mouse wheel input support to the input manager.
  35958. * @returns the current input manager
  35959. */
  35960. addMouseWheel(): ArcRotateCameraInputsManager;
  35961. /**
  35962. * Add pointers input support to the input manager.
  35963. * @returns the current input manager
  35964. */
  35965. addPointers(): ArcRotateCameraInputsManager;
  35966. /**
  35967. * Add keyboard input support to the input manager.
  35968. * @returns the current input manager
  35969. */
  35970. addKeyboard(): ArcRotateCameraInputsManager;
  35971. }
  35972. }
  35973. declare module BABYLON {
  35974. /**
  35975. * This represents an orbital type of camera.
  35976. *
  35977. * 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.
  35978. * 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.
  35979. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35980. */
  35981. export class ArcRotateCamera extends TargetCamera {
  35982. /**
  35983. * Defines the rotation angle of the camera along the longitudinal axis.
  35984. */
  35985. alpha: number;
  35986. /**
  35987. * Defines the rotation angle of the camera along the latitudinal axis.
  35988. */
  35989. beta: number;
  35990. /**
  35991. * Defines the radius of the camera from it s target point.
  35992. */
  35993. radius: number;
  35994. protected _target: Vector3;
  35995. protected _targetHost: Nullable<AbstractMesh>;
  35996. /**
  35997. * Defines the target point of the camera.
  35998. * The camera looks towards it form the radius distance.
  35999. */
  36000. target: Vector3;
  36001. /**
  36002. * Define the current local position of the camera in the scene
  36003. */
  36004. position: Vector3;
  36005. protected _upVector: Vector3;
  36006. protected _upToYMatrix: Matrix;
  36007. protected _YToUpMatrix: Matrix;
  36008. /**
  36009. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36010. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36011. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36012. */
  36013. upVector: Vector3;
  36014. /**
  36015. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36016. */
  36017. setMatUp(): void;
  36018. /**
  36019. * Current inertia value on the longitudinal axis.
  36020. * The bigger this number the longer it will take for the camera to stop.
  36021. */
  36022. inertialAlphaOffset: number;
  36023. /**
  36024. * Current inertia value on the latitudinal axis.
  36025. * The bigger this number the longer it will take for the camera to stop.
  36026. */
  36027. inertialBetaOffset: number;
  36028. /**
  36029. * Current inertia value on the radius axis.
  36030. * The bigger this number the longer it will take for the camera to stop.
  36031. */
  36032. inertialRadiusOffset: number;
  36033. /**
  36034. * Minimum allowed angle on the longitudinal axis.
  36035. * This can help limiting how the Camera is able to move in the scene.
  36036. */
  36037. lowerAlphaLimit: Nullable<number>;
  36038. /**
  36039. * Maximum allowed angle on the longitudinal axis.
  36040. * This can help limiting how the Camera is able to move in the scene.
  36041. */
  36042. upperAlphaLimit: Nullable<number>;
  36043. /**
  36044. * Minimum allowed angle on the latitudinal axis.
  36045. * This can help limiting how the Camera is able to move in the scene.
  36046. */
  36047. lowerBetaLimit: number;
  36048. /**
  36049. * Maximum allowed angle on the latitudinal axis.
  36050. * This can help limiting how the Camera is able to move in the scene.
  36051. */
  36052. upperBetaLimit: number;
  36053. /**
  36054. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36055. * This can help limiting how the Camera is able to move in the scene.
  36056. */
  36057. lowerRadiusLimit: Nullable<number>;
  36058. /**
  36059. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36060. * This can help limiting how the Camera is able to move in the scene.
  36061. */
  36062. upperRadiusLimit: Nullable<number>;
  36063. /**
  36064. * Defines the current inertia value used during panning of the camera along the X axis.
  36065. */
  36066. inertialPanningX: number;
  36067. /**
  36068. * Defines the current inertia value used during panning of the camera along the Y axis.
  36069. */
  36070. inertialPanningY: number;
  36071. /**
  36072. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36073. * Basically if your fingers moves away from more than this distance you will be considered
  36074. * in pinch mode.
  36075. */
  36076. pinchToPanMaxDistance: number;
  36077. /**
  36078. * Defines the maximum distance the camera can pan.
  36079. * This could help keeping the cammera always in your scene.
  36080. */
  36081. panningDistanceLimit: Nullable<number>;
  36082. /**
  36083. * Defines the target of the camera before paning.
  36084. */
  36085. panningOriginTarget: Vector3;
  36086. /**
  36087. * Defines the value of the inertia used during panning.
  36088. * 0 would mean stop inertia and one would mean no decelleration at all.
  36089. */
  36090. panningInertia: number;
  36091. /**
  36092. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36093. */
  36094. angularSensibilityX: number;
  36095. /**
  36096. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36097. */
  36098. angularSensibilityY: number;
  36099. /**
  36100. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36101. */
  36102. pinchPrecision: number;
  36103. /**
  36104. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36105. * It will be used instead of pinchDeltaPrecision if different from 0.
  36106. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36107. */
  36108. pinchDeltaPercentage: number;
  36109. /**
  36110. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36111. */
  36112. panningSensibility: number;
  36113. /**
  36114. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36115. */
  36116. keysUp: number[];
  36117. /**
  36118. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36119. */
  36120. keysDown: number[];
  36121. /**
  36122. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36123. */
  36124. keysLeft: number[];
  36125. /**
  36126. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36127. */
  36128. keysRight: number[];
  36129. /**
  36130. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36131. */
  36132. wheelPrecision: number;
  36133. /**
  36134. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36135. * It will be used instead of pinchDeltaPrecision if different from 0.
  36136. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36137. */
  36138. wheelDeltaPercentage: number;
  36139. /**
  36140. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36141. */
  36142. zoomOnFactor: number;
  36143. /**
  36144. * Defines a screen offset for the camera position.
  36145. */
  36146. targetScreenOffset: Vector2;
  36147. /**
  36148. * Allows the camera to be completely reversed.
  36149. * If false the camera can not arrive upside down.
  36150. */
  36151. allowUpsideDown: boolean;
  36152. /**
  36153. * Define if double tap/click is used to restore the previously saved state of the camera.
  36154. */
  36155. useInputToRestoreState: boolean;
  36156. /** @hidden */
  36157. _viewMatrix: Matrix;
  36158. /** @hidden */
  36159. _useCtrlForPanning: boolean;
  36160. /** @hidden */
  36161. _panningMouseButton: number;
  36162. /**
  36163. * Defines the input associated to the camera.
  36164. */
  36165. inputs: ArcRotateCameraInputsManager;
  36166. /** @hidden */
  36167. _reset: () => void;
  36168. /**
  36169. * Defines the allowed panning axis.
  36170. */
  36171. panningAxis: Vector3;
  36172. protected _localDirection: Vector3;
  36173. protected _transformedDirection: Vector3;
  36174. private _bouncingBehavior;
  36175. /**
  36176. * Gets the bouncing behavior of the camera if it has been enabled.
  36177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36178. */
  36179. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36180. /**
  36181. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36182. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36183. */
  36184. useBouncingBehavior: boolean;
  36185. private _framingBehavior;
  36186. /**
  36187. * Gets the framing behavior of the camera if it has been enabled.
  36188. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36189. */
  36190. readonly framingBehavior: Nullable<FramingBehavior>;
  36191. /**
  36192. * Defines if the framing behavior of the camera is enabled on the camera.
  36193. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36194. */
  36195. useFramingBehavior: boolean;
  36196. private _autoRotationBehavior;
  36197. /**
  36198. * Gets the auto rotation behavior of the camera if it has been enabled.
  36199. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36200. */
  36201. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36202. /**
  36203. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36204. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36205. */
  36206. useAutoRotationBehavior: boolean;
  36207. /**
  36208. * Observable triggered when the mesh target has been changed on the camera.
  36209. */
  36210. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36211. /**
  36212. * Event raised when the camera is colliding with a mesh.
  36213. */
  36214. onCollide: (collidedMesh: AbstractMesh) => void;
  36215. /**
  36216. * Defines whether the camera should check collision with the objects oh the scene.
  36217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36218. */
  36219. checkCollisions: boolean;
  36220. /**
  36221. * Defines the collision radius of the camera.
  36222. * This simulates a sphere around the camera.
  36223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36224. */
  36225. collisionRadius: Vector3;
  36226. protected _collider: Collider;
  36227. protected _previousPosition: Vector3;
  36228. protected _collisionVelocity: Vector3;
  36229. protected _newPosition: Vector3;
  36230. protected _previousAlpha: number;
  36231. protected _previousBeta: number;
  36232. protected _previousRadius: number;
  36233. protected _collisionTriggered: boolean;
  36234. protected _targetBoundingCenter: Nullable<Vector3>;
  36235. private _computationVector;
  36236. /**
  36237. * Instantiates a new ArcRotateCamera in a given scene
  36238. * @param name Defines the name of the camera
  36239. * @param alpha Defines the camera rotation along the logitudinal axis
  36240. * @param beta Defines the camera rotation along the latitudinal axis
  36241. * @param radius Defines the camera distance from its target
  36242. * @param target Defines the camera target
  36243. * @param scene Defines the scene the camera belongs to
  36244. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36245. */
  36246. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36247. /** @hidden */
  36248. _initCache(): void;
  36249. /** @hidden */
  36250. _updateCache(ignoreParentClass?: boolean): void;
  36251. protected _getTargetPosition(): Vector3;
  36252. private _storedAlpha;
  36253. private _storedBeta;
  36254. private _storedRadius;
  36255. private _storedTarget;
  36256. private _storedTargetScreenOffset;
  36257. /**
  36258. * Stores the current state of the camera (alpha, beta, radius and target)
  36259. * @returns the camera itself
  36260. */
  36261. storeState(): Camera;
  36262. /**
  36263. * @hidden
  36264. * Restored camera state. You must call storeState() first
  36265. */
  36266. _restoreStateValues(): boolean;
  36267. /** @hidden */
  36268. _isSynchronizedViewMatrix(): boolean;
  36269. /**
  36270. * Attached controls to the current camera.
  36271. * @param element Defines the element the controls should be listened from
  36272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36273. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36274. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36275. */
  36276. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36277. /**
  36278. * Detach the current controls from the camera.
  36279. * The camera will stop reacting to inputs.
  36280. * @param element Defines the element to stop listening the inputs from
  36281. */
  36282. detachControl(element: HTMLElement): void;
  36283. /** @hidden */
  36284. _checkInputs(): void;
  36285. protected _checkLimits(): void;
  36286. /**
  36287. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36288. */
  36289. rebuildAnglesAndRadius(): void;
  36290. /**
  36291. * Use a position to define the current camera related information like aplha, beta and radius
  36292. * @param position Defines the position to set the camera at
  36293. */
  36294. setPosition(position: Vector3): void;
  36295. /**
  36296. * Defines the target the camera should look at.
  36297. * This will automatically adapt alpha beta and radius to fit within the new target.
  36298. * @param target Defines the new target as a Vector or a mesh
  36299. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36300. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36301. */
  36302. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36303. /** @hidden */
  36304. _getViewMatrix(): Matrix;
  36305. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36306. /**
  36307. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36308. * @param meshes Defines the mesh to zoom on
  36309. * @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)
  36310. */
  36311. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36312. /**
  36313. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36314. * The target will be changed but the radius
  36315. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36316. * @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)
  36317. */
  36318. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36319. min: Vector3;
  36320. max: Vector3;
  36321. distance: number;
  36322. }, doNotUpdateMaxZ?: boolean): void;
  36323. /**
  36324. * @override
  36325. * Override Camera.createRigCamera
  36326. */
  36327. createRigCamera(name: string, cameraIndex: number): Camera;
  36328. /**
  36329. * @hidden
  36330. * @override
  36331. * Override Camera._updateRigCameras
  36332. */
  36333. _updateRigCameras(): void;
  36334. /**
  36335. * Destroy the camera and release the current resources hold by it.
  36336. */
  36337. dispose(): void;
  36338. /**
  36339. * Gets the current object class name.
  36340. * @return the class name
  36341. */
  36342. getClassName(): string;
  36343. }
  36344. }
  36345. declare module BABYLON {
  36346. /**
  36347. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36348. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36349. */
  36350. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36351. /**
  36352. * Gets the name of the behavior.
  36353. */
  36354. readonly name: string;
  36355. private _zoomStopsAnimation;
  36356. private _idleRotationSpeed;
  36357. private _idleRotationWaitTime;
  36358. private _idleRotationSpinupTime;
  36359. /**
  36360. * Sets the flag that indicates if user zooming should stop animation.
  36361. */
  36362. /**
  36363. * Gets the flag that indicates if user zooming should stop animation.
  36364. */
  36365. zoomStopsAnimation: boolean;
  36366. /**
  36367. * Sets the default speed at which the camera rotates around the model.
  36368. */
  36369. /**
  36370. * Gets the default speed at which the camera rotates around the model.
  36371. */
  36372. idleRotationSpeed: number;
  36373. /**
  36374. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36375. */
  36376. /**
  36377. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36378. */
  36379. idleRotationWaitTime: number;
  36380. /**
  36381. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36382. */
  36383. /**
  36384. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36385. */
  36386. idleRotationSpinupTime: number;
  36387. /**
  36388. * Gets a value indicating if the camera is currently rotating because of this behavior
  36389. */
  36390. readonly rotationInProgress: boolean;
  36391. private _onPrePointerObservableObserver;
  36392. private _onAfterCheckInputsObserver;
  36393. private _attachedCamera;
  36394. private _isPointerDown;
  36395. private _lastFrameTime;
  36396. private _lastInteractionTime;
  36397. private _cameraRotationSpeed;
  36398. /**
  36399. * Initializes the behavior.
  36400. */
  36401. init(): void;
  36402. /**
  36403. * Attaches the behavior to its arc rotate camera.
  36404. * @param camera Defines the camera to attach the behavior to
  36405. */
  36406. attach(camera: ArcRotateCamera): void;
  36407. /**
  36408. * Detaches the behavior from its current arc rotate camera.
  36409. */
  36410. detach(): void;
  36411. /**
  36412. * Returns true if user is scrolling.
  36413. * @return true if user is scrolling.
  36414. */
  36415. private _userIsZooming;
  36416. private _lastFrameRadius;
  36417. private _shouldAnimationStopForInteraction;
  36418. /**
  36419. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36420. */
  36421. private _applyUserInteraction;
  36422. private _userIsMoving;
  36423. }
  36424. }
  36425. declare module BABYLON {
  36426. /**
  36427. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36428. */
  36429. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36430. private ui;
  36431. /**
  36432. * The name of the behavior
  36433. */
  36434. name: string;
  36435. /**
  36436. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36437. */
  36438. distanceAwayFromFace: number;
  36439. /**
  36440. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36441. */
  36442. distanceAwayFromBottomOfFace: number;
  36443. private _faceVectors;
  36444. private _target;
  36445. private _scene;
  36446. private _onRenderObserver;
  36447. private _tmpMatrix;
  36448. private _tmpVector;
  36449. /**
  36450. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36451. * @param ui The transform node that should be attched to the mesh
  36452. */
  36453. constructor(ui: TransformNode);
  36454. /**
  36455. * Initializes the behavior
  36456. */
  36457. init(): void;
  36458. private _closestFace;
  36459. private _zeroVector;
  36460. private _lookAtTmpMatrix;
  36461. private _lookAtToRef;
  36462. /**
  36463. * Attaches the AttachToBoxBehavior to the passed in mesh
  36464. * @param target The mesh that the specified node will be attached to
  36465. */
  36466. attach(target: Mesh): void;
  36467. /**
  36468. * Detaches the behavior from the mesh
  36469. */
  36470. detach(): void;
  36471. }
  36472. }
  36473. declare module BABYLON {
  36474. /**
  36475. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36476. */
  36477. export class FadeInOutBehavior implements Behavior<Mesh> {
  36478. /**
  36479. * Time in milliseconds to delay before fading in (Default: 0)
  36480. */
  36481. delay: number;
  36482. /**
  36483. * Time in milliseconds for the mesh to fade in (Default: 300)
  36484. */
  36485. fadeInTime: number;
  36486. private _millisecondsPerFrame;
  36487. private _hovered;
  36488. private _hoverValue;
  36489. private _ownerNode;
  36490. /**
  36491. * Instatiates the FadeInOutBehavior
  36492. */
  36493. constructor();
  36494. /**
  36495. * The name of the behavior
  36496. */
  36497. readonly name: string;
  36498. /**
  36499. * Initializes the behavior
  36500. */
  36501. init(): void;
  36502. /**
  36503. * Attaches the fade behavior on the passed in mesh
  36504. * @param ownerNode The mesh that will be faded in/out once attached
  36505. */
  36506. attach(ownerNode: Mesh): void;
  36507. /**
  36508. * Detaches the behavior from the mesh
  36509. */
  36510. detach(): void;
  36511. /**
  36512. * Triggers the mesh to begin fading in or out
  36513. * @param value if the object should fade in or out (true to fade in)
  36514. */
  36515. fadeIn(value: boolean): void;
  36516. private _update;
  36517. private _setAllVisibility;
  36518. }
  36519. }
  36520. declare module BABYLON {
  36521. /**
  36522. * Class containing a set of static utilities functions for managing Pivots
  36523. * @hidden
  36524. */
  36525. export class PivotTools {
  36526. private static _PivotCached;
  36527. private static _OldPivotPoint;
  36528. private static _PivotTranslation;
  36529. private static _PivotTmpVector;
  36530. /** @hidden */
  36531. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36532. /** @hidden */
  36533. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36534. }
  36535. }
  36536. declare module BABYLON {
  36537. /**
  36538. * Class containing static functions to help procedurally build meshes
  36539. */
  36540. export class PlaneBuilder {
  36541. /**
  36542. * Creates a plane mesh
  36543. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36544. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36545. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36547. * * 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
  36548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36549. * @param name defines the name of the mesh
  36550. * @param options defines the options used to create the mesh
  36551. * @param scene defines the hosting scene
  36552. * @returns the plane mesh
  36553. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36554. */
  36555. static CreatePlane(name: string, options: {
  36556. size?: number;
  36557. width?: number;
  36558. height?: number;
  36559. sideOrientation?: number;
  36560. frontUVs?: Vector4;
  36561. backUVs?: Vector4;
  36562. updatable?: boolean;
  36563. sourcePlane?: Plane;
  36564. }, scene?: Nullable<Scene>): Mesh;
  36565. }
  36566. }
  36567. declare module BABYLON {
  36568. /**
  36569. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36570. */
  36571. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36572. private static _AnyMouseID;
  36573. /**
  36574. * Abstract mesh the behavior is set on
  36575. */
  36576. attachedNode: AbstractMesh;
  36577. private _dragPlane;
  36578. private _scene;
  36579. private _pointerObserver;
  36580. private _beforeRenderObserver;
  36581. private static _planeScene;
  36582. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36583. /**
  36584. * 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)
  36585. */
  36586. maxDragAngle: number;
  36587. /**
  36588. * @hidden
  36589. */
  36590. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36591. /**
  36592. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36593. */
  36594. currentDraggingPointerID: number;
  36595. /**
  36596. * The last position where the pointer hit the drag plane in world space
  36597. */
  36598. lastDragPosition: Vector3;
  36599. /**
  36600. * If the behavior is currently in a dragging state
  36601. */
  36602. dragging: boolean;
  36603. /**
  36604. * 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)
  36605. */
  36606. dragDeltaRatio: number;
  36607. /**
  36608. * If the drag plane orientation should be updated during the dragging (Default: true)
  36609. */
  36610. updateDragPlane: boolean;
  36611. private _debugMode;
  36612. private _moving;
  36613. /**
  36614. * Fires each time the attached mesh is dragged with the pointer
  36615. * * delta between last drag position and current drag position in world space
  36616. * * dragDistance along the drag axis
  36617. * * dragPlaneNormal normal of the current drag plane used during the drag
  36618. * * dragPlanePoint in world space where the drag intersects the drag plane
  36619. */
  36620. onDragObservable: Observable<{
  36621. delta: Vector3;
  36622. dragPlanePoint: Vector3;
  36623. dragPlaneNormal: Vector3;
  36624. dragDistance: number;
  36625. pointerId: number;
  36626. }>;
  36627. /**
  36628. * Fires each time a drag begins (eg. mouse down on mesh)
  36629. */
  36630. onDragStartObservable: Observable<{
  36631. dragPlanePoint: Vector3;
  36632. pointerId: number;
  36633. }>;
  36634. /**
  36635. * Fires each time a drag ends (eg. mouse release after drag)
  36636. */
  36637. onDragEndObservable: Observable<{
  36638. dragPlanePoint: Vector3;
  36639. pointerId: number;
  36640. }>;
  36641. /**
  36642. * If the attached mesh should be moved when dragged
  36643. */
  36644. moveAttached: boolean;
  36645. /**
  36646. * If the drag behavior will react to drag events (Default: true)
  36647. */
  36648. enabled: boolean;
  36649. /**
  36650. * If pointer events should start and release the drag (Default: true)
  36651. */
  36652. startAndReleaseDragOnPointerEvents: boolean;
  36653. /**
  36654. * If camera controls should be detached during the drag
  36655. */
  36656. detachCameraControls: boolean;
  36657. /**
  36658. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36659. */
  36660. useObjectOrienationForDragging: boolean;
  36661. private _options;
  36662. /**
  36663. * Creates a pointer drag behavior that can be attached to a mesh
  36664. * @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)
  36665. */
  36666. constructor(options?: {
  36667. dragAxis?: Vector3;
  36668. dragPlaneNormal?: Vector3;
  36669. });
  36670. /**
  36671. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36672. */
  36673. validateDrag: (targetPosition: Vector3) => boolean;
  36674. /**
  36675. * The name of the behavior
  36676. */
  36677. readonly name: string;
  36678. /**
  36679. * Initializes the behavior
  36680. */
  36681. init(): void;
  36682. private _tmpVector;
  36683. private _alternatePickedPoint;
  36684. private _worldDragAxis;
  36685. private _targetPosition;
  36686. private _attachedElement;
  36687. /**
  36688. * Attaches the drag behavior the passed in mesh
  36689. * @param ownerNode The mesh that will be dragged around once attached
  36690. * @param predicate Predicate to use for pick filtering
  36691. */
  36692. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36693. /**
  36694. * Force relase the drag action by code.
  36695. */
  36696. releaseDrag(): void;
  36697. private _startDragRay;
  36698. private _lastPointerRay;
  36699. /**
  36700. * Simulates the start of a pointer drag event on the behavior
  36701. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36702. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36703. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36704. */
  36705. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36706. private _startDrag;
  36707. private _dragDelta;
  36708. private _moveDrag;
  36709. private _pickWithRayOnDragPlane;
  36710. private _pointA;
  36711. private _pointB;
  36712. private _pointC;
  36713. private _lineA;
  36714. private _lineB;
  36715. private _localAxis;
  36716. private _lookAt;
  36717. private _updateDragPlanePosition;
  36718. /**
  36719. * Detaches the behavior from the mesh
  36720. */
  36721. detach(): void;
  36722. }
  36723. }
  36724. declare module BABYLON {
  36725. /**
  36726. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36727. */
  36728. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36729. private _dragBehaviorA;
  36730. private _dragBehaviorB;
  36731. private _startDistance;
  36732. private _initialScale;
  36733. private _targetScale;
  36734. private _ownerNode;
  36735. private _sceneRenderObserver;
  36736. /**
  36737. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36738. */
  36739. constructor();
  36740. /**
  36741. * The name of the behavior
  36742. */
  36743. readonly name: string;
  36744. /**
  36745. * Initializes the behavior
  36746. */
  36747. init(): void;
  36748. private _getCurrentDistance;
  36749. /**
  36750. * Attaches the scale behavior the passed in mesh
  36751. * @param ownerNode The mesh that will be scaled around once attached
  36752. */
  36753. attach(ownerNode: Mesh): void;
  36754. /**
  36755. * Detaches the behavior from the mesh
  36756. */
  36757. detach(): void;
  36758. }
  36759. }
  36760. declare module BABYLON {
  36761. /**
  36762. * 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
  36763. */
  36764. export class SixDofDragBehavior implements Behavior<Mesh> {
  36765. private static _virtualScene;
  36766. private _ownerNode;
  36767. private _sceneRenderObserver;
  36768. private _scene;
  36769. private _targetPosition;
  36770. private _virtualOriginMesh;
  36771. private _virtualDragMesh;
  36772. private _pointerObserver;
  36773. private _moving;
  36774. private _startingOrientation;
  36775. /**
  36776. * 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)
  36777. */
  36778. private zDragFactor;
  36779. /**
  36780. * If the object should rotate to face the drag origin
  36781. */
  36782. rotateDraggedObject: boolean;
  36783. /**
  36784. * If the behavior is currently in a dragging state
  36785. */
  36786. dragging: boolean;
  36787. /**
  36788. * 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)
  36789. */
  36790. dragDeltaRatio: number;
  36791. /**
  36792. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36793. */
  36794. currentDraggingPointerID: number;
  36795. /**
  36796. * If camera controls should be detached during the drag
  36797. */
  36798. detachCameraControls: boolean;
  36799. /**
  36800. * Fires each time a drag starts
  36801. */
  36802. onDragStartObservable: Observable<{}>;
  36803. /**
  36804. * Fires each time a drag ends (eg. mouse release after drag)
  36805. */
  36806. onDragEndObservable: Observable<{}>;
  36807. /**
  36808. * 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
  36809. */
  36810. constructor();
  36811. /**
  36812. * The name of the behavior
  36813. */
  36814. readonly name: string;
  36815. /**
  36816. * Initializes the behavior
  36817. */
  36818. init(): void;
  36819. /**
  36820. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36821. */
  36822. private readonly _pointerCamera;
  36823. /**
  36824. * Attaches the scale behavior the passed in mesh
  36825. * @param ownerNode The mesh that will be scaled around once attached
  36826. */
  36827. attach(ownerNode: Mesh): void;
  36828. /**
  36829. * Detaches the behavior from the mesh
  36830. */
  36831. detach(): void;
  36832. }
  36833. }
  36834. declare module BABYLON {
  36835. /**
  36836. * Class used to apply inverse kinematics to bones
  36837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36838. */
  36839. export class BoneIKController {
  36840. private static _tmpVecs;
  36841. private static _tmpQuat;
  36842. private static _tmpMats;
  36843. /**
  36844. * Gets or sets the target mesh
  36845. */
  36846. targetMesh: AbstractMesh;
  36847. /** Gets or sets the mesh used as pole */
  36848. poleTargetMesh: AbstractMesh;
  36849. /**
  36850. * Gets or sets the bone used as pole
  36851. */
  36852. poleTargetBone: Nullable<Bone>;
  36853. /**
  36854. * Gets or sets the target position
  36855. */
  36856. targetPosition: Vector3;
  36857. /**
  36858. * Gets or sets the pole target position
  36859. */
  36860. poleTargetPosition: Vector3;
  36861. /**
  36862. * Gets or sets the pole target local offset
  36863. */
  36864. poleTargetLocalOffset: Vector3;
  36865. /**
  36866. * Gets or sets the pole angle
  36867. */
  36868. poleAngle: number;
  36869. /**
  36870. * Gets or sets the mesh associated with the controller
  36871. */
  36872. mesh: AbstractMesh;
  36873. /**
  36874. * 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)
  36875. */
  36876. slerpAmount: number;
  36877. private _bone1Quat;
  36878. private _bone1Mat;
  36879. private _bone2Ang;
  36880. private _bone1;
  36881. private _bone2;
  36882. private _bone1Length;
  36883. private _bone2Length;
  36884. private _maxAngle;
  36885. private _maxReach;
  36886. private _rightHandedSystem;
  36887. private _bendAxis;
  36888. private _slerping;
  36889. private _adjustRoll;
  36890. /**
  36891. * Gets or sets maximum allowed angle
  36892. */
  36893. maxAngle: number;
  36894. /**
  36895. * Creates a new BoneIKController
  36896. * @param mesh defines the mesh to control
  36897. * @param bone defines the bone to control
  36898. * @param options defines options to set up the controller
  36899. */
  36900. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36901. targetMesh?: AbstractMesh;
  36902. poleTargetMesh?: AbstractMesh;
  36903. poleTargetBone?: Bone;
  36904. poleTargetLocalOffset?: Vector3;
  36905. poleAngle?: number;
  36906. bendAxis?: Vector3;
  36907. maxAngle?: number;
  36908. slerpAmount?: number;
  36909. });
  36910. private _setMaxAngle;
  36911. /**
  36912. * Force the controller to update the bones
  36913. */
  36914. update(): void;
  36915. }
  36916. }
  36917. declare module BABYLON {
  36918. /**
  36919. * Class used to make a bone look toward a point in space
  36920. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36921. */
  36922. export class BoneLookController {
  36923. private static _tmpVecs;
  36924. private static _tmpQuat;
  36925. private static _tmpMats;
  36926. /**
  36927. * The target Vector3 that the bone will look at
  36928. */
  36929. target: Vector3;
  36930. /**
  36931. * The mesh that the bone is attached to
  36932. */
  36933. mesh: AbstractMesh;
  36934. /**
  36935. * The bone that will be looking to the target
  36936. */
  36937. bone: Bone;
  36938. /**
  36939. * The up axis of the coordinate system that is used when the bone is rotated
  36940. */
  36941. upAxis: Vector3;
  36942. /**
  36943. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36944. */
  36945. upAxisSpace: Space;
  36946. /**
  36947. * Used to make an adjustment to the yaw of the bone
  36948. */
  36949. adjustYaw: number;
  36950. /**
  36951. * Used to make an adjustment to the pitch of the bone
  36952. */
  36953. adjustPitch: number;
  36954. /**
  36955. * Used to make an adjustment to the roll of the bone
  36956. */
  36957. adjustRoll: number;
  36958. /**
  36959. * 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)
  36960. */
  36961. slerpAmount: number;
  36962. private _minYaw;
  36963. private _maxYaw;
  36964. private _minPitch;
  36965. private _maxPitch;
  36966. private _minYawSin;
  36967. private _minYawCos;
  36968. private _maxYawSin;
  36969. private _maxYawCos;
  36970. private _midYawConstraint;
  36971. private _minPitchTan;
  36972. private _maxPitchTan;
  36973. private _boneQuat;
  36974. private _slerping;
  36975. private _transformYawPitch;
  36976. private _transformYawPitchInv;
  36977. private _firstFrameSkipped;
  36978. private _yawRange;
  36979. private _fowardAxis;
  36980. /**
  36981. * Gets or sets the minimum yaw angle that the bone can look to
  36982. */
  36983. minYaw: number;
  36984. /**
  36985. * Gets or sets the maximum yaw angle that the bone can look to
  36986. */
  36987. maxYaw: number;
  36988. /**
  36989. * Gets or sets the minimum pitch angle that the bone can look to
  36990. */
  36991. minPitch: number;
  36992. /**
  36993. * Gets or sets the maximum pitch angle that the bone can look to
  36994. */
  36995. maxPitch: number;
  36996. /**
  36997. * Create a BoneLookController
  36998. * @param mesh the mesh that the bone belongs to
  36999. * @param bone the bone that will be looking to the target
  37000. * @param target the target Vector3 to look at
  37001. * @param options optional settings:
  37002. * * maxYaw: the maximum angle the bone will yaw to
  37003. * * minYaw: the minimum angle the bone will yaw to
  37004. * * maxPitch: the maximum angle the bone will pitch to
  37005. * * minPitch: the minimum angle the bone will yaw to
  37006. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37007. * * upAxis: the up axis of the coordinate system
  37008. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37009. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37010. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37011. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37012. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37013. * * adjustRoll: used to make an adjustment to the roll of the bone
  37014. **/
  37015. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37016. maxYaw?: number;
  37017. minYaw?: number;
  37018. maxPitch?: number;
  37019. minPitch?: number;
  37020. slerpAmount?: number;
  37021. upAxis?: Vector3;
  37022. upAxisSpace?: Space;
  37023. yawAxis?: Vector3;
  37024. pitchAxis?: Vector3;
  37025. adjustYaw?: number;
  37026. adjustPitch?: number;
  37027. adjustRoll?: number;
  37028. });
  37029. /**
  37030. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37031. */
  37032. update(): void;
  37033. private _getAngleDiff;
  37034. private _getAngleBetween;
  37035. private _isAngleBetween;
  37036. }
  37037. }
  37038. declare module BABYLON {
  37039. /**
  37040. * Manage the gamepad inputs to control an arc rotate camera.
  37041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37042. */
  37043. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37044. /**
  37045. * Defines the camera the input is attached to.
  37046. */
  37047. camera: ArcRotateCamera;
  37048. /**
  37049. * Defines the gamepad the input is gathering event from.
  37050. */
  37051. gamepad: Nullable<Gamepad>;
  37052. /**
  37053. * Defines the gamepad rotation sensiblity.
  37054. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37055. */
  37056. gamepadRotationSensibility: number;
  37057. /**
  37058. * Defines the gamepad move sensiblity.
  37059. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37060. */
  37061. gamepadMoveSensibility: number;
  37062. private _onGamepadConnectedObserver;
  37063. private _onGamepadDisconnectedObserver;
  37064. /**
  37065. * Attach the input controls to a specific dom element to get the input from.
  37066. * @param element Defines the element the controls should be listened from
  37067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37068. */
  37069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37070. /**
  37071. * Detach the current controls from the specified dom element.
  37072. * @param element Defines the element to stop listening the inputs from
  37073. */
  37074. detachControl(element: Nullable<HTMLElement>): void;
  37075. /**
  37076. * Update the current camera state depending on the inputs that have been used this frame.
  37077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37078. */
  37079. checkInputs(): void;
  37080. /**
  37081. * Gets the class name of the current intput.
  37082. * @returns the class name
  37083. */
  37084. getClassName(): string;
  37085. /**
  37086. * Get the friendly name associated with the input class.
  37087. * @returns the input friendly name
  37088. */
  37089. getSimpleName(): string;
  37090. }
  37091. }
  37092. declare module BABYLON {
  37093. interface ArcRotateCameraInputsManager {
  37094. /**
  37095. * Add orientation input support to the input manager.
  37096. * @returns the current input manager
  37097. */
  37098. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37099. }
  37100. /**
  37101. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37103. */
  37104. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37105. /**
  37106. * Defines the camera the input is attached to.
  37107. */
  37108. camera: ArcRotateCamera;
  37109. /**
  37110. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37111. */
  37112. alphaCorrection: number;
  37113. /**
  37114. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37115. */
  37116. gammaCorrection: number;
  37117. private _alpha;
  37118. private _gamma;
  37119. private _dirty;
  37120. private _deviceOrientationHandler;
  37121. /**
  37122. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37123. */
  37124. constructor();
  37125. /**
  37126. * Attach the input controls to a specific dom element to get the input from.
  37127. * @param element Defines the element the controls should be listened from
  37128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37129. */
  37130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37131. /** @hidden */
  37132. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37133. /**
  37134. * Update the current camera state depending on the inputs that have been used this frame.
  37135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37136. */
  37137. checkInputs(): void;
  37138. /**
  37139. * Detach the current controls from the specified dom element.
  37140. * @param element Defines the element to stop listening the inputs from
  37141. */
  37142. detachControl(element: Nullable<HTMLElement>): void;
  37143. /**
  37144. * Gets the class name of the current intput.
  37145. * @returns the class name
  37146. */
  37147. getClassName(): string;
  37148. /**
  37149. * Get the friendly name associated with the input class.
  37150. * @returns the input friendly name
  37151. */
  37152. getSimpleName(): string;
  37153. }
  37154. }
  37155. declare module BABYLON {
  37156. /**
  37157. * Listen to mouse events to control the camera.
  37158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37159. */
  37160. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37161. /**
  37162. * Defines the camera the input is attached to.
  37163. */
  37164. camera: FlyCamera;
  37165. /**
  37166. * Defines if touch is enabled. (Default is true.)
  37167. */
  37168. touchEnabled: boolean;
  37169. /**
  37170. * Defines the buttons associated with the input to handle camera rotation.
  37171. */
  37172. buttons: number[];
  37173. /**
  37174. * Assign buttons for Yaw control.
  37175. */
  37176. buttonsYaw: number[];
  37177. /**
  37178. * Assign buttons for Pitch control.
  37179. */
  37180. buttonsPitch: number[];
  37181. /**
  37182. * Assign buttons for Roll control.
  37183. */
  37184. buttonsRoll: number[];
  37185. /**
  37186. * Detect if any button is being pressed while mouse is moved.
  37187. * -1 = Mouse locked.
  37188. * 0 = Left button.
  37189. * 1 = Middle Button.
  37190. * 2 = Right Button.
  37191. */
  37192. activeButton: number;
  37193. /**
  37194. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37195. * Higher values reduce its sensitivity.
  37196. */
  37197. angularSensibility: number;
  37198. private _mousemoveCallback;
  37199. private _observer;
  37200. private _rollObserver;
  37201. private previousPosition;
  37202. private noPreventDefault;
  37203. private element;
  37204. /**
  37205. * Listen to mouse events to control the camera.
  37206. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37208. */
  37209. constructor(touchEnabled?: boolean);
  37210. /**
  37211. * Attach the mouse control to the HTML DOM element.
  37212. * @param element Defines the element that listens to the input events.
  37213. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37214. */
  37215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37216. /**
  37217. * Detach the current controls from the specified dom element.
  37218. * @param element Defines the element to stop listening the inputs from
  37219. */
  37220. detachControl(element: Nullable<HTMLElement>): void;
  37221. /**
  37222. * Gets the class name of the current input.
  37223. * @returns the class name.
  37224. */
  37225. getClassName(): string;
  37226. /**
  37227. * Get the friendly name associated with the input class.
  37228. * @returns the input's friendly name.
  37229. */
  37230. getSimpleName(): string;
  37231. private _pointerInput;
  37232. private _onMouseMove;
  37233. /**
  37234. * Rotate camera by mouse offset.
  37235. */
  37236. private rotateCamera;
  37237. }
  37238. }
  37239. declare module BABYLON {
  37240. /**
  37241. * Default Inputs manager for the FlyCamera.
  37242. * It groups all the default supported inputs for ease of use.
  37243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37244. */
  37245. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37246. /**
  37247. * Instantiates a new FlyCameraInputsManager.
  37248. * @param camera Defines the camera the inputs belong to.
  37249. */
  37250. constructor(camera: FlyCamera);
  37251. /**
  37252. * Add keyboard input support to the input manager.
  37253. * @returns the new FlyCameraKeyboardMoveInput().
  37254. */
  37255. addKeyboard(): FlyCameraInputsManager;
  37256. /**
  37257. * Add mouse input support to the input manager.
  37258. * @param touchEnabled Enable touch screen support.
  37259. * @returns the new FlyCameraMouseInput().
  37260. */
  37261. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37262. }
  37263. }
  37264. declare module BABYLON {
  37265. /**
  37266. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37267. * such as in a 3D Space Shooter or a Flight Simulator.
  37268. */
  37269. export class FlyCamera extends TargetCamera {
  37270. /**
  37271. * Define the collision ellipsoid of the camera.
  37272. * This is helpful for simulating a camera body, like a player's body.
  37273. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37274. */
  37275. ellipsoid: Vector3;
  37276. /**
  37277. * Define an offset for the position of the ellipsoid around the camera.
  37278. * This can be helpful if the camera is attached away from the player's body center,
  37279. * such as at its head.
  37280. */
  37281. ellipsoidOffset: Vector3;
  37282. /**
  37283. * Enable or disable collisions of the camera with the rest of the scene objects.
  37284. */
  37285. checkCollisions: boolean;
  37286. /**
  37287. * Enable or disable gravity on the camera.
  37288. */
  37289. applyGravity: boolean;
  37290. /**
  37291. * Define the current direction the camera is moving to.
  37292. */
  37293. cameraDirection: Vector3;
  37294. /**
  37295. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37296. * This overrides and empties cameraRotation.
  37297. */
  37298. rotationQuaternion: Quaternion;
  37299. /**
  37300. * Track Roll to maintain the wanted Rolling when looking around.
  37301. */
  37302. _trackRoll: number;
  37303. /**
  37304. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37305. */
  37306. rollCorrect: number;
  37307. /**
  37308. * Mimic a banked turn, Rolling the camera when Yawing.
  37309. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37310. */
  37311. bankedTurn: boolean;
  37312. /**
  37313. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37314. */
  37315. bankedTurnLimit: number;
  37316. /**
  37317. * Value of 0 disables the banked Roll.
  37318. * Value of 1 is equal to the Yaw angle in radians.
  37319. */
  37320. bankedTurnMultiplier: number;
  37321. /**
  37322. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37323. */
  37324. inputs: FlyCameraInputsManager;
  37325. /**
  37326. * Gets the input sensibility for mouse input.
  37327. * Higher values reduce sensitivity.
  37328. */
  37329. /**
  37330. * Sets the input sensibility for a mouse input.
  37331. * Higher values reduce sensitivity.
  37332. */
  37333. angularSensibility: number;
  37334. /**
  37335. * Get the keys for camera movement forward.
  37336. */
  37337. /**
  37338. * Set the keys for camera movement forward.
  37339. */
  37340. keysForward: number[];
  37341. /**
  37342. * Get the keys for camera movement backward.
  37343. */
  37344. keysBackward: number[];
  37345. /**
  37346. * Get the keys for camera movement up.
  37347. */
  37348. /**
  37349. * Set the keys for camera movement up.
  37350. */
  37351. keysUp: number[];
  37352. /**
  37353. * Get the keys for camera movement down.
  37354. */
  37355. /**
  37356. * Set the keys for camera movement down.
  37357. */
  37358. keysDown: number[];
  37359. /**
  37360. * Get the keys for camera movement left.
  37361. */
  37362. /**
  37363. * Set the keys for camera movement left.
  37364. */
  37365. keysLeft: number[];
  37366. /**
  37367. * Set the keys for camera movement right.
  37368. */
  37369. /**
  37370. * Set the keys for camera movement right.
  37371. */
  37372. keysRight: number[];
  37373. /**
  37374. * Event raised when the camera collides with a mesh in the scene.
  37375. */
  37376. onCollide: (collidedMesh: AbstractMesh) => void;
  37377. private _collider;
  37378. private _needMoveForGravity;
  37379. private _oldPosition;
  37380. private _diffPosition;
  37381. private _newPosition;
  37382. /** @hidden */
  37383. _localDirection: Vector3;
  37384. /** @hidden */
  37385. _transformedDirection: Vector3;
  37386. /**
  37387. * Instantiates a FlyCamera.
  37388. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37389. * such as in a 3D Space Shooter or a Flight Simulator.
  37390. * @param name Define the name of the camera in the scene.
  37391. * @param position Define the starting position of the camera in the scene.
  37392. * @param scene Define the scene the camera belongs to.
  37393. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37394. */
  37395. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37396. /**
  37397. * Attach a control to the HTML DOM element.
  37398. * @param element Defines the element that listens to the input events.
  37399. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37400. */
  37401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37402. /**
  37403. * Detach a control from the HTML DOM element.
  37404. * The camera will stop reacting to that input.
  37405. * @param element Defines the element that listens to the input events.
  37406. */
  37407. detachControl(element: HTMLElement): void;
  37408. private _collisionMask;
  37409. /**
  37410. * Get the mask that the camera ignores in collision events.
  37411. */
  37412. /**
  37413. * Set the mask that the camera ignores in collision events.
  37414. */
  37415. collisionMask: number;
  37416. /** @hidden */
  37417. _collideWithWorld(displacement: Vector3): void;
  37418. /** @hidden */
  37419. private _onCollisionPositionChange;
  37420. /** @hidden */
  37421. _checkInputs(): void;
  37422. /** @hidden */
  37423. _decideIfNeedsToMove(): boolean;
  37424. /** @hidden */
  37425. _updatePosition(): void;
  37426. /**
  37427. * Restore the Roll to its target value at the rate specified.
  37428. * @param rate - Higher means slower restoring.
  37429. * @hidden
  37430. */
  37431. restoreRoll(rate: number): void;
  37432. /**
  37433. * Destroy the camera and release the current resources held by it.
  37434. */
  37435. dispose(): void;
  37436. /**
  37437. * Get the current object class name.
  37438. * @returns the class name.
  37439. */
  37440. getClassName(): string;
  37441. }
  37442. }
  37443. declare module BABYLON {
  37444. /**
  37445. * Listen to keyboard events to control the camera.
  37446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37447. */
  37448. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37449. /**
  37450. * Defines the camera the input is attached to.
  37451. */
  37452. camera: FlyCamera;
  37453. /**
  37454. * The list of keyboard keys used to control the forward move of the camera.
  37455. */
  37456. keysForward: number[];
  37457. /**
  37458. * The list of keyboard keys used to control the backward move of the camera.
  37459. */
  37460. keysBackward: number[];
  37461. /**
  37462. * The list of keyboard keys used to control the forward move of the camera.
  37463. */
  37464. keysUp: number[];
  37465. /**
  37466. * The list of keyboard keys used to control the backward move of the camera.
  37467. */
  37468. keysDown: number[];
  37469. /**
  37470. * The list of keyboard keys used to control the right strafe move of the camera.
  37471. */
  37472. keysRight: number[];
  37473. /**
  37474. * The list of keyboard keys used to control the left strafe move of the camera.
  37475. */
  37476. keysLeft: number[];
  37477. private _keys;
  37478. private _onCanvasBlurObserver;
  37479. private _onKeyboardObserver;
  37480. private _engine;
  37481. private _scene;
  37482. /**
  37483. * Attach the input controls to a specific dom element to get the input from.
  37484. * @param element Defines the element the controls should be listened from
  37485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37486. */
  37487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37488. /**
  37489. * Detach the current controls from the specified dom element.
  37490. * @param element Defines the element to stop listening the inputs from
  37491. */
  37492. detachControl(element: Nullable<HTMLElement>): void;
  37493. /**
  37494. * Gets the class name of the current intput.
  37495. * @returns the class name
  37496. */
  37497. getClassName(): string;
  37498. /** @hidden */
  37499. _onLostFocus(e: FocusEvent): void;
  37500. /**
  37501. * Get the friendly name associated with the input class.
  37502. * @returns the input friendly name
  37503. */
  37504. getSimpleName(): string;
  37505. /**
  37506. * Update the current camera state depending on the inputs that have been used this frame.
  37507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37508. */
  37509. checkInputs(): void;
  37510. }
  37511. }
  37512. declare module BABYLON {
  37513. /**
  37514. * Manage the mouse wheel inputs to control a follow camera.
  37515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37516. */
  37517. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37518. /**
  37519. * Defines the camera the input is attached to.
  37520. */
  37521. camera: FollowCamera;
  37522. /**
  37523. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37524. */
  37525. axisControlRadius: boolean;
  37526. /**
  37527. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37528. */
  37529. axisControlHeight: boolean;
  37530. /**
  37531. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37532. */
  37533. axisControlRotation: boolean;
  37534. /**
  37535. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37536. * relation to mouseWheel events.
  37537. */
  37538. wheelPrecision: number;
  37539. /**
  37540. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37541. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37542. */
  37543. wheelDeltaPercentage: number;
  37544. private _wheel;
  37545. private _observer;
  37546. /**
  37547. * Attach the input controls to a specific dom element to get the input from.
  37548. * @param element Defines the element the controls should be listened from
  37549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37550. */
  37551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37552. /**
  37553. * Detach the current controls from the specified dom element.
  37554. * @param element Defines the element to stop listening the inputs from
  37555. */
  37556. detachControl(element: Nullable<HTMLElement>): void;
  37557. /**
  37558. * Gets the class name of the current intput.
  37559. * @returns the class name
  37560. */
  37561. getClassName(): string;
  37562. /**
  37563. * Get the friendly name associated with the input class.
  37564. * @returns the input friendly name
  37565. */
  37566. getSimpleName(): string;
  37567. }
  37568. }
  37569. declare module BABYLON {
  37570. /**
  37571. * Manage the pointers inputs to control an follow camera.
  37572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37573. */
  37574. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37575. /**
  37576. * Defines the camera the input is attached to.
  37577. */
  37578. camera: FollowCamera;
  37579. /**
  37580. * Gets the class name of the current input.
  37581. * @returns the class name
  37582. */
  37583. getClassName(): string;
  37584. /**
  37585. * Defines the pointer angular sensibility along the X axis or how fast is
  37586. * the camera rotating.
  37587. * A negative number will reverse the axis direction.
  37588. */
  37589. angularSensibilityX: number;
  37590. /**
  37591. * Defines the pointer angular sensibility along the Y axis or how fast is
  37592. * the camera rotating.
  37593. * A negative number will reverse the axis direction.
  37594. */
  37595. angularSensibilityY: number;
  37596. /**
  37597. * Defines the pointer pinch precision or how fast is the camera zooming.
  37598. * A negative number will reverse the axis direction.
  37599. */
  37600. pinchPrecision: number;
  37601. /**
  37602. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37603. * from 0.
  37604. * It defines the percentage of current camera.radius to use as delta when
  37605. * pinch zoom is used.
  37606. */
  37607. pinchDeltaPercentage: number;
  37608. /**
  37609. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37610. */
  37611. axisXControlRadius: boolean;
  37612. /**
  37613. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37614. */
  37615. axisXControlHeight: boolean;
  37616. /**
  37617. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37618. */
  37619. axisXControlRotation: boolean;
  37620. /**
  37621. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37622. */
  37623. axisYControlRadius: boolean;
  37624. /**
  37625. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37626. */
  37627. axisYControlHeight: boolean;
  37628. /**
  37629. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37630. */
  37631. axisYControlRotation: boolean;
  37632. /**
  37633. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37634. */
  37635. axisPinchControlRadius: boolean;
  37636. /**
  37637. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37638. */
  37639. axisPinchControlHeight: boolean;
  37640. /**
  37641. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37642. */
  37643. axisPinchControlRotation: boolean;
  37644. /**
  37645. * Log error messages if basic misconfiguration has occurred.
  37646. */
  37647. warningEnable: boolean;
  37648. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37649. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37650. private _warningCounter;
  37651. private _warning;
  37652. }
  37653. }
  37654. declare module BABYLON {
  37655. /**
  37656. * Default Inputs manager for the FollowCamera.
  37657. * It groups all the default supported inputs for ease of use.
  37658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37659. */
  37660. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37661. /**
  37662. * Instantiates a new FollowCameraInputsManager.
  37663. * @param camera Defines the camera the inputs belong to
  37664. */
  37665. constructor(camera: FollowCamera);
  37666. /**
  37667. * Add keyboard input support to the input manager.
  37668. * @returns the current input manager
  37669. */
  37670. addKeyboard(): FollowCameraInputsManager;
  37671. /**
  37672. * Add mouse wheel input support to the input manager.
  37673. * @returns the current input manager
  37674. */
  37675. addMouseWheel(): FollowCameraInputsManager;
  37676. /**
  37677. * Add pointers input support to the input manager.
  37678. * @returns the current input manager
  37679. */
  37680. addPointers(): FollowCameraInputsManager;
  37681. /**
  37682. * Add orientation input support to the input manager.
  37683. * @returns the current input manager
  37684. */
  37685. addVRDeviceOrientation(): FollowCameraInputsManager;
  37686. }
  37687. }
  37688. declare module BABYLON {
  37689. /**
  37690. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37691. * an arc rotate version arcFollowCamera are available.
  37692. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37693. */
  37694. export class FollowCamera extends TargetCamera {
  37695. /**
  37696. * Distance the follow camera should follow an object at
  37697. */
  37698. radius: number;
  37699. /**
  37700. * Minimum allowed distance of the camera to the axis of rotation
  37701. * (The camera can not get closer).
  37702. * This can help limiting how the Camera is able to move in the scene.
  37703. */
  37704. lowerRadiusLimit: Nullable<number>;
  37705. /**
  37706. * Maximum allowed distance of the camera to the axis of rotation
  37707. * (The camera can not get further).
  37708. * This can help limiting how the Camera is able to move in the scene.
  37709. */
  37710. upperRadiusLimit: Nullable<number>;
  37711. /**
  37712. * Define a rotation offset between the camera and the object it follows
  37713. */
  37714. rotationOffset: number;
  37715. /**
  37716. * Minimum allowed angle to camera position relative to target object.
  37717. * This can help limiting how the Camera is able to move in the scene.
  37718. */
  37719. lowerRotationOffsetLimit: Nullable<number>;
  37720. /**
  37721. * Maximum allowed angle to camera position relative to target object.
  37722. * This can help limiting how the Camera is able to move in the scene.
  37723. */
  37724. upperRotationOffsetLimit: Nullable<number>;
  37725. /**
  37726. * Define a height offset between the camera and the object it follows.
  37727. * It can help following an object from the top (like a car chaing a plane)
  37728. */
  37729. heightOffset: number;
  37730. /**
  37731. * Minimum allowed height of camera position relative to target object.
  37732. * This can help limiting how the Camera is able to move in the scene.
  37733. */
  37734. lowerHeightOffsetLimit: Nullable<number>;
  37735. /**
  37736. * Maximum allowed height of camera position relative to target object.
  37737. * This can help limiting how the Camera is able to move in the scene.
  37738. */
  37739. upperHeightOffsetLimit: Nullable<number>;
  37740. /**
  37741. * Define how fast the camera can accelerate to follow it s target.
  37742. */
  37743. cameraAcceleration: number;
  37744. /**
  37745. * Define the speed limit of the camera following an object.
  37746. */
  37747. maxCameraSpeed: number;
  37748. /**
  37749. * Define the target of the camera.
  37750. */
  37751. lockedTarget: Nullable<AbstractMesh>;
  37752. /**
  37753. * Defines the input associated with the camera.
  37754. */
  37755. inputs: FollowCameraInputsManager;
  37756. /**
  37757. * Instantiates the follow camera.
  37758. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37759. * @param name Define the name of the camera in the scene
  37760. * @param position Define the position of the camera
  37761. * @param scene Define the scene the camera belong to
  37762. * @param lockedTarget Define the target of the camera
  37763. */
  37764. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37765. private _follow;
  37766. /**
  37767. * Attached controls to the current camera.
  37768. * @param element Defines the element the controls should be listened from
  37769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37770. */
  37771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37772. /**
  37773. * Detach the current controls from the camera.
  37774. * The camera will stop reacting to inputs.
  37775. * @param element Defines the element to stop listening the inputs from
  37776. */
  37777. detachControl(element: HTMLElement): void;
  37778. /** @hidden */
  37779. _checkInputs(): void;
  37780. private _checkLimits;
  37781. /**
  37782. * Gets the camera class name.
  37783. * @returns the class name
  37784. */
  37785. getClassName(): string;
  37786. }
  37787. /**
  37788. * Arc Rotate version of the follow camera.
  37789. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37790. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37791. */
  37792. export class ArcFollowCamera extends TargetCamera {
  37793. /** The longitudinal angle of the camera */
  37794. alpha: number;
  37795. /** The latitudinal angle of the camera */
  37796. beta: number;
  37797. /** The radius of the camera from its target */
  37798. radius: number;
  37799. /** Define the camera target (the messh it should follow) */
  37800. target: Nullable<AbstractMesh>;
  37801. private _cartesianCoordinates;
  37802. /**
  37803. * Instantiates a new ArcFollowCamera
  37804. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37805. * @param name Define the name of the camera
  37806. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37807. * @param beta Define the rotation angle of the camera around the elevation axis
  37808. * @param radius Define the radius of the camera from its target point
  37809. * @param target Define the target of the camera
  37810. * @param scene Define the scene the camera belongs to
  37811. */
  37812. constructor(name: string,
  37813. /** The longitudinal angle of the camera */
  37814. alpha: number,
  37815. /** The latitudinal angle of the camera */
  37816. beta: number,
  37817. /** The radius of the camera from its target */
  37818. radius: number,
  37819. /** Define the camera target (the messh it should follow) */
  37820. target: Nullable<AbstractMesh>, scene: Scene);
  37821. private _follow;
  37822. /** @hidden */
  37823. _checkInputs(): void;
  37824. /**
  37825. * Returns the class name of the object.
  37826. * It is mostly used internally for serialization purposes.
  37827. */
  37828. getClassName(): string;
  37829. }
  37830. }
  37831. declare module BABYLON {
  37832. /**
  37833. * Manage the keyboard inputs to control the movement of a follow camera.
  37834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37835. */
  37836. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37837. /**
  37838. * Defines the camera the input is attached to.
  37839. */
  37840. camera: FollowCamera;
  37841. /**
  37842. * Defines the list of key codes associated with the up action (increase heightOffset)
  37843. */
  37844. keysHeightOffsetIncr: number[];
  37845. /**
  37846. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37847. */
  37848. keysHeightOffsetDecr: number[];
  37849. /**
  37850. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37851. */
  37852. keysHeightOffsetModifierAlt: boolean;
  37853. /**
  37854. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37855. */
  37856. keysHeightOffsetModifierCtrl: boolean;
  37857. /**
  37858. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37859. */
  37860. keysHeightOffsetModifierShift: boolean;
  37861. /**
  37862. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37863. */
  37864. keysRotationOffsetIncr: number[];
  37865. /**
  37866. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37867. */
  37868. keysRotationOffsetDecr: number[];
  37869. /**
  37870. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37871. */
  37872. keysRotationOffsetModifierAlt: boolean;
  37873. /**
  37874. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37875. */
  37876. keysRotationOffsetModifierCtrl: boolean;
  37877. /**
  37878. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37879. */
  37880. keysRotationOffsetModifierShift: boolean;
  37881. /**
  37882. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37883. */
  37884. keysRadiusIncr: number[];
  37885. /**
  37886. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37887. */
  37888. keysRadiusDecr: number[];
  37889. /**
  37890. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37891. */
  37892. keysRadiusModifierAlt: boolean;
  37893. /**
  37894. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37895. */
  37896. keysRadiusModifierCtrl: boolean;
  37897. /**
  37898. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37899. */
  37900. keysRadiusModifierShift: boolean;
  37901. /**
  37902. * Defines the rate of change of heightOffset.
  37903. */
  37904. heightSensibility: number;
  37905. /**
  37906. * Defines the rate of change of rotationOffset.
  37907. */
  37908. rotationSensibility: number;
  37909. /**
  37910. * Defines the rate of change of radius.
  37911. */
  37912. radiusSensibility: number;
  37913. private _keys;
  37914. private _ctrlPressed;
  37915. private _altPressed;
  37916. private _shiftPressed;
  37917. private _onCanvasBlurObserver;
  37918. private _onKeyboardObserver;
  37919. private _engine;
  37920. private _scene;
  37921. /**
  37922. * Attach the input controls to a specific dom element to get the input from.
  37923. * @param element Defines the element the controls should be listened from
  37924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37925. */
  37926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37927. /**
  37928. * Detach the current controls from the specified dom element.
  37929. * @param element Defines the element to stop listening the inputs from
  37930. */
  37931. detachControl(element: Nullable<HTMLElement>): void;
  37932. /**
  37933. * Update the current camera state depending on the inputs that have been used this frame.
  37934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37935. */
  37936. checkInputs(): void;
  37937. /**
  37938. * Gets the class name of the current input.
  37939. * @returns the class name
  37940. */
  37941. getClassName(): string;
  37942. /**
  37943. * Get the friendly name associated with the input class.
  37944. * @returns the input friendly name
  37945. */
  37946. getSimpleName(): string;
  37947. /**
  37948. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37949. * allow modification of the heightOffset value.
  37950. */
  37951. private _modifierHeightOffset;
  37952. /**
  37953. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37954. * allow modification of the rotationOffset value.
  37955. */
  37956. private _modifierRotationOffset;
  37957. /**
  37958. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37959. * allow modification of the radius value.
  37960. */
  37961. private _modifierRadius;
  37962. }
  37963. }
  37964. declare module BABYLON {
  37965. interface FreeCameraInputsManager {
  37966. /**
  37967. * @hidden
  37968. */
  37969. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37970. /**
  37971. * Add orientation input support to the input manager.
  37972. * @returns the current input manager
  37973. */
  37974. addDeviceOrientation(): FreeCameraInputsManager;
  37975. }
  37976. /**
  37977. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37978. * Screen rotation is taken into account.
  37979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37980. */
  37981. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37982. private _camera;
  37983. private _screenOrientationAngle;
  37984. private _constantTranform;
  37985. private _screenQuaternion;
  37986. private _alpha;
  37987. private _beta;
  37988. private _gamma;
  37989. /**
  37990. * Can be used to detect if a device orientation sensor is availible on a device
  37991. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37992. * @returns a promise that will resolve on orientation change
  37993. */
  37994. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37995. /**
  37996. * @hidden
  37997. */
  37998. _onDeviceOrientationChangedObservable: Observable<void>;
  37999. /**
  38000. * Instantiates a new input
  38001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38002. */
  38003. constructor();
  38004. /**
  38005. * Define the camera controlled by the input.
  38006. */
  38007. camera: FreeCamera;
  38008. /**
  38009. * Attach the input controls to a specific dom element to get the input from.
  38010. * @param element Defines the element the controls should be listened from
  38011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38012. */
  38013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38014. private _orientationChanged;
  38015. private _deviceOrientation;
  38016. /**
  38017. * Detach the current controls from the specified dom element.
  38018. * @param element Defines the element to stop listening the inputs from
  38019. */
  38020. detachControl(element: Nullable<HTMLElement>): void;
  38021. /**
  38022. * Update the current camera state depending on the inputs that have been used this frame.
  38023. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38024. */
  38025. checkInputs(): void;
  38026. /**
  38027. * Gets the class name of the current intput.
  38028. * @returns the class name
  38029. */
  38030. getClassName(): string;
  38031. /**
  38032. * Get the friendly name associated with the input class.
  38033. * @returns the input friendly name
  38034. */
  38035. getSimpleName(): string;
  38036. }
  38037. }
  38038. declare module BABYLON {
  38039. /**
  38040. * Manage the gamepad inputs to control a free camera.
  38041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38042. */
  38043. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38044. /**
  38045. * Define the camera the input is attached to.
  38046. */
  38047. camera: FreeCamera;
  38048. /**
  38049. * Define the Gamepad controlling the input
  38050. */
  38051. gamepad: Nullable<Gamepad>;
  38052. /**
  38053. * Defines the gamepad rotation sensiblity.
  38054. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38055. */
  38056. gamepadAngularSensibility: number;
  38057. /**
  38058. * Defines the gamepad move sensiblity.
  38059. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38060. */
  38061. gamepadMoveSensibility: number;
  38062. private _onGamepadConnectedObserver;
  38063. private _onGamepadDisconnectedObserver;
  38064. private _cameraTransform;
  38065. private _deltaTransform;
  38066. private _vector3;
  38067. private _vector2;
  38068. /**
  38069. * Attach the input controls to a specific dom element to get the input from.
  38070. * @param element Defines the element the controls should be listened from
  38071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38072. */
  38073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38074. /**
  38075. * Detach the current controls from the specified dom element.
  38076. * @param element Defines the element to stop listening the inputs from
  38077. */
  38078. detachControl(element: Nullable<HTMLElement>): void;
  38079. /**
  38080. * Update the current camera state depending on the inputs that have been used this frame.
  38081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38082. */
  38083. checkInputs(): void;
  38084. /**
  38085. * Gets the class name of the current intput.
  38086. * @returns the class name
  38087. */
  38088. getClassName(): string;
  38089. /**
  38090. * Get the friendly name associated with the input class.
  38091. * @returns the input friendly name
  38092. */
  38093. getSimpleName(): string;
  38094. }
  38095. }
  38096. declare module BABYLON {
  38097. /**
  38098. * Defines the potential axis of a Joystick
  38099. */
  38100. export enum JoystickAxis {
  38101. /** X axis */
  38102. X = 0,
  38103. /** Y axis */
  38104. Y = 1,
  38105. /** Z axis */
  38106. Z = 2
  38107. }
  38108. /**
  38109. * Class used to define virtual joystick (used in touch mode)
  38110. */
  38111. export class VirtualJoystick {
  38112. /**
  38113. * Gets or sets a boolean indicating that left and right values must be inverted
  38114. */
  38115. reverseLeftRight: boolean;
  38116. /**
  38117. * Gets or sets a boolean indicating that up and down values must be inverted
  38118. */
  38119. reverseUpDown: boolean;
  38120. /**
  38121. * Gets the offset value for the position (ie. the change of the position value)
  38122. */
  38123. deltaPosition: Vector3;
  38124. /**
  38125. * Gets a boolean indicating if the virtual joystick was pressed
  38126. */
  38127. pressed: boolean;
  38128. /**
  38129. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38130. */
  38131. static Canvas: Nullable<HTMLCanvasElement>;
  38132. private static _globalJoystickIndex;
  38133. private static vjCanvasContext;
  38134. private static vjCanvasWidth;
  38135. private static vjCanvasHeight;
  38136. private static halfWidth;
  38137. private _action;
  38138. private _axisTargetedByLeftAndRight;
  38139. private _axisTargetedByUpAndDown;
  38140. private _joystickSensibility;
  38141. private _inversedSensibility;
  38142. private _joystickPointerID;
  38143. private _joystickColor;
  38144. private _joystickPointerPos;
  38145. private _joystickPreviousPointerPos;
  38146. private _joystickPointerStartPos;
  38147. private _deltaJoystickVector;
  38148. private _leftJoystick;
  38149. private _touches;
  38150. private _onPointerDownHandlerRef;
  38151. private _onPointerMoveHandlerRef;
  38152. private _onPointerUpHandlerRef;
  38153. private _onResize;
  38154. /**
  38155. * Creates a new virtual joystick
  38156. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38157. */
  38158. constructor(leftJoystick?: boolean);
  38159. /**
  38160. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38161. * @param newJoystickSensibility defines the new sensibility
  38162. */
  38163. setJoystickSensibility(newJoystickSensibility: number): void;
  38164. private _onPointerDown;
  38165. private _onPointerMove;
  38166. private _onPointerUp;
  38167. /**
  38168. * Change the color of the virtual joystick
  38169. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38170. */
  38171. setJoystickColor(newColor: string): void;
  38172. /**
  38173. * Defines a callback to call when the joystick is touched
  38174. * @param action defines the callback
  38175. */
  38176. setActionOnTouch(action: () => any): void;
  38177. /**
  38178. * Defines which axis you'd like to control for left & right
  38179. * @param axis defines the axis to use
  38180. */
  38181. setAxisForLeftRight(axis: JoystickAxis): void;
  38182. /**
  38183. * Defines which axis you'd like to control for up & down
  38184. * @param axis defines the axis to use
  38185. */
  38186. setAxisForUpDown(axis: JoystickAxis): void;
  38187. private _drawVirtualJoystick;
  38188. /**
  38189. * Release internal HTML canvas
  38190. */
  38191. releaseCanvas(): void;
  38192. }
  38193. }
  38194. declare module BABYLON {
  38195. interface FreeCameraInputsManager {
  38196. /**
  38197. * Add virtual joystick input support to the input manager.
  38198. * @returns the current input manager
  38199. */
  38200. addVirtualJoystick(): FreeCameraInputsManager;
  38201. }
  38202. /**
  38203. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38205. */
  38206. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38207. /**
  38208. * Defines the camera the input is attached to.
  38209. */
  38210. camera: FreeCamera;
  38211. private _leftjoystick;
  38212. private _rightjoystick;
  38213. /**
  38214. * Gets the left stick of the virtual joystick.
  38215. * @returns The virtual Joystick
  38216. */
  38217. getLeftJoystick(): VirtualJoystick;
  38218. /**
  38219. * Gets the right stick of the virtual joystick.
  38220. * @returns The virtual Joystick
  38221. */
  38222. getRightJoystick(): VirtualJoystick;
  38223. /**
  38224. * Update the current camera state depending on the inputs that have been used this frame.
  38225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38226. */
  38227. checkInputs(): void;
  38228. /**
  38229. * Attach the input controls to a specific dom element to get the input from.
  38230. * @param element Defines the element the controls should be listened from
  38231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38232. */
  38233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38234. /**
  38235. * Detach the current controls from the specified dom element.
  38236. * @param element Defines the element to stop listening the inputs from
  38237. */
  38238. detachControl(element: Nullable<HTMLElement>): void;
  38239. /**
  38240. * Gets the class name of the current intput.
  38241. * @returns the class name
  38242. */
  38243. getClassName(): string;
  38244. /**
  38245. * Get the friendly name associated with the input class.
  38246. * @returns the input friendly name
  38247. */
  38248. getSimpleName(): string;
  38249. }
  38250. }
  38251. declare module BABYLON {
  38252. /**
  38253. * This represents a FPS type of camera controlled by touch.
  38254. * This is like a universal camera minus the Gamepad controls.
  38255. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38256. */
  38257. export class TouchCamera extends FreeCamera {
  38258. /**
  38259. * Defines the touch sensibility for rotation.
  38260. * The higher the faster.
  38261. */
  38262. touchAngularSensibility: number;
  38263. /**
  38264. * Defines the touch sensibility for move.
  38265. * The higher the faster.
  38266. */
  38267. touchMoveSensibility: number;
  38268. /**
  38269. * Instantiates a new touch camera.
  38270. * This represents a FPS type of camera controlled by touch.
  38271. * This is like a universal camera minus the Gamepad controls.
  38272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38273. * @param name Define the name of the camera in the scene
  38274. * @param position Define the start position of the camera in the scene
  38275. * @param scene Define the scene the camera belongs to
  38276. */
  38277. constructor(name: string, position: Vector3, scene: Scene);
  38278. /**
  38279. * Gets the current object class name.
  38280. * @return the class name
  38281. */
  38282. getClassName(): string;
  38283. /** @hidden */
  38284. _setupInputs(): void;
  38285. }
  38286. }
  38287. declare module BABYLON {
  38288. /**
  38289. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38290. * being tilted forward or back and left or right.
  38291. */
  38292. export class DeviceOrientationCamera extends FreeCamera {
  38293. private _initialQuaternion;
  38294. private _quaternionCache;
  38295. private _tmpDragQuaternion;
  38296. private _disablePointerInputWhenUsingDeviceOrientation;
  38297. /**
  38298. * Creates a new device orientation camera
  38299. * @param name The name of the camera
  38300. * @param position The start position camera
  38301. * @param scene The scene the camera belongs to
  38302. */
  38303. constructor(name: string, position: Vector3, scene: Scene);
  38304. /**
  38305. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38306. */
  38307. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38308. private _dragFactor;
  38309. /**
  38310. * Enabled turning on the y axis when the orientation sensor is active
  38311. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38312. */
  38313. enableHorizontalDragging(dragFactor?: number): void;
  38314. /**
  38315. * Gets the current instance class name ("DeviceOrientationCamera").
  38316. * This helps avoiding instanceof at run time.
  38317. * @returns the class name
  38318. */
  38319. getClassName(): string;
  38320. /**
  38321. * @hidden
  38322. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38323. */
  38324. _checkInputs(): void;
  38325. /**
  38326. * Reset the camera to its default orientation on the specified axis only.
  38327. * @param axis The axis to reset
  38328. */
  38329. resetToCurrentRotation(axis?: Axis): void;
  38330. }
  38331. }
  38332. declare module BABYLON {
  38333. /**
  38334. * Defines supported buttons for XBox360 compatible gamepads
  38335. */
  38336. export enum Xbox360Button {
  38337. /** A */
  38338. A = 0,
  38339. /** B */
  38340. B = 1,
  38341. /** X */
  38342. X = 2,
  38343. /** Y */
  38344. Y = 3,
  38345. /** Start */
  38346. Start = 4,
  38347. /** Back */
  38348. Back = 5,
  38349. /** Left button */
  38350. LB = 6,
  38351. /** Right button */
  38352. RB = 7,
  38353. /** Left stick */
  38354. LeftStick = 8,
  38355. /** Right stick */
  38356. RightStick = 9
  38357. }
  38358. /** Defines values for XBox360 DPad */
  38359. export enum Xbox360Dpad {
  38360. /** Up */
  38361. Up = 0,
  38362. /** Down */
  38363. Down = 1,
  38364. /** Left */
  38365. Left = 2,
  38366. /** Right */
  38367. Right = 3
  38368. }
  38369. /**
  38370. * Defines a XBox360 gamepad
  38371. */
  38372. export class Xbox360Pad extends Gamepad {
  38373. private _leftTrigger;
  38374. private _rightTrigger;
  38375. private _onlefttriggerchanged;
  38376. private _onrighttriggerchanged;
  38377. private _onbuttondown;
  38378. private _onbuttonup;
  38379. private _ondpaddown;
  38380. private _ondpadup;
  38381. /** Observable raised when a button is pressed */
  38382. onButtonDownObservable: Observable<Xbox360Button>;
  38383. /** Observable raised when a button is released */
  38384. onButtonUpObservable: Observable<Xbox360Button>;
  38385. /** Observable raised when a pad is pressed */
  38386. onPadDownObservable: Observable<Xbox360Dpad>;
  38387. /** Observable raised when a pad is released */
  38388. onPadUpObservable: Observable<Xbox360Dpad>;
  38389. private _buttonA;
  38390. private _buttonB;
  38391. private _buttonX;
  38392. private _buttonY;
  38393. private _buttonBack;
  38394. private _buttonStart;
  38395. private _buttonLB;
  38396. private _buttonRB;
  38397. private _buttonLeftStick;
  38398. private _buttonRightStick;
  38399. private _dPadUp;
  38400. private _dPadDown;
  38401. private _dPadLeft;
  38402. private _dPadRight;
  38403. private _isXboxOnePad;
  38404. /**
  38405. * Creates a new XBox360 gamepad object
  38406. * @param id defines the id of this gamepad
  38407. * @param index defines its index
  38408. * @param gamepad defines the internal HTML gamepad object
  38409. * @param xboxOne defines if it is a XBox One gamepad
  38410. */
  38411. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38412. /**
  38413. * Defines the callback to call when left trigger is pressed
  38414. * @param callback defines the callback to use
  38415. */
  38416. onlefttriggerchanged(callback: (value: number) => void): void;
  38417. /**
  38418. * Defines the callback to call when right trigger is pressed
  38419. * @param callback defines the callback to use
  38420. */
  38421. onrighttriggerchanged(callback: (value: number) => void): void;
  38422. /**
  38423. * Gets the left trigger value
  38424. */
  38425. /**
  38426. * Sets the left trigger value
  38427. */
  38428. leftTrigger: number;
  38429. /**
  38430. * Gets the right trigger value
  38431. */
  38432. /**
  38433. * Sets the right trigger value
  38434. */
  38435. rightTrigger: number;
  38436. /**
  38437. * Defines the callback to call when a button is pressed
  38438. * @param callback defines the callback to use
  38439. */
  38440. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38441. /**
  38442. * Defines the callback to call when a button is released
  38443. * @param callback defines the callback to use
  38444. */
  38445. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38446. /**
  38447. * Defines the callback to call when a pad is pressed
  38448. * @param callback defines the callback to use
  38449. */
  38450. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38451. /**
  38452. * Defines the callback to call when a pad is released
  38453. * @param callback defines the callback to use
  38454. */
  38455. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38456. private _setButtonValue;
  38457. private _setDPadValue;
  38458. /**
  38459. * Gets the value of the `A` button
  38460. */
  38461. /**
  38462. * Sets the value of the `A` button
  38463. */
  38464. buttonA: number;
  38465. /**
  38466. * Gets the value of the `B` button
  38467. */
  38468. /**
  38469. * Sets the value of the `B` button
  38470. */
  38471. buttonB: number;
  38472. /**
  38473. * Gets the value of the `X` button
  38474. */
  38475. /**
  38476. * Sets the value of the `X` button
  38477. */
  38478. buttonX: number;
  38479. /**
  38480. * Gets the value of the `Y` button
  38481. */
  38482. /**
  38483. * Sets the value of the `Y` button
  38484. */
  38485. buttonY: number;
  38486. /**
  38487. * Gets the value of the `Start` button
  38488. */
  38489. /**
  38490. * Sets the value of the `Start` button
  38491. */
  38492. buttonStart: number;
  38493. /**
  38494. * Gets the value of the `Back` button
  38495. */
  38496. /**
  38497. * Sets the value of the `Back` button
  38498. */
  38499. buttonBack: number;
  38500. /**
  38501. * Gets the value of the `Left` button
  38502. */
  38503. /**
  38504. * Sets the value of the `Left` button
  38505. */
  38506. buttonLB: number;
  38507. /**
  38508. * Gets the value of the `Right` button
  38509. */
  38510. /**
  38511. * Sets the value of the `Right` button
  38512. */
  38513. buttonRB: number;
  38514. /**
  38515. * Gets the value of the Left joystick
  38516. */
  38517. /**
  38518. * Sets the value of the Left joystick
  38519. */
  38520. buttonLeftStick: number;
  38521. /**
  38522. * Gets the value of the Right joystick
  38523. */
  38524. /**
  38525. * Sets the value of the Right joystick
  38526. */
  38527. buttonRightStick: number;
  38528. /**
  38529. * Gets the value of D-pad up
  38530. */
  38531. /**
  38532. * Sets the value of D-pad up
  38533. */
  38534. dPadUp: number;
  38535. /**
  38536. * Gets the value of D-pad down
  38537. */
  38538. /**
  38539. * Sets the value of D-pad down
  38540. */
  38541. dPadDown: number;
  38542. /**
  38543. * Gets the value of D-pad left
  38544. */
  38545. /**
  38546. * Sets the value of D-pad left
  38547. */
  38548. dPadLeft: number;
  38549. /**
  38550. * Gets the value of D-pad right
  38551. */
  38552. /**
  38553. * Sets the value of D-pad right
  38554. */
  38555. dPadRight: number;
  38556. /**
  38557. * Force the gamepad to synchronize with device values
  38558. */
  38559. update(): void;
  38560. /**
  38561. * Disposes the gamepad
  38562. */
  38563. dispose(): void;
  38564. }
  38565. }
  38566. declare module BABYLON {
  38567. /**
  38568. * Defines supported buttons for DualShock compatible gamepads
  38569. */
  38570. export enum DualShockButton {
  38571. /** Cross */
  38572. Cross = 0,
  38573. /** Circle */
  38574. Circle = 1,
  38575. /** Square */
  38576. Square = 2,
  38577. /** Triangle */
  38578. Triangle = 3,
  38579. /** Options */
  38580. Options = 4,
  38581. /** Share */
  38582. Share = 5,
  38583. /** L1 */
  38584. L1 = 6,
  38585. /** R1 */
  38586. R1 = 7,
  38587. /** Left stick */
  38588. LeftStick = 8,
  38589. /** Right stick */
  38590. RightStick = 9
  38591. }
  38592. /** Defines values for DualShock DPad */
  38593. export enum DualShockDpad {
  38594. /** Up */
  38595. Up = 0,
  38596. /** Down */
  38597. Down = 1,
  38598. /** Left */
  38599. Left = 2,
  38600. /** Right */
  38601. Right = 3
  38602. }
  38603. /**
  38604. * Defines a DualShock gamepad
  38605. */
  38606. export class DualShockPad extends Gamepad {
  38607. private _leftTrigger;
  38608. private _rightTrigger;
  38609. private _onlefttriggerchanged;
  38610. private _onrighttriggerchanged;
  38611. private _onbuttondown;
  38612. private _onbuttonup;
  38613. private _ondpaddown;
  38614. private _ondpadup;
  38615. /** Observable raised when a button is pressed */
  38616. onButtonDownObservable: Observable<DualShockButton>;
  38617. /** Observable raised when a button is released */
  38618. onButtonUpObservable: Observable<DualShockButton>;
  38619. /** Observable raised when a pad is pressed */
  38620. onPadDownObservable: Observable<DualShockDpad>;
  38621. /** Observable raised when a pad is released */
  38622. onPadUpObservable: Observable<DualShockDpad>;
  38623. private _buttonCross;
  38624. private _buttonCircle;
  38625. private _buttonSquare;
  38626. private _buttonTriangle;
  38627. private _buttonShare;
  38628. private _buttonOptions;
  38629. private _buttonL1;
  38630. private _buttonR1;
  38631. private _buttonLeftStick;
  38632. private _buttonRightStick;
  38633. private _dPadUp;
  38634. private _dPadDown;
  38635. private _dPadLeft;
  38636. private _dPadRight;
  38637. /**
  38638. * Creates a new DualShock gamepad object
  38639. * @param id defines the id of this gamepad
  38640. * @param index defines its index
  38641. * @param gamepad defines the internal HTML gamepad object
  38642. */
  38643. constructor(id: string, index: number, gamepad: any);
  38644. /**
  38645. * Defines the callback to call when left trigger is pressed
  38646. * @param callback defines the callback to use
  38647. */
  38648. onlefttriggerchanged(callback: (value: number) => void): void;
  38649. /**
  38650. * Defines the callback to call when right trigger is pressed
  38651. * @param callback defines the callback to use
  38652. */
  38653. onrighttriggerchanged(callback: (value: number) => void): void;
  38654. /**
  38655. * Gets the left trigger value
  38656. */
  38657. /**
  38658. * Sets the left trigger value
  38659. */
  38660. leftTrigger: number;
  38661. /**
  38662. * Gets the right trigger value
  38663. */
  38664. /**
  38665. * Sets the right trigger value
  38666. */
  38667. rightTrigger: number;
  38668. /**
  38669. * Defines the callback to call when a button is pressed
  38670. * @param callback defines the callback to use
  38671. */
  38672. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38673. /**
  38674. * Defines the callback to call when a button is released
  38675. * @param callback defines the callback to use
  38676. */
  38677. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38678. /**
  38679. * Defines the callback to call when a pad is pressed
  38680. * @param callback defines the callback to use
  38681. */
  38682. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38683. /**
  38684. * Defines the callback to call when a pad is released
  38685. * @param callback defines the callback to use
  38686. */
  38687. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38688. private _setButtonValue;
  38689. private _setDPadValue;
  38690. /**
  38691. * Gets the value of the `Cross` button
  38692. */
  38693. /**
  38694. * Sets the value of the `Cross` button
  38695. */
  38696. buttonCross: number;
  38697. /**
  38698. * Gets the value of the `Circle` button
  38699. */
  38700. /**
  38701. * Sets the value of the `Circle` button
  38702. */
  38703. buttonCircle: number;
  38704. /**
  38705. * Gets the value of the `Square` button
  38706. */
  38707. /**
  38708. * Sets the value of the `Square` button
  38709. */
  38710. buttonSquare: number;
  38711. /**
  38712. * Gets the value of the `Triangle` button
  38713. */
  38714. /**
  38715. * Sets the value of the `Triangle` button
  38716. */
  38717. buttonTriangle: number;
  38718. /**
  38719. * Gets the value of the `Options` button
  38720. */
  38721. /**
  38722. * Sets the value of the `Options` button
  38723. */
  38724. buttonOptions: number;
  38725. /**
  38726. * Gets the value of the `Share` button
  38727. */
  38728. /**
  38729. * Sets the value of the `Share` button
  38730. */
  38731. buttonShare: number;
  38732. /**
  38733. * Gets the value of the `L1` button
  38734. */
  38735. /**
  38736. * Sets the value of the `L1` button
  38737. */
  38738. buttonL1: number;
  38739. /**
  38740. * Gets the value of the `R1` button
  38741. */
  38742. /**
  38743. * Sets the value of the `R1` button
  38744. */
  38745. buttonR1: number;
  38746. /**
  38747. * Gets the value of the Left joystick
  38748. */
  38749. /**
  38750. * Sets the value of the Left joystick
  38751. */
  38752. buttonLeftStick: number;
  38753. /**
  38754. * Gets the value of the Right joystick
  38755. */
  38756. /**
  38757. * Sets the value of the Right joystick
  38758. */
  38759. buttonRightStick: number;
  38760. /**
  38761. * Gets the value of D-pad up
  38762. */
  38763. /**
  38764. * Sets the value of D-pad up
  38765. */
  38766. dPadUp: number;
  38767. /**
  38768. * Gets the value of D-pad down
  38769. */
  38770. /**
  38771. * Sets the value of D-pad down
  38772. */
  38773. dPadDown: number;
  38774. /**
  38775. * Gets the value of D-pad left
  38776. */
  38777. /**
  38778. * Sets the value of D-pad left
  38779. */
  38780. dPadLeft: number;
  38781. /**
  38782. * Gets the value of D-pad right
  38783. */
  38784. /**
  38785. * Sets the value of D-pad right
  38786. */
  38787. dPadRight: number;
  38788. /**
  38789. * Force the gamepad to synchronize with device values
  38790. */
  38791. update(): void;
  38792. /**
  38793. * Disposes the gamepad
  38794. */
  38795. dispose(): void;
  38796. }
  38797. }
  38798. declare module BABYLON {
  38799. /**
  38800. * Manager for handling gamepads
  38801. */
  38802. export class GamepadManager {
  38803. private _scene?;
  38804. private _babylonGamepads;
  38805. private _oneGamepadConnected;
  38806. /** @hidden */
  38807. _isMonitoring: boolean;
  38808. private _gamepadEventSupported;
  38809. private _gamepadSupport;
  38810. /**
  38811. * observable to be triggered when the gamepad controller has been connected
  38812. */
  38813. onGamepadConnectedObservable: Observable<Gamepad>;
  38814. /**
  38815. * observable to be triggered when the gamepad controller has been disconnected
  38816. */
  38817. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38818. private _onGamepadConnectedEvent;
  38819. private _onGamepadDisconnectedEvent;
  38820. /**
  38821. * Initializes the gamepad manager
  38822. * @param _scene BabylonJS scene
  38823. */
  38824. constructor(_scene?: Scene | undefined);
  38825. /**
  38826. * The gamepads in the game pad manager
  38827. */
  38828. readonly gamepads: Gamepad[];
  38829. /**
  38830. * Get the gamepad controllers based on type
  38831. * @param type The type of gamepad controller
  38832. * @returns Nullable gamepad
  38833. */
  38834. getGamepadByType(type?: number): Nullable<Gamepad>;
  38835. /**
  38836. * Disposes the gamepad manager
  38837. */
  38838. dispose(): void;
  38839. private _addNewGamepad;
  38840. private _startMonitoringGamepads;
  38841. private _stopMonitoringGamepads;
  38842. /** @hidden */
  38843. _checkGamepadsStatus(): void;
  38844. private _updateGamepadObjects;
  38845. }
  38846. }
  38847. declare module BABYLON {
  38848. interface Scene {
  38849. /** @hidden */
  38850. _gamepadManager: Nullable<GamepadManager>;
  38851. /**
  38852. * Gets the gamepad manager associated with the scene
  38853. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38854. */
  38855. gamepadManager: GamepadManager;
  38856. }
  38857. /**
  38858. * Interface representing a free camera inputs manager
  38859. */
  38860. interface FreeCameraInputsManager {
  38861. /**
  38862. * Adds gamepad input support to the FreeCameraInputsManager.
  38863. * @returns the FreeCameraInputsManager
  38864. */
  38865. addGamepad(): FreeCameraInputsManager;
  38866. }
  38867. /**
  38868. * Interface representing an arc rotate camera inputs manager
  38869. */
  38870. interface ArcRotateCameraInputsManager {
  38871. /**
  38872. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38873. * @returns the camera inputs manager
  38874. */
  38875. addGamepad(): ArcRotateCameraInputsManager;
  38876. }
  38877. /**
  38878. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38879. */
  38880. export class GamepadSystemSceneComponent implements ISceneComponent {
  38881. /**
  38882. * The component name helpfull to identify the component in the list of scene components.
  38883. */
  38884. readonly name: string;
  38885. /**
  38886. * The scene the component belongs to.
  38887. */
  38888. scene: Scene;
  38889. /**
  38890. * Creates a new instance of the component for the given scene
  38891. * @param scene Defines the scene to register the component in
  38892. */
  38893. constructor(scene: Scene);
  38894. /**
  38895. * Registers the component in a given scene
  38896. */
  38897. register(): void;
  38898. /**
  38899. * Rebuilds the elements related to this component in case of
  38900. * context lost for instance.
  38901. */
  38902. rebuild(): void;
  38903. /**
  38904. * Disposes the component and the associated ressources
  38905. */
  38906. dispose(): void;
  38907. private _beforeCameraUpdate;
  38908. }
  38909. }
  38910. declare module BABYLON {
  38911. /**
  38912. * 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,
  38913. * which still works and will still be found in many Playgrounds.
  38914. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38915. */
  38916. export class UniversalCamera extends TouchCamera {
  38917. /**
  38918. * Defines the gamepad rotation sensiblity.
  38919. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38920. */
  38921. gamepadAngularSensibility: number;
  38922. /**
  38923. * Defines the gamepad move sensiblity.
  38924. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38925. */
  38926. gamepadMoveSensibility: number;
  38927. /**
  38928. * 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,
  38929. * which still works and will still be found in many Playgrounds.
  38930. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38931. * @param name Define the name of the camera in the scene
  38932. * @param position Define the start position of the camera in the scene
  38933. * @param scene Define the scene the camera belongs to
  38934. */
  38935. constructor(name: string, position: Vector3, scene: Scene);
  38936. /**
  38937. * Gets the current object class name.
  38938. * @return the class name
  38939. */
  38940. getClassName(): string;
  38941. }
  38942. }
  38943. declare module BABYLON {
  38944. /**
  38945. * This represents a FPS type of camera. This is only here for back compat purpose.
  38946. * Please use the UniversalCamera instead as both are identical.
  38947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38948. */
  38949. export class GamepadCamera extends UniversalCamera {
  38950. /**
  38951. * Instantiates a new Gamepad Camera
  38952. * This represents a FPS type of camera. This is only here for back compat purpose.
  38953. * Please use the UniversalCamera instead as both are identical.
  38954. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38955. * @param name Define the name of the camera in the scene
  38956. * @param position Define the start position of the camera in the scene
  38957. * @param scene Define the scene the camera belongs to
  38958. */
  38959. constructor(name: string, position: Vector3, scene: Scene);
  38960. /**
  38961. * Gets the current object class name.
  38962. * @return the class name
  38963. */
  38964. getClassName(): string;
  38965. }
  38966. }
  38967. declare module BABYLON {
  38968. /** @hidden */
  38969. export var passPixelShader: {
  38970. name: string;
  38971. shader: string;
  38972. };
  38973. }
  38974. declare module BABYLON {
  38975. /** @hidden */
  38976. export var passCubePixelShader: {
  38977. name: string;
  38978. shader: string;
  38979. };
  38980. }
  38981. declare module BABYLON {
  38982. /**
  38983. * PassPostProcess which produces an output the same as it's input
  38984. */
  38985. export class PassPostProcess extends PostProcess {
  38986. /**
  38987. * Creates the PassPostProcess
  38988. * @param name The name of the effect.
  38989. * @param options The required width/height ratio to downsize to before computing the render pass.
  38990. * @param camera The camera to apply the render pass to.
  38991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38992. * @param engine The engine which the post process will be applied. (default: current engine)
  38993. * @param reusable If the post process can be reused on the same frame. (default: false)
  38994. * @param textureType The type of texture to be used when performing the post processing.
  38995. * @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)
  38996. */
  38997. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38998. }
  38999. /**
  39000. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39001. */
  39002. export class PassCubePostProcess extends PostProcess {
  39003. private _face;
  39004. /**
  39005. * Gets or sets the cube face to display.
  39006. * * 0 is +X
  39007. * * 1 is -X
  39008. * * 2 is +Y
  39009. * * 3 is -Y
  39010. * * 4 is +Z
  39011. * * 5 is -Z
  39012. */
  39013. face: number;
  39014. /**
  39015. * Creates the PassCubePostProcess
  39016. * @param name The name of the effect.
  39017. * @param options The required width/height ratio to downsize to before computing the render pass.
  39018. * @param camera The camera to apply the render pass to.
  39019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39020. * @param engine The engine which the post process will be applied. (default: current engine)
  39021. * @param reusable If the post process can be reused on the same frame. (default: false)
  39022. * @param textureType The type of texture to be used when performing the post processing.
  39023. * @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)
  39024. */
  39025. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39026. }
  39027. }
  39028. declare module BABYLON {
  39029. /** @hidden */
  39030. export var anaglyphPixelShader: {
  39031. name: string;
  39032. shader: string;
  39033. };
  39034. }
  39035. declare module BABYLON {
  39036. /**
  39037. * Postprocess used to generate anaglyphic rendering
  39038. */
  39039. export class AnaglyphPostProcess extends PostProcess {
  39040. private _passedProcess;
  39041. /**
  39042. * Creates a new AnaglyphPostProcess
  39043. * @param name defines postprocess name
  39044. * @param options defines creation options or target ratio scale
  39045. * @param rigCameras defines cameras using this postprocess
  39046. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39047. * @param engine defines hosting engine
  39048. * @param reusable defines if the postprocess will be reused multiple times per frame
  39049. */
  39050. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39051. }
  39052. }
  39053. declare module BABYLON {
  39054. /**
  39055. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39056. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39057. */
  39058. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39059. /**
  39060. * Creates a new AnaglyphArcRotateCamera
  39061. * @param name defines camera name
  39062. * @param alpha defines alpha angle (in radians)
  39063. * @param beta defines beta angle (in radians)
  39064. * @param radius defines radius
  39065. * @param target defines camera target
  39066. * @param interaxialDistance defines distance between each color axis
  39067. * @param scene defines the hosting scene
  39068. */
  39069. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39070. /**
  39071. * Gets camera class name
  39072. * @returns AnaglyphArcRotateCamera
  39073. */
  39074. getClassName(): string;
  39075. }
  39076. }
  39077. declare module BABYLON {
  39078. /**
  39079. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39080. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39081. */
  39082. export class AnaglyphFreeCamera extends FreeCamera {
  39083. /**
  39084. * Creates a new AnaglyphFreeCamera
  39085. * @param name defines camera name
  39086. * @param position defines initial position
  39087. * @param interaxialDistance defines distance between each color axis
  39088. * @param scene defines the hosting scene
  39089. */
  39090. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39091. /**
  39092. * Gets camera class name
  39093. * @returns AnaglyphFreeCamera
  39094. */
  39095. getClassName(): string;
  39096. }
  39097. }
  39098. declare module BABYLON {
  39099. /**
  39100. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39101. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39102. */
  39103. export class AnaglyphGamepadCamera extends GamepadCamera {
  39104. /**
  39105. * Creates a new AnaglyphGamepadCamera
  39106. * @param name defines camera name
  39107. * @param position defines initial position
  39108. * @param interaxialDistance defines distance between each color axis
  39109. * @param scene defines the hosting scene
  39110. */
  39111. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39112. /**
  39113. * Gets camera class name
  39114. * @returns AnaglyphGamepadCamera
  39115. */
  39116. getClassName(): string;
  39117. }
  39118. }
  39119. declare module BABYLON {
  39120. /**
  39121. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39122. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39123. */
  39124. export class AnaglyphUniversalCamera extends UniversalCamera {
  39125. /**
  39126. * Creates a new AnaglyphUniversalCamera
  39127. * @param name defines camera name
  39128. * @param position defines initial position
  39129. * @param interaxialDistance defines distance between each color axis
  39130. * @param scene defines the hosting scene
  39131. */
  39132. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39133. /**
  39134. * Gets camera class name
  39135. * @returns AnaglyphUniversalCamera
  39136. */
  39137. getClassName(): string;
  39138. }
  39139. }
  39140. declare module BABYLON {
  39141. /** @hidden */
  39142. export var stereoscopicInterlacePixelShader: {
  39143. name: string;
  39144. shader: string;
  39145. };
  39146. }
  39147. declare module BABYLON {
  39148. /**
  39149. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39150. */
  39151. export class StereoscopicInterlacePostProcess extends PostProcess {
  39152. private _stepSize;
  39153. private _passedProcess;
  39154. /**
  39155. * Initializes a StereoscopicInterlacePostProcess
  39156. * @param name The name of the effect.
  39157. * @param rigCameras The rig cameras to be appled to the post process
  39158. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39160. * @param engine The engine which the post process will be applied. (default: current engine)
  39161. * @param reusable If the post process can be reused on the same frame. (default: false)
  39162. */
  39163. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39164. }
  39165. }
  39166. declare module BABYLON {
  39167. /**
  39168. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39169. * @see http://doc.babylonjs.com/features/cameras
  39170. */
  39171. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39172. /**
  39173. * Creates a new StereoscopicArcRotateCamera
  39174. * @param name defines camera name
  39175. * @param alpha defines alpha angle (in radians)
  39176. * @param beta defines beta angle (in radians)
  39177. * @param radius defines radius
  39178. * @param target defines camera target
  39179. * @param interaxialDistance defines distance between each color axis
  39180. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39181. * @param scene defines the hosting scene
  39182. */
  39183. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39184. /**
  39185. * Gets camera class name
  39186. * @returns StereoscopicArcRotateCamera
  39187. */
  39188. getClassName(): string;
  39189. }
  39190. }
  39191. declare module BABYLON {
  39192. /**
  39193. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39194. * @see http://doc.babylonjs.com/features/cameras
  39195. */
  39196. export class StereoscopicFreeCamera extends FreeCamera {
  39197. /**
  39198. * Creates a new StereoscopicFreeCamera
  39199. * @param name defines camera name
  39200. * @param position defines initial position
  39201. * @param interaxialDistance defines distance between each color axis
  39202. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39203. * @param scene defines the hosting scene
  39204. */
  39205. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39206. /**
  39207. * Gets camera class name
  39208. * @returns StereoscopicFreeCamera
  39209. */
  39210. getClassName(): string;
  39211. }
  39212. }
  39213. declare module BABYLON {
  39214. /**
  39215. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39216. * @see http://doc.babylonjs.com/features/cameras
  39217. */
  39218. export class StereoscopicGamepadCamera extends GamepadCamera {
  39219. /**
  39220. * Creates a new StereoscopicGamepadCamera
  39221. * @param name defines camera name
  39222. * @param position defines initial position
  39223. * @param interaxialDistance defines distance between each color axis
  39224. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39225. * @param scene defines the hosting scene
  39226. */
  39227. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39228. /**
  39229. * Gets camera class name
  39230. * @returns StereoscopicGamepadCamera
  39231. */
  39232. getClassName(): string;
  39233. }
  39234. }
  39235. declare module BABYLON {
  39236. /**
  39237. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39238. * @see http://doc.babylonjs.com/features/cameras
  39239. */
  39240. export class StereoscopicUniversalCamera extends UniversalCamera {
  39241. /**
  39242. * Creates a new StereoscopicUniversalCamera
  39243. * @param name defines camera name
  39244. * @param position defines initial position
  39245. * @param interaxialDistance defines distance between each color axis
  39246. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39247. * @param scene defines the hosting scene
  39248. */
  39249. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39250. /**
  39251. * Gets camera class name
  39252. * @returns StereoscopicUniversalCamera
  39253. */
  39254. getClassName(): string;
  39255. }
  39256. }
  39257. declare module BABYLON {
  39258. /**
  39259. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39260. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39261. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39262. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39263. */
  39264. export class VirtualJoysticksCamera extends FreeCamera {
  39265. /**
  39266. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39267. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39268. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39269. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39270. * @param name Define the name of the camera in the scene
  39271. * @param position Define the start position of the camera in the scene
  39272. * @param scene Define the scene the camera belongs to
  39273. */
  39274. constructor(name: string, position: Vector3, scene: Scene);
  39275. /**
  39276. * Gets the current object class name.
  39277. * @return the class name
  39278. */
  39279. getClassName(): string;
  39280. }
  39281. }
  39282. declare module BABYLON {
  39283. /**
  39284. * This represents all the required metrics to create a VR camera.
  39285. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39286. */
  39287. export class VRCameraMetrics {
  39288. /**
  39289. * Define the horizontal resolution off the screen.
  39290. */
  39291. hResolution: number;
  39292. /**
  39293. * Define the vertical resolution off the screen.
  39294. */
  39295. vResolution: number;
  39296. /**
  39297. * Define the horizontal screen size.
  39298. */
  39299. hScreenSize: number;
  39300. /**
  39301. * Define the vertical screen size.
  39302. */
  39303. vScreenSize: number;
  39304. /**
  39305. * Define the vertical screen center position.
  39306. */
  39307. vScreenCenter: number;
  39308. /**
  39309. * Define the distance of the eyes to the screen.
  39310. */
  39311. eyeToScreenDistance: number;
  39312. /**
  39313. * Define the distance between both lenses
  39314. */
  39315. lensSeparationDistance: number;
  39316. /**
  39317. * Define the distance between both viewer's eyes.
  39318. */
  39319. interpupillaryDistance: number;
  39320. /**
  39321. * Define the distortion factor of the VR postprocess.
  39322. * Please, touch with care.
  39323. */
  39324. distortionK: number[];
  39325. /**
  39326. * Define the chromatic aberration correction factors for the VR post process.
  39327. */
  39328. chromaAbCorrection: number[];
  39329. /**
  39330. * Define the scale factor of the post process.
  39331. * The smaller the better but the slower.
  39332. */
  39333. postProcessScaleFactor: number;
  39334. /**
  39335. * Define an offset for the lens center.
  39336. */
  39337. lensCenterOffset: number;
  39338. /**
  39339. * Define if the current vr camera should compensate the distortion of the lense or not.
  39340. */
  39341. compensateDistortion: boolean;
  39342. /**
  39343. * Defines if multiview should be enabled when rendering (Default: false)
  39344. */
  39345. multiviewEnabled: boolean;
  39346. /**
  39347. * Gets the rendering aspect ratio based on the provided resolutions.
  39348. */
  39349. readonly aspectRatio: number;
  39350. /**
  39351. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39352. */
  39353. readonly aspectRatioFov: number;
  39354. /**
  39355. * @hidden
  39356. */
  39357. readonly leftHMatrix: Matrix;
  39358. /**
  39359. * @hidden
  39360. */
  39361. readonly rightHMatrix: Matrix;
  39362. /**
  39363. * @hidden
  39364. */
  39365. readonly leftPreViewMatrix: Matrix;
  39366. /**
  39367. * @hidden
  39368. */
  39369. readonly rightPreViewMatrix: Matrix;
  39370. /**
  39371. * Get the default VRMetrics based on the most generic setup.
  39372. * @returns the default vr metrics
  39373. */
  39374. static GetDefault(): VRCameraMetrics;
  39375. }
  39376. }
  39377. declare module BABYLON {
  39378. /** @hidden */
  39379. export var vrDistortionCorrectionPixelShader: {
  39380. name: string;
  39381. shader: string;
  39382. };
  39383. }
  39384. declare module BABYLON {
  39385. /**
  39386. * VRDistortionCorrectionPostProcess used for mobile VR
  39387. */
  39388. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39389. private _isRightEye;
  39390. private _distortionFactors;
  39391. private _postProcessScaleFactor;
  39392. private _lensCenterOffset;
  39393. private _scaleIn;
  39394. private _scaleFactor;
  39395. private _lensCenter;
  39396. /**
  39397. * Initializes the VRDistortionCorrectionPostProcess
  39398. * @param name The name of the effect.
  39399. * @param camera The camera to apply the render pass to.
  39400. * @param isRightEye If this is for the right eye distortion
  39401. * @param vrMetrics All the required metrics for the VR camera
  39402. */
  39403. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39404. }
  39405. }
  39406. declare module BABYLON {
  39407. /**
  39408. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39409. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39410. */
  39411. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39412. /**
  39413. * Creates a new VRDeviceOrientationArcRotateCamera
  39414. * @param name defines camera name
  39415. * @param alpha defines the camera rotation along the logitudinal axis
  39416. * @param beta defines the camera rotation along the latitudinal axis
  39417. * @param radius defines the camera distance from its target
  39418. * @param target defines the camera target
  39419. * @param scene defines the scene the camera belongs to
  39420. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39421. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39422. */
  39423. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39424. /**
  39425. * Gets camera class name
  39426. * @returns VRDeviceOrientationArcRotateCamera
  39427. */
  39428. getClassName(): string;
  39429. }
  39430. }
  39431. declare module BABYLON {
  39432. /**
  39433. * Camera used to simulate VR rendering (based on FreeCamera)
  39434. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39435. */
  39436. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39437. /**
  39438. * Creates a new VRDeviceOrientationFreeCamera
  39439. * @param name defines camera name
  39440. * @param position defines the start position of the camera
  39441. * @param scene defines the scene the camera belongs to
  39442. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39443. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39444. */
  39445. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39446. /**
  39447. * Gets camera class name
  39448. * @returns VRDeviceOrientationFreeCamera
  39449. */
  39450. getClassName(): string;
  39451. }
  39452. }
  39453. declare module BABYLON {
  39454. /**
  39455. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39456. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39457. */
  39458. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39459. /**
  39460. * Creates a new VRDeviceOrientationGamepadCamera
  39461. * @param name defines camera name
  39462. * @param position defines the start position of the camera
  39463. * @param scene defines the scene the camera belongs to
  39464. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39465. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39466. */
  39467. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39468. /**
  39469. * Gets camera class name
  39470. * @returns VRDeviceOrientationGamepadCamera
  39471. */
  39472. getClassName(): string;
  39473. }
  39474. }
  39475. declare module BABYLON {
  39476. /**
  39477. * Base class of materials working in push mode in babylon JS
  39478. * @hidden
  39479. */
  39480. export class PushMaterial extends Material {
  39481. protected _activeEffect: Effect;
  39482. protected _normalMatrix: Matrix;
  39483. /**
  39484. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39485. * This means that the material can keep using a previous shader while a new one is being compiled.
  39486. * This is mostly used when shader parallel compilation is supported (true by default)
  39487. */
  39488. allowShaderHotSwapping: boolean;
  39489. constructor(name: string, scene: Scene);
  39490. getEffect(): Effect;
  39491. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39492. /**
  39493. * Binds the given world matrix to the active effect
  39494. *
  39495. * @param world the matrix to bind
  39496. */
  39497. bindOnlyWorldMatrix(world: Matrix): void;
  39498. /**
  39499. * Binds the given normal matrix to the active effect
  39500. *
  39501. * @param normalMatrix the matrix to bind
  39502. */
  39503. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39504. bind(world: Matrix, mesh?: Mesh): void;
  39505. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39506. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39507. }
  39508. }
  39509. declare module BABYLON {
  39510. /**
  39511. * This groups all the flags used to control the materials channel.
  39512. */
  39513. export class MaterialFlags {
  39514. private static _DiffuseTextureEnabled;
  39515. /**
  39516. * Are diffuse textures enabled in the application.
  39517. */
  39518. static DiffuseTextureEnabled: boolean;
  39519. private static _AmbientTextureEnabled;
  39520. /**
  39521. * Are ambient textures enabled in the application.
  39522. */
  39523. static AmbientTextureEnabled: boolean;
  39524. private static _OpacityTextureEnabled;
  39525. /**
  39526. * Are opacity textures enabled in the application.
  39527. */
  39528. static OpacityTextureEnabled: boolean;
  39529. private static _ReflectionTextureEnabled;
  39530. /**
  39531. * Are reflection textures enabled in the application.
  39532. */
  39533. static ReflectionTextureEnabled: boolean;
  39534. private static _EmissiveTextureEnabled;
  39535. /**
  39536. * Are emissive textures enabled in the application.
  39537. */
  39538. static EmissiveTextureEnabled: boolean;
  39539. private static _SpecularTextureEnabled;
  39540. /**
  39541. * Are specular textures enabled in the application.
  39542. */
  39543. static SpecularTextureEnabled: boolean;
  39544. private static _BumpTextureEnabled;
  39545. /**
  39546. * Are bump textures enabled in the application.
  39547. */
  39548. static BumpTextureEnabled: boolean;
  39549. private static _LightmapTextureEnabled;
  39550. /**
  39551. * Are lightmap textures enabled in the application.
  39552. */
  39553. static LightmapTextureEnabled: boolean;
  39554. private static _RefractionTextureEnabled;
  39555. /**
  39556. * Are refraction textures enabled in the application.
  39557. */
  39558. static RefractionTextureEnabled: boolean;
  39559. private static _ColorGradingTextureEnabled;
  39560. /**
  39561. * Are color grading textures enabled in the application.
  39562. */
  39563. static ColorGradingTextureEnabled: boolean;
  39564. private static _FresnelEnabled;
  39565. /**
  39566. * Are fresnels enabled in the application.
  39567. */
  39568. static FresnelEnabled: boolean;
  39569. private static _ClearCoatTextureEnabled;
  39570. /**
  39571. * Are clear coat textures enabled in the application.
  39572. */
  39573. static ClearCoatTextureEnabled: boolean;
  39574. private static _ClearCoatBumpTextureEnabled;
  39575. /**
  39576. * Are clear coat bump textures enabled in the application.
  39577. */
  39578. static ClearCoatBumpTextureEnabled: boolean;
  39579. private static _ClearCoatTintTextureEnabled;
  39580. /**
  39581. * Are clear coat tint textures enabled in the application.
  39582. */
  39583. static ClearCoatTintTextureEnabled: boolean;
  39584. private static _SheenTextureEnabled;
  39585. /**
  39586. * Are sheen textures enabled in the application.
  39587. */
  39588. static SheenTextureEnabled: boolean;
  39589. private static _AnisotropicTextureEnabled;
  39590. /**
  39591. * Are anisotropic textures enabled in the application.
  39592. */
  39593. static AnisotropicTextureEnabled: boolean;
  39594. private static _ThicknessTextureEnabled;
  39595. /**
  39596. * Are thickness textures enabled in the application.
  39597. */
  39598. static ThicknessTextureEnabled: boolean;
  39599. }
  39600. }
  39601. declare module BABYLON {
  39602. /** @hidden */
  39603. export var defaultFragmentDeclaration: {
  39604. name: string;
  39605. shader: string;
  39606. };
  39607. }
  39608. declare module BABYLON {
  39609. /** @hidden */
  39610. export var defaultUboDeclaration: {
  39611. name: string;
  39612. shader: string;
  39613. };
  39614. }
  39615. declare module BABYLON {
  39616. /** @hidden */
  39617. export var lightFragmentDeclaration: {
  39618. name: string;
  39619. shader: string;
  39620. };
  39621. }
  39622. declare module BABYLON {
  39623. /** @hidden */
  39624. export var lightUboDeclaration: {
  39625. name: string;
  39626. shader: string;
  39627. };
  39628. }
  39629. declare module BABYLON {
  39630. /** @hidden */
  39631. export var lightsFragmentFunctions: {
  39632. name: string;
  39633. shader: string;
  39634. };
  39635. }
  39636. declare module BABYLON {
  39637. /** @hidden */
  39638. export var shadowsFragmentFunctions: {
  39639. name: string;
  39640. shader: string;
  39641. };
  39642. }
  39643. declare module BABYLON {
  39644. /** @hidden */
  39645. export var fresnelFunction: {
  39646. name: string;
  39647. shader: string;
  39648. };
  39649. }
  39650. declare module BABYLON {
  39651. /** @hidden */
  39652. export var reflectionFunction: {
  39653. name: string;
  39654. shader: string;
  39655. };
  39656. }
  39657. declare module BABYLON {
  39658. /** @hidden */
  39659. export var bumpFragmentFunctions: {
  39660. name: string;
  39661. shader: string;
  39662. };
  39663. }
  39664. declare module BABYLON {
  39665. /** @hidden */
  39666. export var logDepthDeclaration: {
  39667. name: string;
  39668. shader: string;
  39669. };
  39670. }
  39671. declare module BABYLON {
  39672. /** @hidden */
  39673. export var bumpFragment: {
  39674. name: string;
  39675. shader: string;
  39676. };
  39677. }
  39678. declare module BABYLON {
  39679. /** @hidden */
  39680. export var depthPrePass: {
  39681. name: string;
  39682. shader: string;
  39683. };
  39684. }
  39685. declare module BABYLON {
  39686. /** @hidden */
  39687. export var lightFragment: {
  39688. name: string;
  39689. shader: string;
  39690. };
  39691. }
  39692. declare module BABYLON {
  39693. /** @hidden */
  39694. export var logDepthFragment: {
  39695. name: string;
  39696. shader: string;
  39697. };
  39698. }
  39699. declare module BABYLON {
  39700. /** @hidden */
  39701. export var defaultPixelShader: {
  39702. name: string;
  39703. shader: string;
  39704. };
  39705. }
  39706. declare module BABYLON {
  39707. /** @hidden */
  39708. export var defaultVertexDeclaration: {
  39709. name: string;
  39710. shader: string;
  39711. };
  39712. }
  39713. declare module BABYLON {
  39714. /** @hidden */
  39715. export var bumpVertexDeclaration: {
  39716. name: string;
  39717. shader: string;
  39718. };
  39719. }
  39720. declare module BABYLON {
  39721. /** @hidden */
  39722. export var bumpVertex: {
  39723. name: string;
  39724. shader: string;
  39725. };
  39726. }
  39727. declare module BABYLON {
  39728. /** @hidden */
  39729. export var fogVertex: {
  39730. name: string;
  39731. shader: string;
  39732. };
  39733. }
  39734. declare module BABYLON {
  39735. /** @hidden */
  39736. export var shadowsVertex: {
  39737. name: string;
  39738. shader: string;
  39739. };
  39740. }
  39741. declare module BABYLON {
  39742. /** @hidden */
  39743. export var pointCloudVertex: {
  39744. name: string;
  39745. shader: string;
  39746. };
  39747. }
  39748. declare module BABYLON {
  39749. /** @hidden */
  39750. export var logDepthVertex: {
  39751. name: string;
  39752. shader: string;
  39753. };
  39754. }
  39755. declare module BABYLON {
  39756. /** @hidden */
  39757. export var defaultVertexShader: {
  39758. name: string;
  39759. shader: string;
  39760. };
  39761. }
  39762. declare module BABYLON {
  39763. /** @hidden */
  39764. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39765. MAINUV1: boolean;
  39766. MAINUV2: boolean;
  39767. DIFFUSE: boolean;
  39768. DIFFUSEDIRECTUV: number;
  39769. AMBIENT: boolean;
  39770. AMBIENTDIRECTUV: number;
  39771. OPACITY: boolean;
  39772. OPACITYDIRECTUV: number;
  39773. OPACITYRGB: boolean;
  39774. REFLECTION: boolean;
  39775. EMISSIVE: boolean;
  39776. EMISSIVEDIRECTUV: number;
  39777. SPECULAR: boolean;
  39778. SPECULARDIRECTUV: number;
  39779. BUMP: boolean;
  39780. BUMPDIRECTUV: number;
  39781. PARALLAX: boolean;
  39782. PARALLAXOCCLUSION: boolean;
  39783. SPECULAROVERALPHA: boolean;
  39784. CLIPPLANE: boolean;
  39785. CLIPPLANE2: boolean;
  39786. CLIPPLANE3: boolean;
  39787. CLIPPLANE4: boolean;
  39788. ALPHATEST: boolean;
  39789. DEPTHPREPASS: boolean;
  39790. ALPHAFROMDIFFUSE: boolean;
  39791. POINTSIZE: boolean;
  39792. FOG: boolean;
  39793. SPECULARTERM: boolean;
  39794. DIFFUSEFRESNEL: boolean;
  39795. OPACITYFRESNEL: boolean;
  39796. REFLECTIONFRESNEL: boolean;
  39797. REFRACTIONFRESNEL: boolean;
  39798. EMISSIVEFRESNEL: boolean;
  39799. FRESNEL: boolean;
  39800. NORMAL: boolean;
  39801. UV1: boolean;
  39802. UV2: boolean;
  39803. VERTEXCOLOR: boolean;
  39804. VERTEXALPHA: boolean;
  39805. NUM_BONE_INFLUENCERS: number;
  39806. BonesPerMesh: number;
  39807. BONETEXTURE: boolean;
  39808. INSTANCES: boolean;
  39809. GLOSSINESS: boolean;
  39810. ROUGHNESS: boolean;
  39811. EMISSIVEASILLUMINATION: boolean;
  39812. LINKEMISSIVEWITHDIFFUSE: boolean;
  39813. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39814. LIGHTMAP: boolean;
  39815. LIGHTMAPDIRECTUV: number;
  39816. OBJECTSPACE_NORMALMAP: boolean;
  39817. USELIGHTMAPASSHADOWMAP: boolean;
  39818. REFLECTIONMAP_3D: boolean;
  39819. REFLECTIONMAP_SPHERICAL: boolean;
  39820. REFLECTIONMAP_PLANAR: boolean;
  39821. REFLECTIONMAP_CUBIC: boolean;
  39822. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39823. REFLECTIONMAP_PROJECTION: boolean;
  39824. REFLECTIONMAP_SKYBOX: boolean;
  39825. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39826. REFLECTIONMAP_EXPLICIT: boolean;
  39827. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39828. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39829. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39830. INVERTCUBICMAP: boolean;
  39831. LOGARITHMICDEPTH: boolean;
  39832. REFRACTION: boolean;
  39833. REFRACTIONMAP_3D: boolean;
  39834. REFLECTIONOVERALPHA: boolean;
  39835. TWOSIDEDLIGHTING: boolean;
  39836. SHADOWFLOAT: boolean;
  39837. MORPHTARGETS: boolean;
  39838. MORPHTARGETS_NORMAL: boolean;
  39839. MORPHTARGETS_TANGENT: boolean;
  39840. MORPHTARGETS_UV: boolean;
  39841. NUM_MORPH_INFLUENCERS: number;
  39842. NONUNIFORMSCALING: boolean;
  39843. PREMULTIPLYALPHA: boolean;
  39844. IMAGEPROCESSING: boolean;
  39845. VIGNETTE: boolean;
  39846. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39847. VIGNETTEBLENDMODEOPAQUE: boolean;
  39848. TONEMAPPING: boolean;
  39849. TONEMAPPING_ACES: boolean;
  39850. CONTRAST: boolean;
  39851. COLORCURVES: boolean;
  39852. COLORGRADING: boolean;
  39853. COLORGRADING3D: boolean;
  39854. SAMPLER3DGREENDEPTH: boolean;
  39855. SAMPLER3DBGRMAP: boolean;
  39856. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39857. MULTIVIEW: boolean;
  39858. /**
  39859. * If the reflection texture on this material is in linear color space
  39860. * @hidden
  39861. */
  39862. IS_REFLECTION_LINEAR: boolean;
  39863. /**
  39864. * If the refraction texture on this material is in linear color space
  39865. * @hidden
  39866. */
  39867. IS_REFRACTION_LINEAR: boolean;
  39868. EXPOSURE: boolean;
  39869. constructor();
  39870. setReflectionMode(modeToEnable: string): void;
  39871. }
  39872. /**
  39873. * This is the default material used in Babylon. It is the best trade off between quality
  39874. * and performances.
  39875. * @see http://doc.babylonjs.com/babylon101/materials
  39876. */
  39877. export class StandardMaterial extends PushMaterial {
  39878. private _diffuseTexture;
  39879. /**
  39880. * The basic texture of the material as viewed under a light.
  39881. */
  39882. diffuseTexture: Nullable<BaseTexture>;
  39883. private _ambientTexture;
  39884. /**
  39885. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39886. */
  39887. ambientTexture: Nullable<BaseTexture>;
  39888. private _opacityTexture;
  39889. /**
  39890. * Define the transparency of the material from a texture.
  39891. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39892. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39893. */
  39894. opacityTexture: Nullable<BaseTexture>;
  39895. private _reflectionTexture;
  39896. /**
  39897. * Define the texture used to display the reflection.
  39898. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39899. */
  39900. reflectionTexture: Nullable<BaseTexture>;
  39901. private _emissiveTexture;
  39902. /**
  39903. * Define texture of the material as if self lit.
  39904. * This will be mixed in the final result even in the absence of light.
  39905. */
  39906. emissiveTexture: Nullable<BaseTexture>;
  39907. private _specularTexture;
  39908. /**
  39909. * Define how the color and intensity of the highlight given by the light in the material.
  39910. */
  39911. specularTexture: Nullable<BaseTexture>;
  39912. private _bumpTexture;
  39913. /**
  39914. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39915. * 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.
  39916. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39917. */
  39918. bumpTexture: Nullable<BaseTexture>;
  39919. private _lightmapTexture;
  39920. /**
  39921. * Complex lighting can be computationally expensive to compute at runtime.
  39922. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39923. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39924. */
  39925. lightmapTexture: Nullable<BaseTexture>;
  39926. private _refractionTexture;
  39927. /**
  39928. * Define the texture used to display the refraction.
  39929. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39930. */
  39931. refractionTexture: Nullable<BaseTexture>;
  39932. /**
  39933. * The color of the material lit by the environmental background lighting.
  39934. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39935. */
  39936. ambientColor: Color3;
  39937. /**
  39938. * The basic color of the material as viewed under a light.
  39939. */
  39940. diffuseColor: Color3;
  39941. /**
  39942. * Define how the color and intensity of the highlight given by the light in the material.
  39943. */
  39944. specularColor: Color3;
  39945. /**
  39946. * Define the color of the material as if self lit.
  39947. * This will be mixed in the final result even in the absence of light.
  39948. */
  39949. emissiveColor: Color3;
  39950. /**
  39951. * Defines how sharp are the highlights in the material.
  39952. * The bigger the value the sharper giving a more glossy feeling to the result.
  39953. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39954. */
  39955. specularPower: number;
  39956. private _useAlphaFromDiffuseTexture;
  39957. /**
  39958. * Does the transparency come from the diffuse texture alpha channel.
  39959. */
  39960. useAlphaFromDiffuseTexture: boolean;
  39961. private _useEmissiveAsIllumination;
  39962. /**
  39963. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39964. */
  39965. useEmissiveAsIllumination: boolean;
  39966. private _linkEmissiveWithDiffuse;
  39967. /**
  39968. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39969. * the emissive level when the final color is close to one.
  39970. */
  39971. linkEmissiveWithDiffuse: boolean;
  39972. private _useSpecularOverAlpha;
  39973. /**
  39974. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39975. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39976. */
  39977. useSpecularOverAlpha: boolean;
  39978. private _useReflectionOverAlpha;
  39979. /**
  39980. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39981. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39982. */
  39983. useReflectionOverAlpha: boolean;
  39984. private _disableLighting;
  39985. /**
  39986. * Does lights from the scene impacts this material.
  39987. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39988. */
  39989. disableLighting: boolean;
  39990. private _useObjectSpaceNormalMap;
  39991. /**
  39992. * Allows using an object space normal map (instead of tangent space).
  39993. */
  39994. useObjectSpaceNormalMap: boolean;
  39995. private _useParallax;
  39996. /**
  39997. * Is parallax enabled or not.
  39998. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39999. */
  40000. useParallax: boolean;
  40001. private _useParallaxOcclusion;
  40002. /**
  40003. * Is parallax occlusion enabled or not.
  40004. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40005. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40006. */
  40007. useParallaxOcclusion: boolean;
  40008. /**
  40009. * 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.
  40010. */
  40011. parallaxScaleBias: number;
  40012. private _roughness;
  40013. /**
  40014. * Helps to define how blurry the reflections should appears in the material.
  40015. */
  40016. roughness: number;
  40017. /**
  40018. * In case of refraction, define the value of the index of refraction.
  40019. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40020. */
  40021. indexOfRefraction: number;
  40022. /**
  40023. * Invert the refraction texture alongside the y axis.
  40024. * It can be useful with procedural textures or probe for instance.
  40025. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40026. */
  40027. invertRefractionY: boolean;
  40028. /**
  40029. * Defines the alpha limits in alpha test mode.
  40030. */
  40031. alphaCutOff: number;
  40032. private _useLightmapAsShadowmap;
  40033. /**
  40034. * In case of light mapping, define whether the map contains light or shadow informations.
  40035. */
  40036. useLightmapAsShadowmap: boolean;
  40037. private _diffuseFresnelParameters;
  40038. /**
  40039. * Define the diffuse fresnel parameters of the material.
  40040. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40041. */
  40042. diffuseFresnelParameters: FresnelParameters;
  40043. private _opacityFresnelParameters;
  40044. /**
  40045. * Define the opacity fresnel parameters of the material.
  40046. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40047. */
  40048. opacityFresnelParameters: FresnelParameters;
  40049. private _reflectionFresnelParameters;
  40050. /**
  40051. * Define the reflection fresnel parameters of the material.
  40052. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40053. */
  40054. reflectionFresnelParameters: FresnelParameters;
  40055. private _refractionFresnelParameters;
  40056. /**
  40057. * Define the refraction fresnel parameters of the material.
  40058. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40059. */
  40060. refractionFresnelParameters: FresnelParameters;
  40061. private _emissiveFresnelParameters;
  40062. /**
  40063. * Define the emissive fresnel parameters of the material.
  40064. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40065. */
  40066. emissiveFresnelParameters: FresnelParameters;
  40067. private _useReflectionFresnelFromSpecular;
  40068. /**
  40069. * If true automatically deducts the fresnels values from the material specularity.
  40070. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40071. */
  40072. useReflectionFresnelFromSpecular: boolean;
  40073. private _useGlossinessFromSpecularMapAlpha;
  40074. /**
  40075. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40076. */
  40077. useGlossinessFromSpecularMapAlpha: boolean;
  40078. private _maxSimultaneousLights;
  40079. /**
  40080. * Defines the maximum number of lights that can be used in the material
  40081. */
  40082. maxSimultaneousLights: number;
  40083. private _invertNormalMapX;
  40084. /**
  40085. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40086. */
  40087. invertNormalMapX: boolean;
  40088. private _invertNormalMapY;
  40089. /**
  40090. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40091. */
  40092. invertNormalMapY: boolean;
  40093. private _twoSidedLighting;
  40094. /**
  40095. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40096. */
  40097. twoSidedLighting: boolean;
  40098. /**
  40099. * Default configuration related to image processing available in the standard Material.
  40100. */
  40101. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40102. /**
  40103. * Gets the image processing configuration used either in this material.
  40104. */
  40105. /**
  40106. * Sets the Default image processing configuration used either in the this material.
  40107. *
  40108. * If sets to null, the scene one is in use.
  40109. */
  40110. imageProcessingConfiguration: ImageProcessingConfiguration;
  40111. /**
  40112. * Keep track of the image processing observer to allow dispose and replace.
  40113. */
  40114. private _imageProcessingObserver;
  40115. /**
  40116. * Attaches a new image processing configuration to the Standard Material.
  40117. * @param configuration
  40118. */
  40119. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40120. /**
  40121. * Gets wether the color curves effect is enabled.
  40122. */
  40123. /**
  40124. * Sets wether the color curves effect is enabled.
  40125. */
  40126. cameraColorCurvesEnabled: boolean;
  40127. /**
  40128. * Gets wether the color grading effect is enabled.
  40129. */
  40130. /**
  40131. * Gets wether the color grading effect is enabled.
  40132. */
  40133. cameraColorGradingEnabled: boolean;
  40134. /**
  40135. * Gets wether tonemapping is enabled or not.
  40136. */
  40137. /**
  40138. * Sets wether tonemapping is enabled or not
  40139. */
  40140. cameraToneMappingEnabled: boolean;
  40141. /**
  40142. * The camera exposure used on this material.
  40143. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40144. * This corresponds to a photographic exposure.
  40145. */
  40146. /**
  40147. * The camera exposure used on this material.
  40148. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40149. * This corresponds to a photographic exposure.
  40150. */
  40151. cameraExposure: number;
  40152. /**
  40153. * Gets The camera contrast used on this material.
  40154. */
  40155. /**
  40156. * Sets The camera contrast used on this material.
  40157. */
  40158. cameraContrast: number;
  40159. /**
  40160. * Gets the Color Grading 2D Lookup Texture.
  40161. */
  40162. /**
  40163. * Sets the Color Grading 2D Lookup Texture.
  40164. */
  40165. cameraColorGradingTexture: Nullable<BaseTexture>;
  40166. /**
  40167. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40168. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40169. * 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;
  40170. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40171. */
  40172. /**
  40173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40175. * 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;
  40176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40177. */
  40178. cameraColorCurves: Nullable<ColorCurves>;
  40179. /**
  40180. * Custom callback helping to override the default shader used in the material.
  40181. */
  40182. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40183. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40184. protected _worldViewProjectionMatrix: Matrix;
  40185. protected _globalAmbientColor: Color3;
  40186. protected _useLogarithmicDepth: boolean;
  40187. protected _rebuildInParallel: boolean;
  40188. /**
  40189. * Instantiates a new standard material.
  40190. * This is the default material used in Babylon. It is the best trade off between quality
  40191. * and performances.
  40192. * @see http://doc.babylonjs.com/babylon101/materials
  40193. * @param name Define the name of the material in the scene
  40194. * @param scene Define the scene the material belong to
  40195. */
  40196. constructor(name: string, scene: Scene);
  40197. /**
  40198. * Gets a boolean indicating that current material needs to register RTT
  40199. */
  40200. readonly hasRenderTargetTextures: boolean;
  40201. /**
  40202. * Gets the current class name of the material e.g. "StandardMaterial"
  40203. * Mainly use in serialization.
  40204. * @returns the class name
  40205. */
  40206. getClassName(): string;
  40207. /**
  40208. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40209. * You can try switching to logarithmic depth.
  40210. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40211. */
  40212. useLogarithmicDepth: boolean;
  40213. /**
  40214. * Specifies if the material will require alpha blending
  40215. * @returns a boolean specifying if alpha blending is needed
  40216. */
  40217. needAlphaBlending(): boolean;
  40218. /**
  40219. * Specifies if this material should be rendered in alpha test mode
  40220. * @returns a boolean specifying if an alpha test is needed.
  40221. */
  40222. needAlphaTesting(): boolean;
  40223. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40224. /**
  40225. * Get the texture used for alpha test purpose.
  40226. * @returns the diffuse texture in case of the standard material.
  40227. */
  40228. getAlphaTestTexture(): Nullable<BaseTexture>;
  40229. /**
  40230. * Get if the submesh is ready to be used and all its information available.
  40231. * Child classes can use it to update shaders
  40232. * @param mesh defines the mesh to check
  40233. * @param subMesh defines which submesh to check
  40234. * @param useInstances specifies that instances should be used
  40235. * @returns a boolean indicating that the submesh is ready or not
  40236. */
  40237. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40238. /**
  40239. * Builds the material UBO layouts.
  40240. * Used internally during the effect preparation.
  40241. */
  40242. buildUniformLayout(): void;
  40243. /**
  40244. * Unbinds the material from the mesh
  40245. */
  40246. unbind(): void;
  40247. /**
  40248. * Binds the submesh to this material by preparing the effect and shader to draw
  40249. * @param world defines the world transformation matrix
  40250. * @param mesh defines the mesh containing the submesh
  40251. * @param subMesh defines the submesh to bind the material to
  40252. */
  40253. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40254. /**
  40255. * Get the list of animatables in the material.
  40256. * @returns the list of animatables object used in the material
  40257. */
  40258. getAnimatables(): IAnimatable[];
  40259. /**
  40260. * Gets the active textures from the material
  40261. * @returns an array of textures
  40262. */
  40263. getActiveTextures(): BaseTexture[];
  40264. /**
  40265. * Specifies if the material uses a texture
  40266. * @param texture defines the texture to check against the material
  40267. * @returns a boolean specifying if the material uses the texture
  40268. */
  40269. hasTexture(texture: BaseTexture): boolean;
  40270. /**
  40271. * Disposes the material
  40272. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40273. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40274. */
  40275. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40276. /**
  40277. * Makes a duplicate of the material, and gives it a new name
  40278. * @param name defines the new name for the duplicated material
  40279. * @returns the cloned material
  40280. */
  40281. clone(name: string): StandardMaterial;
  40282. /**
  40283. * Serializes this material in a JSON representation
  40284. * @returns the serialized material object
  40285. */
  40286. serialize(): any;
  40287. /**
  40288. * Creates a standard material from parsed material data
  40289. * @param source defines the JSON representation of the material
  40290. * @param scene defines the hosting scene
  40291. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40292. * @returns a new standard material
  40293. */
  40294. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40295. /**
  40296. * Are diffuse textures enabled in the application.
  40297. */
  40298. static DiffuseTextureEnabled: boolean;
  40299. /**
  40300. * Are ambient textures enabled in the application.
  40301. */
  40302. static AmbientTextureEnabled: boolean;
  40303. /**
  40304. * Are opacity textures enabled in the application.
  40305. */
  40306. static OpacityTextureEnabled: boolean;
  40307. /**
  40308. * Are reflection textures enabled in the application.
  40309. */
  40310. static ReflectionTextureEnabled: boolean;
  40311. /**
  40312. * Are emissive textures enabled in the application.
  40313. */
  40314. static EmissiveTextureEnabled: boolean;
  40315. /**
  40316. * Are specular textures enabled in the application.
  40317. */
  40318. static SpecularTextureEnabled: boolean;
  40319. /**
  40320. * Are bump textures enabled in the application.
  40321. */
  40322. static BumpTextureEnabled: boolean;
  40323. /**
  40324. * Are lightmap textures enabled in the application.
  40325. */
  40326. static LightmapTextureEnabled: boolean;
  40327. /**
  40328. * Are refraction textures enabled in the application.
  40329. */
  40330. static RefractionTextureEnabled: boolean;
  40331. /**
  40332. * Are color grading textures enabled in the application.
  40333. */
  40334. static ColorGradingTextureEnabled: boolean;
  40335. /**
  40336. * Are fresnels enabled in the application.
  40337. */
  40338. static FresnelEnabled: boolean;
  40339. }
  40340. }
  40341. declare module BABYLON {
  40342. /** @hidden */
  40343. export var imageProcessingPixelShader: {
  40344. name: string;
  40345. shader: string;
  40346. };
  40347. }
  40348. declare module BABYLON {
  40349. /**
  40350. * ImageProcessingPostProcess
  40351. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40352. */
  40353. export class ImageProcessingPostProcess extends PostProcess {
  40354. /**
  40355. * Default configuration related to image processing available in the PBR Material.
  40356. */
  40357. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40358. /**
  40359. * Gets the image processing configuration used either in this material.
  40360. */
  40361. /**
  40362. * Sets the Default image processing configuration used either in the this material.
  40363. *
  40364. * If sets to null, the scene one is in use.
  40365. */
  40366. imageProcessingConfiguration: ImageProcessingConfiguration;
  40367. /**
  40368. * Keep track of the image processing observer to allow dispose and replace.
  40369. */
  40370. private _imageProcessingObserver;
  40371. /**
  40372. * Attaches a new image processing configuration to the PBR Material.
  40373. * @param configuration
  40374. */
  40375. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40376. /**
  40377. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40378. */
  40379. /**
  40380. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40381. */
  40382. colorCurves: Nullable<ColorCurves>;
  40383. /**
  40384. * Gets wether the color curves effect is enabled.
  40385. */
  40386. /**
  40387. * Sets wether the color curves effect is enabled.
  40388. */
  40389. colorCurvesEnabled: boolean;
  40390. /**
  40391. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40392. */
  40393. /**
  40394. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40395. */
  40396. colorGradingTexture: Nullable<BaseTexture>;
  40397. /**
  40398. * Gets wether the color grading effect is enabled.
  40399. */
  40400. /**
  40401. * Gets wether the color grading effect is enabled.
  40402. */
  40403. colorGradingEnabled: boolean;
  40404. /**
  40405. * Gets exposure used in the effect.
  40406. */
  40407. /**
  40408. * Sets exposure used in the effect.
  40409. */
  40410. exposure: number;
  40411. /**
  40412. * Gets wether tonemapping is enabled or not.
  40413. */
  40414. /**
  40415. * Sets wether tonemapping is enabled or not
  40416. */
  40417. toneMappingEnabled: boolean;
  40418. /**
  40419. * Gets the type of tone mapping effect.
  40420. */
  40421. /**
  40422. * Sets the type of tone mapping effect.
  40423. */
  40424. toneMappingType: number;
  40425. /**
  40426. * Gets contrast used in the effect.
  40427. */
  40428. /**
  40429. * Sets contrast used in the effect.
  40430. */
  40431. contrast: number;
  40432. /**
  40433. * Gets Vignette stretch size.
  40434. */
  40435. /**
  40436. * Sets Vignette stretch size.
  40437. */
  40438. vignetteStretch: number;
  40439. /**
  40440. * Gets Vignette centre X Offset.
  40441. */
  40442. /**
  40443. * Sets Vignette centre X Offset.
  40444. */
  40445. vignetteCentreX: number;
  40446. /**
  40447. * Gets Vignette centre Y Offset.
  40448. */
  40449. /**
  40450. * Sets Vignette centre Y Offset.
  40451. */
  40452. vignetteCentreY: number;
  40453. /**
  40454. * Gets Vignette weight or intensity of the vignette effect.
  40455. */
  40456. /**
  40457. * Sets Vignette weight or intensity of the vignette effect.
  40458. */
  40459. vignetteWeight: number;
  40460. /**
  40461. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40462. * if vignetteEnabled is set to true.
  40463. */
  40464. /**
  40465. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40466. * if vignetteEnabled is set to true.
  40467. */
  40468. vignetteColor: Color4;
  40469. /**
  40470. * Gets Camera field of view used by the Vignette effect.
  40471. */
  40472. /**
  40473. * Sets Camera field of view used by the Vignette effect.
  40474. */
  40475. vignetteCameraFov: number;
  40476. /**
  40477. * Gets the vignette blend mode allowing different kind of effect.
  40478. */
  40479. /**
  40480. * Sets the vignette blend mode allowing different kind of effect.
  40481. */
  40482. vignetteBlendMode: number;
  40483. /**
  40484. * Gets wether the vignette effect is enabled.
  40485. */
  40486. /**
  40487. * Sets wether the vignette effect is enabled.
  40488. */
  40489. vignetteEnabled: boolean;
  40490. private _fromLinearSpace;
  40491. /**
  40492. * Gets wether the input of the processing is in Gamma or Linear Space.
  40493. */
  40494. /**
  40495. * Sets wether the input of the processing is in Gamma or Linear Space.
  40496. */
  40497. fromLinearSpace: boolean;
  40498. /**
  40499. * Defines cache preventing GC.
  40500. */
  40501. private _defines;
  40502. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40503. /**
  40504. * "ImageProcessingPostProcess"
  40505. * @returns "ImageProcessingPostProcess"
  40506. */
  40507. getClassName(): string;
  40508. protected _updateParameters(): void;
  40509. dispose(camera?: Camera): void;
  40510. }
  40511. }
  40512. declare module BABYLON {
  40513. /**
  40514. * Class containing static functions to help procedurally build meshes
  40515. */
  40516. export class GroundBuilder {
  40517. /**
  40518. * Creates a ground mesh
  40519. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40520. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40522. * @param name defines the name of the mesh
  40523. * @param options defines the options used to create the mesh
  40524. * @param scene defines the hosting scene
  40525. * @returns the ground mesh
  40526. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40527. */
  40528. static CreateGround(name: string, options: {
  40529. width?: number;
  40530. height?: number;
  40531. subdivisions?: number;
  40532. subdivisionsX?: number;
  40533. subdivisionsY?: number;
  40534. updatable?: boolean;
  40535. }, scene: any): Mesh;
  40536. /**
  40537. * Creates a tiled ground mesh
  40538. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40539. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40540. * * 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
  40541. * * 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
  40542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40543. * @param name defines the name of the mesh
  40544. * @param options defines the options used to create the mesh
  40545. * @param scene defines the hosting scene
  40546. * @returns the tiled ground mesh
  40547. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40548. */
  40549. static CreateTiledGround(name: string, options: {
  40550. xmin: number;
  40551. zmin: number;
  40552. xmax: number;
  40553. zmax: number;
  40554. subdivisions?: {
  40555. w: number;
  40556. h: number;
  40557. };
  40558. precision?: {
  40559. w: number;
  40560. h: number;
  40561. };
  40562. updatable?: boolean;
  40563. }, scene?: Nullable<Scene>): Mesh;
  40564. /**
  40565. * Creates a ground mesh from a height map
  40566. * * The parameter `url` sets the URL of the height map image resource.
  40567. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40568. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40569. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40570. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40571. * * 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.
  40572. * * 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).
  40573. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40575. * @param name defines the name of the mesh
  40576. * @param url defines the url to the height map
  40577. * @param options defines the options used to create the mesh
  40578. * @param scene defines the hosting scene
  40579. * @returns the ground mesh
  40580. * @see https://doc.babylonjs.com/babylon101/height_map
  40581. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40582. */
  40583. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40584. width?: number;
  40585. height?: number;
  40586. subdivisions?: number;
  40587. minHeight?: number;
  40588. maxHeight?: number;
  40589. colorFilter?: Color3;
  40590. alphaFilter?: number;
  40591. updatable?: boolean;
  40592. onReady?: (mesh: GroundMesh) => void;
  40593. }, scene?: Nullable<Scene>): GroundMesh;
  40594. }
  40595. }
  40596. declare module BABYLON {
  40597. /**
  40598. * Class containing static functions to help procedurally build meshes
  40599. */
  40600. export class TorusBuilder {
  40601. /**
  40602. * Creates a torus mesh
  40603. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40604. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40605. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40607. * * 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
  40608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40609. * @param name defines the name of the mesh
  40610. * @param options defines the options used to create the mesh
  40611. * @param scene defines the hosting scene
  40612. * @returns the torus mesh
  40613. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40614. */
  40615. static CreateTorus(name: string, options: {
  40616. diameter?: number;
  40617. thickness?: number;
  40618. tessellation?: number;
  40619. updatable?: boolean;
  40620. sideOrientation?: number;
  40621. frontUVs?: Vector4;
  40622. backUVs?: Vector4;
  40623. }, scene: any): Mesh;
  40624. }
  40625. }
  40626. declare module BABYLON {
  40627. /**
  40628. * Class containing static functions to help procedurally build meshes
  40629. */
  40630. export class CylinderBuilder {
  40631. /**
  40632. * Creates a cylinder or a cone mesh
  40633. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40634. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40635. * * 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.
  40636. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40637. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40638. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40639. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40640. * * 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).
  40641. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40642. * * 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).
  40643. * * 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
  40644. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40645. * * 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
  40646. * * 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.
  40647. * * If `enclose` is false, a ring surface is one element.
  40648. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40649. * * 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
  40650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40651. * * 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
  40652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40653. * @param name defines the name of the mesh
  40654. * @param options defines the options used to create the mesh
  40655. * @param scene defines the hosting scene
  40656. * @returns the cylinder mesh
  40657. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40658. */
  40659. static CreateCylinder(name: string, options: {
  40660. height?: number;
  40661. diameterTop?: number;
  40662. diameterBottom?: number;
  40663. diameter?: number;
  40664. tessellation?: number;
  40665. subdivisions?: number;
  40666. arc?: number;
  40667. faceColors?: Color4[];
  40668. faceUV?: Vector4[];
  40669. updatable?: boolean;
  40670. hasRings?: boolean;
  40671. enclose?: boolean;
  40672. cap?: number;
  40673. sideOrientation?: number;
  40674. frontUVs?: Vector4;
  40675. backUVs?: Vector4;
  40676. }, scene: any): Mesh;
  40677. }
  40678. }
  40679. declare module BABYLON {
  40680. /**
  40681. * Options to modify the vr teleportation behavior.
  40682. */
  40683. export interface VRTeleportationOptions {
  40684. /**
  40685. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40686. */
  40687. floorMeshName?: string;
  40688. /**
  40689. * A list of meshes to be used as the teleportation floor. (default: empty)
  40690. */
  40691. floorMeshes?: Mesh[];
  40692. }
  40693. /**
  40694. * Options to modify the vr experience helper's behavior.
  40695. */
  40696. export interface VRExperienceHelperOptions extends WebVROptions {
  40697. /**
  40698. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40699. */
  40700. createDeviceOrientationCamera?: boolean;
  40701. /**
  40702. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40703. */
  40704. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40705. /**
  40706. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40707. */
  40708. laserToggle?: boolean;
  40709. /**
  40710. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40711. */
  40712. floorMeshes?: Mesh[];
  40713. /**
  40714. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40715. */
  40716. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40717. }
  40718. /**
  40719. * Event containing information after VR has been entered
  40720. */
  40721. export class OnAfterEnteringVRObservableEvent {
  40722. /**
  40723. * If entering vr was successful
  40724. */
  40725. success: boolean;
  40726. }
  40727. /**
  40728. * Helps to quickly add VR support to an existing scene.
  40729. * See http://doc.babylonjs.com/how_to/webvr_helper
  40730. */
  40731. export class VRExperienceHelper {
  40732. /** Options to modify the vr experience helper's behavior. */
  40733. webVROptions: VRExperienceHelperOptions;
  40734. private _scene;
  40735. private _position;
  40736. private _btnVR;
  40737. private _btnVRDisplayed;
  40738. private _webVRsupported;
  40739. private _webVRready;
  40740. private _webVRrequesting;
  40741. private _webVRpresenting;
  40742. private _hasEnteredVR;
  40743. private _fullscreenVRpresenting;
  40744. private _canvas;
  40745. private _webVRCamera;
  40746. private _vrDeviceOrientationCamera;
  40747. private _deviceOrientationCamera;
  40748. private _existingCamera;
  40749. private _onKeyDown;
  40750. private _onVrDisplayPresentChange;
  40751. private _onVRDisplayChanged;
  40752. private _onVRRequestPresentStart;
  40753. private _onVRRequestPresentComplete;
  40754. /**
  40755. * 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)
  40756. */
  40757. enableGazeEvenWhenNoPointerLock: boolean;
  40758. /**
  40759. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40760. */
  40761. exitVROnDoubleTap: boolean;
  40762. /**
  40763. * Observable raised right before entering VR.
  40764. */
  40765. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40766. /**
  40767. * Observable raised when entering VR has completed.
  40768. */
  40769. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40770. /**
  40771. * Observable raised when exiting VR.
  40772. */
  40773. onExitingVRObservable: Observable<VRExperienceHelper>;
  40774. /**
  40775. * Observable raised when controller mesh is loaded.
  40776. */
  40777. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40778. /** Return this.onEnteringVRObservable
  40779. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40780. */
  40781. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40782. /** Return this.onExitingVRObservable
  40783. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40784. */
  40785. readonly onExitingVR: Observable<VRExperienceHelper>;
  40786. /** Return this.onControllerMeshLoadedObservable
  40787. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40788. */
  40789. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40790. private _rayLength;
  40791. private _useCustomVRButton;
  40792. private _teleportationRequested;
  40793. private _teleportActive;
  40794. private _floorMeshName;
  40795. private _floorMeshesCollection;
  40796. private _rotationAllowed;
  40797. private _teleportBackwardsVector;
  40798. private _teleportationTarget;
  40799. private _isDefaultTeleportationTarget;
  40800. private _postProcessMove;
  40801. private _teleportationFillColor;
  40802. private _teleportationBorderColor;
  40803. private _rotationAngle;
  40804. private _haloCenter;
  40805. private _cameraGazer;
  40806. private _padSensibilityUp;
  40807. private _padSensibilityDown;
  40808. private _leftController;
  40809. private _rightController;
  40810. /**
  40811. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40812. */
  40813. onNewMeshSelected: Observable<AbstractMesh>;
  40814. /**
  40815. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40816. * This observable will provide the mesh and the controller used to select the mesh
  40817. */
  40818. onMeshSelectedWithController: Observable<{
  40819. mesh: AbstractMesh;
  40820. controller: WebVRController;
  40821. }>;
  40822. /**
  40823. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40824. */
  40825. onNewMeshPicked: Observable<PickingInfo>;
  40826. private _circleEase;
  40827. /**
  40828. * Observable raised before camera teleportation
  40829. */
  40830. onBeforeCameraTeleport: Observable<Vector3>;
  40831. /**
  40832. * Observable raised after camera teleportation
  40833. */
  40834. onAfterCameraTeleport: Observable<Vector3>;
  40835. /**
  40836. * Observable raised when current selected mesh gets unselected
  40837. */
  40838. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40839. private _raySelectionPredicate;
  40840. /**
  40841. * To be optionaly changed by user to define custom ray selection
  40842. */
  40843. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40844. /**
  40845. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40846. */
  40847. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40848. /**
  40849. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40850. */
  40851. teleportationEnabled: boolean;
  40852. private _defaultHeight;
  40853. private _teleportationInitialized;
  40854. private _interactionsEnabled;
  40855. private _interactionsRequested;
  40856. private _displayGaze;
  40857. private _displayLaserPointer;
  40858. /**
  40859. * The mesh used to display where the user is going to teleport.
  40860. */
  40861. /**
  40862. * Sets the mesh to be used to display where the user is going to teleport.
  40863. */
  40864. teleportationTarget: Mesh;
  40865. /**
  40866. * 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
  40867. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40868. * See http://doc.babylonjs.com/resources/baking_transformations
  40869. */
  40870. gazeTrackerMesh: Mesh;
  40871. /**
  40872. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40873. */
  40874. updateGazeTrackerScale: boolean;
  40875. /**
  40876. * If the gaze trackers color should be updated when selecting meshes
  40877. */
  40878. updateGazeTrackerColor: boolean;
  40879. /**
  40880. * If the controller laser color should be updated when selecting meshes
  40881. */
  40882. updateControllerLaserColor: boolean;
  40883. /**
  40884. * The gaze tracking mesh corresponding to the left controller
  40885. */
  40886. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40887. /**
  40888. * The gaze tracking mesh corresponding to the right controller
  40889. */
  40890. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40891. /**
  40892. * If the ray of the gaze should be displayed.
  40893. */
  40894. /**
  40895. * Sets if the ray of the gaze should be displayed.
  40896. */
  40897. displayGaze: boolean;
  40898. /**
  40899. * If the ray of the LaserPointer should be displayed.
  40900. */
  40901. /**
  40902. * Sets if the ray of the LaserPointer should be displayed.
  40903. */
  40904. displayLaserPointer: boolean;
  40905. /**
  40906. * The deviceOrientationCamera used as the camera when not in VR.
  40907. */
  40908. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40909. /**
  40910. * Based on the current WebVR support, returns the current VR camera used.
  40911. */
  40912. readonly currentVRCamera: Nullable<Camera>;
  40913. /**
  40914. * The webVRCamera which is used when in VR.
  40915. */
  40916. readonly webVRCamera: WebVRFreeCamera;
  40917. /**
  40918. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40919. */
  40920. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40921. /**
  40922. * The html button that is used to trigger entering into VR.
  40923. */
  40924. readonly vrButton: Nullable<HTMLButtonElement>;
  40925. private readonly _teleportationRequestInitiated;
  40926. /**
  40927. * Defines wether or not Pointer lock should be requested when switching to
  40928. * full screen.
  40929. */
  40930. requestPointerLockOnFullScreen: boolean;
  40931. /**
  40932. * Instantiates a VRExperienceHelper.
  40933. * Helps to quickly add VR support to an existing scene.
  40934. * @param scene The scene the VRExperienceHelper belongs to.
  40935. * @param webVROptions Options to modify the vr experience helper's behavior.
  40936. */
  40937. constructor(scene: Scene,
  40938. /** Options to modify the vr experience helper's behavior. */
  40939. webVROptions?: VRExperienceHelperOptions);
  40940. private _onDefaultMeshLoaded;
  40941. private _onResize;
  40942. private _onFullscreenChange;
  40943. /**
  40944. * Gets a value indicating if we are currently in VR mode.
  40945. */
  40946. readonly isInVRMode: boolean;
  40947. private onVrDisplayPresentChange;
  40948. private onVRDisplayChanged;
  40949. private moveButtonToBottomRight;
  40950. private displayVRButton;
  40951. private updateButtonVisibility;
  40952. private _cachedAngularSensibility;
  40953. /**
  40954. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40955. * Otherwise, will use the fullscreen API.
  40956. */
  40957. enterVR(): void;
  40958. /**
  40959. * Attempt to exit VR, or fullscreen.
  40960. */
  40961. exitVR(): void;
  40962. /**
  40963. * The position of the vr experience helper.
  40964. */
  40965. /**
  40966. * Sets the position of the vr experience helper.
  40967. */
  40968. position: Vector3;
  40969. /**
  40970. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40971. */
  40972. enableInteractions(): void;
  40973. private readonly _noControllerIsActive;
  40974. private beforeRender;
  40975. private _isTeleportationFloor;
  40976. /**
  40977. * Adds a floor mesh to be used for teleportation.
  40978. * @param floorMesh the mesh to be used for teleportation.
  40979. */
  40980. addFloorMesh(floorMesh: Mesh): void;
  40981. /**
  40982. * Removes a floor mesh from being used for teleportation.
  40983. * @param floorMesh the mesh to be removed.
  40984. */
  40985. removeFloorMesh(floorMesh: Mesh): void;
  40986. /**
  40987. * Enables interactions and teleportation using the VR controllers and gaze.
  40988. * @param vrTeleportationOptions options to modify teleportation behavior.
  40989. */
  40990. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40991. private _onNewGamepadConnected;
  40992. private _tryEnableInteractionOnController;
  40993. private _onNewGamepadDisconnected;
  40994. private _enableInteractionOnController;
  40995. private _checkTeleportWithRay;
  40996. private _checkRotate;
  40997. private _checkTeleportBackwards;
  40998. private _enableTeleportationOnController;
  40999. private _createTeleportationCircles;
  41000. private _displayTeleportationTarget;
  41001. private _hideTeleportationTarget;
  41002. private _rotateCamera;
  41003. private _moveTeleportationSelectorTo;
  41004. private _workingVector;
  41005. private _workingQuaternion;
  41006. private _workingMatrix;
  41007. /**
  41008. * Teleports the users feet to the desired location
  41009. * @param location The location where the user's feet should be placed
  41010. */
  41011. teleportCamera(location: Vector3): void;
  41012. private _convertNormalToDirectionOfRay;
  41013. private _castRayAndSelectObject;
  41014. private _notifySelectedMeshUnselected;
  41015. /**
  41016. * Sets the color of the laser ray from the vr controllers.
  41017. * @param color new color for the ray.
  41018. */
  41019. changeLaserColor(color: Color3): void;
  41020. /**
  41021. * Sets the color of the ray from the vr headsets gaze.
  41022. * @param color new color for the ray.
  41023. */
  41024. changeGazeColor(color: Color3): void;
  41025. /**
  41026. * Exits VR and disposes of the vr experience helper
  41027. */
  41028. dispose(): void;
  41029. /**
  41030. * Gets the name of the VRExperienceHelper class
  41031. * @returns "VRExperienceHelper"
  41032. */
  41033. getClassName(): string;
  41034. }
  41035. }
  41036. declare module BABYLON {
  41037. /**
  41038. * Manages an XRSession to work with Babylon's engine
  41039. * @see https://doc.babylonjs.com/how_to/webxr
  41040. */
  41041. export class WebXRSessionManager implements IDisposable {
  41042. private scene;
  41043. /**
  41044. * Fires every time a new xrFrame arrives which can be used to update the camera
  41045. */
  41046. onXRFrameObservable: Observable<any>;
  41047. /**
  41048. * Fires when the xr session is ended either by the device or manually done
  41049. */
  41050. onXRSessionEnded: Observable<any>;
  41051. /**
  41052. * Underlying xr session
  41053. */
  41054. session: XRSession;
  41055. /**
  41056. * Type of reference space used when creating the session
  41057. */
  41058. referenceSpace: XRReferenceSpace;
  41059. /** @hidden */
  41060. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41061. /**
  41062. * Current XR frame
  41063. */
  41064. currentFrame: Nullable<XRFrame>;
  41065. private _xrNavigator;
  41066. private baseLayer;
  41067. /**
  41068. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41069. * @param scene The scene which the session should be created for
  41070. */
  41071. constructor(scene: Scene);
  41072. /**
  41073. * Initializes the manager
  41074. * After initialization enterXR can be called to start an XR session
  41075. * @returns Promise which resolves after it is initialized
  41076. */
  41077. initializeAsync(): Promise<void>;
  41078. /**
  41079. * Initializes an xr session
  41080. * @param xrSessionMode mode to initialize
  41081. * @returns a promise which will resolve once the session has been initialized
  41082. */
  41083. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41084. /**
  41085. * Sets the reference space on the xr session
  41086. * @param referenceSpace space to set
  41087. * @returns a promise that will resolve once the reference space has been set
  41088. */
  41089. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41090. /**
  41091. * Updates the render state of the session
  41092. * @param state state to set
  41093. * @returns a promise that resolves once the render state has been updated
  41094. */
  41095. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41096. /**
  41097. * Starts rendering to the xr layer
  41098. * @returns a promise that will resolve once rendering has started
  41099. */
  41100. startRenderingToXRAsync(): Promise<void>;
  41101. /**
  41102. * Stops the xrSession and restores the renderloop
  41103. * @returns Promise which resolves after it exits XR
  41104. */
  41105. exitXRAsync(): Promise<unknown>;
  41106. /**
  41107. * Checks if a session would be supported for the creation options specified
  41108. * @param sessionMode session mode to check if supported eg. immersive-vr
  41109. * @returns true if supported
  41110. */
  41111. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41112. /**
  41113. * @hidden
  41114. * Converts the render layer of xrSession to a render target
  41115. * @param session session to create render target for
  41116. * @param scene scene the new render target should be created for
  41117. */
  41118. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41119. /**
  41120. * Disposes of the session manager
  41121. */
  41122. dispose(): void;
  41123. }
  41124. }
  41125. declare module BABYLON {
  41126. /**
  41127. * WebXR Camera which holds the views for the xrSession
  41128. * @see https://doc.babylonjs.com/how_to/webxr
  41129. */
  41130. export class WebXRCamera extends FreeCamera {
  41131. private static _TmpMatrix;
  41132. /**
  41133. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41134. * @param name the name of the camera
  41135. * @param scene the scene to add the camera to
  41136. */
  41137. constructor(name: string, scene: Scene);
  41138. private _updateNumberOfRigCameras;
  41139. /** @hidden */
  41140. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41141. /**
  41142. * Updates the cameras position from the current pose information of the XR session
  41143. * @param xrSessionManager the session containing pose information
  41144. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41145. */
  41146. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41147. }
  41148. }
  41149. declare module BABYLON {
  41150. /**
  41151. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41152. */
  41153. export class WebXRManagedOutputCanvas implements IDisposable {
  41154. private helper;
  41155. private _canvas;
  41156. /**
  41157. * xrpresent context of the canvas which can be used to display/mirror xr content
  41158. */
  41159. canvasContext: WebGLRenderingContext;
  41160. /**
  41161. * xr layer for the canvas
  41162. */
  41163. xrLayer: Nullable<XRWebGLLayer>;
  41164. /**
  41165. * Initializes the xr layer for the session
  41166. * @param xrSession xr session
  41167. * @returns a promise that will resolve once the XR Layer has been created
  41168. */
  41169. initializeXRLayerAsync(xrSession: any): any;
  41170. /**
  41171. * Initializes the canvas to be added/removed upon entering/exiting xr
  41172. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41173. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41174. */
  41175. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41176. /**
  41177. * Disposes of the object
  41178. */
  41179. dispose(): void;
  41180. private _setManagedOutputCanvas;
  41181. private _addCanvas;
  41182. private _removeCanvas;
  41183. }
  41184. }
  41185. declare module BABYLON {
  41186. /**
  41187. * States of the webXR experience
  41188. */
  41189. export enum WebXRState {
  41190. /**
  41191. * Transitioning to being in XR mode
  41192. */
  41193. ENTERING_XR = 0,
  41194. /**
  41195. * Transitioning to non XR mode
  41196. */
  41197. EXITING_XR = 1,
  41198. /**
  41199. * In XR mode and presenting
  41200. */
  41201. IN_XR = 2,
  41202. /**
  41203. * Not entered XR mode
  41204. */
  41205. NOT_IN_XR = 3
  41206. }
  41207. /**
  41208. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41209. * @see https://doc.babylonjs.com/how_to/webxr
  41210. */
  41211. export class WebXRExperienceHelper implements IDisposable {
  41212. private scene;
  41213. /**
  41214. * 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
  41215. */
  41216. container: AbstractMesh;
  41217. /**
  41218. * Camera used to render xr content
  41219. */
  41220. camera: WebXRCamera;
  41221. /**
  41222. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41223. */
  41224. state: WebXRState;
  41225. private _setState;
  41226. private static _TmpVector;
  41227. /**
  41228. * Fires when the state of the experience helper has changed
  41229. */
  41230. onStateChangedObservable: Observable<WebXRState>;
  41231. /** Session manager used to keep track of xr session */
  41232. sessionManager: WebXRSessionManager;
  41233. private _nonVRCamera;
  41234. private _originalSceneAutoClear;
  41235. private _supported;
  41236. /**
  41237. * Creates the experience helper
  41238. * @param scene the scene to attach the experience helper to
  41239. * @returns a promise for the experience helper
  41240. */
  41241. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41242. /**
  41243. * Creates a WebXRExperienceHelper
  41244. * @param scene The scene the helper should be created in
  41245. */
  41246. private constructor();
  41247. /**
  41248. * Exits XR mode and returns the scene to its original state
  41249. * @returns promise that resolves after xr mode has exited
  41250. */
  41251. exitXRAsync(): Promise<unknown>;
  41252. /**
  41253. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41254. * @param sessionCreationOptions options for the XR session
  41255. * @param referenceSpaceType frame of reference of the XR session
  41256. * @param outputCanvas the output canvas that will be used to enter XR mode
  41257. * @returns promise that resolves after xr mode has entered
  41258. */
  41259. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41260. /**
  41261. * Updates the global position of the camera by moving the camera's container
  41262. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41263. * @param position The desired global position of the camera
  41264. */
  41265. setPositionOfCameraUsingContainer(position: Vector3): void;
  41266. /**
  41267. * Rotates the xr camera by rotating the camera's container around the camera's position
  41268. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41269. * @param rotation the desired quaternion rotation to apply to the camera
  41270. */
  41271. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41272. /**
  41273. * Disposes of the experience helper
  41274. */
  41275. dispose(): void;
  41276. }
  41277. }
  41278. declare module BABYLON {
  41279. /**
  41280. * Button which can be used to enter a different mode of XR
  41281. */
  41282. export class WebXREnterExitUIButton {
  41283. /** button element */
  41284. element: HTMLElement;
  41285. /** XR initialization options for the button */
  41286. sessionMode: XRSessionMode;
  41287. /** Reference space type */
  41288. referenceSpaceType: XRReferenceSpaceType;
  41289. /**
  41290. * Creates a WebXREnterExitUIButton
  41291. * @param element button element
  41292. * @param sessionMode XR initialization session mode
  41293. * @param referenceSpaceType the type of reference space to be used
  41294. */
  41295. constructor(
  41296. /** button element */
  41297. element: HTMLElement,
  41298. /** XR initialization options for the button */
  41299. sessionMode: XRSessionMode,
  41300. /** Reference space type */
  41301. referenceSpaceType: XRReferenceSpaceType);
  41302. /**
  41303. * Overwritable function which can be used to update the button's visuals when the state changes
  41304. * @param activeButton the current active button in the UI
  41305. */
  41306. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41307. }
  41308. /**
  41309. * Options to create the webXR UI
  41310. */
  41311. export class WebXREnterExitUIOptions {
  41312. /**
  41313. * Context to enter xr with
  41314. */
  41315. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41316. /**
  41317. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41318. */
  41319. customButtons?: Array<WebXREnterExitUIButton>;
  41320. }
  41321. /**
  41322. * UI to allow the user to enter/exit XR mode
  41323. */
  41324. export class WebXREnterExitUI implements IDisposable {
  41325. private scene;
  41326. private _overlay;
  41327. private _buttons;
  41328. private _activeButton;
  41329. /**
  41330. * Fired every time the active button is changed.
  41331. *
  41332. * When xr is entered via a button that launches xr that button will be the callback parameter
  41333. *
  41334. * When exiting xr the callback parameter will be null)
  41335. */
  41336. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41337. /**
  41338. * Creates UI to allow the user to enter/exit XR mode
  41339. * @param scene the scene to add the ui to
  41340. * @param helper the xr experience helper to enter/exit xr with
  41341. * @param options options to configure the UI
  41342. * @returns the created ui
  41343. */
  41344. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41345. private constructor();
  41346. private _updateButtons;
  41347. /**
  41348. * Disposes of the object
  41349. */
  41350. dispose(): void;
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /**
  41355. * Represents an XR input
  41356. */
  41357. export class WebXRController {
  41358. private scene;
  41359. /** The underlying input source for the controller */
  41360. inputSource: XRInputSource;
  41361. private parentContainer;
  41362. /**
  41363. * 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
  41364. */
  41365. grip?: AbstractMesh;
  41366. /**
  41367. * Pointer which can be used to select objects or attach a visible laser to
  41368. */
  41369. pointer: AbstractMesh;
  41370. /**
  41371. * Event that fires when the controller is removed/disposed
  41372. */
  41373. onDisposeObservable: Observable<{}>;
  41374. private _tmpMatrix;
  41375. private _tmpQuaternion;
  41376. private _tmpVector;
  41377. /**
  41378. * Creates the controller
  41379. * @see https://doc.babylonjs.com/how_to/webxr
  41380. * @param scene the scene which the controller should be associated to
  41381. * @param inputSource the underlying input source for the controller
  41382. * @param parentContainer parent that the controller meshes should be children of
  41383. */
  41384. constructor(scene: Scene,
  41385. /** The underlying input source for the controller */
  41386. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41387. /**
  41388. * Updates the controller pose based on the given XRFrame
  41389. * @param xrFrame xr frame to update the pose with
  41390. * @param referenceSpace reference space to use
  41391. */
  41392. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41393. /**
  41394. * Gets a world space ray coming from the controller
  41395. * @param result the resulting ray
  41396. */
  41397. getWorldPointerRayToRef(result: Ray): void;
  41398. /**
  41399. * Disposes of the object
  41400. */
  41401. dispose(): void;
  41402. }
  41403. }
  41404. declare module BABYLON {
  41405. /**
  41406. * XR input used to track XR inputs such as controllers/rays
  41407. */
  41408. export class WebXRInput implements IDisposable {
  41409. /**
  41410. * Base experience the input listens to
  41411. */
  41412. baseExperience: WebXRExperienceHelper;
  41413. /**
  41414. * XR controllers being tracked
  41415. */
  41416. controllers: Array<WebXRController>;
  41417. private _frameObserver;
  41418. private _stateObserver;
  41419. /**
  41420. * Event when a controller has been connected/added
  41421. */
  41422. onControllerAddedObservable: Observable<WebXRController>;
  41423. /**
  41424. * Event when a controller has been removed/disconnected
  41425. */
  41426. onControllerRemovedObservable: Observable<WebXRController>;
  41427. /**
  41428. * Initializes the WebXRInput
  41429. * @param baseExperience experience helper which the input should be created for
  41430. */
  41431. constructor(
  41432. /**
  41433. * Base experience the input listens to
  41434. */
  41435. baseExperience: WebXRExperienceHelper);
  41436. private _onInputSourcesChange;
  41437. private _addAndRemoveControllers;
  41438. /**
  41439. * Disposes of the object
  41440. */
  41441. dispose(): void;
  41442. }
  41443. }
  41444. declare module BABYLON {
  41445. /**
  41446. * Enables teleportation
  41447. */
  41448. export class WebXRControllerTeleportation {
  41449. private _teleportationFillColor;
  41450. private _teleportationBorderColor;
  41451. private _tmpRay;
  41452. private _tmpVector;
  41453. /**
  41454. * Creates a WebXRControllerTeleportation
  41455. * @param input input manager to add teleportation to
  41456. * @param floorMeshes floormeshes which can be teleported to
  41457. */
  41458. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41459. }
  41460. }
  41461. declare module BABYLON {
  41462. /**
  41463. * Handles pointer input automatically for the pointer of XR controllers
  41464. */
  41465. export class WebXRControllerPointerSelection {
  41466. private static _idCounter;
  41467. private _tmpRay;
  41468. /**
  41469. * Creates a WebXRControllerPointerSelection
  41470. * @param input input manager to setup pointer selection
  41471. */
  41472. constructor(input: WebXRInput);
  41473. private _convertNormalToDirectionOfRay;
  41474. private _updatePointerDistance;
  41475. }
  41476. }
  41477. declare module BABYLON {
  41478. /**
  41479. * Class used to represent data loading progression
  41480. */
  41481. export class SceneLoaderProgressEvent {
  41482. /** defines if data length to load can be evaluated */
  41483. readonly lengthComputable: boolean;
  41484. /** defines the loaded data length */
  41485. readonly loaded: number;
  41486. /** defines the data length to load */
  41487. readonly total: number;
  41488. /**
  41489. * Create a new progress event
  41490. * @param lengthComputable defines if data length to load can be evaluated
  41491. * @param loaded defines the loaded data length
  41492. * @param total defines the data length to load
  41493. */
  41494. constructor(
  41495. /** defines if data length to load can be evaluated */
  41496. lengthComputable: boolean,
  41497. /** defines the loaded data length */
  41498. loaded: number,
  41499. /** defines the data length to load */
  41500. total: number);
  41501. /**
  41502. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41503. * @param event defines the source event
  41504. * @returns a new SceneLoaderProgressEvent
  41505. */
  41506. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41507. }
  41508. /**
  41509. * Interface used by SceneLoader plugins to define supported file extensions
  41510. */
  41511. export interface ISceneLoaderPluginExtensions {
  41512. /**
  41513. * Defines the list of supported extensions
  41514. */
  41515. [extension: string]: {
  41516. isBinary: boolean;
  41517. };
  41518. }
  41519. /**
  41520. * Interface used by SceneLoader plugin factory
  41521. */
  41522. export interface ISceneLoaderPluginFactory {
  41523. /**
  41524. * Defines the name of the factory
  41525. */
  41526. name: string;
  41527. /**
  41528. * Function called to create a new plugin
  41529. * @return the new plugin
  41530. */
  41531. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41532. /**
  41533. * Boolean indicating if the plugin can direct load specific data
  41534. */
  41535. canDirectLoad?: (data: string) => boolean;
  41536. }
  41537. /**
  41538. * Interface used to define a SceneLoader plugin
  41539. */
  41540. export interface ISceneLoaderPlugin {
  41541. /**
  41542. * The friendly name of this plugin.
  41543. */
  41544. name: string;
  41545. /**
  41546. * The file extensions supported by this plugin.
  41547. */
  41548. extensions: string | ISceneLoaderPluginExtensions;
  41549. /**
  41550. * Import meshes into a scene.
  41551. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41552. * @param scene The scene to import into
  41553. * @param data The data to import
  41554. * @param rootUrl The root url for scene and resources
  41555. * @param meshes The meshes array to import into
  41556. * @param particleSystems The particle systems array to import into
  41557. * @param skeletons The skeletons array to import into
  41558. * @param onError The callback when import fails
  41559. * @returns True if successful or false otherwise
  41560. */
  41561. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41562. /**
  41563. * Load into a scene.
  41564. * @param scene The scene to load into
  41565. * @param data The data to import
  41566. * @param rootUrl The root url for scene and resources
  41567. * @param onError The callback when import fails
  41568. * @returns true if successful or false otherwise
  41569. */
  41570. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41571. /**
  41572. * The callback that returns true if the data can be directly loaded.
  41573. */
  41574. canDirectLoad?: (data: string) => boolean;
  41575. /**
  41576. * The callback that allows custom handling of the root url based on the response url.
  41577. */
  41578. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41579. /**
  41580. * Load into an asset container.
  41581. * @param scene The scene to load into
  41582. * @param data The data to import
  41583. * @param rootUrl The root url for scene and resources
  41584. * @param onError The callback when import fails
  41585. * @returns The loaded asset container
  41586. */
  41587. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41588. }
  41589. /**
  41590. * Interface used to define an async SceneLoader plugin
  41591. */
  41592. export interface ISceneLoaderPluginAsync {
  41593. /**
  41594. * The friendly name of this plugin.
  41595. */
  41596. name: string;
  41597. /**
  41598. * The file extensions supported by this plugin.
  41599. */
  41600. extensions: string | ISceneLoaderPluginExtensions;
  41601. /**
  41602. * Import meshes into a scene.
  41603. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41604. * @param scene The scene to import into
  41605. * @param data The data to import
  41606. * @param rootUrl The root url for scene and resources
  41607. * @param onProgress The callback when the load progresses
  41608. * @param fileName Defines the name of the file to load
  41609. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41610. */
  41611. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41612. meshes: AbstractMesh[];
  41613. particleSystems: IParticleSystem[];
  41614. skeletons: Skeleton[];
  41615. animationGroups: AnimationGroup[];
  41616. }>;
  41617. /**
  41618. * Load into a scene.
  41619. * @param scene The scene to load into
  41620. * @param data The data to import
  41621. * @param rootUrl The root url for scene and resources
  41622. * @param onProgress The callback when the load progresses
  41623. * @param fileName Defines the name of the file to load
  41624. * @returns Nothing
  41625. */
  41626. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41627. /**
  41628. * The callback that returns true if the data can be directly loaded.
  41629. */
  41630. canDirectLoad?: (data: string) => boolean;
  41631. /**
  41632. * The callback that allows custom handling of the root url based on the response url.
  41633. */
  41634. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41635. /**
  41636. * Load into an asset container.
  41637. * @param scene The scene to load into
  41638. * @param data The data to import
  41639. * @param rootUrl The root url for scene and resources
  41640. * @param onProgress The callback when the load progresses
  41641. * @param fileName Defines the name of the file to load
  41642. * @returns The loaded asset container
  41643. */
  41644. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41645. }
  41646. /**
  41647. * Class used to load scene from various file formats using registered plugins
  41648. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41649. */
  41650. export class SceneLoader {
  41651. /**
  41652. * No logging while loading
  41653. */
  41654. static readonly NO_LOGGING: number;
  41655. /**
  41656. * Minimal logging while loading
  41657. */
  41658. static readonly MINIMAL_LOGGING: number;
  41659. /**
  41660. * Summary logging while loading
  41661. */
  41662. static readonly SUMMARY_LOGGING: number;
  41663. /**
  41664. * Detailled logging while loading
  41665. */
  41666. static readonly DETAILED_LOGGING: number;
  41667. /**
  41668. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41669. */
  41670. static ForceFullSceneLoadingForIncremental: boolean;
  41671. /**
  41672. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41673. */
  41674. static ShowLoadingScreen: boolean;
  41675. /**
  41676. * Defines the current logging level (while loading the scene)
  41677. * @ignorenaming
  41678. */
  41679. static loggingLevel: number;
  41680. /**
  41681. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41682. */
  41683. static CleanBoneMatrixWeights: boolean;
  41684. /**
  41685. * Event raised when a plugin is used to load a scene
  41686. */
  41687. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41688. private static _registeredPlugins;
  41689. private static _getDefaultPlugin;
  41690. private static _getPluginForExtension;
  41691. private static _getPluginForDirectLoad;
  41692. private static _getPluginForFilename;
  41693. private static _getDirectLoad;
  41694. private static _loadData;
  41695. private static _getFileInfo;
  41696. /**
  41697. * Gets a plugin that can load the given extension
  41698. * @param extension defines the extension to load
  41699. * @returns a plugin or null if none works
  41700. */
  41701. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41702. /**
  41703. * Gets a boolean indicating that the given extension can be loaded
  41704. * @param extension defines the extension to load
  41705. * @returns true if the extension is supported
  41706. */
  41707. static IsPluginForExtensionAvailable(extension: string): boolean;
  41708. /**
  41709. * Adds a new plugin to the list of registered plugins
  41710. * @param plugin defines the plugin to add
  41711. */
  41712. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41713. /**
  41714. * Import meshes into a scene
  41715. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41716. * @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)
  41717. * @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)
  41718. * @param scene the instance of BABYLON.Scene to append to
  41719. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41720. * @param onProgress a callback with a progress event for each file being loaded
  41721. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41722. * @param pluginExtension the extension used to determine the plugin
  41723. * @returns The loaded plugin
  41724. */
  41725. 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>;
  41726. /**
  41727. * Import meshes into a scene
  41728. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41729. * @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)
  41730. * @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)
  41731. * @param scene the instance of BABYLON.Scene to append to
  41732. * @param onProgress a callback with a progress event for each file being loaded
  41733. * @param pluginExtension the extension used to determine the plugin
  41734. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41735. */
  41736. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41737. meshes: AbstractMesh[];
  41738. particleSystems: IParticleSystem[];
  41739. skeletons: Skeleton[];
  41740. animationGroups: AnimationGroup[];
  41741. }>;
  41742. /**
  41743. * Load a scene
  41744. * @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)
  41745. * @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)
  41746. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41747. * @param onSuccess a callback with the scene when import succeeds
  41748. * @param onProgress a callback with a progress event for each file being loaded
  41749. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41750. * @param pluginExtension the extension used to determine the plugin
  41751. * @returns The loaded plugin
  41752. */
  41753. 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>;
  41754. /**
  41755. * Load a scene
  41756. * @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)
  41757. * @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)
  41758. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41759. * @param onProgress a callback with a progress event for each file being loaded
  41760. * @param pluginExtension the extension used to determine the plugin
  41761. * @returns The loaded scene
  41762. */
  41763. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41764. /**
  41765. * Append a scene
  41766. * @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)
  41767. * @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)
  41768. * @param scene is the instance of BABYLON.Scene to append to
  41769. * @param onSuccess a callback with the scene when import succeeds
  41770. * @param onProgress a callback with a progress event for each file being loaded
  41771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41772. * @param pluginExtension the extension used to determine the plugin
  41773. * @returns The loaded plugin
  41774. */
  41775. 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>;
  41776. /**
  41777. * Append a scene
  41778. * @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)
  41779. * @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)
  41780. * @param scene is the instance of BABYLON.Scene to append to
  41781. * @param onProgress a callback with a progress event for each file being loaded
  41782. * @param pluginExtension the extension used to determine the plugin
  41783. * @returns The given scene
  41784. */
  41785. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41786. /**
  41787. * Load a scene into an asset container
  41788. * @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)
  41789. * @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)
  41790. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41791. * @param onSuccess a callback with the scene when import succeeds
  41792. * @param onProgress a callback with a progress event for each file being loaded
  41793. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41794. * @param pluginExtension the extension used to determine the plugin
  41795. * @returns The loaded plugin
  41796. */
  41797. 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>;
  41798. /**
  41799. * Load a scene into an asset container
  41800. * @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)
  41801. * @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)
  41802. * @param scene is the instance of Scene to append to
  41803. * @param onProgress a callback with a progress event for each file being loaded
  41804. * @param pluginExtension the extension used to determine the plugin
  41805. * @returns The loaded asset container
  41806. */
  41807. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41808. }
  41809. }
  41810. declare module BABYLON {
  41811. /**
  41812. * Generic Controller
  41813. */
  41814. export class GenericController extends WebVRController {
  41815. /**
  41816. * Base Url for the controller model.
  41817. */
  41818. static readonly MODEL_BASE_URL: string;
  41819. /**
  41820. * File name for the controller model.
  41821. */
  41822. static readonly MODEL_FILENAME: string;
  41823. /**
  41824. * Creates a new GenericController from a gamepad
  41825. * @param vrGamepad the gamepad that the controller should be created from
  41826. */
  41827. constructor(vrGamepad: any);
  41828. /**
  41829. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41830. * @param scene scene in which to add meshes
  41831. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41832. */
  41833. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41834. /**
  41835. * Called once for each button that changed state since the last frame
  41836. * @param buttonIdx Which button index changed
  41837. * @param state New state of the button
  41838. * @param changes Which properties on the state changed since last frame
  41839. */
  41840. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41841. }
  41842. }
  41843. declare module BABYLON {
  41844. /**
  41845. * Defines the WindowsMotionController object that the state of the windows motion controller
  41846. */
  41847. export class WindowsMotionController extends WebVRController {
  41848. /**
  41849. * The base url used to load the left and right controller models
  41850. */
  41851. static MODEL_BASE_URL: string;
  41852. /**
  41853. * The name of the left controller model file
  41854. */
  41855. static MODEL_LEFT_FILENAME: string;
  41856. /**
  41857. * The name of the right controller model file
  41858. */
  41859. static MODEL_RIGHT_FILENAME: string;
  41860. /**
  41861. * The controller name prefix for this controller type
  41862. */
  41863. static readonly GAMEPAD_ID_PREFIX: string;
  41864. /**
  41865. * The controller id pattern for this controller type
  41866. */
  41867. private static readonly GAMEPAD_ID_PATTERN;
  41868. private _loadedMeshInfo;
  41869. private readonly _mapping;
  41870. /**
  41871. * Fired when the trackpad on this controller is clicked
  41872. */
  41873. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41874. /**
  41875. * Fired when the trackpad on this controller is modified
  41876. */
  41877. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41878. /**
  41879. * The current x and y values of this controller's trackpad
  41880. */
  41881. trackpad: StickValues;
  41882. /**
  41883. * Creates a new WindowsMotionController from a gamepad
  41884. * @param vrGamepad the gamepad that the controller should be created from
  41885. */
  41886. constructor(vrGamepad: any);
  41887. /**
  41888. * Fired when the trigger on this controller is modified
  41889. */
  41890. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41891. /**
  41892. * Fired when the menu button on this controller is modified
  41893. */
  41894. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41895. /**
  41896. * Fired when the grip button on this controller is modified
  41897. */
  41898. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41899. /**
  41900. * Fired when the thumbstick button on this controller is modified
  41901. */
  41902. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41903. /**
  41904. * Fired when the touchpad button on this controller is modified
  41905. */
  41906. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41907. /**
  41908. * Fired when the touchpad values on this controller are modified
  41909. */
  41910. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41911. private _updateTrackpad;
  41912. /**
  41913. * Called once per frame by the engine.
  41914. */
  41915. update(): void;
  41916. /**
  41917. * Called once for each button that changed state since the last frame
  41918. * @param buttonIdx Which button index changed
  41919. * @param state New state of the button
  41920. * @param changes Which properties on the state changed since last frame
  41921. */
  41922. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41923. /**
  41924. * Moves the buttons on the controller mesh based on their current state
  41925. * @param buttonName the name of the button to move
  41926. * @param buttonValue the value of the button which determines the buttons new position
  41927. */
  41928. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41929. /**
  41930. * Moves the axis on the controller mesh based on its current state
  41931. * @param axis the index of the axis
  41932. * @param axisValue the value of the axis which determines the meshes new position
  41933. * @hidden
  41934. */
  41935. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41936. /**
  41937. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41938. * @param scene scene in which to add meshes
  41939. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41940. */
  41941. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41942. /**
  41943. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41944. * can be transformed by button presses and axes values, based on this._mapping.
  41945. *
  41946. * @param scene scene in which the meshes exist
  41947. * @param meshes list of meshes that make up the controller model to process
  41948. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41949. */
  41950. private processModel;
  41951. private createMeshInfo;
  41952. /**
  41953. * Gets the ray of the controller in the direction the controller is pointing
  41954. * @param length the length the resulting ray should be
  41955. * @returns a ray in the direction the controller is pointing
  41956. */
  41957. getForwardRay(length?: number): Ray;
  41958. /**
  41959. * Disposes of the controller
  41960. */
  41961. dispose(): void;
  41962. }
  41963. }
  41964. declare module BABYLON {
  41965. /**
  41966. * Oculus Touch Controller
  41967. */
  41968. export class OculusTouchController extends WebVRController {
  41969. /**
  41970. * Base Url for the controller model.
  41971. */
  41972. static MODEL_BASE_URL: string;
  41973. /**
  41974. * File name for the left controller model.
  41975. */
  41976. static MODEL_LEFT_FILENAME: string;
  41977. /**
  41978. * File name for the right controller model.
  41979. */
  41980. static MODEL_RIGHT_FILENAME: string;
  41981. /**
  41982. * Base Url for the Quest controller model.
  41983. */
  41984. static QUEST_MODEL_BASE_URL: string;
  41985. /**
  41986. * @hidden
  41987. * If the controllers are running on a device that needs the updated Quest controller models
  41988. */
  41989. static _IsQuest: boolean;
  41990. /**
  41991. * Fired when the secondary trigger on this controller is modified
  41992. */
  41993. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41994. /**
  41995. * Fired when the thumb rest on this controller is modified
  41996. */
  41997. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41998. /**
  41999. * Creates a new OculusTouchController from a gamepad
  42000. * @param vrGamepad the gamepad that the controller should be created from
  42001. */
  42002. constructor(vrGamepad: any);
  42003. /**
  42004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42005. * @param scene scene in which to add meshes
  42006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42007. */
  42008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42009. /**
  42010. * Fired when the A button on this controller is modified
  42011. */
  42012. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42013. /**
  42014. * Fired when the B button on this controller is modified
  42015. */
  42016. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42017. /**
  42018. * Fired when the X button on this controller is modified
  42019. */
  42020. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42021. /**
  42022. * Fired when the Y button on this controller is modified
  42023. */
  42024. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42025. /**
  42026. * Called once for each button that changed state since the last frame
  42027. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42028. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42029. * 2) secondary trigger (same)
  42030. * 3) A (right) X (left), touch, pressed = value
  42031. * 4) B / Y
  42032. * 5) thumb rest
  42033. * @param buttonIdx Which button index changed
  42034. * @param state New state of the button
  42035. * @param changes Which properties on the state changed since last frame
  42036. */
  42037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42038. }
  42039. }
  42040. declare module BABYLON {
  42041. /**
  42042. * Vive Controller
  42043. */
  42044. export class ViveController extends WebVRController {
  42045. /**
  42046. * Base Url for the controller model.
  42047. */
  42048. static MODEL_BASE_URL: string;
  42049. /**
  42050. * File name for the controller model.
  42051. */
  42052. static MODEL_FILENAME: string;
  42053. /**
  42054. * Creates a new ViveController from a gamepad
  42055. * @param vrGamepad the gamepad that the controller should be created from
  42056. */
  42057. constructor(vrGamepad: any);
  42058. /**
  42059. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42060. * @param scene scene in which to add meshes
  42061. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42062. */
  42063. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42064. /**
  42065. * Fired when the left button on this controller is modified
  42066. */
  42067. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42068. /**
  42069. * Fired when the right button on this controller is modified
  42070. */
  42071. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42072. /**
  42073. * Fired when the menu button on this controller is modified
  42074. */
  42075. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42076. /**
  42077. * Called once for each button that changed state since the last frame
  42078. * Vive mapping:
  42079. * 0: touchpad
  42080. * 1: trigger
  42081. * 2: left AND right buttons
  42082. * 3: menu button
  42083. * @param buttonIdx Which button index changed
  42084. * @param state New state of the button
  42085. * @param changes Which properties on the state changed since last frame
  42086. */
  42087. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42088. }
  42089. }
  42090. declare module BABYLON {
  42091. /**
  42092. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42093. */
  42094. export class WebXRControllerModelLoader {
  42095. /**
  42096. * Creates the WebXRControllerModelLoader
  42097. * @param input xr input that creates the controllers
  42098. */
  42099. constructor(input: WebXRInput);
  42100. }
  42101. }
  42102. declare module BABYLON {
  42103. /**
  42104. * Contains an array of blocks representing the octree
  42105. */
  42106. export interface IOctreeContainer<T> {
  42107. /**
  42108. * Blocks within the octree
  42109. */
  42110. blocks: Array<OctreeBlock<T>>;
  42111. }
  42112. /**
  42113. * Class used to store a cell in an octree
  42114. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42115. */
  42116. export class OctreeBlock<T> {
  42117. /**
  42118. * Gets the content of the current block
  42119. */
  42120. entries: T[];
  42121. /**
  42122. * Gets the list of block children
  42123. */
  42124. blocks: Array<OctreeBlock<T>>;
  42125. private _depth;
  42126. private _maxDepth;
  42127. private _capacity;
  42128. private _minPoint;
  42129. private _maxPoint;
  42130. private _boundingVectors;
  42131. private _creationFunc;
  42132. /**
  42133. * Creates a new block
  42134. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42135. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42136. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42137. * @param depth defines the current depth of this block in the octree
  42138. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42139. * @param creationFunc defines a callback to call when an element is added to the block
  42140. */
  42141. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42142. /**
  42143. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42144. */
  42145. readonly capacity: number;
  42146. /**
  42147. * Gets the minimum vector (in world space) of the block's bounding box
  42148. */
  42149. readonly minPoint: Vector3;
  42150. /**
  42151. * Gets the maximum vector (in world space) of the block's bounding box
  42152. */
  42153. readonly maxPoint: Vector3;
  42154. /**
  42155. * Add a new element to this block
  42156. * @param entry defines the element to add
  42157. */
  42158. addEntry(entry: T): void;
  42159. /**
  42160. * Remove an element from this block
  42161. * @param entry defines the element to remove
  42162. */
  42163. removeEntry(entry: T): void;
  42164. /**
  42165. * Add an array of elements to this block
  42166. * @param entries defines the array of elements to add
  42167. */
  42168. addEntries(entries: T[]): void;
  42169. /**
  42170. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42171. * @param frustumPlanes defines the frustum planes to test
  42172. * @param selection defines the array to store current content if selection is positive
  42173. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42174. */
  42175. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42176. /**
  42177. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42178. * @param sphereCenter defines the bounding sphere center
  42179. * @param sphereRadius defines the bounding sphere radius
  42180. * @param selection defines the array to store current content if selection is positive
  42181. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42182. */
  42183. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42184. /**
  42185. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42186. * @param ray defines the ray to test with
  42187. * @param selection defines the array to store current content if selection is positive
  42188. */
  42189. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42190. /**
  42191. * Subdivide the content into child blocks (this block will then be empty)
  42192. */
  42193. createInnerBlocks(): void;
  42194. /**
  42195. * @hidden
  42196. */
  42197. 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;
  42198. }
  42199. }
  42200. declare module BABYLON {
  42201. /**
  42202. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42203. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42204. */
  42205. export class Octree<T> {
  42206. /** 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.) */
  42207. maxDepth: number;
  42208. /**
  42209. * Blocks within the octree containing objects
  42210. */
  42211. blocks: Array<OctreeBlock<T>>;
  42212. /**
  42213. * Content stored in the octree
  42214. */
  42215. dynamicContent: T[];
  42216. private _maxBlockCapacity;
  42217. private _selectionContent;
  42218. private _creationFunc;
  42219. /**
  42220. * Creates a octree
  42221. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42222. * @param creationFunc function to be used to instatiate the octree
  42223. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42224. * @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.)
  42225. */
  42226. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42227. /** 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.) */
  42228. maxDepth?: number);
  42229. /**
  42230. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42231. * @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);
  42232. * @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);
  42233. * @param entries meshes to be added to the octree blocks
  42234. */
  42235. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42236. /**
  42237. * Adds a mesh to the octree
  42238. * @param entry Mesh to add to the octree
  42239. */
  42240. addMesh(entry: T): void;
  42241. /**
  42242. * Remove an element from the octree
  42243. * @param entry defines the element to remove
  42244. */
  42245. removeMesh(entry: T): void;
  42246. /**
  42247. * Selects an array of meshes within the frustum
  42248. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42249. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42250. * @returns array of meshes within the frustum
  42251. */
  42252. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42253. /**
  42254. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42255. * @param sphereCenter defines the bounding sphere center
  42256. * @param sphereRadius defines the bounding sphere radius
  42257. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42258. * @returns an array of objects that intersect the sphere
  42259. */
  42260. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42261. /**
  42262. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42263. * @param ray defines the ray to test with
  42264. * @returns array of intersected objects
  42265. */
  42266. intersectsRay(ray: Ray): SmartArray<T>;
  42267. /**
  42268. * Adds a mesh into the octree block if it intersects the block
  42269. */
  42270. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42271. /**
  42272. * Adds a submesh into the octree block if it intersects the block
  42273. */
  42274. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42275. }
  42276. }
  42277. declare module BABYLON {
  42278. interface Scene {
  42279. /**
  42280. * @hidden
  42281. * Backing Filed
  42282. */
  42283. _selectionOctree: Octree<AbstractMesh>;
  42284. /**
  42285. * Gets the octree used to boost mesh selection (picking)
  42286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42287. */
  42288. selectionOctree: Octree<AbstractMesh>;
  42289. /**
  42290. * Creates or updates the octree used to boost selection (picking)
  42291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42292. * @param maxCapacity defines the maximum capacity per leaf
  42293. * @param maxDepth defines the maximum depth of the octree
  42294. * @returns an octree of AbstractMesh
  42295. */
  42296. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42297. }
  42298. interface AbstractMesh {
  42299. /**
  42300. * @hidden
  42301. * Backing Field
  42302. */
  42303. _submeshesOctree: Octree<SubMesh>;
  42304. /**
  42305. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42306. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42307. * @param maxCapacity defines the maximum size of each block (64 by default)
  42308. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42309. * @returns the new octree
  42310. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42311. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42312. */
  42313. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42314. }
  42315. /**
  42316. * Defines the octree scene component responsible to manage any octrees
  42317. * in a given scene.
  42318. */
  42319. export class OctreeSceneComponent {
  42320. /**
  42321. * The component name help to identify the component in the list of scene components.
  42322. */
  42323. readonly name: string;
  42324. /**
  42325. * The scene the component belongs to.
  42326. */
  42327. scene: Scene;
  42328. /**
  42329. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42330. */
  42331. readonly checksIsEnabled: boolean;
  42332. /**
  42333. * Creates a new instance of the component for the given scene
  42334. * @param scene Defines the scene to register the component in
  42335. */
  42336. constructor(scene: Scene);
  42337. /**
  42338. * Registers the component in a given scene
  42339. */
  42340. register(): void;
  42341. /**
  42342. * Return the list of active meshes
  42343. * @returns the list of active meshes
  42344. */
  42345. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42346. /**
  42347. * Return the list of active sub meshes
  42348. * @param mesh The mesh to get the candidates sub meshes from
  42349. * @returns the list of active sub meshes
  42350. */
  42351. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42352. private _tempRay;
  42353. /**
  42354. * Return the list of sub meshes intersecting with a given local ray
  42355. * @param mesh defines the mesh to find the submesh for
  42356. * @param localRay defines the ray in local space
  42357. * @returns the list of intersecting sub meshes
  42358. */
  42359. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42360. /**
  42361. * Return the list of sub meshes colliding with a collider
  42362. * @param mesh defines the mesh to find the submesh for
  42363. * @param collider defines the collider to evaluate the collision against
  42364. * @returns the list of colliding sub meshes
  42365. */
  42366. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42367. /**
  42368. * Rebuilds the elements related to this component in case of
  42369. * context lost for instance.
  42370. */
  42371. rebuild(): void;
  42372. /**
  42373. * Disposes the component and the associated ressources.
  42374. */
  42375. dispose(): void;
  42376. }
  42377. }
  42378. declare module BABYLON {
  42379. /**
  42380. * Renders a layer on top of an existing scene
  42381. */
  42382. export class UtilityLayerRenderer implements IDisposable {
  42383. /** the original scene that will be rendered on top of */
  42384. originalScene: Scene;
  42385. private _pointerCaptures;
  42386. private _lastPointerEvents;
  42387. private static _DefaultUtilityLayer;
  42388. private static _DefaultKeepDepthUtilityLayer;
  42389. private _sharedGizmoLight;
  42390. private _renderCamera;
  42391. /**
  42392. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42393. * @returns the camera that is used when rendering the utility layer
  42394. */
  42395. getRenderCamera(): Nullable<Camera>;
  42396. /**
  42397. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42398. * @param cam the camera that should be used when rendering the utility layer
  42399. */
  42400. setRenderCamera(cam: Nullable<Camera>): void;
  42401. /**
  42402. * @hidden
  42403. * Light which used by gizmos to get light shading
  42404. */
  42405. _getSharedGizmoLight(): HemisphericLight;
  42406. /**
  42407. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42408. */
  42409. pickUtilitySceneFirst: boolean;
  42410. /**
  42411. * 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)
  42412. */
  42413. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42414. /**
  42415. * 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)
  42416. */
  42417. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42418. /**
  42419. * The scene that is rendered on top of the original scene
  42420. */
  42421. utilityLayerScene: Scene;
  42422. /**
  42423. * If the utility layer should automatically be rendered on top of existing scene
  42424. */
  42425. shouldRender: boolean;
  42426. /**
  42427. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42428. */
  42429. onlyCheckPointerDownEvents: boolean;
  42430. /**
  42431. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42432. */
  42433. processAllEvents: boolean;
  42434. /**
  42435. * Observable raised when the pointer move from the utility layer scene to the main scene
  42436. */
  42437. onPointerOutObservable: Observable<number>;
  42438. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42439. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42440. private _afterRenderObserver;
  42441. private _sceneDisposeObserver;
  42442. private _originalPointerObserver;
  42443. /**
  42444. * Instantiates a UtilityLayerRenderer
  42445. * @param originalScene the original scene that will be rendered on top of
  42446. * @param handleEvents boolean indicating if the utility layer should handle events
  42447. */
  42448. constructor(
  42449. /** the original scene that will be rendered on top of */
  42450. originalScene: Scene, handleEvents?: boolean);
  42451. private _notifyObservers;
  42452. /**
  42453. * Renders the utility layers scene on top of the original scene
  42454. */
  42455. render(): void;
  42456. /**
  42457. * Disposes of the renderer
  42458. */
  42459. dispose(): void;
  42460. private _updateCamera;
  42461. }
  42462. }
  42463. declare module BABYLON {
  42464. /**
  42465. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42466. */
  42467. export class Gizmo implements IDisposable {
  42468. /** The utility layer the gizmo will be added to */
  42469. gizmoLayer: UtilityLayerRenderer;
  42470. /**
  42471. * The root mesh of the gizmo
  42472. */
  42473. _rootMesh: Mesh;
  42474. private _attachedMesh;
  42475. /**
  42476. * Ratio for the scale of the gizmo (Default: 1)
  42477. */
  42478. scaleRatio: number;
  42479. /**
  42480. * If a custom mesh has been set (Default: false)
  42481. */
  42482. protected _customMeshSet: boolean;
  42483. /**
  42484. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42485. * * When set, interactions will be enabled
  42486. */
  42487. attachedMesh: Nullable<AbstractMesh>;
  42488. /**
  42489. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42490. * @param mesh The mesh to replace the default mesh of the gizmo
  42491. */
  42492. setCustomMesh(mesh: Mesh): void;
  42493. /**
  42494. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42495. */
  42496. updateGizmoRotationToMatchAttachedMesh: boolean;
  42497. /**
  42498. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42499. */
  42500. updateGizmoPositionToMatchAttachedMesh: boolean;
  42501. /**
  42502. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42503. */
  42504. updateScale: boolean;
  42505. protected _interactionsEnabled: boolean;
  42506. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42507. private _beforeRenderObserver;
  42508. private _tempVector;
  42509. /**
  42510. * Creates a gizmo
  42511. * @param gizmoLayer The utility layer the gizmo will be added to
  42512. */
  42513. constructor(
  42514. /** The utility layer the gizmo will be added to */
  42515. gizmoLayer?: UtilityLayerRenderer);
  42516. /**
  42517. * Updates the gizmo to match the attached mesh's position/rotation
  42518. */
  42519. protected _update(): void;
  42520. /**
  42521. * Disposes of the gizmo
  42522. */
  42523. dispose(): void;
  42524. }
  42525. }
  42526. declare module BABYLON {
  42527. /**
  42528. * Single plane drag gizmo
  42529. */
  42530. export class PlaneDragGizmo extends Gizmo {
  42531. /**
  42532. * Drag behavior responsible for the gizmos dragging interactions
  42533. */
  42534. dragBehavior: PointerDragBehavior;
  42535. private _pointerObserver;
  42536. /**
  42537. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42538. */
  42539. snapDistance: number;
  42540. /**
  42541. * Event that fires each time the gizmo snaps to a new location.
  42542. * * snapDistance is the the change in distance
  42543. */
  42544. onSnapObservable: Observable<{
  42545. snapDistance: number;
  42546. }>;
  42547. private _plane;
  42548. private _coloredMaterial;
  42549. private _hoverMaterial;
  42550. private _isEnabled;
  42551. private _parent;
  42552. /** @hidden */
  42553. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42554. /** @hidden */
  42555. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42556. /**
  42557. * Creates a PlaneDragGizmo
  42558. * @param gizmoLayer The utility layer the gizmo will be added to
  42559. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42560. * @param color The color of the gizmo
  42561. */
  42562. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42563. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42564. /**
  42565. * If the gizmo is enabled
  42566. */
  42567. isEnabled: boolean;
  42568. /**
  42569. * Disposes of the gizmo
  42570. */
  42571. dispose(): void;
  42572. }
  42573. }
  42574. declare module BABYLON {
  42575. /**
  42576. * Gizmo that enables dragging a mesh along 3 axis
  42577. */
  42578. export class PositionGizmo extends Gizmo {
  42579. /**
  42580. * Internal gizmo used for interactions on the x axis
  42581. */
  42582. xGizmo: AxisDragGizmo;
  42583. /**
  42584. * Internal gizmo used for interactions on the y axis
  42585. */
  42586. yGizmo: AxisDragGizmo;
  42587. /**
  42588. * Internal gizmo used for interactions on the z axis
  42589. */
  42590. zGizmo: AxisDragGizmo;
  42591. /**
  42592. * Internal gizmo used for interactions on the yz plane
  42593. */
  42594. xPlaneGizmo: PlaneDragGizmo;
  42595. /**
  42596. * Internal gizmo used for interactions on the xz plane
  42597. */
  42598. yPlaneGizmo: PlaneDragGizmo;
  42599. /**
  42600. * Internal gizmo used for interactions on the xy plane
  42601. */
  42602. zPlaneGizmo: PlaneDragGizmo;
  42603. /**
  42604. * private variables
  42605. */
  42606. private _meshAttached;
  42607. private _updateGizmoRotationToMatchAttachedMesh;
  42608. private _snapDistance;
  42609. private _scaleRatio;
  42610. /** Fires an event when any of it's sub gizmos are dragged */
  42611. onDragStartObservable: Observable<unknown>;
  42612. /** Fires an event when any of it's sub gizmos are released from dragging */
  42613. onDragEndObservable: Observable<unknown>;
  42614. /**
  42615. * If set to true, planar drag is enabled
  42616. */
  42617. private _planarGizmoEnabled;
  42618. attachedMesh: Nullable<AbstractMesh>;
  42619. /**
  42620. * Creates a PositionGizmo
  42621. * @param gizmoLayer The utility layer the gizmo will be added to
  42622. */
  42623. constructor(gizmoLayer?: UtilityLayerRenderer);
  42624. /**
  42625. * If the planar drag gizmo is enabled
  42626. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42627. */
  42628. planarGizmoEnabled: boolean;
  42629. updateGizmoRotationToMatchAttachedMesh: boolean;
  42630. /**
  42631. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42632. */
  42633. snapDistance: number;
  42634. /**
  42635. * Ratio for the scale of the gizmo (Default: 1)
  42636. */
  42637. scaleRatio: number;
  42638. /**
  42639. * Disposes of the gizmo
  42640. */
  42641. dispose(): void;
  42642. /**
  42643. * CustomMeshes are not supported by this gizmo
  42644. * @param mesh The mesh to replace the default mesh of the gizmo
  42645. */
  42646. setCustomMesh(mesh: Mesh): void;
  42647. }
  42648. }
  42649. declare module BABYLON {
  42650. /**
  42651. * Single axis drag gizmo
  42652. */
  42653. export class AxisDragGizmo extends Gizmo {
  42654. /**
  42655. * Drag behavior responsible for the gizmos dragging interactions
  42656. */
  42657. dragBehavior: PointerDragBehavior;
  42658. private _pointerObserver;
  42659. /**
  42660. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42661. */
  42662. snapDistance: number;
  42663. /**
  42664. * Event that fires each time the gizmo snaps to a new location.
  42665. * * snapDistance is the the change in distance
  42666. */
  42667. onSnapObservable: Observable<{
  42668. snapDistance: number;
  42669. }>;
  42670. private _isEnabled;
  42671. private _parent;
  42672. private _arrow;
  42673. private _coloredMaterial;
  42674. private _hoverMaterial;
  42675. /** @hidden */
  42676. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42677. /** @hidden */
  42678. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42679. /**
  42680. * Creates an AxisDragGizmo
  42681. * @param gizmoLayer The utility layer the gizmo will be added to
  42682. * @param dragAxis The axis which the gizmo will be able to drag on
  42683. * @param color The color of the gizmo
  42684. */
  42685. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42686. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42687. /**
  42688. * If the gizmo is enabled
  42689. */
  42690. isEnabled: boolean;
  42691. /**
  42692. * Disposes of the gizmo
  42693. */
  42694. dispose(): void;
  42695. }
  42696. }
  42697. declare module BABYLON.Debug {
  42698. /**
  42699. * The Axes viewer will show 3 axes in a specific point in space
  42700. */
  42701. export class AxesViewer {
  42702. private _xAxis;
  42703. private _yAxis;
  42704. private _zAxis;
  42705. private _scaleLinesFactor;
  42706. private _instanced;
  42707. /**
  42708. * Gets the hosting scene
  42709. */
  42710. scene: Scene;
  42711. /**
  42712. * Gets or sets a number used to scale line length
  42713. */
  42714. scaleLines: number;
  42715. /** Gets the node hierarchy used to render x-axis */
  42716. readonly xAxis: TransformNode;
  42717. /** Gets the node hierarchy used to render y-axis */
  42718. readonly yAxis: TransformNode;
  42719. /** Gets the node hierarchy used to render z-axis */
  42720. readonly zAxis: TransformNode;
  42721. /**
  42722. * Creates a new AxesViewer
  42723. * @param scene defines the hosting scene
  42724. * @param scaleLines defines a number used to scale line length (1 by default)
  42725. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42726. * @param xAxis defines the node hierarchy used to render the x-axis
  42727. * @param yAxis defines the node hierarchy used to render the y-axis
  42728. * @param zAxis defines the node hierarchy used to render the z-axis
  42729. */
  42730. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42731. /**
  42732. * Force the viewer to update
  42733. * @param position defines the position of the viewer
  42734. * @param xaxis defines the x axis of the viewer
  42735. * @param yaxis defines the y axis of the viewer
  42736. * @param zaxis defines the z axis of the viewer
  42737. */
  42738. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42739. /**
  42740. * Creates an instance of this axes viewer.
  42741. * @returns a new axes viewer with instanced meshes
  42742. */
  42743. createInstance(): AxesViewer;
  42744. /** Releases resources */
  42745. dispose(): void;
  42746. private static _SetRenderingGroupId;
  42747. }
  42748. }
  42749. declare module BABYLON.Debug {
  42750. /**
  42751. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42752. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42753. */
  42754. export class BoneAxesViewer extends AxesViewer {
  42755. /**
  42756. * Gets or sets the target mesh where to display the axes viewer
  42757. */
  42758. mesh: Nullable<Mesh>;
  42759. /**
  42760. * Gets or sets the target bone where to display the axes viewer
  42761. */
  42762. bone: Nullable<Bone>;
  42763. /** Gets current position */
  42764. pos: Vector3;
  42765. /** Gets direction of X axis */
  42766. xaxis: Vector3;
  42767. /** Gets direction of Y axis */
  42768. yaxis: Vector3;
  42769. /** Gets direction of Z axis */
  42770. zaxis: Vector3;
  42771. /**
  42772. * Creates a new BoneAxesViewer
  42773. * @param scene defines the hosting scene
  42774. * @param bone defines the target bone
  42775. * @param mesh defines the target mesh
  42776. * @param scaleLines defines a scaling factor for line length (1 by default)
  42777. */
  42778. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42779. /**
  42780. * Force the viewer to update
  42781. */
  42782. update(): void;
  42783. /** Releases resources */
  42784. dispose(): void;
  42785. }
  42786. }
  42787. declare module BABYLON {
  42788. /**
  42789. * Interface used to define scene explorer extensibility option
  42790. */
  42791. export interface IExplorerExtensibilityOption {
  42792. /**
  42793. * Define the option label
  42794. */
  42795. label: string;
  42796. /**
  42797. * Defines the action to execute on click
  42798. */
  42799. action: (entity: any) => void;
  42800. }
  42801. /**
  42802. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42803. */
  42804. export interface IExplorerExtensibilityGroup {
  42805. /**
  42806. * Defines a predicate to test if a given type mut be extended
  42807. */
  42808. predicate: (entity: any) => boolean;
  42809. /**
  42810. * Gets the list of options added to a type
  42811. */
  42812. entries: IExplorerExtensibilityOption[];
  42813. }
  42814. /**
  42815. * Interface used to define the options to use to create the Inspector
  42816. */
  42817. export interface IInspectorOptions {
  42818. /**
  42819. * Display in overlay mode (default: false)
  42820. */
  42821. overlay?: boolean;
  42822. /**
  42823. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42824. */
  42825. globalRoot?: HTMLElement;
  42826. /**
  42827. * Display the Scene explorer
  42828. */
  42829. showExplorer?: boolean;
  42830. /**
  42831. * Display the property inspector
  42832. */
  42833. showInspector?: boolean;
  42834. /**
  42835. * Display in embed mode (both panes on the right)
  42836. */
  42837. embedMode?: boolean;
  42838. /**
  42839. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42840. */
  42841. handleResize?: boolean;
  42842. /**
  42843. * Allow the panes to popup (default: true)
  42844. */
  42845. enablePopup?: boolean;
  42846. /**
  42847. * Allow the panes to be closed by users (default: true)
  42848. */
  42849. enableClose?: boolean;
  42850. /**
  42851. * Optional list of extensibility entries
  42852. */
  42853. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42854. /**
  42855. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42856. */
  42857. inspectorURL?: string;
  42858. }
  42859. interface Scene {
  42860. /**
  42861. * @hidden
  42862. * Backing field
  42863. */
  42864. _debugLayer: DebugLayer;
  42865. /**
  42866. * Gets the debug layer (aka Inspector) associated with the scene
  42867. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42868. */
  42869. debugLayer: DebugLayer;
  42870. }
  42871. /**
  42872. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42873. * what is happening in your scene
  42874. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42875. */
  42876. export class DebugLayer {
  42877. /**
  42878. * Define the url to get the inspector script from.
  42879. * By default it uses the babylonjs CDN.
  42880. * @ignoreNaming
  42881. */
  42882. static InspectorURL: string;
  42883. private _scene;
  42884. private BJSINSPECTOR;
  42885. private _onPropertyChangedObservable?;
  42886. /**
  42887. * Observable triggered when a property is changed through the inspector.
  42888. */
  42889. readonly onPropertyChangedObservable: any;
  42890. /**
  42891. * Instantiates a new debug layer.
  42892. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42893. * what is happening in your scene
  42894. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42895. * @param scene Defines the scene to inspect
  42896. */
  42897. constructor(scene: Scene);
  42898. /** Creates the inspector window. */
  42899. private _createInspector;
  42900. /**
  42901. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42902. * @param entity defines the entity to select
  42903. * @param lineContainerTitle defines the specific block to highlight
  42904. */
  42905. select(entity: any, lineContainerTitle?: string): void;
  42906. /** Get the inspector from bundle or global */
  42907. private _getGlobalInspector;
  42908. /**
  42909. * Get if the inspector is visible or not.
  42910. * @returns true if visible otherwise, false
  42911. */
  42912. isVisible(): boolean;
  42913. /**
  42914. * Hide the inspector and close its window.
  42915. */
  42916. hide(): void;
  42917. /**
  42918. * Launch the debugLayer.
  42919. * @param config Define the configuration of the inspector
  42920. * @return a promise fulfilled when the debug layer is visible
  42921. */
  42922. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42923. }
  42924. }
  42925. declare module BABYLON {
  42926. /**
  42927. * Class containing static functions to help procedurally build meshes
  42928. */
  42929. export class BoxBuilder {
  42930. /**
  42931. * Creates a box mesh
  42932. * * The parameter `size` sets the size (float) of each box side (default 1)
  42933. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42934. * * 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)
  42935. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42937. * * 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
  42938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42939. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42940. * @param name defines the name of the mesh
  42941. * @param options defines the options used to create the mesh
  42942. * @param scene defines the hosting scene
  42943. * @returns the box mesh
  42944. */
  42945. static CreateBox(name: string, options: {
  42946. size?: number;
  42947. width?: number;
  42948. height?: number;
  42949. depth?: number;
  42950. faceUV?: Vector4[];
  42951. faceColors?: Color4[];
  42952. sideOrientation?: number;
  42953. frontUVs?: Vector4;
  42954. backUVs?: Vector4;
  42955. wrap?: boolean;
  42956. topBaseAt?: number;
  42957. bottomBaseAt?: number;
  42958. updatable?: boolean;
  42959. }, scene?: Nullable<Scene>): Mesh;
  42960. }
  42961. }
  42962. declare module BABYLON {
  42963. /**
  42964. * Class containing static functions to help procedurally build meshes
  42965. */
  42966. export class SphereBuilder {
  42967. /**
  42968. * Creates a sphere mesh
  42969. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42970. * * 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`)
  42971. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42972. * * 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
  42973. * * 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)
  42974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42975. * * 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
  42976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42977. * @param name defines the name of the mesh
  42978. * @param options defines the options used to create the mesh
  42979. * @param scene defines the hosting scene
  42980. * @returns the sphere mesh
  42981. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42982. */
  42983. static CreateSphere(name: string, options: {
  42984. segments?: number;
  42985. diameter?: number;
  42986. diameterX?: number;
  42987. diameterY?: number;
  42988. diameterZ?: number;
  42989. arc?: number;
  42990. slice?: number;
  42991. sideOrientation?: number;
  42992. frontUVs?: Vector4;
  42993. backUVs?: Vector4;
  42994. updatable?: boolean;
  42995. }, scene?: Nullable<Scene>): Mesh;
  42996. }
  42997. }
  42998. declare module BABYLON.Debug {
  42999. /**
  43000. * Used to show the physics impostor around the specific mesh
  43001. */
  43002. export class PhysicsViewer {
  43003. /** @hidden */
  43004. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43005. /** @hidden */
  43006. protected _meshes: Array<Nullable<AbstractMesh>>;
  43007. /** @hidden */
  43008. protected _scene: Nullable<Scene>;
  43009. /** @hidden */
  43010. protected _numMeshes: number;
  43011. /** @hidden */
  43012. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43013. private _renderFunction;
  43014. private _utilityLayer;
  43015. private _debugBoxMesh;
  43016. private _debugSphereMesh;
  43017. private _debugCylinderMesh;
  43018. private _debugMaterial;
  43019. private _debugMeshMeshes;
  43020. /**
  43021. * Creates a new PhysicsViewer
  43022. * @param scene defines the hosting scene
  43023. */
  43024. constructor(scene: Scene);
  43025. /** @hidden */
  43026. protected _updateDebugMeshes(): void;
  43027. /**
  43028. * Renders a specified physic impostor
  43029. * @param impostor defines the impostor to render
  43030. * @param targetMesh defines the mesh represented by the impostor
  43031. * @returns the new debug mesh used to render the impostor
  43032. */
  43033. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43034. /**
  43035. * Hides a specified physic impostor
  43036. * @param impostor defines the impostor to hide
  43037. */
  43038. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43039. private _getDebugMaterial;
  43040. private _getDebugBoxMesh;
  43041. private _getDebugSphereMesh;
  43042. private _getDebugCylinderMesh;
  43043. private _getDebugMeshMesh;
  43044. private _getDebugMesh;
  43045. /** Releases all resources */
  43046. dispose(): void;
  43047. }
  43048. }
  43049. declare module BABYLON {
  43050. /**
  43051. * Class containing static functions to help procedurally build meshes
  43052. */
  43053. export class LinesBuilder {
  43054. /**
  43055. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43056. * * 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
  43057. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43058. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43059. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43060. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43061. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43062. * * 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
  43063. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43066. * @param name defines the name of the new line system
  43067. * @param options defines the options used to create the line system
  43068. * @param scene defines the hosting scene
  43069. * @returns a new line system mesh
  43070. */
  43071. static CreateLineSystem(name: string, options: {
  43072. lines: Vector3[][];
  43073. updatable?: boolean;
  43074. instance?: Nullable<LinesMesh>;
  43075. colors?: Nullable<Color4[][]>;
  43076. useVertexAlpha?: boolean;
  43077. }, scene: Nullable<Scene>): LinesMesh;
  43078. /**
  43079. * Creates a line mesh
  43080. * 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
  43081. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43082. * * The parameter `points` is an array successive Vector3
  43083. * * 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
  43084. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43085. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43086. * * When updating an instance, remember that only point positions can change, not the number of points
  43087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43089. * @param name defines the name of the new line system
  43090. * @param options defines the options used to create the line system
  43091. * @param scene defines the hosting scene
  43092. * @returns a new line mesh
  43093. */
  43094. static CreateLines(name: string, options: {
  43095. points: Vector3[];
  43096. updatable?: boolean;
  43097. instance?: Nullable<LinesMesh>;
  43098. colors?: Color4[];
  43099. useVertexAlpha?: boolean;
  43100. }, scene?: Nullable<Scene>): LinesMesh;
  43101. /**
  43102. * Creates a dashed line mesh
  43103. * * 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
  43104. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43105. * * The parameter `points` is an array successive Vector3
  43106. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43107. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43108. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43109. * * 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
  43110. * * When updating an instance, remember that only point positions can change, not the number of points
  43111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43112. * @param name defines the name of the mesh
  43113. * @param options defines the options used to create the mesh
  43114. * @param scene defines the hosting scene
  43115. * @returns the dashed line mesh
  43116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43117. */
  43118. static CreateDashedLines(name: string, options: {
  43119. points: Vector3[];
  43120. dashSize?: number;
  43121. gapSize?: number;
  43122. dashNb?: number;
  43123. updatable?: boolean;
  43124. instance?: LinesMesh;
  43125. }, scene?: Nullable<Scene>): LinesMesh;
  43126. }
  43127. }
  43128. declare module BABYLON {
  43129. /**
  43130. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43131. * in order to better appreciate the issue one might have.
  43132. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43133. */
  43134. export class RayHelper {
  43135. /**
  43136. * Defines the ray we are currently tryin to visualize.
  43137. */
  43138. ray: Nullable<Ray>;
  43139. private _renderPoints;
  43140. private _renderLine;
  43141. private _renderFunction;
  43142. private _scene;
  43143. private _updateToMeshFunction;
  43144. private _attachedToMesh;
  43145. private _meshSpaceDirection;
  43146. private _meshSpaceOrigin;
  43147. /**
  43148. * Helper function to create a colored helper in a scene in one line.
  43149. * @param ray Defines the ray we are currently tryin to visualize
  43150. * @param scene Defines the scene the ray is used in
  43151. * @param color Defines the color we want to see the ray in
  43152. * @returns The newly created ray helper.
  43153. */
  43154. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43155. /**
  43156. * Instantiate a new ray helper.
  43157. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43158. * in order to better appreciate the issue one might have.
  43159. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43160. * @param ray Defines the ray we are currently tryin to visualize
  43161. */
  43162. constructor(ray: Ray);
  43163. /**
  43164. * Shows the ray we are willing to debug.
  43165. * @param scene Defines the scene the ray needs to be rendered in
  43166. * @param color Defines the color the ray needs to be rendered in
  43167. */
  43168. show(scene: Scene, color?: Color3): void;
  43169. /**
  43170. * Hides the ray we are debugging.
  43171. */
  43172. hide(): void;
  43173. private _render;
  43174. /**
  43175. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43176. * @param mesh Defines the mesh we want the helper attached to
  43177. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43178. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43179. * @param length Defines the length of the ray
  43180. */
  43181. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43182. /**
  43183. * Detach the ray helper from the mesh it has previously been attached to.
  43184. */
  43185. detachFromMesh(): void;
  43186. private _updateToMesh;
  43187. /**
  43188. * Dispose the helper and release its associated resources.
  43189. */
  43190. dispose(): void;
  43191. }
  43192. }
  43193. declare module BABYLON.Debug {
  43194. /**
  43195. * Class used to render a debug view of a given skeleton
  43196. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43197. */
  43198. export class SkeletonViewer {
  43199. /** defines the skeleton to render */
  43200. skeleton: Skeleton;
  43201. /** defines the mesh attached to the skeleton */
  43202. mesh: AbstractMesh;
  43203. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43204. autoUpdateBonesMatrices: boolean;
  43205. /** defines the rendering group id to use with the viewer */
  43206. renderingGroupId: number;
  43207. /** Gets or sets the color used to render the skeleton */
  43208. color: Color3;
  43209. private _scene;
  43210. private _debugLines;
  43211. private _debugMesh;
  43212. private _isEnabled;
  43213. private _renderFunction;
  43214. private _utilityLayer;
  43215. /**
  43216. * Returns the mesh used to render the bones
  43217. */
  43218. readonly debugMesh: Nullable<LinesMesh>;
  43219. /**
  43220. * Creates a new SkeletonViewer
  43221. * @param skeleton defines the skeleton to render
  43222. * @param mesh defines the mesh attached to the skeleton
  43223. * @param scene defines the hosting scene
  43224. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43225. * @param renderingGroupId defines the rendering group id to use with the viewer
  43226. */
  43227. constructor(
  43228. /** defines the skeleton to render */
  43229. skeleton: Skeleton,
  43230. /** defines the mesh attached to the skeleton */
  43231. mesh: AbstractMesh, scene: Scene,
  43232. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43233. autoUpdateBonesMatrices?: boolean,
  43234. /** defines the rendering group id to use with the viewer */
  43235. renderingGroupId?: number);
  43236. /** Gets or sets a boolean indicating if the viewer is enabled */
  43237. isEnabled: boolean;
  43238. private _getBonePosition;
  43239. private _getLinesForBonesWithLength;
  43240. private _getLinesForBonesNoLength;
  43241. /** Update the viewer to sync with current skeleton state */
  43242. update(): void;
  43243. /** Release associated resources */
  43244. dispose(): void;
  43245. }
  43246. }
  43247. declare module BABYLON {
  43248. /**
  43249. * Options to create the null engine
  43250. */
  43251. export class NullEngineOptions {
  43252. /**
  43253. * Render width (Default: 512)
  43254. */
  43255. renderWidth: number;
  43256. /**
  43257. * Render height (Default: 256)
  43258. */
  43259. renderHeight: number;
  43260. /**
  43261. * Texture size (Default: 512)
  43262. */
  43263. textureSize: number;
  43264. /**
  43265. * If delta time between frames should be constant
  43266. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43267. */
  43268. deterministicLockstep: boolean;
  43269. /**
  43270. * Maximum about of steps between frames (Default: 4)
  43271. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43272. */
  43273. lockstepMaxSteps: number;
  43274. }
  43275. /**
  43276. * The null engine class provides support for headless version of babylon.js.
  43277. * This can be used in server side scenario or for testing purposes
  43278. */
  43279. export class NullEngine extends Engine {
  43280. private _options;
  43281. /**
  43282. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43283. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43284. * @returns true if engine is in deterministic lock step mode
  43285. */
  43286. isDeterministicLockStep(): boolean;
  43287. /**
  43288. * Gets the max steps when engine is running in deterministic lock step
  43289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43290. * @returns the max steps
  43291. */
  43292. getLockstepMaxSteps(): number;
  43293. /**
  43294. * Gets the current hardware scaling level.
  43295. * By default the hardware scaling level is computed from the window device ratio.
  43296. * 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.
  43297. * @returns a number indicating the current hardware scaling level
  43298. */
  43299. getHardwareScalingLevel(): number;
  43300. constructor(options?: NullEngineOptions);
  43301. /**
  43302. * Creates a vertex buffer
  43303. * @param vertices the data for the vertex buffer
  43304. * @returns the new WebGL static buffer
  43305. */
  43306. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43307. /**
  43308. * Creates a new index buffer
  43309. * @param indices defines the content of the index buffer
  43310. * @param updatable defines if the index buffer must be updatable
  43311. * @returns a new webGL buffer
  43312. */
  43313. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43314. /**
  43315. * Clear the current render buffer or the current render target (if any is set up)
  43316. * @param color defines the color to use
  43317. * @param backBuffer defines if the back buffer must be cleared
  43318. * @param depth defines if the depth buffer must be cleared
  43319. * @param stencil defines if the stencil buffer must be cleared
  43320. */
  43321. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43322. /**
  43323. * Gets the current render width
  43324. * @param useScreen defines if screen size must be used (or the current render target if any)
  43325. * @returns a number defining the current render width
  43326. */
  43327. getRenderWidth(useScreen?: boolean): number;
  43328. /**
  43329. * Gets the current render height
  43330. * @param useScreen defines if screen size must be used (or the current render target if any)
  43331. * @returns a number defining the current render height
  43332. */
  43333. getRenderHeight(useScreen?: boolean): number;
  43334. /**
  43335. * Set the WebGL's viewport
  43336. * @param viewport defines the viewport element to be used
  43337. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43338. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43339. */
  43340. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43341. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43342. /**
  43343. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43344. * @param pipelineContext defines the pipeline context to use
  43345. * @param uniformsNames defines the list of uniform names
  43346. * @returns an array of webGL uniform locations
  43347. */
  43348. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43349. /**
  43350. * Gets the lsit of active attributes for a given webGL program
  43351. * @param pipelineContext defines the pipeline context to use
  43352. * @param attributesNames defines the list of attribute names to get
  43353. * @returns an array of indices indicating the offset of each attribute
  43354. */
  43355. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43356. /**
  43357. * Binds an effect to the webGL context
  43358. * @param effect defines the effect to bind
  43359. */
  43360. bindSamplers(effect: Effect): void;
  43361. /**
  43362. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43363. * @param effect defines the effect to activate
  43364. */
  43365. enableEffect(effect: Effect): void;
  43366. /**
  43367. * Set various states to the webGL context
  43368. * @param culling defines backface culling state
  43369. * @param zOffset defines the value to apply to zOffset (0 by default)
  43370. * @param force defines if states must be applied even if cache is up to date
  43371. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43372. */
  43373. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43374. /**
  43375. * Set the value of an uniform to an array of int32
  43376. * @param uniform defines the webGL uniform location where to store the value
  43377. * @param array defines the array of int32 to store
  43378. */
  43379. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43380. /**
  43381. * Set the value of an uniform to an array of int32 (stored as vec2)
  43382. * @param uniform defines the webGL uniform location where to store the value
  43383. * @param array defines the array of int32 to store
  43384. */
  43385. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43386. /**
  43387. * Set the value of an uniform to an array of int32 (stored as vec3)
  43388. * @param uniform defines the webGL uniform location where to store the value
  43389. * @param array defines the array of int32 to store
  43390. */
  43391. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43392. /**
  43393. * Set the value of an uniform to an array of int32 (stored as vec4)
  43394. * @param uniform defines the webGL uniform location where to store the value
  43395. * @param array defines the array of int32 to store
  43396. */
  43397. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43398. /**
  43399. * Set the value of an uniform to an array of float32
  43400. * @param uniform defines the webGL uniform location where to store the value
  43401. * @param array defines the array of float32 to store
  43402. */
  43403. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43404. /**
  43405. * Set the value of an uniform to an array of float32 (stored as vec2)
  43406. * @param uniform defines the webGL uniform location where to store the value
  43407. * @param array defines the array of float32 to store
  43408. */
  43409. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43410. /**
  43411. * Set the value of an uniform to an array of float32 (stored as vec3)
  43412. * @param uniform defines the webGL uniform location where to store the value
  43413. * @param array defines the array of float32 to store
  43414. */
  43415. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43416. /**
  43417. * Set the value of an uniform to an array of float32 (stored as vec4)
  43418. * @param uniform defines the webGL uniform location where to store the value
  43419. * @param array defines the array of float32 to store
  43420. */
  43421. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43422. /**
  43423. * Set the value of an uniform to an array of number
  43424. * @param uniform defines the webGL uniform location where to store the value
  43425. * @param array defines the array of number to store
  43426. */
  43427. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43428. /**
  43429. * Set the value of an uniform to an array of number (stored as vec2)
  43430. * @param uniform defines the webGL uniform location where to store the value
  43431. * @param array defines the array of number to store
  43432. */
  43433. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43434. /**
  43435. * Set the value of an uniform to an array of number (stored as vec3)
  43436. * @param uniform defines the webGL uniform location where to store the value
  43437. * @param array defines the array of number to store
  43438. */
  43439. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43440. /**
  43441. * Set the value of an uniform to an array of number (stored as vec4)
  43442. * @param uniform defines the webGL uniform location where to store the value
  43443. * @param array defines the array of number to store
  43444. */
  43445. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43446. /**
  43447. * Set the value of an uniform to an array of float32 (stored as matrices)
  43448. * @param uniform defines the webGL uniform location where to store the value
  43449. * @param matrices defines the array of float32 to store
  43450. */
  43451. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43452. /**
  43453. * Set the value of an uniform to a matrix (3x3)
  43454. * @param uniform defines the webGL uniform location where to store the value
  43455. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43456. */
  43457. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43458. /**
  43459. * Set the value of an uniform to a matrix (2x2)
  43460. * @param uniform defines the webGL uniform location where to store the value
  43461. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43462. */
  43463. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43464. /**
  43465. * Set the value of an uniform to a number (float)
  43466. * @param uniform defines the webGL uniform location where to store the value
  43467. * @param value defines the float number to store
  43468. */
  43469. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43470. /**
  43471. * Set the value of an uniform to a vec2
  43472. * @param uniform defines the webGL uniform location where to store the value
  43473. * @param x defines the 1st component of the value
  43474. * @param y defines the 2nd component of the value
  43475. */
  43476. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43477. /**
  43478. * Set the value of an uniform to a vec3
  43479. * @param uniform defines the webGL uniform location where to store the value
  43480. * @param x defines the 1st component of the value
  43481. * @param y defines the 2nd component of the value
  43482. * @param z defines the 3rd component of the value
  43483. */
  43484. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43485. /**
  43486. * Set the value of an uniform to a boolean
  43487. * @param uniform defines the webGL uniform location where to store the value
  43488. * @param bool defines the boolean to store
  43489. */
  43490. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43491. /**
  43492. * Set the value of an uniform to a vec4
  43493. * @param uniform defines the webGL uniform location where to store the value
  43494. * @param x defines the 1st component of the value
  43495. * @param y defines the 2nd component of the value
  43496. * @param z defines the 3rd component of the value
  43497. * @param w defines the 4th component of the value
  43498. */
  43499. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43500. /**
  43501. * Sets the current alpha mode
  43502. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43503. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43504. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43505. */
  43506. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43507. /**
  43508. * Bind webGl buffers directly to the webGL context
  43509. * @param vertexBuffers defines the vertex buffer to bind
  43510. * @param indexBuffer defines the index buffer to bind
  43511. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43512. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43513. * @param effect defines the effect associated with the vertex buffer
  43514. */
  43515. bindBuffers(vertexBuffers: {
  43516. [key: string]: VertexBuffer;
  43517. }, indexBuffer: DataBuffer, effect: Effect): void;
  43518. /**
  43519. * Force the entire cache to be cleared
  43520. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43521. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43522. */
  43523. wipeCaches(bruteForce?: boolean): void;
  43524. /**
  43525. * Send a draw order
  43526. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43527. * @param indexStart defines the starting index
  43528. * @param indexCount defines the number of index to draw
  43529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43530. */
  43531. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43532. /**
  43533. * Draw a list of indexed primitives
  43534. * @param fillMode defines the primitive to use
  43535. * @param indexStart defines the starting index
  43536. * @param indexCount defines the number of index to draw
  43537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43538. */
  43539. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43540. /**
  43541. * Draw a list of unindexed primitives
  43542. * @param fillMode defines the primitive to use
  43543. * @param verticesStart defines the index of first vertex to draw
  43544. * @param verticesCount defines the count of vertices to draw
  43545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43546. */
  43547. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43548. /** @hidden */
  43549. _createTexture(): WebGLTexture;
  43550. /** @hidden */
  43551. _releaseTexture(texture: InternalTexture): void;
  43552. /**
  43553. * Usually called from Texture.ts.
  43554. * Passed information to create a WebGLTexture
  43555. * @param urlArg defines a value which contains one of the following:
  43556. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43557. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43558. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43559. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43560. * @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)
  43561. * @param scene needed for loading to the correct scene
  43562. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43563. * @param onLoad optional callback to be called upon successful completion
  43564. * @param onError optional callback to be called upon failure
  43565. * @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
  43566. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43567. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43568. * @param forcedExtension defines the extension to use to pick the right loader
  43569. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43570. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43571. */
  43572. 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;
  43573. /**
  43574. * Creates a new render target texture
  43575. * @param size defines the size of the texture
  43576. * @param options defines the options used to create the texture
  43577. * @returns a new render target texture stored in an InternalTexture
  43578. */
  43579. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43580. /**
  43581. * Update the sampling mode of a given texture
  43582. * @param samplingMode defines the required sampling mode
  43583. * @param texture defines the texture to update
  43584. */
  43585. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43586. /**
  43587. * Binds the frame buffer to the specified texture.
  43588. * @param texture The texture to render to or null for the default canvas
  43589. * @param faceIndex The face of the texture to render to in case of cube texture
  43590. * @param requiredWidth The width of the target to render to
  43591. * @param requiredHeight The height of the target to render to
  43592. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43593. * @param depthStencilTexture The depth stencil texture to use to render
  43594. * @param lodLevel defines le lod level to bind to the frame buffer
  43595. */
  43596. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43597. /**
  43598. * Unbind the current render target texture from the webGL context
  43599. * @param texture defines the render target texture to unbind
  43600. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43601. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43602. */
  43603. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43604. /**
  43605. * Creates a dynamic vertex buffer
  43606. * @param vertices the data for the dynamic vertex buffer
  43607. * @returns the new WebGL dynamic buffer
  43608. */
  43609. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43610. /**
  43611. * Update the content of a dynamic texture
  43612. * @param texture defines the texture to update
  43613. * @param canvas defines the canvas containing the source
  43614. * @param invertY defines if data must be stored with Y axis inverted
  43615. * @param premulAlpha defines if alpha is stored as premultiplied
  43616. * @param format defines the format of the data
  43617. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43618. */
  43619. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43620. /**
  43621. * Gets a boolean indicating if all created effects are ready
  43622. * @returns true if all effects are ready
  43623. */
  43624. areAllEffectsReady(): boolean;
  43625. /**
  43626. * @hidden
  43627. * Get the current error code of the webGL context
  43628. * @returns the error code
  43629. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43630. */
  43631. getError(): number;
  43632. /** @hidden */
  43633. _getUnpackAlignement(): number;
  43634. /** @hidden */
  43635. _unpackFlipY(value: boolean): void;
  43636. /**
  43637. * Update a dynamic index buffer
  43638. * @param indexBuffer defines the target index buffer
  43639. * @param indices defines the data to update
  43640. * @param offset defines the offset in the target index buffer where update should start
  43641. */
  43642. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43643. /**
  43644. * Updates a dynamic vertex buffer.
  43645. * @param vertexBuffer the vertex buffer to update
  43646. * @param vertices the data used to update the vertex buffer
  43647. * @param byteOffset the byte offset of the data (optional)
  43648. * @param byteLength the byte length of the data (optional)
  43649. */
  43650. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43651. /** @hidden */
  43652. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43653. /** @hidden */
  43654. _bindTexture(channel: number, texture: InternalTexture): void;
  43655. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43656. /**
  43657. * 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
  43658. */
  43659. releaseEffects(): void;
  43660. displayLoadingUI(): void;
  43661. hideLoadingUI(): void;
  43662. /** @hidden */
  43663. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43664. /** @hidden */
  43665. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43666. /** @hidden */
  43667. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43668. /** @hidden */
  43669. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43670. }
  43671. }
  43672. declare module BABYLON {
  43673. /** @hidden */
  43674. export class _OcclusionDataStorage {
  43675. /** @hidden */
  43676. occlusionInternalRetryCounter: number;
  43677. /** @hidden */
  43678. isOcclusionQueryInProgress: boolean;
  43679. /** @hidden */
  43680. isOccluded: boolean;
  43681. /** @hidden */
  43682. occlusionRetryCount: number;
  43683. /** @hidden */
  43684. occlusionType: number;
  43685. /** @hidden */
  43686. occlusionQueryAlgorithmType: number;
  43687. }
  43688. interface Engine {
  43689. /**
  43690. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43691. * @return the new query
  43692. */
  43693. createQuery(): WebGLQuery;
  43694. /**
  43695. * Delete and release a webGL query
  43696. * @param query defines the query to delete
  43697. * @return the current engine
  43698. */
  43699. deleteQuery(query: WebGLQuery): Engine;
  43700. /**
  43701. * Check if a given query has resolved and got its value
  43702. * @param query defines the query to check
  43703. * @returns true if the query got its value
  43704. */
  43705. isQueryResultAvailable(query: WebGLQuery): boolean;
  43706. /**
  43707. * Gets the value of a given query
  43708. * @param query defines the query to check
  43709. * @returns the value of the query
  43710. */
  43711. getQueryResult(query: WebGLQuery): number;
  43712. /**
  43713. * Initiates an occlusion query
  43714. * @param algorithmType defines the algorithm to use
  43715. * @param query defines the query to use
  43716. * @returns the current engine
  43717. * @see http://doc.babylonjs.com/features/occlusionquery
  43718. */
  43719. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43720. /**
  43721. * Ends an occlusion query
  43722. * @see http://doc.babylonjs.com/features/occlusionquery
  43723. * @param algorithmType defines the algorithm to use
  43724. * @returns the current engine
  43725. */
  43726. endOcclusionQuery(algorithmType: number): Engine;
  43727. /**
  43728. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43729. * Please note that only one query can be issued at a time
  43730. * @returns a time token used to track the time span
  43731. */
  43732. startTimeQuery(): Nullable<_TimeToken>;
  43733. /**
  43734. * Ends a time query
  43735. * @param token defines the token used to measure the time span
  43736. * @returns the time spent (in ns)
  43737. */
  43738. endTimeQuery(token: _TimeToken): int;
  43739. /** @hidden */
  43740. _currentNonTimestampToken: Nullable<_TimeToken>;
  43741. /** @hidden */
  43742. _createTimeQuery(): WebGLQuery;
  43743. /** @hidden */
  43744. _deleteTimeQuery(query: WebGLQuery): void;
  43745. /** @hidden */
  43746. _getGlAlgorithmType(algorithmType: number): number;
  43747. /** @hidden */
  43748. _getTimeQueryResult(query: WebGLQuery): any;
  43749. /** @hidden */
  43750. _getTimeQueryAvailability(query: WebGLQuery): any;
  43751. }
  43752. interface AbstractMesh {
  43753. /**
  43754. * Backing filed
  43755. * @hidden
  43756. */
  43757. __occlusionDataStorage: _OcclusionDataStorage;
  43758. /**
  43759. * Access property
  43760. * @hidden
  43761. */
  43762. _occlusionDataStorage: _OcclusionDataStorage;
  43763. /**
  43764. * 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.
  43765. * The default value is -1 which means don't break the query and wait till the result
  43766. * @see http://doc.babylonjs.com/features/occlusionquery
  43767. */
  43768. occlusionRetryCount: number;
  43769. /**
  43770. * 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:
  43771. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43772. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43773. * * 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.
  43774. * @see http://doc.babylonjs.com/features/occlusionquery
  43775. */
  43776. occlusionType: number;
  43777. /**
  43778. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43779. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43780. * * 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.
  43781. * @see http://doc.babylonjs.com/features/occlusionquery
  43782. */
  43783. occlusionQueryAlgorithmType: number;
  43784. /**
  43785. * 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
  43786. * @see http://doc.babylonjs.com/features/occlusionquery
  43787. */
  43788. isOccluded: boolean;
  43789. /**
  43790. * Flag to check the progress status of the query
  43791. * @see http://doc.babylonjs.com/features/occlusionquery
  43792. */
  43793. isOcclusionQueryInProgress: boolean;
  43794. }
  43795. }
  43796. declare module BABYLON {
  43797. /** @hidden */
  43798. export var _forceTransformFeedbackToBundle: boolean;
  43799. interface Engine {
  43800. /**
  43801. * Creates a webGL transform feedback object
  43802. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43803. * @returns the webGL transform feedback object
  43804. */
  43805. createTransformFeedback(): WebGLTransformFeedback;
  43806. /**
  43807. * Delete a webGL transform feedback object
  43808. * @param value defines the webGL transform feedback object to delete
  43809. */
  43810. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43811. /**
  43812. * Bind a webGL transform feedback object to the webgl context
  43813. * @param value defines the webGL transform feedback object to bind
  43814. */
  43815. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43816. /**
  43817. * Begins a transform feedback operation
  43818. * @param usePoints defines if points or triangles must be used
  43819. */
  43820. beginTransformFeedback(usePoints: boolean): void;
  43821. /**
  43822. * Ends a transform feedback operation
  43823. */
  43824. endTransformFeedback(): void;
  43825. /**
  43826. * Specify the varyings to use with transform feedback
  43827. * @param program defines the associated webGL program
  43828. * @param value defines the list of strings representing the varying names
  43829. */
  43830. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43831. /**
  43832. * Bind a webGL buffer for a transform feedback operation
  43833. * @param value defines the webGL buffer to bind
  43834. */
  43835. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43836. }
  43837. }
  43838. declare module BABYLON {
  43839. /**
  43840. * Creation options of the multi render target texture.
  43841. */
  43842. export interface IMultiRenderTargetOptions {
  43843. /**
  43844. * Define if the texture needs to create mip maps after render.
  43845. */
  43846. generateMipMaps?: boolean;
  43847. /**
  43848. * Define the types of all the draw buffers we want to create
  43849. */
  43850. types?: number[];
  43851. /**
  43852. * Define the sampling modes of all the draw buffers we want to create
  43853. */
  43854. samplingModes?: number[];
  43855. /**
  43856. * Define if a depth buffer is required
  43857. */
  43858. generateDepthBuffer?: boolean;
  43859. /**
  43860. * Define if a stencil buffer is required
  43861. */
  43862. generateStencilBuffer?: boolean;
  43863. /**
  43864. * Define if a depth texture is required instead of a depth buffer
  43865. */
  43866. generateDepthTexture?: boolean;
  43867. /**
  43868. * Define the number of desired draw buffers
  43869. */
  43870. textureCount?: number;
  43871. /**
  43872. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43873. */
  43874. doNotChangeAspectRatio?: boolean;
  43875. /**
  43876. * Define the default type of the buffers we are creating
  43877. */
  43878. defaultType?: number;
  43879. }
  43880. /**
  43881. * A multi render target, like a render target provides the ability to render to a texture.
  43882. * Unlike the render target, it can render to several draw buffers in one draw.
  43883. * This is specially interesting in deferred rendering or for any effects requiring more than
  43884. * just one color from a single pass.
  43885. */
  43886. export class MultiRenderTarget extends RenderTargetTexture {
  43887. private _internalTextures;
  43888. private _textures;
  43889. private _multiRenderTargetOptions;
  43890. /**
  43891. * Get if draw buffers are currently supported by the used hardware and browser.
  43892. */
  43893. readonly isSupported: boolean;
  43894. /**
  43895. * Get the list of textures generated by the multi render target.
  43896. */
  43897. readonly textures: Texture[];
  43898. /**
  43899. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43900. */
  43901. readonly depthTexture: Texture;
  43902. /**
  43903. * Set the wrapping mode on U of all the textures we are rendering to.
  43904. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43905. */
  43906. wrapU: number;
  43907. /**
  43908. * Set the wrapping mode on V of all the textures we are rendering to.
  43909. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43910. */
  43911. wrapV: number;
  43912. /**
  43913. * Instantiate a new multi render target texture.
  43914. * A multi render target, like a render target provides the ability to render to a texture.
  43915. * Unlike the render target, it can render to several draw buffers in one draw.
  43916. * This is specially interesting in deferred rendering or for any effects requiring more than
  43917. * just one color from a single pass.
  43918. * @param name Define the name of the texture
  43919. * @param size Define the size of the buffers to render to
  43920. * @param count Define the number of target we are rendering into
  43921. * @param scene Define the scene the texture belongs to
  43922. * @param options Define the options used to create the multi render target
  43923. */
  43924. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43925. /** @hidden */
  43926. _rebuild(): void;
  43927. private _createInternalTextures;
  43928. private _createTextures;
  43929. /**
  43930. * Define the number of samples used if MSAA is enabled.
  43931. */
  43932. samples: number;
  43933. /**
  43934. * Resize all the textures in the multi render target.
  43935. * Be carrefull as it will recreate all the data in the new texture.
  43936. * @param size Define the new size
  43937. */
  43938. resize(size: any): void;
  43939. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43940. /**
  43941. * Dispose the render targets and their associated resources
  43942. */
  43943. dispose(): void;
  43944. /**
  43945. * Release all the underlying texture used as draw buffers.
  43946. */
  43947. releaseInternalTextures(): void;
  43948. }
  43949. }
  43950. declare module BABYLON {
  43951. interface BaseEngine {
  43952. /**
  43953. * Unbind a list of render target textures from the webGL context
  43954. * This is used only when drawBuffer extension or webGL2 are active
  43955. * @param textures defines the render target textures to unbind
  43956. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43957. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43958. */
  43959. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43960. /**
  43961. * Create a multi render target texture
  43962. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43963. * @param size defines the size of the texture
  43964. * @param options defines the creation options
  43965. * @returns the cube texture as an InternalTexture
  43966. */
  43967. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43968. /**
  43969. * Update the sample count for a given multiple render target texture
  43970. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43971. * @param textures defines the textures to update
  43972. * @param samples defines the sample count to set
  43973. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43974. */
  43975. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43976. }
  43977. }
  43978. declare module BABYLON {
  43979. /** @hidden */
  43980. export var rgbdEncodePixelShader: {
  43981. name: string;
  43982. shader: string;
  43983. };
  43984. }
  43985. declare module BABYLON {
  43986. /** @hidden */
  43987. export var rgbdDecodePixelShader: {
  43988. name: string;
  43989. shader: string;
  43990. };
  43991. }
  43992. declare module BABYLON {
  43993. /**
  43994. * Raw texture data and descriptor sufficient for WebGL texture upload
  43995. */
  43996. export interface EnvironmentTextureInfo {
  43997. /**
  43998. * Version of the environment map
  43999. */
  44000. version: number;
  44001. /**
  44002. * Width of image
  44003. */
  44004. width: number;
  44005. /**
  44006. * Irradiance information stored in the file.
  44007. */
  44008. irradiance: any;
  44009. /**
  44010. * Specular information stored in the file.
  44011. */
  44012. specular: any;
  44013. }
  44014. /**
  44015. * Defines One Image in the file. It requires only the position in the file
  44016. * as well as the length.
  44017. */
  44018. interface BufferImageData {
  44019. /**
  44020. * Length of the image data.
  44021. */
  44022. length: number;
  44023. /**
  44024. * Position of the data from the null terminator delimiting the end of the JSON.
  44025. */
  44026. position: number;
  44027. }
  44028. /**
  44029. * Defines the specular data enclosed in the file.
  44030. * This corresponds to the version 1 of the data.
  44031. */
  44032. export interface EnvironmentTextureSpecularInfoV1 {
  44033. /**
  44034. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44035. */
  44036. specularDataPosition?: number;
  44037. /**
  44038. * This contains all the images data needed to reconstruct the cubemap.
  44039. */
  44040. mipmaps: Array<BufferImageData>;
  44041. /**
  44042. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44043. */
  44044. lodGenerationScale: number;
  44045. }
  44046. /**
  44047. * Sets of helpers addressing the serialization and deserialization of environment texture
  44048. * stored in a BabylonJS env file.
  44049. * Those files are usually stored as .env files.
  44050. */
  44051. export class EnvironmentTextureTools {
  44052. /**
  44053. * Magic number identifying the env file.
  44054. */
  44055. private static _MagicBytes;
  44056. /**
  44057. * Gets the environment info from an env file.
  44058. * @param data The array buffer containing the .env bytes.
  44059. * @returns the environment file info (the json header) if successfully parsed.
  44060. */
  44061. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44062. /**
  44063. * Creates an environment texture from a loaded cube texture.
  44064. * @param texture defines the cube texture to convert in env file
  44065. * @return a promise containing the environment data if succesfull.
  44066. */
  44067. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44068. /**
  44069. * Creates a JSON representation of the spherical data.
  44070. * @param texture defines the texture containing the polynomials
  44071. * @return the JSON representation of the spherical info
  44072. */
  44073. private static _CreateEnvTextureIrradiance;
  44074. /**
  44075. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44076. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44077. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44078. * @return the views described by info providing access to the underlying buffer
  44079. */
  44080. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44081. /**
  44082. * Uploads the texture info contained in the env file to the GPU.
  44083. * @param texture defines the internal texture to upload to
  44084. * @param arrayBuffer defines the buffer cotaining the data to load
  44085. * @param info defines the texture info retrieved through the GetEnvInfo method
  44086. * @returns a promise
  44087. */
  44088. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44089. /**
  44090. * Uploads the levels of image data to the GPU.
  44091. * @param texture defines the internal texture to upload to
  44092. * @param imageData defines the array buffer views of image data [mipmap][face]
  44093. * @returns a promise
  44094. */
  44095. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44096. /**
  44097. * Uploads spherical polynomials information to the texture.
  44098. * @param texture defines the texture we are trying to upload the information to
  44099. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44100. */
  44101. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44102. /** @hidden */
  44103. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44104. }
  44105. }
  44106. declare module BABYLON {
  44107. /**
  44108. * Contains position and normal vectors for a vertex
  44109. */
  44110. export class PositionNormalVertex {
  44111. /** the position of the vertex (defaut: 0,0,0) */
  44112. position: Vector3;
  44113. /** the normal of the vertex (defaut: 0,1,0) */
  44114. normal: Vector3;
  44115. /**
  44116. * Creates a PositionNormalVertex
  44117. * @param position the position of the vertex (defaut: 0,0,0)
  44118. * @param normal the normal of the vertex (defaut: 0,1,0)
  44119. */
  44120. constructor(
  44121. /** the position of the vertex (defaut: 0,0,0) */
  44122. position?: Vector3,
  44123. /** the normal of the vertex (defaut: 0,1,0) */
  44124. normal?: Vector3);
  44125. /**
  44126. * Clones the PositionNormalVertex
  44127. * @returns the cloned PositionNormalVertex
  44128. */
  44129. clone(): PositionNormalVertex;
  44130. }
  44131. /**
  44132. * Contains position, normal and uv vectors for a vertex
  44133. */
  44134. export class PositionNormalTextureVertex {
  44135. /** the position of the vertex (defaut: 0,0,0) */
  44136. position: Vector3;
  44137. /** the normal of the vertex (defaut: 0,1,0) */
  44138. normal: Vector3;
  44139. /** the uv of the vertex (default: 0,0) */
  44140. uv: Vector2;
  44141. /**
  44142. * Creates a PositionNormalTextureVertex
  44143. * @param position the position of the vertex (defaut: 0,0,0)
  44144. * @param normal the normal of the vertex (defaut: 0,1,0)
  44145. * @param uv the uv of the vertex (default: 0,0)
  44146. */
  44147. constructor(
  44148. /** the position of the vertex (defaut: 0,0,0) */
  44149. position?: Vector3,
  44150. /** the normal of the vertex (defaut: 0,1,0) */
  44151. normal?: Vector3,
  44152. /** the uv of the vertex (default: 0,0) */
  44153. uv?: Vector2);
  44154. /**
  44155. * Clones the PositionNormalTextureVertex
  44156. * @returns the cloned PositionNormalTextureVertex
  44157. */
  44158. clone(): PositionNormalTextureVertex;
  44159. }
  44160. }
  44161. declare module BABYLON {
  44162. /** @hidden */
  44163. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44164. private _genericAttributeLocation;
  44165. private _varyingLocationCount;
  44166. private _varyingLocationMap;
  44167. private _replacements;
  44168. private _textureCount;
  44169. private _uniforms;
  44170. lineProcessor(line: string): string;
  44171. attributeProcessor(attribute: string): string;
  44172. varyingProcessor(varying: string, isFragment: boolean): string;
  44173. uniformProcessor(uniform: string): string;
  44174. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44175. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44176. }
  44177. }
  44178. declare module BABYLON {
  44179. /**
  44180. * Container for accessors for natively-stored mesh data buffers.
  44181. */
  44182. class NativeDataBuffer extends DataBuffer {
  44183. /**
  44184. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44185. */
  44186. nativeIndexBuffer?: any;
  44187. /**
  44188. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44189. */
  44190. nativeVertexBuffer?: any;
  44191. }
  44192. /** @hidden */
  44193. export class NativeEngine extends Engine {
  44194. private readonly _native;
  44195. getHardwareScalingLevel(): number;
  44196. constructor();
  44197. /**
  44198. * Can be used to override the current requestAnimationFrame requester.
  44199. * @hidden
  44200. */
  44201. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44202. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44203. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44204. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44205. recordVertexArrayObject(vertexBuffers: {
  44206. [key: string]: VertexBuffer;
  44207. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44208. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44209. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44210. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44211. /**
  44212. * Draw a list of indexed primitives
  44213. * @param fillMode defines the primitive to use
  44214. * @param indexStart defines the starting index
  44215. * @param indexCount defines the number of index to draw
  44216. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44217. */
  44218. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44219. /**
  44220. * Draw a list of unindexed primitives
  44221. * @param fillMode defines the primitive to use
  44222. * @param verticesStart defines the index of first vertex to draw
  44223. * @param verticesCount defines the count of vertices to draw
  44224. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44225. */
  44226. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44227. createPipelineContext(): IPipelineContext;
  44228. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44229. /** @hidden */
  44230. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44231. /** @hidden */
  44232. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44233. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44234. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44235. protected _setProgram(program: WebGLProgram): void;
  44236. _releaseEffect(effect: Effect): void;
  44237. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44238. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44239. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44240. bindSamplers(effect: Effect): void;
  44241. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44242. getRenderWidth(useScreen?: boolean): number;
  44243. getRenderHeight(useScreen?: boolean): number;
  44244. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44245. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44246. /**
  44247. * Set the z offset to apply to current rendering
  44248. * @param value defines the offset to apply
  44249. */
  44250. setZOffset(value: number): void;
  44251. /**
  44252. * Gets the current value of the zOffset
  44253. * @returns the current zOffset state
  44254. */
  44255. getZOffset(): number;
  44256. /**
  44257. * Enable or disable depth buffering
  44258. * @param enable defines the state to set
  44259. */
  44260. setDepthBuffer(enable: boolean): void;
  44261. /**
  44262. * Gets a boolean indicating if depth writing is enabled
  44263. * @returns the current depth writing state
  44264. */
  44265. getDepthWrite(): boolean;
  44266. /**
  44267. * Enable or disable depth writing
  44268. * @param enable defines the state to set
  44269. */
  44270. setDepthWrite(enable: boolean): void;
  44271. /**
  44272. * Enable or disable color writing
  44273. * @param enable defines the state to set
  44274. */
  44275. setColorWrite(enable: boolean): void;
  44276. /**
  44277. * Gets a boolean indicating if color writing is enabled
  44278. * @returns the current color writing state
  44279. */
  44280. getColorWrite(): boolean;
  44281. /**
  44282. * Sets alpha constants used by some alpha blending modes
  44283. * @param r defines the red component
  44284. * @param g defines the green component
  44285. * @param b defines the blue component
  44286. * @param a defines the alpha component
  44287. */
  44288. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44289. /**
  44290. * Sets the current alpha mode
  44291. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44292. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44293. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44294. */
  44295. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44296. /**
  44297. * Gets the current alpha mode
  44298. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44299. * @returns the current alpha mode
  44300. */
  44301. getAlphaMode(): number;
  44302. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44303. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44304. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44305. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44306. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44307. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44308. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44309. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44310. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44311. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44312. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44313. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44314. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44315. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44316. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44317. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44318. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44319. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44320. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44321. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44322. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44323. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44324. wipeCaches(bruteForce?: boolean): void;
  44325. _createTexture(): WebGLTexture;
  44326. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44327. /**
  44328. * Usually called from BABYLON.Texture.ts.
  44329. * Passed information to create a WebGLTexture
  44330. * @param urlArg defines a value which contains one of the following:
  44331. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44332. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44333. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44334. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44335. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44336. * @param scene needed for loading to the correct scene
  44337. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44338. * @param onLoad optional callback to be called upon successful completion
  44339. * @param onError optional callback to be called upon failure
  44340. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44341. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44342. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44343. * @param forcedExtension defines the extension to use to pick the right loader
  44344. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44345. */
  44346. 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;
  44347. /**
  44348. * Creates a cube texture
  44349. * @param rootUrl defines the url where the files to load is located
  44350. * @param scene defines the current scene
  44351. * @param files defines the list of files to load (1 per face)
  44352. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44353. * @param onLoad defines an optional callback raised when the texture is loaded
  44354. * @param onError defines an optional callback raised if there is an issue to load the texture
  44355. * @param format defines the format of the data
  44356. * @param forcedExtension defines the extension to use to pick the right loader
  44357. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44358. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44359. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44360. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44361. * @returns the cube texture as an InternalTexture
  44362. */
  44363. 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;
  44364. private _getSamplingFilter;
  44365. private static _GetNativeTextureFormat;
  44366. createRenderTargetTexture(size: number | {
  44367. width: number;
  44368. height: number;
  44369. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44370. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44371. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44372. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44373. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44374. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44375. /**
  44376. * Updates a dynamic vertex buffer.
  44377. * @param vertexBuffer the vertex buffer to update
  44378. * @param data the data used to update the vertex buffer
  44379. * @param byteOffset the byte offset of the data (optional)
  44380. * @param byteLength the byte length of the data (optional)
  44381. */
  44382. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44383. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44384. private _updateAnisotropicLevel;
  44385. private _getAddressMode;
  44386. /** @hidden */
  44387. _bindTexture(channel: number, texture: InternalTexture): void;
  44388. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44389. releaseEffects(): void;
  44390. /** @hidden */
  44391. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44392. /** @hidden */
  44393. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44394. /** @hidden */
  44395. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44396. /** @hidden */
  44397. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44398. }
  44399. }
  44400. declare module BABYLON {
  44401. /**
  44402. * Gather the list of clipboard event types as constants.
  44403. */
  44404. export class ClipboardEventTypes {
  44405. /**
  44406. * The clipboard event is fired when a copy command is active (pressed).
  44407. */
  44408. static readonly COPY: number;
  44409. /**
  44410. * The clipboard event is fired when a cut command is active (pressed).
  44411. */
  44412. static readonly CUT: number;
  44413. /**
  44414. * The clipboard event is fired when a paste command is active (pressed).
  44415. */
  44416. static readonly PASTE: number;
  44417. }
  44418. /**
  44419. * This class is used to store clipboard related info for the onClipboardObservable event.
  44420. */
  44421. export class ClipboardInfo {
  44422. /**
  44423. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44424. */
  44425. type: number;
  44426. /**
  44427. * Defines the related dom event
  44428. */
  44429. event: ClipboardEvent;
  44430. /**
  44431. *Creates an instance of ClipboardInfo.
  44432. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44433. * @param event Defines the related dom event
  44434. */
  44435. constructor(
  44436. /**
  44437. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44438. */
  44439. type: number,
  44440. /**
  44441. * Defines the related dom event
  44442. */
  44443. event: ClipboardEvent);
  44444. /**
  44445. * Get the clipboard event's type from the keycode.
  44446. * @param keyCode Defines the keyCode for the current keyboard event.
  44447. * @return {number}
  44448. */
  44449. static GetTypeFromCharacter(keyCode: number): number;
  44450. }
  44451. }
  44452. declare module BABYLON {
  44453. /**
  44454. * Google Daydream controller
  44455. */
  44456. export class DaydreamController extends WebVRController {
  44457. /**
  44458. * Base Url for the controller model.
  44459. */
  44460. static MODEL_BASE_URL: string;
  44461. /**
  44462. * File name for the controller model.
  44463. */
  44464. static MODEL_FILENAME: string;
  44465. /**
  44466. * Gamepad Id prefix used to identify Daydream Controller.
  44467. */
  44468. static readonly GAMEPAD_ID_PREFIX: string;
  44469. /**
  44470. * Creates a new DaydreamController from a gamepad
  44471. * @param vrGamepad the gamepad that the controller should be created from
  44472. */
  44473. constructor(vrGamepad: any);
  44474. /**
  44475. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44476. * @param scene scene in which to add meshes
  44477. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44478. */
  44479. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44480. /**
  44481. * Called once for each button that changed state since the last frame
  44482. * @param buttonIdx Which button index changed
  44483. * @param state New state of the button
  44484. * @param changes Which properties on the state changed since last frame
  44485. */
  44486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44487. }
  44488. }
  44489. declare module BABYLON {
  44490. /**
  44491. * Gear VR Controller
  44492. */
  44493. export class GearVRController extends WebVRController {
  44494. /**
  44495. * Base Url for the controller model.
  44496. */
  44497. static MODEL_BASE_URL: string;
  44498. /**
  44499. * File name for the controller model.
  44500. */
  44501. static MODEL_FILENAME: string;
  44502. /**
  44503. * Gamepad Id prefix used to identify this controller.
  44504. */
  44505. static readonly GAMEPAD_ID_PREFIX: string;
  44506. private readonly _buttonIndexToObservableNameMap;
  44507. /**
  44508. * Creates a new GearVRController from a gamepad
  44509. * @param vrGamepad the gamepad that the controller should be created from
  44510. */
  44511. constructor(vrGamepad: any);
  44512. /**
  44513. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44514. * @param scene scene in which to add meshes
  44515. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44516. */
  44517. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44518. /**
  44519. * Called once for each button that changed state since the last frame
  44520. * @param buttonIdx Which button index changed
  44521. * @param state New state of the button
  44522. * @param changes Which properties on the state changed since last frame
  44523. */
  44524. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44525. }
  44526. }
  44527. declare module BABYLON {
  44528. /**
  44529. * Class containing static functions to help procedurally build meshes
  44530. */
  44531. export class PolyhedronBuilder {
  44532. /**
  44533. * Creates a polyhedron mesh
  44534. * * 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
  44535. * * The parameter `size` (positive float, default 1) sets the polygon size
  44536. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44537. * * 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`
  44538. * * 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
  44539. * * 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)`)
  44540. * * 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
  44541. * * 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
  44542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44543. * * 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
  44544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44545. * @param name defines the name of the mesh
  44546. * @param options defines the options used to create the mesh
  44547. * @param scene defines the hosting scene
  44548. * @returns the polyhedron mesh
  44549. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44550. */
  44551. static CreatePolyhedron(name: string, options: {
  44552. type?: number;
  44553. size?: number;
  44554. sizeX?: number;
  44555. sizeY?: number;
  44556. sizeZ?: number;
  44557. custom?: any;
  44558. faceUV?: Vector4[];
  44559. faceColors?: Color4[];
  44560. flat?: boolean;
  44561. updatable?: boolean;
  44562. sideOrientation?: number;
  44563. frontUVs?: Vector4;
  44564. backUVs?: Vector4;
  44565. }, scene?: Nullable<Scene>): Mesh;
  44566. }
  44567. }
  44568. declare module BABYLON {
  44569. /**
  44570. * Gizmo that enables scaling a mesh along 3 axis
  44571. */
  44572. export class ScaleGizmo extends Gizmo {
  44573. /**
  44574. * Internal gizmo used for interactions on the x axis
  44575. */
  44576. xGizmo: AxisScaleGizmo;
  44577. /**
  44578. * Internal gizmo used for interactions on the y axis
  44579. */
  44580. yGizmo: AxisScaleGizmo;
  44581. /**
  44582. * Internal gizmo used for interactions on the z axis
  44583. */
  44584. zGizmo: AxisScaleGizmo;
  44585. /**
  44586. * Internal gizmo used to scale all axis equally
  44587. */
  44588. uniformScaleGizmo: AxisScaleGizmo;
  44589. private _meshAttached;
  44590. private _updateGizmoRotationToMatchAttachedMesh;
  44591. private _snapDistance;
  44592. private _scaleRatio;
  44593. private _uniformScalingMesh;
  44594. private _octahedron;
  44595. /** Fires an event when any of it's sub gizmos are dragged */
  44596. onDragStartObservable: Observable<unknown>;
  44597. /** Fires an event when any of it's sub gizmos are released from dragging */
  44598. onDragEndObservable: Observable<unknown>;
  44599. attachedMesh: Nullable<AbstractMesh>;
  44600. /**
  44601. * Creates a ScaleGizmo
  44602. * @param gizmoLayer The utility layer the gizmo will be added to
  44603. */
  44604. constructor(gizmoLayer?: UtilityLayerRenderer);
  44605. updateGizmoRotationToMatchAttachedMesh: boolean;
  44606. /**
  44607. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44608. */
  44609. snapDistance: number;
  44610. /**
  44611. * Ratio for the scale of the gizmo (Default: 1)
  44612. */
  44613. scaleRatio: number;
  44614. /**
  44615. * Disposes of the gizmo
  44616. */
  44617. dispose(): void;
  44618. }
  44619. }
  44620. declare module BABYLON {
  44621. /**
  44622. * Single axis scale gizmo
  44623. */
  44624. export class AxisScaleGizmo extends Gizmo {
  44625. /**
  44626. * Drag behavior responsible for the gizmos dragging interactions
  44627. */
  44628. dragBehavior: PointerDragBehavior;
  44629. private _pointerObserver;
  44630. /**
  44631. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44632. */
  44633. snapDistance: number;
  44634. /**
  44635. * Event that fires each time the gizmo snaps to a new location.
  44636. * * snapDistance is the the change in distance
  44637. */
  44638. onSnapObservable: Observable<{
  44639. snapDistance: number;
  44640. }>;
  44641. /**
  44642. * If the scaling operation should be done on all axis (default: false)
  44643. */
  44644. uniformScaling: boolean;
  44645. private _isEnabled;
  44646. private _parent;
  44647. private _arrow;
  44648. private _coloredMaterial;
  44649. private _hoverMaterial;
  44650. /**
  44651. * Creates an AxisScaleGizmo
  44652. * @param gizmoLayer The utility layer the gizmo will be added to
  44653. * @param dragAxis The axis which the gizmo will be able to scale on
  44654. * @param color The color of the gizmo
  44655. */
  44656. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44657. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44658. /**
  44659. * If the gizmo is enabled
  44660. */
  44661. isEnabled: boolean;
  44662. /**
  44663. * Disposes of the gizmo
  44664. */
  44665. dispose(): void;
  44666. /**
  44667. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44668. * @param mesh The mesh to replace the default mesh of the gizmo
  44669. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44670. */
  44671. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44672. }
  44673. }
  44674. declare module BABYLON {
  44675. /**
  44676. * Bounding box gizmo
  44677. */
  44678. export class BoundingBoxGizmo extends Gizmo {
  44679. private _lineBoundingBox;
  44680. private _rotateSpheresParent;
  44681. private _scaleBoxesParent;
  44682. private _boundingDimensions;
  44683. private _renderObserver;
  44684. private _pointerObserver;
  44685. private _scaleDragSpeed;
  44686. private _tmpQuaternion;
  44687. private _tmpVector;
  44688. private _tmpRotationMatrix;
  44689. /**
  44690. * 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)
  44691. */
  44692. ignoreChildren: boolean;
  44693. /**
  44694. * 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)
  44695. */
  44696. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44697. /**
  44698. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44699. */
  44700. rotationSphereSize: number;
  44701. /**
  44702. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44703. */
  44704. scaleBoxSize: number;
  44705. /**
  44706. * 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)
  44707. */
  44708. fixedDragMeshScreenSize: boolean;
  44709. /**
  44710. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44711. */
  44712. fixedDragMeshScreenSizeDistanceFactor: number;
  44713. /**
  44714. * Fired when a rotation sphere or scale box is dragged
  44715. */
  44716. onDragStartObservable: Observable<{}>;
  44717. /**
  44718. * Fired when a scale box is dragged
  44719. */
  44720. onScaleBoxDragObservable: Observable<{}>;
  44721. /**
  44722. * Fired when a scale box drag is ended
  44723. */
  44724. onScaleBoxDragEndObservable: Observable<{}>;
  44725. /**
  44726. * Fired when a rotation sphere is dragged
  44727. */
  44728. onRotationSphereDragObservable: Observable<{}>;
  44729. /**
  44730. * Fired when a rotation sphere drag is ended
  44731. */
  44732. onRotationSphereDragEndObservable: Observable<{}>;
  44733. /**
  44734. * 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)
  44735. */
  44736. scalePivot: Nullable<Vector3>;
  44737. /**
  44738. * Mesh used as a pivot to rotate the attached mesh
  44739. */
  44740. private _anchorMesh;
  44741. private _existingMeshScale;
  44742. private _dragMesh;
  44743. private pointerDragBehavior;
  44744. private coloredMaterial;
  44745. private hoverColoredMaterial;
  44746. /**
  44747. * Sets the color of the bounding box gizmo
  44748. * @param color the color to set
  44749. */
  44750. setColor(color: Color3): void;
  44751. /**
  44752. * Creates an BoundingBoxGizmo
  44753. * @param gizmoLayer The utility layer the gizmo will be added to
  44754. * @param color The color of the gizmo
  44755. */
  44756. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44757. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44758. private _selectNode;
  44759. /**
  44760. * Updates the bounding box information for the Gizmo
  44761. */
  44762. updateBoundingBox(): void;
  44763. private _updateRotationSpheres;
  44764. private _updateScaleBoxes;
  44765. /**
  44766. * Enables rotation on the specified axis and disables rotation on the others
  44767. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44768. */
  44769. setEnabledRotationAxis(axis: string): void;
  44770. /**
  44771. * Enables/disables scaling
  44772. * @param enable if scaling should be enabled
  44773. */
  44774. setEnabledScaling(enable: boolean): void;
  44775. private _updateDummy;
  44776. /**
  44777. * Enables a pointer drag behavior on the bounding box of the gizmo
  44778. */
  44779. enableDragBehavior(): void;
  44780. /**
  44781. * Disposes of the gizmo
  44782. */
  44783. dispose(): void;
  44784. /**
  44785. * 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)
  44786. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44787. * @returns the bounding box mesh with the passed in mesh as a child
  44788. */
  44789. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44790. /**
  44791. * CustomMeshes are not supported by this gizmo
  44792. * @param mesh The mesh to replace the default mesh of the gizmo
  44793. */
  44794. setCustomMesh(mesh: Mesh): void;
  44795. }
  44796. }
  44797. declare module BABYLON {
  44798. /**
  44799. * Single plane rotation gizmo
  44800. */
  44801. export class PlaneRotationGizmo extends Gizmo {
  44802. /**
  44803. * Drag behavior responsible for the gizmos dragging interactions
  44804. */
  44805. dragBehavior: PointerDragBehavior;
  44806. private _pointerObserver;
  44807. /**
  44808. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44809. */
  44810. snapDistance: number;
  44811. /**
  44812. * Event that fires each time the gizmo snaps to a new location.
  44813. * * snapDistance is the the change in distance
  44814. */
  44815. onSnapObservable: Observable<{
  44816. snapDistance: number;
  44817. }>;
  44818. private _isEnabled;
  44819. private _parent;
  44820. /**
  44821. * Creates a PlaneRotationGizmo
  44822. * @param gizmoLayer The utility layer the gizmo will be added to
  44823. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44824. * @param color The color of the gizmo
  44825. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44826. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44827. */
  44828. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44829. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44830. /**
  44831. * If the gizmo is enabled
  44832. */
  44833. isEnabled: boolean;
  44834. /**
  44835. * Disposes of the gizmo
  44836. */
  44837. dispose(): void;
  44838. }
  44839. }
  44840. declare module BABYLON {
  44841. /**
  44842. * Gizmo that enables rotating a mesh along 3 axis
  44843. */
  44844. export class RotationGizmo extends Gizmo {
  44845. /**
  44846. * Internal gizmo used for interactions on the x axis
  44847. */
  44848. xGizmo: PlaneRotationGizmo;
  44849. /**
  44850. * Internal gizmo used for interactions on the y axis
  44851. */
  44852. yGizmo: PlaneRotationGizmo;
  44853. /**
  44854. * Internal gizmo used for interactions on the z axis
  44855. */
  44856. zGizmo: PlaneRotationGizmo;
  44857. /** Fires an event when any of it's sub gizmos are dragged */
  44858. onDragStartObservable: Observable<unknown>;
  44859. /** Fires an event when any of it's sub gizmos are released from dragging */
  44860. onDragEndObservable: Observable<unknown>;
  44861. private _meshAttached;
  44862. attachedMesh: Nullable<AbstractMesh>;
  44863. /**
  44864. * Creates a RotationGizmo
  44865. * @param gizmoLayer The utility layer the gizmo will be added to
  44866. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44867. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44868. */
  44869. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44870. updateGizmoRotationToMatchAttachedMesh: boolean;
  44871. /**
  44872. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44873. */
  44874. snapDistance: number;
  44875. /**
  44876. * Ratio for the scale of the gizmo (Default: 1)
  44877. */
  44878. scaleRatio: number;
  44879. /**
  44880. * Disposes of the gizmo
  44881. */
  44882. dispose(): void;
  44883. /**
  44884. * CustomMeshes are not supported by this gizmo
  44885. * @param mesh The mesh to replace the default mesh of the gizmo
  44886. */
  44887. setCustomMesh(mesh: Mesh): void;
  44888. }
  44889. }
  44890. declare module BABYLON {
  44891. /**
  44892. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44893. */
  44894. export class GizmoManager implements IDisposable {
  44895. private scene;
  44896. /**
  44897. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44898. */
  44899. gizmos: {
  44900. positionGizmo: Nullable<PositionGizmo>;
  44901. rotationGizmo: Nullable<RotationGizmo>;
  44902. scaleGizmo: Nullable<ScaleGizmo>;
  44903. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44904. };
  44905. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44906. clearGizmoOnEmptyPointerEvent: boolean;
  44907. /** Fires an event when the manager is attached to a mesh */
  44908. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44909. private _gizmosEnabled;
  44910. private _pointerObserver;
  44911. private _attachedMesh;
  44912. private _boundingBoxColor;
  44913. private _defaultUtilityLayer;
  44914. private _defaultKeepDepthUtilityLayer;
  44915. /**
  44916. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44917. */
  44918. boundingBoxDragBehavior: SixDofDragBehavior;
  44919. /**
  44920. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44921. */
  44922. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44923. /**
  44924. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44925. */
  44926. usePointerToAttachGizmos: boolean;
  44927. /**
  44928. * Utility layer that the bounding box gizmo belongs to
  44929. */
  44930. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44931. /**
  44932. * Utility layer that all gizmos besides bounding box belong to
  44933. */
  44934. readonly utilityLayer: UtilityLayerRenderer;
  44935. /**
  44936. * Instatiates a gizmo manager
  44937. * @param scene the scene to overlay the gizmos on top of
  44938. */
  44939. constructor(scene: Scene);
  44940. /**
  44941. * Attaches a set of gizmos to the specified mesh
  44942. * @param mesh The mesh the gizmo's should be attached to
  44943. */
  44944. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44945. /**
  44946. * If the position gizmo is enabled
  44947. */
  44948. positionGizmoEnabled: boolean;
  44949. /**
  44950. * If the rotation gizmo is enabled
  44951. */
  44952. rotationGizmoEnabled: boolean;
  44953. /**
  44954. * If the scale gizmo is enabled
  44955. */
  44956. scaleGizmoEnabled: boolean;
  44957. /**
  44958. * If the boundingBox gizmo is enabled
  44959. */
  44960. boundingBoxGizmoEnabled: boolean;
  44961. /**
  44962. * Disposes of the gizmo manager
  44963. */
  44964. dispose(): void;
  44965. }
  44966. }
  44967. declare module BABYLON {
  44968. /**
  44969. * A directional light is defined by a direction (what a surprise!).
  44970. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44971. * 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.
  44972. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44973. */
  44974. export class DirectionalLight extends ShadowLight {
  44975. private _shadowFrustumSize;
  44976. /**
  44977. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44978. */
  44979. /**
  44980. * Specifies a fix frustum size for the shadow generation.
  44981. */
  44982. shadowFrustumSize: number;
  44983. private _shadowOrthoScale;
  44984. /**
  44985. * Gets the shadow projection scale against the optimal computed one.
  44986. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44987. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44988. */
  44989. /**
  44990. * Sets the shadow projection scale against the optimal computed one.
  44991. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44992. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44993. */
  44994. shadowOrthoScale: number;
  44995. /**
  44996. * Automatically compute the projection matrix to best fit (including all the casters)
  44997. * on each frame.
  44998. */
  44999. autoUpdateExtends: boolean;
  45000. private _orthoLeft;
  45001. private _orthoRight;
  45002. private _orthoTop;
  45003. private _orthoBottom;
  45004. /**
  45005. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45006. * The directional light is emitted from everywhere in the given direction.
  45007. * It can cast shadows.
  45008. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45009. * @param name The friendly name of the light
  45010. * @param direction The direction of the light
  45011. * @param scene The scene the light belongs to
  45012. */
  45013. constructor(name: string, direction: Vector3, scene: Scene);
  45014. /**
  45015. * Returns the string "DirectionalLight".
  45016. * @return The class name
  45017. */
  45018. getClassName(): string;
  45019. /**
  45020. * Returns the integer 1.
  45021. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45022. */
  45023. getTypeID(): number;
  45024. /**
  45025. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45026. * Returns the DirectionalLight Shadow projection matrix.
  45027. */
  45028. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45029. /**
  45030. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45031. * Returns the DirectionalLight Shadow projection matrix.
  45032. */
  45033. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45034. /**
  45035. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45036. * Returns the DirectionalLight Shadow projection matrix.
  45037. */
  45038. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45039. protected _buildUniformLayout(): void;
  45040. /**
  45041. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45042. * @param effect The effect to update
  45043. * @param lightIndex The index of the light in the effect to update
  45044. * @returns The directional light
  45045. */
  45046. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45047. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45048. /**
  45049. * Gets the minZ used for shadow according to both the scene and the light.
  45050. *
  45051. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45052. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45053. * @param activeCamera The camera we are returning the min for
  45054. * @returns the depth min z
  45055. */
  45056. getDepthMinZ(activeCamera: Camera): number;
  45057. /**
  45058. * Gets the maxZ used for shadow according to both the scene and the light.
  45059. *
  45060. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45061. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45062. * @param activeCamera The camera we are returning the max for
  45063. * @returns the depth max z
  45064. */
  45065. getDepthMaxZ(activeCamera: Camera): number;
  45066. /**
  45067. * Prepares the list of defines specific to the light type.
  45068. * @param defines the list of defines
  45069. * @param lightIndex defines the index of the light for the effect
  45070. */
  45071. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45072. }
  45073. }
  45074. declare module BABYLON {
  45075. /**
  45076. * Class containing static functions to help procedurally build meshes
  45077. */
  45078. export class HemisphereBuilder {
  45079. /**
  45080. * Creates a hemisphere mesh
  45081. * @param name defines the name of the mesh
  45082. * @param options defines the options used to create the mesh
  45083. * @param scene defines the hosting scene
  45084. * @returns the hemisphere mesh
  45085. */
  45086. static CreateHemisphere(name: string, options: {
  45087. segments?: number;
  45088. diameter?: number;
  45089. sideOrientation?: number;
  45090. }, scene: any): Mesh;
  45091. }
  45092. }
  45093. declare module BABYLON {
  45094. /**
  45095. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45096. * These values define a cone of light starting from the position, emitting toward the direction.
  45097. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45098. * and the exponent defines the speed of the decay of the light with distance (reach).
  45099. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45100. */
  45101. export class SpotLight extends ShadowLight {
  45102. private _angle;
  45103. private _innerAngle;
  45104. private _cosHalfAngle;
  45105. private _lightAngleScale;
  45106. private _lightAngleOffset;
  45107. /**
  45108. * Gets the cone angle of the spot light in Radians.
  45109. */
  45110. /**
  45111. * Sets the cone angle of the spot light in Radians.
  45112. */
  45113. angle: number;
  45114. /**
  45115. * Only used in gltf falloff mode, this defines the angle where
  45116. * the directional falloff will start before cutting at angle which could be seen
  45117. * as outer angle.
  45118. */
  45119. /**
  45120. * Only used in gltf falloff mode, this defines the angle where
  45121. * the directional falloff will start before cutting at angle which could be seen
  45122. * as outer angle.
  45123. */
  45124. innerAngle: number;
  45125. private _shadowAngleScale;
  45126. /**
  45127. * Allows scaling the angle of the light for shadow generation only.
  45128. */
  45129. /**
  45130. * Allows scaling the angle of the light for shadow generation only.
  45131. */
  45132. shadowAngleScale: number;
  45133. /**
  45134. * The light decay speed with the distance from the emission spot.
  45135. */
  45136. exponent: number;
  45137. private _projectionTextureMatrix;
  45138. /**
  45139. * Allows reading the projecton texture
  45140. */
  45141. readonly projectionTextureMatrix: Matrix;
  45142. protected _projectionTextureLightNear: number;
  45143. /**
  45144. * Gets the near clip of the Spotlight for texture projection.
  45145. */
  45146. /**
  45147. * Sets the near clip of the Spotlight for texture projection.
  45148. */
  45149. projectionTextureLightNear: number;
  45150. protected _projectionTextureLightFar: number;
  45151. /**
  45152. * Gets the far clip of the Spotlight for texture projection.
  45153. */
  45154. /**
  45155. * Sets the far clip of the Spotlight for texture projection.
  45156. */
  45157. projectionTextureLightFar: number;
  45158. protected _projectionTextureUpDirection: Vector3;
  45159. /**
  45160. * Gets the Up vector of the Spotlight for texture projection.
  45161. */
  45162. /**
  45163. * Sets the Up vector of the Spotlight for texture projection.
  45164. */
  45165. projectionTextureUpDirection: Vector3;
  45166. private _projectionTexture;
  45167. /**
  45168. * Gets the projection texture of the light.
  45169. */
  45170. /**
  45171. * Sets the projection texture of the light.
  45172. */
  45173. projectionTexture: Nullable<BaseTexture>;
  45174. private _projectionTextureViewLightDirty;
  45175. private _projectionTextureProjectionLightDirty;
  45176. private _projectionTextureDirty;
  45177. private _projectionTextureViewTargetVector;
  45178. private _projectionTextureViewLightMatrix;
  45179. private _projectionTextureProjectionLightMatrix;
  45180. private _projectionTextureScalingMatrix;
  45181. /**
  45182. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45183. * It can cast shadows.
  45184. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45185. * @param name The light friendly name
  45186. * @param position The position of the spot light in the scene
  45187. * @param direction The direction of the light in the scene
  45188. * @param angle The cone angle of the light in Radians
  45189. * @param exponent The light decay speed with the distance from the emission spot
  45190. * @param scene The scene the lights belongs to
  45191. */
  45192. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45193. /**
  45194. * Returns the string "SpotLight".
  45195. * @returns the class name
  45196. */
  45197. getClassName(): string;
  45198. /**
  45199. * Returns the integer 2.
  45200. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45201. */
  45202. getTypeID(): number;
  45203. /**
  45204. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45205. */
  45206. protected _setDirection(value: Vector3): void;
  45207. /**
  45208. * Overrides the position setter to recompute the projection texture view light Matrix.
  45209. */
  45210. protected _setPosition(value: Vector3): void;
  45211. /**
  45212. * 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.
  45213. * Returns the SpotLight.
  45214. */
  45215. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45216. protected _computeProjectionTextureViewLightMatrix(): void;
  45217. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45218. /**
  45219. * Main function for light texture projection matrix computing.
  45220. */
  45221. protected _computeProjectionTextureMatrix(): void;
  45222. protected _buildUniformLayout(): void;
  45223. private _computeAngleValues;
  45224. /**
  45225. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45226. * @param effect The effect to update
  45227. * @param lightIndex The index of the light in the effect to update
  45228. * @returns The spot light
  45229. */
  45230. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45231. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45232. /**
  45233. * Disposes the light and the associated resources.
  45234. */
  45235. dispose(): void;
  45236. /**
  45237. * Prepares the list of defines specific to the light type.
  45238. * @param defines the list of defines
  45239. * @param lightIndex defines the index of the light for the effect
  45240. */
  45241. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45242. }
  45243. }
  45244. declare module BABYLON {
  45245. /**
  45246. * Gizmo that enables viewing a light
  45247. */
  45248. export class LightGizmo extends Gizmo {
  45249. private _lightMesh;
  45250. private _material;
  45251. private cachedPosition;
  45252. private cachedForward;
  45253. /**
  45254. * Creates a LightGizmo
  45255. * @param gizmoLayer The utility layer the gizmo will be added to
  45256. */
  45257. constructor(gizmoLayer?: UtilityLayerRenderer);
  45258. private _light;
  45259. /**
  45260. * The light that the gizmo is attached to
  45261. */
  45262. light: Nullable<Light>;
  45263. /**
  45264. * Gets the material used to render the light gizmo
  45265. */
  45266. readonly material: StandardMaterial;
  45267. /**
  45268. * @hidden
  45269. * Updates the gizmo to match the attached mesh's position/rotation
  45270. */
  45271. protected _update(): void;
  45272. private static _Scale;
  45273. /**
  45274. * Creates the lines for a light mesh
  45275. */
  45276. private static _createLightLines;
  45277. /**
  45278. * Disposes of the light gizmo
  45279. */
  45280. dispose(): void;
  45281. private static _CreateHemisphericLightMesh;
  45282. private static _CreatePointLightMesh;
  45283. private static _CreateSpotLightMesh;
  45284. private static _CreateDirectionalLightMesh;
  45285. }
  45286. }
  45287. declare module BABYLON {
  45288. /** @hidden */
  45289. export var backgroundFragmentDeclaration: {
  45290. name: string;
  45291. shader: string;
  45292. };
  45293. }
  45294. declare module BABYLON {
  45295. /** @hidden */
  45296. export var backgroundUboDeclaration: {
  45297. name: string;
  45298. shader: string;
  45299. };
  45300. }
  45301. declare module BABYLON {
  45302. /** @hidden */
  45303. export var backgroundPixelShader: {
  45304. name: string;
  45305. shader: string;
  45306. };
  45307. }
  45308. declare module BABYLON {
  45309. /** @hidden */
  45310. export var backgroundVertexDeclaration: {
  45311. name: string;
  45312. shader: string;
  45313. };
  45314. }
  45315. declare module BABYLON {
  45316. /** @hidden */
  45317. export var backgroundVertexShader: {
  45318. name: string;
  45319. shader: string;
  45320. };
  45321. }
  45322. declare module BABYLON {
  45323. /**
  45324. * Background material used to create an efficient environement around your scene.
  45325. */
  45326. export class BackgroundMaterial extends PushMaterial {
  45327. /**
  45328. * Standard reflectance value at parallel view angle.
  45329. */
  45330. static StandardReflectance0: number;
  45331. /**
  45332. * Standard reflectance value at grazing angle.
  45333. */
  45334. static StandardReflectance90: number;
  45335. protected _primaryColor: Color3;
  45336. /**
  45337. * Key light Color (multiply against the environement texture)
  45338. */
  45339. primaryColor: Color3;
  45340. protected __perceptualColor: Nullable<Color3>;
  45341. /**
  45342. * Experimental Internal Use Only.
  45343. *
  45344. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45345. * This acts as a helper to set the primary color to a more "human friendly" value.
  45346. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45347. * output color as close as possible from the chosen value.
  45348. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45349. * part of lighting setup.)
  45350. */
  45351. _perceptualColor: Nullable<Color3>;
  45352. protected _primaryColorShadowLevel: float;
  45353. /**
  45354. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45355. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45356. */
  45357. primaryColorShadowLevel: float;
  45358. protected _primaryColorHighlightLevel: float;
  45359. /**
  45360. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45361. * The primary color is used at the level chosen to define what the white area would look.
  45362. */
  45363. primaryColorHighlightLevel: float;
  45364. protected _reflectionTexture: Nullable<BaseTexture>;
  45365. /**
  45366. * Reflection Texture used in the material.
  45367. * Should be author in a specific way for the best result (refer to the documentation).
  45368. */
  45369. reflectionTexture: Nullable<BaseTexture>;
  45370. protected _reflectionBlur: float;
  45371. /**
  45372. * Reflection Texture level of blur.
  45373. *
  45374. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45375. * texture twice.
  45376. */
  45377. reflectionBlur: float;
  45378. protected _diffuseTexture: Nullable<BaseTexture>;
  45379. /**
  45380. * Diffuse Texture used in the material.
  45381. * Should be author in a specific way for the best result (refer to the documentation).
  45382. */
  45383. diffuseTexture: Nullable<BaseTexture>;
  45384. protected _shadowLights: Nullable<IShadowLight[]>;
  45385. /**
  45386. * Specify the list of lights casting shadow on the material.
  45387. * All scene shadow lights will be included if null.
  45388. */
  45389. shadowLights: Nullable<IShadowLight[]>;
  45390. protected _shadowLevel: float;
  45391. /**
  45392. * Helps adjusting the shadow to a softer level if required.
  45393. * 0 means black shadows and 1 means no shadows.
  45394. */
  45395. shadowLevel: float;
  45396. protected _sceneCenter: Vector3;
  45397. /**
  45398. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45399. * It is usually zero but might be interesting to modify according to your setup.
  45400. */
  45401. sceneCenter: Vector3;
  45402. protected _opacityFresnel: boolean;
  45403. /**
  45404. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45405. * This helps ensuring a nice transition when the camera goes under the ground.
  45406. */
  45407. opacityFresnel: boolean;
  45408. protected _reflectionFresnel: boolean;
  45409. /**
  45410. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45411. * This helps adding a mirror texture on the ground.
  45412. */
  45413. reflectionFresnel: boolean;
  45414. protected _reflectionFalloffDistance: number;
  45415. /**
  45416. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45417. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45418. */
  45419. reflectionFalloffDistance: number;
  45420. protected _reflectionAmount: number;
  45421. /**
  45422. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45423. */
  45424. reflectionAmount: number;
  45425. protected _reflectionReflectance0: number;
  45426. /**
  45427. * This specifies the weight of the reflection at grazing angle.
  45428. */
  45429. reflectionReflectance0: number;
  45430. protected _reflectionReflectance90: number;
  45431. /**
  45432. * This specifies the weight of the reflection at a perpendicular point of view.
  45433. */
  45434. reflectionReflectance90: number;
  45435. /**
  45436. * Sets the reflection reflectance fresnel values according to the default standard
  45437. * empirically know to work well :-)
  45438. */
  45439. reflectionStandardFresnelWeight: number;
  45440. protected _useRGBColor: boolean;
  45441. /**
  45442. * Helps to directly use the maps channels instead of their level.
  45443. */
  45444. useRGBColor: boolean;
  45445. protected _enableNoise: boolean;
  45446. /**
  45447. * This helps reducing the banding effect that could occur on the background.
  45448. */
  45449. enableNoise: boolean;
  45450. /**
  45451. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45452. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45453. * Recommended to be keep at 1.0 except for special cases.
  45454. */
  45455. fovMultiplier: number;
  45456. private _fovMultiplier;
  45457. /**
  45458. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45459. */
  45460. useEquirectangularFOV: boolean;
  45461. private _maxSimultaneousLights;
  45462. /**
  45463. * Number of Simultaneous lights allowed on the material.
  45464. */
  45465. maxSimultaneousLights: int;
  45466. /**
  45467. * Default configuration related to image processing available in the Background Material.
  45468. */
  45469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45470. /**
  45471. * Keep track of the image processing observer to allow dispose and replace.
  45472. */
  45473. private _imageProcessingObserver;
  45474. /**
  45475. * Attaches a new image processing configuration to the PBR Material.
  45476. * @param configuration (if null the scene configuration will be use)
  45477. */
  45478. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45479. /**
  45480. * Gets the image processing configuration used either in this material.
  45481. */
  45482. /**
  45483. * Sets the Default image processing configuration used either in the this material.
  45484. *
  45485. * If sets to null, the scene one is in use.
  45486. */
  45487. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45488. /**
  45489. * Gets wether the color curves effect is enabled.
  45490. */
  45491. /**
  45492. * Sets wether the color curves effect is enabled.
  45493. */
  45494. cameraColorCurvesEnabled: boolean;
  45495. /**
  45496. * Gets wether the color grading effect is enabled.
  45497. */
  45498. /**
  45499. * Gets wether the color grading effect is enabled.
  45500. */
  45501. cameraColorGradingEnabled: boolean;
  45502. /**
  45503. * Gets wether tonemapping is enabled or not.
  45504. */
  45505. /**
  45506. * Sets wether tonemapping is enabled or not
  45507. */
  45508. cameraToneMappingEnabled: boolean;
  45509. /**
  45510. * The camera exposure used on this material.
  45511. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45512. * This corresponds to a photographic exposure.
  45513. */
  45514. /**
  45515. * The camera exposure used on this material.
  45516. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45517. * This corresponds to a photographic exposure.
  45518. */
  45519. cameraExposure: float;
  45520. /**
  45521. * Gets The camera contrast used on this material.
  45522. */
  45523. /**
  45524. * Sets The camera contrast used on this material.
  45525. */
  45526. cameraContrast: float;
  45527. /**
  45528. * Gets the Color Grading 2D Lookup Texture.
  45529. */
  45530. /**
  45531. * Sets the Color Grading 2D Lookup Texture.
  45532. */
  45533. cameraColorGradingTexture: Nullable<BaseTexture>;
  45534. /**
  45535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45537. * 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;
  45538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45539. */
  45540. /**
  45541. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45542. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45543. * 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;
  45544. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45545. */
  45546. cameraColorCurves: Nullable<ColorCurves>;
  45547. /**
  45548. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45549. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45550. */
  45551. switchToBGR: boolean;
  45552. private _renderTargets;
  45553. private _reflectionControls;
  45554. private _white;
  45555. private _primaryShadowColor;
  45556. private _primaryHighlightColor;
  45557. /**
  45558. * Instantiates a Background Material in the given scene
  45559. * @param name The friendly name of the material
  45560. * @param scene The scene to add the material to
  45561. */
  45562. constructor(name: string, scene: Scene);
  45563. /**
  45564. * Gets a boolean indicating that current material needs to register RTT
  45565. */
  45566. readonly hasRenderTargetTextures: boolean;
  45567. /**
  45568. * The entire material has been created in order to prevent overdraw.
  45569. * @returns false
  45570. */
  45571. needAlphaTesting(): boolean;
  45572. /**
  45573. * The entire material has been created in order to prevent overdraw.
  45574. * @returns true if blending is enable
  45575. */
  45576. needAlphaBlending(): boolean;
  45577. /**
  45578. * Checks wether the material is ready to be rendered for a given mesh.
  45579. * @param mesh The mesh to render
  45580. * @param subMesh The submesh to check against
  45581. * @param useInstances Specify wether or not the material is used with instances
  45582. * @returns true if all the dependencies are ready (Textures, Effects...)
  45583. */
  45584. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45585. /**
  45586. * Compute the primary color according to the chosen perceptual color.
  45587. */
  45588. private _computePrimaryColorFromPerceptualColor;
  45589. /**
  45590. * Compute the highlights and shadow colors according to their chosen levels.
  45591. */
  45592. private _computePrimaryColors;
  45593. /**
  45594. * Build the uniform buffer used in the material.
  45595. */
  45596. buildUniformLayout(): void;
  45597. /**
  45598. * Unbind the material.
  45599. */
  45600. unbind(): void;
  45601. /**
  45602. * Bind only the world matrix to the material.
  45603. * @param world The world matrix to bind.
  45604. */
  45605. bindOnlyWorldMatrix(world: Matrix): void;
  45606. /**
  45607. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45608. * @param world The world matrix to bind.
  45609. * @param subMesh The submesh to bind for.
  45610. */
  45611. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45612. /**
  45613. * Checks to see if a texture is used in the material.
  45614. * @param texture - Base texture to use.
  45615. * @returns - Boolean specifying if a texture is used in the material.
  45616. */
  45617. hasTexture(texture: BaseTexture): boolean;
  45618. /**
  45619. * Dispose the material.
  45620. * @param forceDisposeEffect Force disposal of the associated effect.
  45621. * @param forceDisposeTextures Force disposal of the associated textures.
  45622. */
  45623. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45624. /**
  45625. * Clones the material.
  45626. * @param name The cloned name.
  45627. * @returns The cloned material.
  45628. */
  45629. clone(name: string): BackgroundMaterial;
  45630. /**
  45631. * Serializes the current material to its JSON representation.
  45632. * @returns The JSON representation.
  45633. */
  45634. serialize(): any;
  45635. /**
  45636. * Gets the class name of the material
  45637. * @returns "BackgroundMaterial"
  45638. */
  45639. getClassName(): string;
  45640. /**
  45641. * Parse a JSON input to create back a background material.
  45642. * @param source The JSON data to parse
  45643. * @param scene The scene to create the parsed material in
  45644. * @param rootUrl The root url of the assets the material depends upon
  45645. * @returns the instantiated BackgroundMaterial.
  45646. */
  45647. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45648. }
  45649. }
  45650. declare module BABYLON {
  45651. /**
  45652. * Represents the different options available during the creation of
  45653. * a Environment helper.
  45654. *
  45655. * This can control the default ground, skybox and image processing setup of your scene.
  45656. */
  45657. export interface IEnvironmentHelperOptions {
  45658. /**
  45659. * Specifies wether or not to create a ground.
  45660. * True by default.
  45661. */
  45662. createGround: boolean;
  45663. /**
  45664. * Specifies the ground size.
  45665. * 15 by default.
  45666. */
  45667. groundSize: number;
  45668. /**
  45669. * The texture used on the ground for the main color.
  45670. * Comes from the BabylonJS CDN by default.
  45671. *
  45672. * Remarks: Can be either a texture or a url.
  45673. */
  45674. groundTexture: string | BaseTexture;
  45675. /**
  45676. * The color mixed in the ground texture by default.
  45677. * BabylonJS clearColor by default.
  45678. */
  45679. groundColor: Color3;
  45680. /**
  45681. * Specifies the ground opacity.
  45682. * 1 by default.
  45683. */
  45684. groundOpacity: number;
  45685. /**
  45686. * Enables the ground to receive shadows.
  45687. * True by default.
  45688. */
  45689. enableGroundShadow: boolean;
  45690. /**
  45691. * Helps preventing the shadow to be fully black on the ground.
  45692. * 0.5 by default.
  45693. */
  45694. groundShadowLevel: number;
  45695. /**
  45696. * Creates a mirror texture attach to the ground.
  45697. * false by default.
  45698. */
  45699. enableGroundMirror: boolean;
  45700. /**
  45701. * Specifies the ground mirror size ratio.
  45702. * 0.3 by default as the default kernel is 64.
  45703. */
  45704. groundMirrorSizeRatio: number;
  45705. /**
  45706. * Specifies the ground mirror blur kernel size.
  45707. * 64 by default.
  45708. */
  45709. groundMirrorBlurKernel: number;
  45710. /**
  45711. * Specifies the ground mirror visibility amount.
  45712. * 1 by default
  45713. */
  45714. groundMirrorAmount: number;
  45715. /**
  45716. * Specifies the ground mirror reflectance weight.
  45717. * This uses the standard weight of the background material to setup the fresnel effect
  45718. * of the mirror.
  45719. * 1 by default.
  45720. */
  45721. groundMirrorFresnelWeight: number;
  45722. /**
  45723. * Specifies the ground mirror Falloff distance.
  45724. * This can helps reducing the size of the reflection.
  45725. * 0 by Default.
  45726. */
  45727. groundMirrorFallOffDistance: number;
  45728. /**
  45729. * Specifies the ground mirror texture type.
  45730. * Unsigned Int by Default.
  45731. */
  45732. groundMirrorTextureType: number;
  45733. /**
  45734. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45735. * the shown objects.
  45736. */
  45737. groundYBias: number;
  45738. /**
  45739. * Specifies wether or not to create a skybox.
  45740. * True by default.
  45741. */
  45742. createSkybox: boolean;
  45743. /**
  45744. * Specifies the skybox size.
  45745. * 20 by default.
  45746. */
  45747. skyboxSize: number;
  45748. /**
  45749. * The texture used on the skybox for the main color.
  45750. * Comes from the BabylonJS CDN by default.
  45751. *
  45752. * Remarks: Can be either a texture or a url.
  45753. */
  45754. skyboxTexture: string | BaseTexture;
  45755. /**
  45756. * The color mixed in the skybox texture by default.
  45757. * BabylonJS clearColor by default.
  45758. */
  45759. skyboxColor: Color3;
  45760. /**
  45761. * The background rotation around the Y axis of the scene.
  45762. * This helps aligning the key lights of your scene with the background.
  45763. * 0 by default.
  45764. */
  45765. backgroundYRotation: number;
  45766. /**
  45767. * Compute automatically the size of the elements to best fit with the scene.
  45768. */
  45769. sizeAuto: boolean;
  45770. /**
  45771. * Default position of the rootMesh if autoSize is not true.
  45772. */
  45773. rootPosition: Vector3;
  45774. /**
  45775. * Sets up the image processing in the scene.
  45776. * true by default.
  45777. */
  45778. setupImageProcessing: boolean;
  45779. /**
  45780. * The texture used as your environment texture in the scene.
  45781. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45782. *
  45783. * Remarks: Can be either a texture or a url.
  45784. */
  45785. environmentTexture: string | BaseTexture;
  45786. /**
  45787. * The value of the exposure to apply to the scene.
  45788. * 0.6 by default if setupImageProcessing is true.
  45789. */
  45790. cameraExposure: number;
  45791. /**
  45792. * The value of the contrast to apply to the scene.
  45793. * 1.6 by default if setupImageProcessing is true.
  45794. */
  45795. cameraContrast: number;
  45796. /**
  45797. * Specifies wether or not tonemapping should be enabled in the scene.
  45798. * true by default if setupImageProcessing is true.
  45799. */
  45800. toneMappingEnabled: boolean;
  45801. }
  45802. /**
  45803. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45804. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45805. * It also helps with the default setup of your imageProcessing configuration.
  45806. */
  45807. export class EnvironmentHelper {
  45808. /**
  45809. * Default ground texture URL.
  45810. */
  45811. private static _groundTextureCDNUrl;
  45812. /**
  45813. * Default skybox texture URL.
  45814. */
  45815. private static _skyboxTextureCDNUrl;
  45816. /**
  45817. * Default environment texture URL.
  45818. */
  45819. private static _environmentTextureCDNUrl;
  45820. /**
  45821. * Creates the default options for the helper.
  45822. */
  45823. private static _getDefaultOptions;
  45824. private _rootMesh;
  45825. /**
  45826. * Gets the root mesh created by the helper.
  45827. */
  45828. readonly rootMesh: Mesh;
  45829. private _skybox;
  45830. /**
  45831. * Gets the skybox created by the helper.
  45832. */
  45833. readonly skybox: Nullable<Mesh>;
  45834. private _skyboxTexture;
  45835. /**
  45836. * Gets the skybox texture created by the helper.
  45837. */
  45838. readonly skyboxTexture: Nullable<BaseTexture>;
  45839. private _skyboxMaterial;
  45840. /**
  45841. * Gets the skybox material created by the helper.
  45842. */
  45843. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45844. private _ground;
  45845. /**
  45846. * Gets the ground mesh created by the helper.
  45847. */
  45848. readonly ground: Nullable<Mesh>;
  45849. private _groundTexture;
  45850. /**
  45851. * Gets the ground texture created by the helper.
  45852. */
  45853. readonly groundTexture: Nullable<BaseTexture>;
  45854. private _groundMirror;
  45855. /**
  45856. * Gets the ground mirror created by the helper.
  45857. */
  45858. readonly groundMirror: Nullable<MirrorTexture>;
  45859. /**
  45860. * Gets the ground mirror render list to helps pushing the meshes
  45861. * you wish in the ground reflection.
  45862. */
  45863. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45864. private _groundMaterial;
  45865. /**
  45866. * Gets the ground material created by the helper.
  45867. */
  45868. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45869. /**
  45870. * Stores the creation options.
  45871. */
  45872. private readonly _scene;
  45873. private _options;
  45874. /**
  45875. * This observable will be notified with any error during the creation of the environment,
  45876. * mainly texture creation errors.
  45877. */
  45878. onErrorObservable: Observable<{
  45879. message?: string;
  45880. exception?: any;
  45881. }>;
  45882. /**
  45883. * constructor
  45884. * @param options Defines the options we want to customize the helper
  45885. * @param scene The scene to add the material to
  45886. */
  45887. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45888. /**
  45889. * Updates the background according to the new options
  45890. * @param options
  45891. */
  45892. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45893. /**
  45894. * Sets the primary color of all the available elements.
  45895. * @param color the main color to affect to the ground and the background
  45896. */
  45897. setMainColor(color: Color3): void;
  45898. /**
  45899. * Setup the image processing according to the specified options.
  45900. */
  45901. private _setupImageProcessing;
  45902. /**
  45903. * Setup the environment texture according to the specified options.
  45904. */
  45905. private _setupEnvironmentTexture;
  45906. /**
  45907. * Setup the background according to the specified options.
  45908. */
  45909. private _setupBackground;
  45910. /**
  45911. * Get the scene sizes according to the setup.
  45912. */
  45913. private _getSceneSize;
  45914. /**
  45915. * Setup the ground according to the specified options.
  45916. */
  45917. private _setupGround;
  45918. /**
  45919. * Setup the ground material according to the specified options.
  45920. */
  45921. private _setupGroundMaterial;
  45922. /**
  45923. * Setup the ground diffuse texture according to the specified options.
  45924. */
  45925. private _setupGroundDiffuseTexture;
  45926. /**
  45927. * Setup the ground mirror texture according to the specified options.
  45928. */
  45929. private _setupGroundMirrorTexture;
  45930. /**
  45931. * Setup the ground to receive the mirror texture.
  45932. */
  45933. private _setupMirrorInGroundMaterial;
  45934. /**
  45935. * Setup the skybox according to the specified options.
  45936. */
  45937. private _setupSkybox;
  45938. /**
  45939. * Setup the skybox material according to the specified options.
  45940. */
  45941. private _setupSkyboxMaterial;
  45942. /**
  45943. * Setup the skybox reflection texture according to the specified options.
  45944. */
  45945. private _setupSkyboxReflectionTexture;
  45946. private _errorHandler;
  45947. /**
  45948. * Dispose all the elements created by the Helper.
  45949. */
  45950. dispose(): void;
  45951. }
  45952. }
  45953. declare module BABYLON {
  45954. /**
  45955. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45956. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45957. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45958. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45959. */
  45960. export class PhotoDome extends TransformNode {
  45961. /**
  45962. * Define the image as a Monoscopic panoramic 360 image.
  45963. */
  45964. static readonly MODE_MONOSCOPIC: number;
  45965. /**
  45966. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45967. */
  45968. static readonly MODE_TOPBOTTOM: number;
  45969. /**
  45970. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45971. */
  45972. static readonly MODE_SIDEBYSIDE: number;
  45973. private _useDirectMapping;
  45974. /**
  45975. * The texture being displayed on the sphere
  45976. */
  45977. protected _photoTexture: Texture;
  45978. /**
  45979. * Gets or sets the texture being displayed on the sphere
  45980. */
  45981. photoTexture: Texture;
  45982. /**
  45983. * Observable raised when an error occured while loading the 360 image
  45984. */
  45985. onLoadErrorObservable: Observable<string>;
  45986. /**
  45987. * The skybox material
  45988. */
  45989. protected _material: BackgroundMaterial;
  45990. /**
  45991. * The surface used for the skybox
  45992. */
  45993. protected _mesh: Mesh;
  45994. /**
  45995. * Gets the mesh used for the skybox.
  45996. */
  45997. readonly mesh: Mesh;
  45998. /**
  45999. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46000. * Also see the options.resolution property.
  46001. */
  46002. fovMultiplier: number;
  46003. private _imageMode;
  46004. /**
  46005. * Gets or set the current video mode for the video. It can be:
  46006. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46007. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46008. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46009. */
  46010. imageMode: number;
  46011. /**
  46012. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46013. * @param name Element's name, child elements will append suffixes for their own names.
  46014. * @param urlsOfPhoto defines the url of the photo to display
  46015. * @param options defines an object containing optional or exposed sub element properties
  46016. * @param onError defines a callback called when an error occured while loading the texture
  46017. */
  46018. constructor(name: string, urlOfPhoto: string, options: {
  46019. resolution?: number;
  46020. size?: number;
  46021. useDirectMapping?: boolean;
  46022. faceForward?: boolean;
  46023. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46024. private _onBeforeCameraRenderObserver;
  46025. private _changeImageMode;
  46026. /**
  46027. * Releases resources associated with this node.
  46028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46030. */
  46031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46032. }
  46033. }
  46034. declare module BABYLON {
  46035. /**
  46036. * Class used to host RGBD texture specific utilities
  46037. */
  46038. export class RGBDTextureTools {
  46039. /**
  46040. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46041. * @param texture the texture to expand.
  46042. */
  46043. static ExpandRGBDTexture(texture: Texture): void;
  46044. }
  46045. }
  46046. declare module BABYLON {
  46047. /**
  46048. * Class used to host texture specific utilities
  46049. */
  46050. export class BRDFTextureTools {
  46051. /**
  46052. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46053. * @param scene defines the hosting scene
  46054. * @returns the environment BRDF texture
  46055. */
  46056. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46057. private static _environmentBRDFBase64Texture;
  46058. }
  46059. }
  46060. declare module BABYLON {
  46061. /**
  46062. * @hidden
  46063. */
  46064. export interface IMaterialClearCoatDefines {
  46065. CLEARCOAT: boolean;
  46066. CLEARCOAT_DEFAULTIOR: boolean;
  46067. CLEARCOAT_TEXTURE: boolean;
  46068. CLEARCOAT_TEXTUREDIRECTUV: number;
  46069. CLEARCOAT_BUMP: boolean;
  46070. CLEARCOAT_BUMPDIRECTUV: number;
  46071. CLEARCOAT_TINT: boolean;
  46072. CLEARCOAT_TINT_TEXTURE: boolean;
  46073. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46074. /** @hidden */
  46075. _areTexturesDirty: boolean;
  46076. }
  46077. /**
  46078. * Define the code related to the clear coat parameters of the pbr material.
  46079. */
  46080. export class PBRClearCoatConfiguration {
  46081. /**
  46082. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46083. * The default fits with a polyurethane material.
  46084. */
  46085. private static readonly _DefaultIndexOfRefraction;
  46086. private _isEnabled;
  46087. /**
  46088. * Defines if the clear coat is enabled in the material.
  46089. */
  46090. isEnabled: boolean;
  46091. /**
  46092. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46093. */
  46094. intensity: number;
  46095. /**
  46096. * Defines the clear coat layer roughness.
  46097. */
  46098. roughness: number;
  46099. private _indexOfRefraction;
  46100. /**
  46101. * Defines the index of refraction of the clear coat.
  46102. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46103. * The default fits with a polyurethane material.
  46104. * Changing the default value is more performance intensive.
  46105. */
  46106. indexOfRefraction: number;
  46107. private _texture;
  46108. /**
  46109. * Stores the clear coat values in a texture.
  46110. */
  46111. texture: Nullable<BaseTexture>;
  46112. private _bumpTexture;
  46113. /**
  46114. * Define the clear coat specific bump texture.
  46115. */
  46116. bumpTexture: Nullable<BaseTexture>;
  46117. private _isTintEnabled;
  46118. /**
  46119. * Defines if the clear coat tint is enabled in the material.
  46120. */
  46121. isTintEnabled: boolean;
  46122. /**
  46123. * Defines the clear coat tint of the material.
  46124. * This is only use if tint is enabled
  46125. */
  46126. tintColor: Color3;
  46127. /**
  46128. * Defines the distance at which the tint color should be found in the
  46129. * clear coat media.
  46130. * This is only use if tint is enabled
  46131. */
  46132. tintColorAtDistance: number;
  46133. /**
  46134. * Defines the clear coat layer thickness.
  46135. * This is only use if tint is enabled
  46136. */
  46137. tintThickness: number;
  46138. private _tintTexture;
  46139. /**
  46140. * Stores the clear tint values in a texture.
  46141. * rgb is tint
  46142. * a is a thickness factor
  46143. */
  46144. tintTexture: Nullable<BaseTexture>;
  46145. /** @hidden */
  46146. private _internalMarkAllSubMeshesAsTexturesDirty;
  46147. /** @hidden */
  46148. _markAllSubMeshesAsTexturesDirty(): void;
  46149. /**
  46150. * Instantiate a new istance of clear coat configuration.
  46151. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46152. */
  46153. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46154. /**
  46155. * Gets wehter the submesh is ready to be used or not.
  46156. * @param defines the list of "defines" to update.
  46157. * @param scene defines the scene the material belongs to.
  46158. * @param engine defines the engine the material belongs to.
  46159. * @param disableBumpMap defines wether the material disables bump or not.
  46160. * @returns - boolean indicating that the submesh is ready or not.
  46161. */
  46162. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46163. /**
  46164. * Checks to see if a texture is used in the material.
  46165. * @param defines the list of "defines" to update.
  46166. * @param scene defines the scene to the material belongs to.
  46167. */
  46168. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46169. /**
  46170. * Binds the material data.
  46171. * @param uniformBuffer defines the Uniform buffer to fill in.
  46172. * @param scene defines the scene the material belongs to.
  46173. * @param engine defines the engine the material belongs to.
  46174. * @param disableBumpMap defines wether the material disables bump or not.
  46175. * @param isFrozen defines wether the material is frozen or not.
  46176. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46177. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46178. */
  46179. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46180. /**
  46181. * Checks to see if a texture is used in the material.
  46182. * @param texture - Base texture to use.
  46183. * @returns - Boolean specifying if a texture is used in the material.
  46184. */
  46185. hasTexture(texture: BaseTexture): boolean;
  46186. /**
  46187. * Returns an array of the actively used textures.
  46188. * @param activeTextures Array of BaseTextures
  46189. */
  46190. getActiveTextures(activeTextures: BaseTexture[]): void;
  46191. /**
  46192. * Returns the animatable textures.
  46193. * @param animatables Array of animatable textures.
  46194. */
  46195. getAnimatables(animatables: IAnimatable[]): void;
  46196. /**
  46197. * Disposes the resources of the material.
  46198. * @param forceDisposeTextures - Forces the disposal of all textures.
  46199. */
  46200. dispose(forceDisposeTextures?: boolean): void;
  46201. /**
  46202. * Get the current class name of the texture useful for serialization or dynamic coding.
  46203. * @returns "PBRClearCoatConfiguration"
  46204. */
  46205. getClassName(): string;
  46206. /**
  46207. * Add fallbacks to the effect fallbacks list.
  46208. * @param defines defines the Base texture to use.
  46209. * @param fallbacks defines the current fallback list.
  46210. * @param currentRank defines the current fallback rank.
  46211. * @returns the new fallback rank.
  46212. */
  46213. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46214. /**
  46215. * Add the required uniforms to the current list.
  46216. * @param uniforms defines the current uniform list.
  46217. */
  46218. static AddUniforms(uniforms: string[]): void;
  46219. /**
  46220. * Add the required samplers to the current list.
  46221. * @param samplers defines the current sampler list.
  46222. */
  46223. static AddSamplers(samplers: string[]): void;
  46224. /**
  46225. * Add the required uniforms to the current buffer.
  46226. * @param uniformBuffer defines the current uniform buffer.
  46227. */
  46228. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46229. /**
  46230. * Makes a duplicate of the current configuration into another one.
  46231. * @param clearCoatConfiguration define the config where to copy the info
  46232. */
  46233. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46234. /**
  46235. * Serializes this clear coat configuration.
  46236. * @returns - An object with the serialized config.
  46237. */
  46238. serialize(): any;
  46239. /**
  46240. * Parses a anisotropy Configuration from a serialized object.
  46241. * @param source - Serialized object.
  46242. * @param scene Defines the scene we are parsing for
  46243. * @param rootUrl Defines the rootUrl to load from
  46244. */
  46245. parse(source: any, scene: Scene, rootUrl: string): void;
  46246. }
  46247. }
  46248. declare module BABYLON {
  46249. /**
  46250. * @hidden
  46251. */
  46252. export interface IMaterialAnisotropicDefines {
  46253. ANISOTROPIC: boolean;
  46254. ANISOTROPIC_TEXTURE: boolean;
  46255. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46256. MAINUV1: boolean;
  46257. _areTexturesDirty: boolean;
  46258. _needUVs: boolean;
  46259. }
  46260. /**
  46261. * Define the code related to the anisotropic parameters of the pbr material.
  46262. */
  46263. export class PBRAnisotropicConfiguration {
  46264. private _isEnabled;
  46265. /**
  46266. * Defines if the anisotropy is enabled in the material.
  46267. */
  46268. isEnabled: boolean;
  46269. /**
  46270. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46271. */
  46272. intensity: number;
  46273. /**
  46274. * Defines if the effect is along the tangents, bitangents or in between.
  46275. * By default, the effect is "strectching" the highlights along the tangents.
  46276. */
  46277. direction: Vector2;
  46278. private _texture;
  46279. /**
  46280. * Stores the anisotropy values in a texture.
  46281. * rg is direction (like normal from -1 to 1)
  46282. * b is a intensity
  46283. */
  46284. texture: Nullable<BaseTexture>;
  46285. /** @hidden */
  46286. private _internalMarkAllSubMeshesAsTexturesDirty;
  46287. /** @hidden */
  46288. _markAllSubMeshesAsTexturesDirty(): void;
  46289. /**
  46290. * Instantiate a new istance of anisotropy configuration.
  46291. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46292. */
  46293. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46294. /**
  46295. * Specifies that the submesh is ready to be used.
  46296. * @param defines the list of "defines" to update.
  46297. * @param scene defines the scene the material belongs to.
  46298. * @returns - boolean indicating that the submesh is ready or not.
  46299. */
  46300. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46301. /**
  46302. * Checks to see if a texture is used in the material.
  46303. * @param defines the list of "defines" to update.
  46304. * @param mesh the mesh we are preparing the defines for.
  46305. * @param scene defines the scene the material belongs to.
  46306. */
  46307. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46308. /**
  46309. * Binds the material data.
  46310. * @param uniformBuffer defines the Uniform buffer to fill in.
  46311. * @param scene defines the scene the material belongs to.
  46312. * @param isFrozen defines wether the material is frozen or not.
  46313. */
  46314. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46315. /**
  46316. * Checks to see if a texture is used in the material.
  46317. * @param texture - Base texture to use.
  46318. * @returns - Boolean specifying if a texture is used in the material.
  46319. */
  46320. hasTexture(texture: BaseTexture): boolean;
  46321. /**
  46322. * Returns an array of the actively used textures.
  46323. * @param activeTextures Array of BaseTextures
  46324. */
  46325. getActiveTextures(activeTextures: BaseTexture[]): void;
  46326. /**
  46327. * Returns the animatable textures.
  46328. * @param animatables Array of animatable textures.
  46329. */
  46330. getAnimatables(animatables: IAnimatable[]): void;
  46331. /**
  46332. * Disposes the resources of the material.
  46333. * @param forceDisposeTextures - Forces the disposal of all textures.
  46334. */
  46335. dispose(forceDisposeTextures?: boolean): void;
  46336. /**
  46337. * Get the current class name of the texture useful for serialization or dynamic coding.
  46338. * @returns "PBRAnisotropicConfiguration"
  46339. */
  46340. getClassName(): string;
  46341. /**
  46342. * Add fallbacks to the effect fallbacks list.
  46343. * @param defines defines the Base texture to use.
  46344. * @param fallbacks defines the current fallback list.
  46345. * @param currentRank defines the current fallback rank.
  46346. * @returns the new fallback rank.
  46347. */
  46348. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46349. /**
  46350. * Add the required uniforms to the current list.
  46351. * @param uniforms defines the current uniform list.
  46352. */
  46353. static AddUniforms(uniforms: string[]): void;
  46354. /**
  46355. * Add the required uniforms to the current buffer.
  46356. * @param uniformBuffer defines the current uniform buffer.
  46357. */
  46358. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46359. /**
  46360. * Add the required samplers to the current list.
  46361. * @param samplers defines the current sampler list.
  46362. */
  46363. static AddSamplers(samplers: string[]): void;
  46364. /**
  46365. * Makes a duplicate of the current configuration into another one.
  46366. * @param anisotropicConfiguration define the config where to copy the info
  46367. */
  46368. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46369. /**
  46370. * Serializes this anisotropy configuration.
  46371. * @returns - An object with the serialized config.
  46372. */
  46373. serialize(): any;
  46374. /**
  46375. * Parses a anisotropy Configuration from a serialized object.
  46376. * @param source - Serialized object.
  46377. * @param scene Defines the scene we are parsing for
  46378. * @param rootUrl Defines the rootUrl to load from
  46379. */
  46380. parse(source: any, scene: Scene, rootUrl: string): void;
  46381. }
  46382. }
  46383. declare module BABYLON {
  46384. /**
  46385. * @hidden
  46386. */
  46387. export interface IMaterialBRDFDefines {
  46388. BRDF_V_HEIGHT_CORRELATED: boolean;
  46389. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46390. SPHERICAL_HARMONICS: boolean;
  46391. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46392. /** @hidden */
  46393. _areMiscDirty: boolean;
  46394. }
  46395. /**
  46396. * Define the code related to the BRDF parameters of the pbr material.
  46397. */
  46398. export class PBRBRDFConfiguration {
  46399. /**
  46400. * Default value used for the energy conservation.
  46401. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46402. */
  46403. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46404. /**
  46405. * Default value used for the Smith Visibility Height Correlated mode.
  46406. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46407. */
  46408. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46409. /**
  46410. * Default value used for the IBL diffuse part.
  46411. * This can help switching back to the polynomials mode globally which is a tiny bit
  46412. * less GPU intensive at the drawback of a lower quality.
  46413. */
  46414. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46415. /**
  46416. * Default value used for activating energy conservation for the specular workflow.
  46417. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46418. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46419. */
  46420. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46421. private _useEnergyConservation;
  46422. /**
  46423. * Defines if the material uses energy conservation.
  46424. */
  46425. useEnergyConservation: boolean;
  46426. private _useSmithVisibilityHeightCorrelated;
  46427. /**
  46428. * LEGACY Mode set to false
  46429. * Defines if the material uses height smith correlated visibility term.
  46430. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46431. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46432. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46433. * Not relying on height correlated will also disable energy conservation.
  46434. */
  46435. useSmithVisibilityHeightCorrelated: boolean;
  46436. private _useSphericalHarmonics;
  46437. /**
  46438. * LEGACY Mode set to false
  46439. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46440. * diffuse part of the IBL.
  46441. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46442. * to the ground truth.
  46443. */
  46444. useSphericalHarmonics: boolean;
  46445. private _useSpecularGlossinessInputEnergyConservation;
  46446. /**
  46447. * Defines if the material uses energy conservation, when the specular workflow is active.
  46448. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46449. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46450. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46451. */
  46452. useSpecularGlossinessInputEnergyConservation: boolean;
  46453. /** @hidden */
  46454. private _internalMarkAllSubMeshesAsMiscDirty;
  46455. /** @hidden */
  46456. _markAllSubMeshesAsMiscDirty(): void;
  46457. /**
  46458. * Instantiate a new istance of clear coat configuration.
  46459. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46460. */
  46461. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46462. /**
  46463. * Checks to see if a texture is used in the material.
  46464. * @param defines the list of "defines" to update.
  46465. */
  46466. prepareDefines(defines: IMaterialBRDFDefines): void;
  46467. /**
  46468. * Get the current class name of the texture useful for serialization or dynamic coding.
  46469. * @returns "PBRClearCoatConfiguration"
  46470. */
  46471. getClassName(): string;
  46472. /**
  46473. * Makes a duplicate of the current configuration into another one.
  46474. * @param brdfConfiguration define the config where to copy the info
  46475. */
  46476. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46477. /**
  46478. * Serializes this BRDF configuration.
  46479. * @returns - An object with the serialized config.
  46480. */
  46481. serialize(): any;
  46482. /**
  46483. * Parses a anisotropy Configuration from a serialized object.
  46484. * @param source - Serialized object.
  46485. * @param scene Defines the scene we are parsing for
  46486. * @param rootUrl Defines the rootUrl to load from
  46487. */
  46488. parse(source: any, scene: Scene, rootUrl: string): void;
  46489. }
  46490. }
  46491. declare module BABYLON {
  46492. /**
  46493. * @hidden
  46494. */
  46495. export interface IMaterialSheenDefines {
  46496. SHEEN: boolean;
  46497. SHEEN_TEXTURE: boolean;
  46498. SHEEN_TEXTUREDIRECTUV: number;
  46499. SHEEN_LINKWITHALBEDO: boolean;
  46500. /** @hidden */
  46501. _areTexturesDirty: boolean;
  46502. }
  46503. /**
  46504. * Define the code related to the Sheen parameters of the pbr material.
  46505. */
  46506. export class PBRSheenConfiguration {
  46507. private _isEnabled;
  46508. /**
  46509. * Defines if the material uses sheen.
  46510. */
  46511. isEnabled: boolean;
  46512. private _linkSheenWithAlbedo;
  46513. /**
  46514. * Defines if the sheen is linked to the sheen color.
  46515. */
  46516. linkSheenWithAlbedo: boolean;
  46517. /**
  46518. * Defines the sheen intensity.
  46519. */
  46520. intensity: number;
  46521. /**
  46522. * Defines the sheen color.
  46523. */
  46524. color: Color3;
  46525. private _texture;
  46526. /**
  46527. * Stores the sheen tint values in a texture.
  46528. * rgb is tint
  46529. * a is a intensity
  46530. */
  46531. texture: Nullable<BaseTexture>;
  46532. /** @hidden */
  46533. private _internalMarkAllSubMeshesAsTexturesDirty;
  46534. /** @hidden */
  46535. _markAllSubMeshesAsTexturesDirty(): void;
  46536. /**
  46537. * Instantiate a new istance of clear coat configuration.
  46538. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46539. */
  46540. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46541. /**
  46542. * Specifies that the submesh is ready to be used.
  46543. * @param defines the list of "defines" to update.
  46544. * @param scene defines the scene the material belongs to.
  46545. * @returns - boolean indicating that the submesh is ready or not.
  46546. */
  46547. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46548. /**
  46549. * Checks to see if a texture is used in the material.
  46550. * @param defines the list of "defines" to update.
  46551. * @param scene defines the scene the material belongs to.
  46552. */
  46553. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46554. /**
  46555. * Binds the material data.
  46556. * @param uniformBuffer defines the Uniform buffer to fill in.
  46557. * @param scene defines the scene the material belongs to.
  46558. * @param isFrozen defines wether the material is frozen or not.
  46559. */
  46560. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46561. /**
  46562. * Checks to see if a texture is used in the material.
  46563. * @param texture - Base texture to use.
  46564. * @returns - Boolean specifying if a texture is used in the material.
  46565. */
  46566. hasTexture(texture: BaseTexture): boolean;
  46567. /**
  46568. * Returns an array of the actively used textures.
  46569. * @param activeTextures Array of BaseTextures
  46570. */
  46571. getActiveTextures(activeTextures: BaseTexture[]): void;
  46572. /**
  46573. * Returns the animatable textures.
  46574. * @param animatables Array of animatable textures.
  46575. */
  46576. getAnimatables(animatables: IAnimatable[]): void;
  46577. /**
  46578. * Disposes the resources of the material.
  46579. * @param forceDisposeTextures - Forces the disposal of all textures.
  46580. */
  46581. dispose(forceDisposeTextures?: boolean): void;
  46582. /**
  46583. * Get the current class name of the texture useful for serialization or dynamic coding.
  46584. * @returns "PBRSheenConfiguration"
  46585. */
  46586. getClassName(): string;
  46587. /**
  46588. * Add fallbacks to the effect fallbacks list.
  46589. * @param defines defines the Base texture to use.
  46590. * @param fallbacks defines the current fallback list.
  46591. * @param currentRank defines the current fallback rank.
  46592. * @returns the new fallback rank.
  46593. */
  46594. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46595. /**
  46596. * Add the required uniforms to the current list.
  46597. * @param uniforms defines the current uniform list.
  46598. */
  46599. static AddUniforms(uniforms: string[]): void;
  46600. /**
  46601. * Add the required uniforms to the current buffer.
  46602. * @param uniformBuffer defines the current uniform buffer.
  46603. */
  46604. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46605. /**
  46606. * Add the required samplers to the current list.
  46607. * @param samplers defines the current sampler list.
  46608. */
  46609. static AddSamplers(samplers: string[]): void;
  46610. /**
  46611. * Makes a duplicate of the current configuration into another one.
  46612. * @param sheenConfiguration define the config where to copy the info
  46613. */
  46614. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46615. /**
  46616. * Serializes this BRDF configuration.
  46617. * @returns - An object with the serialized config.
  46618. */
  46619. serialize(): any;
  46620. /**
  46621. * Parses a anisotropy Configuration from a serialized object.
  46622. * @param source - Serialized object.
  46623. * @param scene Defines the scene we are parsing for
  46624. * @param rootUrl Defines the rootUrl to load from
  46625. */
  46626. parse(source: any, scene: Scene, rootUrl: string): void;
  46627. }
  46628. }
  46629. declare module BABYLON {
  46630. /**
  46631. * @hidden
  46632. */
  46633. export interface IMaterialSubSurfaceDefines {
  46634. SUBSURFACE: boolean;
  46635. SS_REFRACTION: boolean;
  46636. SS_TRANSLUCENCY: boolean;
  46637. SS_SCATERRING: boolean;
  46638. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46639. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46640. SS_REFRACTIONMAP_3D: boolean;
  46641. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46642. SS_LODINREFRACTIONALPHA: boolean;
  46643. SS_GAMMAREFRACTION: boolean;
  46644. SS_RGBDREFRACTION: boolean;
  46645. SS_LINEARSPECULARREFRACTION: boolean;
  46646. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46647. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46648. /** @hidden */
  46649. _areTexturesDirty: boolean;
  46650. }
  46651. /**
  46652. * Define the code related to the sub surface parameters of the pbr material.
  46653. */
  46654. export class PBRSubSurfaceConfiguration {
  46655. private _isRefractionEnabled;
  46656. /**
  46657. * Defines if the refraction is enabled in the material.
  46658. */
  46659. isRefractionEnabled: boolean;
  46660. private _isTranslucencyEnabled;
  46661. /**
  46662. * Defines if the translucency is enabled in the material.
  46663. */
  46664. isTranslucencyEnabled: boolean;
  46665. private _isScatteringEnabled;
  46666. /**
  46667. * Defines the refraction intensity of the material.
  46668. * The refraction when enabled replaces the Diffuse part of the material.
  46669. * The intensity helps transitionning between diffuse and refraction.
  46670. */
  46671. refractionIntensity: number;
  46672. /**
  46673. * Defines the translucency intensity of the material.
  46674. * When translucency has been enabled, this defines how much of the "translucency"
  46675. * is addded to the diffuse part of the material.
  46676. */
  46677. translucencyIntensity: number;
  46678. /**
  46679. * Defines the scattering intensity of the material.
  46680. * When scattering has been enabled, this defines how much of the "scattered light"
  46681. * is addded to the diffuse part of the material.
  46682. */
  46683. scatteringIntensity: number;
  46684. private _thicknessTexture;
  46685. /**
  46686. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46687. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46688. * 0 would mean minimumThickness
  46689. * 1 would mean maximumThickness
  46690. * The other channels might be use as a mask to vary the different effects intensity.
  46691. */
  46692. thicknessTexture: Nullable<BaseTexture>;
  46693. private _refractionTexture;
  46694. /**
  46695. * Defines the texture to use for refraction.
  46696. */
  46697. refractionTexture: Nullable<BaseTexture>;
  46698. private _indexOfRefraction;
  46699. /**
  46700. * Defines the index of refraction used in the material.
  46701. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46702. */
  46703. indexOfRefraction: number;
  46704. private _invertRefractionY;
  46705. /**
  46706. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46707. */
  46708. invertRefractionY: boolean;
  46709. private _linkRefractionWithTransparency;
  46710. /**
  46711. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46712. * Materials half opaque for instance using refraction could benefit from this control.
  46713. */
  46714. linkRefractionWithTransparency: boolean;
  46715. /**
  46716. * Defines the minimum thickness stored in the thickness map.
  46717. * If no thickness map is defined, this value will be used to simulate thickness.
  46718. */
  46719. minimumThickness: number;
  46720. /**
  46721. * Defines the maximum thickness stored in the thickness map.
  46722. */
  46723. maximumThickness: number;
  46724. /**
  46725. * Defines the volume tint of the material.
  46726. * This is used for both translucency and scattering.
  46727. */
  46728. tintColor: Color3;
  46729. /**
  46730. * Defines the distance at which the tint color should be found in the media.
  46731. * This is used for refraction only.
  46732. */
  46733. tintColorAtDistance: number;
  46734. /**
  46735. * Defines how far each channel transmit through the media.
  46736. * It is defined as a color to simplify it selection.
  46737. */
  46738. diffusionDistance: Color3;
  46739. private _useMaskFromThicknessTexture;
  46740. /**
  46741. * Stores the intensity of the different subsurface effects in the thickness texture.
  46742. * * the green channel is the translucency intensity.
  46743. * * the blue channel is the scattering intensity.
  46744. * * the alpha channel is the refraction intensity.
  46745. */
  46746. useMaskFromThicknessTexture: boolean;
  46747. /** @hidden */
  46748. private _internalMarkAllSubMeshesAsTexturesDirty;
  46749. /** @hidden */
  46750. _markAllSubMeshesAsTexturesDirty(): void;
  46751. /**
  46752. * Instantiate a new istance of sub surface configuration.
  46753. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46754. */
  46755. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46756. /**
  46757. * Gets wehter the submesh is ready to be used or not.
  46758. * @param defines the list of "defines" to update.
  46759. * @param scene defines the scene the material belongs to.
  46760. * @returns - boolean indicating that the submesh is ready or not.
  46761. */
  46762. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46763. /**
  46764. * Checks to see if a texture is used in the material.
  46765. * @param defines the list of "defines" to update.
  46766. * @param scene defines the scene to the material belongs to.
  46767. */
  46768. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46769. /**
  46770. * Binds the material data.
  46771. * @param uniformBuffer defines the Uniform buffer to fill in.
  46772. * @param scene defines the scene the material belongs to.
  46773. * @param engine defines the engine the material belongs to.
  46774. * @param isFrozen defines wether the material is frozen or not.
  46775. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46776. */
  46777. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46778. /**
  46779. * Unbinds the material from the mesh.
  46780. * @param activeEffect defines the effect that should be unbound from.
  46781. * @returns true if unbound, otherwise false
  46782. */
  46783. unbind(activeEffect: Effect): boolean;
  46784. /**
  46785. * Returns the texture used for refraction or null if none is used.
  46786. * @param scene defines the scene the material belongs to.
  46787. * @returns - Refraction texture if present. If no refraction texture and refraction
  46788. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46789. */
  46790. private _getRefractionTexture;
  46791. /**
  46792. * Returns true if alpha blending should be disabled.
  46793. */
  46794. readonly disableAlphaBlending: boolean;
  46795. /**
  46796. * Fills the list of render target textures.
  46797. * @param renderTargets the list of render targets to update
  46798. */
  46799. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46800. /**
  46801. * Checks to see if a texture is used in the material.
  46802. * @param texture - Base texture to use.
  46803. * @returns - Boolean specifying if a texture is used in the material.
  46804. */
  46805. hasTexture(texture: BaseTexture): boolean;
  46806. /**
  46807. * Gets a boolean indicating that current material needs to register RTT
  46808. * @returns true if this uses a render target otherwise false.
  46809. */
  46810. hasRenderTargetTextures(): boolean;
  46811. /**
  46812. * Returns an array of the actively used textures.
  46813. * @param activeTextures Array of BaseTextures
  46814. */
  46815. getActiveTextures(activeTextures: BaseTexture[]): void;
  46816. /**
  46817. * Returns the animatable textures.
  46818. * @param animatables Array of animatable textures.
  46819. */
  46820. getAnimatables(animatables: IAnimatable[]): void;
  46821. /**
  46822. * Disposes the resources of the material.
  46823. * @param forceDisposeTextures - Forces the disposal of all textures.
  46824. */
  46825. dispose(forceDisposeTextures?: boolean): void;
  46826. /**
  46827. * Get the current class name of the texture useful for serialization or dynamic coding.
  46828. * @returns "PBRSubSurfaceConfiguration"
  46829. */
  46830. getClassName(): string;
  46831. /**
  46832. * Add fallbacks to the effect fallbacks list.
  46833. * @param defines defines the Base texture to use.
  46834. * @param fallbacks defines the current fallback list.
  46835. * @param currentRank defines the current fallback rank.
  46836. * @returns the new fallback rank.
  46837. */
  46838. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46839. /**
  46840. * Add the required uniforms to the current list.
  46841. * @param uniforms defines the current uniform list.
  46842. */
  46843. static AddUniforms(uniforms: string[]): void;
  46844. /**
  46845. * Add the required samplers to the current list.
  46846. * @param samplers defines the current sampler list.
  46847. */
  46848. static AddSamplers(samplers: string[]): void;
  46849. /**
  46850. * Add the required uniforms to the current buffer.
  46851. * @param uniformBuffer defines the current uniform buffer.
  46852. */
  46853. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46854. /**
  46855. * Makes a duplicate of the current configuration into another one.
  46856. * @param configuration define the config where to copy the info
  46857. */
  46858. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46859. /**
  46860. * Serializes this Sub Surface configuration.
  46861. * @returns - An object with the serialized config.
  46862. */
  46863. serialize(): any;
  46864. /**
  46865. * Parses a anisotropy Configuration from a serialized object.
  46866. * @param source - Serialized object.
  46867. * @param scene Defines the scene we are parsing for
  46868. * @param rootUrl Defines the rootUrl to load from
  46869. */
  46870. parse(source: any, scene: Scene, rootUrl: string): void;
  46871. }
  46872. }
  46873. declare module BABYLON {
  46874. /** @hidden */
  46875. export var pbrFragmentDeclaration: {
  46876. name: string;
  46877. shader: string;
  46878. };
  46879. }
  46880. declare module BABYLON {
  46881. /** @hidden */
  46882. export var pbrUboDeclaration: {
  46883. name: string;
  46884. shader: string;
  46885. };
  46886. }
  46887. declare module BABYLON {
  46888. /** @hidden */
  46889. export var pbrFragmentExtraDeclaration: {
  46890. name: string;
  46891. shader: string;
  46892. };
  46893. }
  46894. declare module BABYLON {
  46895. /** @hidden */
  46896. export var pbrFragmentSamplersDeclaration: {
  46897. name: string;
  46898. shader: string;
  46899. };
  46900. }
  46901. declare module BABYLON {
  46902. /** @hidden */
  46903. export var pbrHelperFunctions: {
  46904. name: string;
  46905. shader: string;
  46906. };
  46907. }
  46908. declare module BABYLON {
  46909. /** @hidden */
  46910. export var harmonicsFunctions: {
  46911. name: string;
  46912. shader: string;
  46913. };
  46914. }
  46915. declare module BABYLON {
  46916. /** @hidden */
  46917. export var pbrDirectLightingSetupFunctions: {
  46918. name: string;
  46919. shader: string;
  46920. };
  46921. }
  46922. declare module BABYLON {
  46923. /** @hidden */
  46924. export var pbrDirectLightingFalloffFunctions: {
  46925. name: string;
  46926. shader: string;
  46927. };
  46928. }
  46929. declare module BABYLON {
  46930. /** @hidden */
  46931. export var pbrBRDFFunctions: {
  46932. name: string;
  46933. shader: string;
  46934. };
  46935. }
  46936. declare module BABYLON {
  46937. /** @hidden */
  46938. export var pbrDirectLightingFunctions: {
  46939. name: string;
  46940. shader: string;
  46941. };
  46942. }
  46943. declare module BABYLON {
  46944. /** @hidden */
  46945. export var pbrIBLFunctions: {
  46946. name: string;
  46947. shader: string;
  46948. };
  46949. }
  46950. declare module BABYLON {
  46951. /** @hidden */
  46952. export var pbrDebug: {
  46953. name: string;
  46954. shader: string;
  46955. };
  46956. }
  46957. declare module BABYLON {
  46958. /** @hidden */
  46959. export var pbrPixelShader: {
  46960. name: string;
  46961. shader: string;
  46962. };
  46963. }
  46964. declare module BABYLON {
  46965. /** @hidden */
  46966. export var pbrVertexDeclaration: {
  46967. name: string;
  46968. shader: string;
  46969. };
  46970. }
  46971. declare module BABYLON {
  46972. /** @hidden */
  46973. export var pbrVertexShader: {
  46974. name: string;
  46975. shader: string;
  46976. };
  46977. }
  46978. declare module BABYLON {
  46979. /**
  46980. * Manages the defines for the PBR Material.
  46981. * @hidden
  46982. */
  46983. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46984. PBR: boolean;
  46985. MAINUV1: boolean;
  46986. MAINUV2: boolean;
  46987. UV1: boolean;
  46988. UV2: boolean;
  46989. ALBEDO: boolean;
  46990. ALBEDODIRECTUV: number;
  46991. VERTEXCOLOR: boolean;
  46992. AMBIENT: boolean;
  46993. AMBIENTDIRECTUV: number;
  46994. AMBIENTINGRAYSCALE: boolean;
  46995. OPACITY: boolean;
  46996. VERTEXALPHA: boolean;
  46997. OPACITYDIRECTUV: number;
  46998. OPACITYRGB: boolean;
  46999. ALPHATEST: boolean;
  47000. DEPTHPREPASS: boolean;
  47001. ALPHABLEND: boolean;
  47002. ALPHAFROMALBEDO: boolean;
  47003. ALPHATESTVALUE: string;
  47004. SPECULAROVERALPHA: boolean;
  47005. RADIANCEOVERALPHA: boolean;
  47006. ALPHAFRESNEL: boolean;
  47007. LINEARALPHAFRESNEL: boolean;
  47008. PREMULTIPLYALPHA: boolean;
  47009. EMISSIVE: boolean;
  47010. EMISSIVEDIRECTUV: number;
  47011. REFLECTIVITY: boolean;
  47012. REFLECTIVITYDIRECTUV: number;
  47013. SPECULARTERM: boolean;
  47014. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47015. MICROSURFACEAUTOMATIC: boolean;
  47016. LODBASEDMICROSFURACE: boolean;
  47017. MICROSURFACEMAP: boolean;
  47018. MICROSURFACEMAPDIRECTUV: number;
  47019. METALLICWORKFLOW: boolean;
  47020. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47021. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47022. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47023. AOSTOREINMETALMAPRED: boolean;
  47024. ENVIRONMENTBRDF: boolean;
  47025. ENVIRONMENTBRDF_RGBD: boolean;
  47026. NORMAL: boolean;
  47027. TANGENT: boolean;
  47028. BUMP: boolean;
  47029. BUMPDIRECTUV: number;
  47030. OBJECTSPACE_NORMALMAP: boolean;
  47031. PARALLAX: boolean;
  47032. PARALLAXOCCLUSION: boolean;
  47033. NORMALXYSCALE: boolean;
  47034. LIGHTMAP: boolean;
  47035. LIGHTMAPDIRECTUV: number;
  47036. USELIGHTMAPASSHADOWMAP: boolean;
  47037. GAMMALIGHTMAP: boolean;
  47038. RGBDLIGHTMAP: boolean;
  47039. REFLECTION: boolean;
  47040. REFLECTIONMAP_3D: boolean;
  47041. REFLECTIONMAP_SPHERICAL: boolean;
  47042. REFLECTIONMAP_PLANAR: boolean;
  47043. REFLECTIONMAP_CUBIC: boolean;
  47044. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47045. REFLECTIONMAP_PROJECTION: boolean;
  47046. REFLECTIONMAP_SKYBOX: boolean;
  47047. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47048. REFLECTIONMAP_EXPLICIT: boolean;
  47049. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47050. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47051. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47052. INVERTCUBICMAP: boolean;
  47053. USESPHERICALFROMREFLECTIONMAP: boolean;
  47054. USEIRRADIANCEMAP: boolean;
  47055. SPHERICAL_HARMONICS: boolean;
  47056. USESPHERICALINVERTEX: boolean;
  47057. REFLECTIONMAP_OPPOSITEZ: boolean;
  47058. LODINREFLECTIONALPHA: boolean;
  47059. GAMMAREFLECTION: boolean;
  47060. RGBDREFLECTION: boolean;
  47061. LINEARSPECULARREFLECTION: boolean;
  47062. RADIANCEOCCLUSION: boolean;
  47063. HORIZONOCCLUSION: boolean;
  47064. INSTANCES: boolean;
  47065. NUM_BONE_INFLUENCERS: number;
  47066. BonesPerMesh: number;
  47067. BONETEXTURE: boolean;
  47068. NONUNIFORMSCALING: boolean;
  47069. MORPHTARGETS: boolean;
  47070. MORPHTARGETS_NORMAL: boolean;
  47071. MORPHTARGETS_TANGENT: boolean;
  47072. MORPHTARGETS_UV: boolean;
  47073. NUM_MORPH_INFLUENCERS: number;
  47074. IMAGEPROCESSING: boolean;
  47075. VIGNETTE: boolean;
  47076. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47077. VIGNETTEBLENDMODEOPAQUE: boolean;
  47078. TONEMAPPING: boolean;
  47079. TONEMAPPING_ACES: boolean;
  47080. CONTRAST: boolean;
  47081. COLORCURVES: boolean;
  47082. COLORGRADING: boolean;
  47083. COLORGRADING3D: boolean;
  47084. SAMPLER3DGREENDEPTH: boolean;
  47085. SAMPLER3DBGRMAP: boolean;
  47086. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47087. EXPOSURE: boolean;
  47088. MULTIVIEW: boolean;
  47089. USEPHYSICALLIGHTFALLOFF: boolean;
  47090. USEGLTFLIGHTFALLOFF: boolean;
  47091. TWOSIDEDLIGHTING: boolean;
  47092. SHADOWFLOAT: boolean;
  47093. CLIPPLANE: boolean;
  47094. CLIPPLANE2: boolean;
  47095. CLIPPLANE3: boolean;
  47096. CLIPPLANE4: boolean;
  47097. POINTSIZE: boolean;
  47098. FOG: boolean;
  47099. LOGARITHMICDEPTH: boolean;
  47100. FORCENORMALFORWARD: boolean;
  47101. SPECULARAA: boolean;
  47102. CLEARCOAT: boolean;
  47103. CLEARCOAT_DEFAULTIOR: boolean;
  47104. CLEARCOAT_TEXTURE: boolean;
  47105. CLEARCOAT_TEXTUREDIRECTUV: number;
  47106. CLEARCOAT_BUMP: boolean;
  47107. CLEARCOAT_BUMPDIRECTUV: number;
  47108. CLEARCOAT_TINT: boolean;
  47109. CLEARCOAT_TINT_TEXTURE: boolean;
  47110. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47111. ANISOTROPIC: boolean;
  47112. ANISOTROPIC_TEXTURE: boolean;
  47113. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47114. BRDF_V_HEIGHT_CORRELATED: boolean;
  47115. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47116. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47117. SHEEN: boolean;
  47118. SHEEN_TEXTURE: boolean;
  47119. SHEEN_TEXTUREDIRECTUV: number;
  47120. SHEEN_LINKWITHALBEDO: boolean;
  47121. SUBSURFACE: boolean;
  47122. SS_REFRACTION: boolean;
  47123. SS_TRANSLUCENCY: boolean;
  47124. SS_SCATERRING: boolean;
  47125. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47126. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47127. SS_REFRACTIONMAP_3D: boolean;
  47128. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47129. SS_LODINREFRACTIONALPHA: boolean;
  47130. SS_GAMMAREFRACTION: boolean;
  47131. SS_RGBDREFRACTION: boolean;
  47132. SS_LINEARSPECULARREFRACTION: boolean;
  47133. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47134. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47135. UNLIT: boolean;
  47136. DEBUGMODE: number;
  47137. /**
  47138. * Initializes the PBR Material defines.
  47139. */
  47140. constructor();
  47141. /**
  47142. * Resets the PBR Material defines.
  47143. */
  47144. reset(): void;
  47145. }
  47146. /**
  47147. * The Physically based material base class of BJS.
  47148. *
  47149. * This offers the main features of a standard PBR material.
  47150. * For more information, please refer to the documentation :
  47151. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47152. */
  47153. export abstract class PBRBaseMaterial extends PushMaterial {
  47154. /**
  47155. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47156. */
  47157. static readonly PBRMATERIAL_OPAQUE: number;
  47158. /**
  47159. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47160. */
  47161. static readonly PBRMATERIAL_ALPHATEST: number;
  47162. /**
  47163. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47164. */
  47165. static readonly PBRMATERIAL_ALPHABLEND: number;
  47166. /**
  47167. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47168. * They are also discarded below the alpha cutoff threshold to improve performances.
  47169. */
  47170. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47171. /**
  47172. * Defines the default value of how much AO map is occluding the analytical lights
  47173. * (point spot...).
  47174. */
  47175. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47176. /**
  47177. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47178. */
  47179. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47180. /**
  47181. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47182. * to enhance interoperability with other engines.
  47183. */
  47184. static readonly LIGHTFALLOFF_GLTF: number;
  47185. /**
  47186. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47187. * to enhance interoperability with other materials.
  47188. */
  47189. static readonly LIGHTFALLOFF_STANDARD: number;
  47190. /**
  47191. * Intensity of the direct lights e.g. the four lights available in your scene.
  47192. * This impacts both the direct diffuse and specular highlights.
  47193. */
  47194. protected _directIntensity: number;
  47195. /**
  47196. * Intensity of the emissive part of the material.
  47197. * This helps controlling the emissive effect without modifying the emissive color.
  47198. */
  47199. protected _emissiveIntensity: number;
  47200. /**
  47201. * Intensity of the environment e.g. how much the environment will light the object
  47202. * either through harmonics for rough material or through the refelction for shiny ones.
  47203. */
  47204. protected _environmentIntensity: number;
  47205. /**
  47206. * This is a special control allowing the reduction of the specular highlights coming from the
  47207. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47208. */
  47209. protected _specularIntensity: number;
  47210. /**
  47211. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47212. */
  47213. private _lightingInfos;
  47214. /**
  47215. * Debug Control allowing disabling the bump map on this material.
  47216. */
  47217. protected _disableBumpMap: boolean;
  47218. /**
  47219. * AKA Diffuse Texture in standard nomenclature.
  47220. */
  47221. protected _albedoTexture: Nullable<BaseTexture>;
  47222. /**
  47223. * AKA Occlusion Texture in other nomenclature.
  47224. */
  47225. protected _ambientTexture: Nullable<BaseTexture>;
  47226. /**
  47227. * AKA Occlusion Texture Intensity in other nomenclature.
  47228. */
  47229. protected _ambientTextureStrength: number;
  47230. /**
  47231. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47232. * 1 means it completely occludes it
  47233. * 0 mean it has no impact
  47234. */
  47235. protected _ambientTextureImpactOnAnalyticalLights: number;
  47236. /**
  47237. * Stores the alpha values in a texture.
  47238. */
  47239. protected _opacityTexture: Nullable<BaseTexture>;
  47240. /**
  47241. * Stores the reflection values in a texture.
  47242. */
  47243. protected _reflectionTexture: Nullable<BaseTexture>;
  47244. /**
  47245. * Stores the emissive values in a texture.
  47246. */
  47247. protected _emissiveTexture: Nullable<BaseTexture>;
  47248. /**
  47249. * AKA Specular texture in other nomenclature.
  47250. */
  47251. protected _reflectivityTexture: Nullable<BaseTexture>;
  47252. /**
  47253. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47254. */
  47255. protected _metallicTexture: Nullable<BaseTexture>;
  47256. /**
  47257. * Specifies the metallic scalar of the metallic/roughness workflow.
  47258. * Can also be used to scale the metalness values of the metallic texture.
  47259. */
  47260. protected _metallic: Nullable<number>;
  47261. /**
  47262. * Specifies the roughness scalar of the metallic/roughness workflow.
  47263. * Can also be used to scale the roughness values of the metallic texture.
  47264. */
  47265. protected _roughness: Nullable<number>;
  47266. /**
  47267. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47268. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47269. */
  47270. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47271. /**
  47272. * Stores surface normal data used to displace a mesh in a texture.
  47273. */
  47274. protected _bumpTexture: Nullable<BaseTexture>;
  47275. /**
  47276. * Stores the pre-calculated light information of a mesh in a texture.
  47277. */
  47278. protected _lightmapTexture: Nullable<BaseTexture>;
  47279. /**
  47280. * The color of a material in ambient lighting.
  47281. */
  47282. protected _ambientColor: Color3;
  47283. /**
  47284. * AKA Diffuse Color in other nomenclature.
  47285. */
  47286. protected _albedoColor: Color3;
  47287. /**
  47288. * AKA Specular Color in other nomenclature.
  47289. */
  47290. protected _reflectivityColor: Color3;
  47291. /**
  47292. * The color applied when light is reflected from a material.
  47293. */
  47294. protected _reflectionColor: Color3;
  47295. /**
  47296. * The color applied when light is emitted from a material.
  47297. */
  47298. protected _emissiveColor: Color3;
  47299. /**
  47300. * AKA Glossiness in other nomenclature.
  47301. */
  47302. protected _microSurface: number;
  47303. /**
  47304. * Specifies that the material will use the light map as a show map.
  47305. */
  47306. protected _useLightmapAsShadowmap: boolean;
  47307. /**
  47308. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47309. * makes the reflect vector face the model (under horizon).
  47310. */
  47311. protected _useHorizonOcclusion: boolean;
  47312. /**
  47313. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47314. * too much the area relying on ambient texture to define their ambient occlusion.
  47315. */
  47316. protected _useRadianceOcclusion: boolean;
  47317. /**
  47318. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47319. */
  47320. protected _useAlphaFromAlbedoTexture: boolean;
  47321. /**
  47322. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47323. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47324. */
  47325. protected _useSpecularOverAlpha: boolean;
  47326. /**
  47327. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47328. */
  47329. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47330. /**
  47331. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47332. */
  47333. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47334. /**
  47335. * Specifies if the metallic texture contains the roughness information in its green channel.
  47336. */
  47337. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47338. /**
  47339. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47340. */
  47341. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47342. /**
  47343. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47344. */
  47345. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47346. /**
  47347. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47348. */
  47349. protected _useAmbientInGrayScale: boolean;
  47350. /**
  47351. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47352. * The material will try to infer what glossiness each pixel should be.
  47353. */
  47354. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47355. /**
  47356. * Defines the falloff type used in this material.
  47357. * It by default is Physical.
  47358. */
  47359. protected _lightFalloff: number;
  47360. /**
  47361. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47362. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47363. */
  47364. protected _useRadianceOverAlpha: boolean;
  47365. /**
  47366. * Allows using an object space normal map (instead of tangent space).
  47367. */
  47368. protected _useObjectSpaceNormalMap: boolean;
  47369. /**
  47370. * Allows using the bump map in parallax mode.
  47371. */
  47372. protected _useParallax: boolean;
  47373. /**
  47374. * Allows using the bump map in parallax occlusion mode.
  47375. */
  47376. protected _useParallaxOcclusion: boolean;
  47377. /**
  47378. * Controls the scale bias of the parallax mode.
  47379. */
  47380. protected _parallaxScaleBias: number;
  47381. /**
  47382. * If sets to true, disables all the lights affecting the material.
  47383. */
  47384. protected _disableLighting: boolean;
  47385. /**
  47386. * Number of Simultaneous lights allowed on the material.
  47387. */
  47388. protected _maxSimultaneousLights: number;
  47389. /**
  47390. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47391. */
  47392. protected _invertNormalMapX: boolean;
  47393. /**
  47394. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47395. */
  47396. protected _invertNormalMapY: boolean;
  47397. /**
  47398. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47399. */
  47400. protected _twoSidedLighting: boolean;
  47401. /**
  47402. * Defines the alpha limits in alpha test mode.
  47403. */
  47404. protected _alphaCutOff: number;
  47405. /**
  47406. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47407. */
  47408. protected _forceAlphaTest: boolean;
  47409. /**
  47410. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47411. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47412. */
  47413. protected _useAlphaFresnel: boolean;
  47414. /**
  47415. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47416. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47417. */
  47418. protected _useLinearAlphaFresnel: boolean;
  47419. /**
  47420. * The transparency mode of the material.
  47421. */
  47422. protected _transparencyMode: Nullable<number>;
  47423. /**
  47424. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47425. * from cos thetav and roughness:
  47426. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47427. */
  47428. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47429. /**
  47430. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47431. */
  47432. protected _forceIrradianceInFragment: boolean;
  47433. /**
  47434. * Force normal to face away from face.
  47435. */
  47436. protected _forceNormalForward: boolean;
  47437. /**
  47438. * Enables specular anti aliasing in the PBR shader.
  47439. * It will both interacts on the Geometry for analytical and IBL lighting.
  47440. * It also prefilter the roughness map based on the bump values.
  47441. */
  47442. protected _enableSpecularAntiAliasing: boolean;
  47443. /**
  47444. * Default configuration related to image processing available in the PBR Material.
  47445. */
  47446. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47447. /**
  47448. * Keep track of the image processing observer to allow dispose and replace.
  47449. */
  47450. private _imageProcessingObserver;
  47451. /**
  47452. * Attaches a new image processing configuration to the PBR Material.
  47453. * @param configuration
  47454. */
  47455. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47456. /**
  47457. * Stores the available render targets.
  47458. */
  47459. private _renderTargets;
  47460. /**
  47461. * Sets the global ambient color for the material used in lighting calculations.
  47462. */
  47463. private _globalAmbientColor;
  47464. /**
  47465. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47466. */
  47467. private _useLogarithmicDepth;
  47468. /**
  47469. * If set to true, no lighting calculations will be applied.
  47470. */
  47471. private _unlit;
  47472. private _debugMode;
  47473. /**
  47474. * @hidden
  47475. * This is reserved for the inspector.
  47476. * Defines the material debug mode.
  47477. * It helps seeing only some components of the material while troubleshooting.
  47478. */
  47479. debugMode: number;
  47480. /**
  47481. * @hidden
  47482. * This is reserved for the inspector.
  47483. * Specify from where on screen the debug mode should start.
  47484. * The value goes from -1 (full screen) to 1 (not visible)
  47485. * It helps with side by side comparison against the final render
  47486. * This defaults to -1
  47487. */
  47488. private debugLimit;
  47489. /**
  47490. * @hidden
  47491. * This is reserved for the inspector.
  47492. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47493. * You can use the factor to better multiply the final value.
  47494. */
  47495. private debugFactor;
  47496. /**
  47497. * Defines the clear coat layer parameters for the material.
  47498. */
  47499. readonly clearCoat: PBRClearCoatConfiguration;
  47500. /**
  47501. * Defines the anisotropic parameters for the material.
  47502. */
  47503. readonly anisotropy: PBRAnisotropicConfiguration;
  47504. /**
  47505. * Defines the BRDF parameters for the material.
  47506. */
  47507. readonly brdf: PBRBRDFConfiguration;
  47508. /**
  47509. * Defines the Sheen parameters for the material.
  47510. */
  47511. readonly sheen: PBRSheenConfiguration;
  47512. /**
  47513. * Defines the SubSurface parameters for the material.
  47514. */
  47515. readonly subSurface: PBRSubSurfaceConfiguration;
  47516. /**
  47517. * Custom callback helping to override the default shader used in the material.
  47518. */
  47519. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47520. protected _rebuildInParallel: boolean;
  47521. /**
  47522. * Instantiates a new PBRMaterial instance.
  47523. *
  47524. * @param name The material name
  47525. * @param scene The scene the material will be use in.
  47526. */
  47527. constructor(name: string, scene: Scene);
  47528. /**
  47529. * Gets a boolean indicating that current material needs to register RTT
  47530. */
  47531. readonly hasRenderTargetTextures: boolean;
  47532. /**
  47533. * Gets the name of the material class.
  47534. */
  47535. getClassName(): string;
  47536. /**
  47537. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47538. */
  47539. /**
  47540. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47541. */
  47542. useLogarithmicDepth: boolean;
  47543. /**
  47544. * Gets the current transparency mode.
  47545. */
  47546. /**
  47547. * Sets the transparency mode of the material.
  47548. *
  47549. * | Value | Type | Description |
  47550. * | ----- | ----------------------------------- | ----------- |
  47551. * | 0 | OPAQUE | |
  47552. * | 1 | ALPHATEST | |
  47553. * | 2 | ALPHABLEND | |
  47554. * | 3 | ALPHATESTANDBLEND | |
  47555. *
  47556. */
  47557. transparencyMode: Nullable<number>;
  47558. /**
  47559. * Returns true if alpha blending should be disabled.
  47560. */
  47561. private readonly _disableAlphaBlending;
  47562. /**
  47563. * Specifies whether or not this material should be rendered in alpha blend mode.
  47564. */
  47565. needAlphaBlending(): boolean;
  47566. /**
  47567. * Specifies if the mesh will require alpha blending.
  47568. * @param mesh - BJS mesh.
  47569. */
  47570. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47571. /**
  47572. * Specifies whether or not this material should be rendered in alpha test mode.
  47573. */
  47574. needAlphaTesting(): boolean;
  47575. /**
  47576. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47577. */
  47578. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47579. /**
  47580. * Gets the texture used for the alpha test.
  47581. */
  47582. getAlphaTestTexture(): Nullable<BaseTexture>;
  47583. /**
  47584. * Specifies that the submesh is ready to be used.
  47585. * @param mesh - BJS mesh.
  47586. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47587. * @param useInstances - Specifies that instances should be used.
  47588. * @returns - boolean indicating that the submesh is ready or not.
  47589. */
  47590. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47591. /**
  47592. * Specifies if the material uses metallic roughness workflow.
  47593. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47594. */
  47595. isMetallicWorkflow(): boolean;
  47596. private _prepareEffect;
  47597. private _prepareDefines;
  47598. /**
  47599. * Force shader compilation
  47600. */
  47601. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47602. clipPlane: boolean;
  47603. }>): void;
  47604. /**
  47605. * Initializes the uniform buffer layout for the shader.
  47606. */
  47607. buildUniformLayout(): void;
  47608. /**
  47609. * Unbinds the material from the mesh
  47610. */
  47611. unbind(): void;
  47612. /**
  47613. * Binds the submesh data.
  47614. * @param world - The world matrix.
  47615. * @param mesh - The BJS mesh.
  47616. * @param subMesh - A submesh of the BJS mesh.
  47617. */
  47618. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47619. /**
  47620. * Returns the animatable textures.
  47621. * @returns - Array of animatable textures.
  47622. */
  47623. getAnimatables(): IAnimatable[];
  47624. /**
  47625. * Returns the texture used for reflections.
  47626. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47627. */
  47628. private _getReflectionTexture;
  47629. /**
  47630. * Returns an array of the actively used textures.
  47631. * @returns - Array of BaseTextures
  47632. */
  47633. getActiveTextures(): BaseTexture[];
  47634. /**
  47635. * Checks to see if a texture is used in the material.
  47636. * @param texture - Base texture to use.
  47637. * @returns - Boolean specifying if a texture is used in the material.
  47638. */
  47639. hasTexture(texture: BaseTexture): boolean;
  47640. /**
  47641. * Disposes the resources of the material.
  47642. * @param forceDisposeEffect - Forces the disposal of effects.
  47643. * @param forceDisposeTextures - Forces the disposal of all textures.
  47644. */
  47645. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47646. }
  47647. }
  47648. declare module BABYLON {
  47649. /**
  47650. * The Physically based material of BJS.
  47651. *
  47652. * This offers the main features of a standard PBR material.
  47653. * For more information, please refer to the documentation :
  47654. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47655. */
  47656. export class PBRMaterial extends PBRBaseMaterial {
  47657. /**
  47658. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47659. */
  47660. static readonly PBRMATERIAL_OPAQUE: number;
  47661. /**
  47662. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47663. */
  47664. static readonly PBRMATERIAL_ALPHATEST: number;
  47665. /**
  47666. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47667. */
  47668. static readonly PBRMATERIAL_ALPHABLEND: number;
  47669. /**
  47670. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47671. * They are also discarded below the alpha cutoff threshold to improve performances.
  47672. */
  47673. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47674. /**
  47675. * Defines the default value of how much AO map is occluding the analytical lights
  47676. * (point spot...).
  47677. */
  47678. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47679. /**
  47680. * Intensity of the direct lights e.g. the four lights available in your scene.
  47681. * This impacts both the direct diffuse and specular highlights.
  47682. */
  47683. directIntensity: number;
  47684. /**
  47685. * Intensity of the emissive part of the material.
  47686. * This helps controlling the emissive effect without modifying the emissive color.
  47687. */
  47688. emissiveIntensity: number;
  47689. /**
  47690. * Intensity of the environment e.g. how much the environment will light the object
  47691. * either through harmonics for rough material or through the refelction for shiny ones.
  47692. */
  47693. environmentIntensity: number;
  47694. /**
  47695. * This is a special control allowing the reduction of the specular highlights coming from the
  47696. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47697. */
  47698. specularIntensity: number;
  47699. /**
  47700. * Debug Control allowing disabling the bump map on this material.
  47701. */
  47702. disableBumpMap: boolean;
  47703. /**
  47704. * AKA Diffuse Texture in standard nomenclature.
  47705. */
  47706. albedoTexture: BaseTexture;
  47707. /**
  47708. * AKA Occlusion Texture in other nomenclature.
  47709. */
  47710. ambientTexture: BaseTexture;
  47711. /**
  47712. * AKA Occlusion Texture Intensity in other nomenclature.
  47713. */
  47714. ambientTextureStrength: number;
  47715. /**
  47716. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47717. * 1 means it completely occludes it
  47718. * 0 mean it has no impact
  47719. */
  47720. ambientTextureImpactOnAnalyticalLights: number;
  47721. /**
  47722. * Stores the alpha values in a texture.
  47723. */
  47724. opacityTexture: BaseTexture;
  47725. /**
  47726. * Stores the reflection values in a texture.
  47727. */
  47728. reflectionTexture: Nullable<BaseTexture>;
  47729. /**
  47730. * Stores the emissive values in a texture.
  47731. */
  47732. emissiveTexture: BaseTexture;
  47733. /**
  47734. * AKA Specular texture in other nomenclature.
  47735. */
  47736. reflectivityTexture: BaseTexture;
  47737. /**
  47738. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47739. */
  47740. metallicTexture: BaseTexture;
  47741. /**
  47742. * Specifies the metallic scalar of the metallic/roughness workflow.
  47743. * Can also be used to scale the metalness values of the metallic texture.
  47744. */
  47745. metallic: Nullable<number>;
  47746. /**
  47747. * Specifies the roughness scalar of the metallic/roughness workflow.
  47748. * Can also be used to scale the roughness values of the metallic texture.
  47749. */
  47750. roughness: Nullable<number>;
  47751. /**
  47752. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47753. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47754. */
  47755. microSurfaceTexture: BaseTexture;
  47756. /**
  47757. * Stores surface normal data used to displace a mesh in a texture.
  47758. */
  47759. bumpTexture: BaseTexture;
  47760. /**
  47761. * Stores the pre-calculated light information of a mesh in a texture.
  47762. */
  47763. lightmapTexture: BaseTexture;
  47764. /**
  47765. * Stores the refracted light information in a texture.
  47766. */
  47767. refractionTexture: Nullable<BaseTexture>;
  47768. /**
  47769. * The color of a material in ambient lighting.
  47770. */
  47771. ambientColor: Color3;
  47772. /**
  47773. * AKA Diffuse Color in other nomenclature.
  47774. */
  47775. albedoColor: Color3;
  47776. /**
  47777. * AKA Specular Color in other nomenclature.
  47778. */
  47779. reflectivityColor: Color3;
  47780. /**
  47781. * The color reflected from the material.
  47782. */
  47783. reflectionColor: Color3;
  47784. /**
  47785. * The color emitted from the material.
  47786. */
  47787. emissiveColor: Color3;
  47788. /**
  47789. * AKA Glossiness in other nomenclature.
  47790. */
  47791. microSurface: number;
  47792. /**
  47793. * source material index of refraction (IOR)' / 'destination material IOR.
  47794. */
  47795. indexOfRefraction: number;
  47796. /**
  47797. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47798. */
  47799. invertRefractionY: boolean;
  47800. /**
  47801. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47802. * Materials half opaque for instance using refraction could benefit from this control.
  47803. */
  47804. linkRefractionWithTransparency: boolean;
  47805. /**
  47806. * If true, the light map contains occlusion information instead of lighting info.
  47807. */
  47808. useLightmapAsShadowmap: boolean;
  47809. /**
  47810. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47811. */
  47812. useAlphaFromAlbedoTexture: boolean;
  47813. /**
  47814. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47815. */
  47816. forceAlphaTest: boolean;
  47817. /**
  47818. * Defines the alpha limits in alpha test mode.
  47819. */
  47820. alphaCutOff: number;
  47821. /**
  47822. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47823. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47824. */
  47825. useSpecularOverAlpha: boolean;
  47826. /**
  47827. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47828. */
  47829. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47830. /**
  47831. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47832. */
  47833. useRoughnessFromMetallicTextureAlpha: boolean;
  47834. /**
  47835. * Specifies if the metallic texture contains the roughness information in its green channel.
  47836. */
  47837. useRoughnessFromMetallicTextureGreen: boolean;
  47838. /**
  47839. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47840. */
  47841. useMetallnessFromMetallicTextureBlue: boolean;
  47842. /**
  47843. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47844. */
  47845. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47846. /**
  47847. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47848. */
  47849. useAmbientInGrayScale: boolean;
  47850. /**
  47851. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47852. * The material will try to infer what glossiness each pixel should be.
  47853. */
  47854. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47855. /**
  47856. * BJS is using an harcoded light falloff based on a manually sets up range.
  47857. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47858. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47859. */
  47860. /**
  47861. * BJS is using an harcoded light falloff based on a manually sets up range.
  47862. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47863. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47864. */
  47865. usePhysicalLightFalloff: boolean;
  47866. /**
  47867. * In order to support the falloff compatibility with gltf, a special mode has been added
  47868. * to reproduce the gltf light falloff.
  47869. */
  47870. /**
  47871. * In order to support the falloff compatibility with gltf, a special mode has been added
  47872. * to reproduce the gltf light falloff.
  47873. */
  47874. useGLTFLightFalloff: boolean;
  47875. /**
  47876. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47877. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47878. */
  47879. useRadianceOverAlpha: boolean;
  47880. /**
  47881. * Allows using an object space normal map (instead of tangent space).
  47882. */
  47883. useObjectSpaceNormalMap: boolean;
  47884. /**
  47885. * Allows using the bump map in parallax mode.
  47886. */
  47887. useParallax: boolean;
  47888. /**
  47889. * Allows using the bump map in parallax occlusion mode.
  47890. */
  47891. useParallaxOcclusion: boolean;
  47892. /**
  47893. * Controls the scale bias of the parallax mode.
  47894. */
  47895. parallaxScaleBias: number;
  47896. /**
  47897. * If sets to true, disables all the lights affecting the material.
  47898. */
  47899. disableLighting: boolean;
  47900. /**
  47901. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47902. */
  47903. forceIrradianceInFragment: boolean;
  47904. /**
  47905. * Number of Simultaneous lights allowed on the material.
  47906. */
  47907. maxSimultaneousLights: number;
  47908. /**
  47909. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47910. */
  47911. invertNormalMapX: boolean;
  47912. /**
  47913. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47914. */
  47915. invertNormalMapY: boolean;
  47916. /**
  47917. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47918. */
  47919. twoSidedLighting: boolean;
  47920. /**
  47921. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47922. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47923. */
  47924. useAlphaFresnel: boolean;
  47925. /**
  47926. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47927. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47928. */
  47929. useLinearAlphaFresnel: boolean;
  47930. /**
  47931. * Let user defines the brdf lookup texture used for IBL.
  47932. * A default 8bit version is embedded but you could point at :
  47933. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47934. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47935. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47936. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47937. */
  47938. environmentBRDFTexture: Nullable<BaseTexture>;
  47939. /**
  47940. * Force normal to face away from face.
  47941. */
  47942. forceNormalForward: boolean;
  47943. /**
  47944. * Enables specular anti aliasing in the PBR shader.
  47945. * It will both interacts on the Geometry for analytical and IBL lighting.
  47946. * It also prefilter the roughness map based on the bump values.
  47947. */
  47948. enableSpecularAntiAliasing: boolean;
  47949. /**
  47950. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47951. * makes the reflect vector face the model (under horizon).
  47952. */
  47953. useHorizonOcclusion: boolean;
  47954. /**
  47955. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47956. * too much the area relying on ambient texture to define their ambient occlusion.
  47957. */
  47958. useRadianceOcclusion: boolean;
  47959. /**
  47960. * If set to true, no lighting calculations will be applied.
  47961. */
  47962. unlit: boolean;
  47963. /**
  47964. * Gets the image processing configuration used either in this material.
  47965. */
  47966. /**
  47967. * Sets the Default image processing configuration used either in the this material.
  47968. *
  47969. * If sets to null, the scene one is in use.
  47970. */
  47971. imageProcessingConfiguration: ImageProcessingConfiguration;
  47972. /**
  47973. * Gets wether the color curves effect is enabled.
  47974. */
  47975. /**
  47976. * Sets wether the color curves effect is enabled.
  47977. */
  47978. cameraColorCurvesEnabled: boolean;
  47979. /**
  47980. * Gets wether the color grading effect is enabled.
  47981. */
  47982. /**
  47983. * Gets wether the color grading effect is enabled.
  47984. */
  47985. cameraColorGradingEnabled: boolean;
  47986. /**
  47987. * Gets wether tonemapping is enabled or not.
  47988. */
  47989. /**
  47990. * Sets wether tonemapping is enabled or not
  47991. */
  47992. cameraToneMappingEnabled: boolean;
  47993. /**
  47994. * The camera exposure used on this material.
  47995. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47996. * This corresponds to a photographic exposure.
  47997. */
  47998. /**
  47999. * The camera exposure used on this material.
  48000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48001. * This corresponds to a photographic exposure.
  48002. */
  48003. cameraExposure: number;
  48004. /**
  48005. * Gets The camera contrast used on this material.
  48006. */
  48007. /**
  48008. * Sets The camera contrast used on this material.
  48009. */
  48010. cameraContrast: number;
  48011. /**
  48012. * Gets the Color Grading 2D Lookup Texture.
  48013. */
  48014. /**
  48015. * Sets the Color Grading 2D Lookup Texture.
  48016. */
  48017. cameraColorGradingTexture: Nullable<BaseTexture>;
  48018. /**
  48019. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48020. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48021. * 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;
  48022. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48023. */
  48024. /**
  48025. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48026. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48027. * 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;
  48028. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48029. */
  48030. cameraColorCurves: Nullable<ColorCurves>;
  48031. /**
  48032. * Instantiates a new PBRMaterial instance.
  48033. *
  48034. * @param name The material name
  48035. * @param scene The scene the material will be use in.
  48036. */
  48037. constructor(name: string, scene: Scene);
  48038. /**
  48039. * Returns the name of this material class.
  48040. */
  48041. getClassName(): string;
  48042. /**
  48043. * Makes a duplicate of the current material.
  48044. * @param name - name to use for the new material.
  48045. */
  48046. clone(name: string): PBRMaterial;
  48047. /**
  48048. * Serializes this PBR Material.
  48049. * @returns - An object with the serialized material.
  48050. */
  48051. serialize(): any;
  48052. /**
  48053. * Parses a PBR Material from a serialized object.
  48054. * @param source - Serialized object.
  48055. * @param scene - BJS scene instance.
  48056. * @param rootUrl - url for the scene object
  48057. * @returns - PBRMaterial
  48058. */
  48059. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48060. }
  48061. }
  48062. declare module BABYLON {
  48063. /**
  48064. * Direct draw surface info
  48065. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48066. */
  48067. export interface DDSInfo {
  48068. /**
  48069. * Width of the texture
  48070. */
  48071. width: number;
  48072. /**
  48073. * Width of the texture
  48074. */
  48075. height: number;
  48076. /**
  48077. * Number of Mipmaps for the texture
  48078. * @see https://en.wikipedia.org/wiki/Mipmap
  48079. */
  48080. mipmapCount: number;
  48081. /**
  48082. * If the textures format is a known fourCC format
  48083. * @see https://www.fourcc.org/
  48084. */
  48085. isFourCC: boolean;
  48086. /**
  48087. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48088. */
  48089. isRGB: boolean;
  48090. /**
  48091. * If the texture is a lumincance format
  48092. */
  48093. isLuminance: boolean;
  48094. /**
  48095. * If this is a cube texture
  48096. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48097. */
  48098. isCube: boolean;
  48099. /**
  48100. * If the texture is a compressed format eg. FOURCC_DXT1
  48101. */
  48102. isCompressed: boolean;
  48103. /**
  48104. * The dxgiFormat of the texture
  48105. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48106. */
  48107. dxgiFormat: number;
  48108. /**
  48109. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48110. */
  48111. textureType: number;
  48112. /**
  48113. * Sphericle polynomial created for the dds texture
  48114. */
  48115. sphericalPolynomial?: SphericalPolynomial;
  48116. }
  48117. /**
  48118. * Class used to provide DDS decompression tools
  48119. */
  48120. export class DDSTools {
  48121. /**
  48122. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48123. */
  48124. static StoreLODInAlphaChannel: boolean;
  48125. /**
  48126. * Gets DDS information from an array buffer
  48127. * @param arrayBuffer defines the array buffer to read data from
  48128. * @returns the DDS information
  48129. */
  48130. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48131. private static _FloatView;
  48132. private static _Int32View;
  48133. private static _ToHalfFloat;
  48134. private static _FromHalfFloat;
  48135. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48136. private static _GetHalfFloatRGBAArrayBuffer;
  48137. private static _GetFloatRGBAArrayBuffer;
  48138. private static _GetFloatAsUIntRGBAArrayBuffer;
  48139. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48140. private static _GetRGBAArrayBuffer;
  48141. private static _ExtractLongWordOrder;
  48142. private static _GetRGBArrayBuffer;
  48143. private static _GetLuminanceArrayBuffer;
  48144. /**
  48145. * Uploads DDS Levels to a Babylon Texture
  48146. * @hidden
  48147. */
  48148. static UploadDDSLevels(engine: BaseEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48149. }
  48150. interface BaseEngine {
  48151. /**
  48152. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48153. * @param rootUrl defines the url where the file to load is located
  48154. * @param scene defines the current scene
  48155. * @param lodScale defines scale to apply to the mip map selection
  48156. * @param lodOffset defines offset to apply to the mip map selection
  48157. * @param onLoad defines an optional callback raised when the texture is loaded
  48158. * @param onError defines an optional callback raised if there is an issue to load the texture
  48159. * @param format defines the format of the data
  48160. * @param forcedExtension defines the extension to use to pick the right loader
  48161. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48162. * @returns the cube texture as an InternalTexture
  48163. */
  48164. 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;
  48165. }
  48166. }
  48167. declare module BABYLON {
  48168. /**
  48169. * Implementation of the DDS Texture Loader.
  48170. * @hidden
  48171. */
  48172. export class _DDSTextureLoader implements IInternalTextureLoader {
  48173. /**
  48174. * Defines wether the loader supports cascade loading the different faces.
  48175. */
  48176. readonly supportCascades: boolean;
  48177. /**
  48178. * This returns if the loader support the current file information.
  48179. * @param extension defines the file extension of the file being loaded
  48180. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48181. * @param fallback defines the fallback internal texture if any
  48182. * @param isBase64 defines whether the texture is encoded as a base64
  48183. * @param isBuffer defines whether the texture data are stored as a buffer
  48184. * @returns true if the loader can load the specified file
  48185. */
  48186. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48187. /**
  48188. * Transform the url before loading if required.
  48189. * @param rootUrl the url of the texture
  48190. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48191. * @returns the transformed texture
  48192. */
  48193. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48194. /**
  48195. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48196. * @param rootUrl the url of the texture
  48197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48198. * @returns the fallback texture
  48199. */
  48200. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48201. /**
  48202. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48203. * @param data contains the texture data
  48204. * @param texture defines the BabylonJS internal texture
  48205. * @param createPolynomials will be true if polynomials have been requested
  48206. * @param onLoad defines the callback to trigger once the texture is ready
  48207. * @param onError defines the callback to trigger in case of error
  48208. */
  48209. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48210. /**
  48211. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48212. * @param data contains the texture data
  48213. * @param texture defines the BabylonJS internal texture
  48214. * @param callback defines the method to call once ready to upload
  48215. */
  48216. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48217. }
  48218. }
  48219. declare module BABYLON {
  48220. /**
  48221. * Implementation of the ENV Texture Loader.
  48222. * @hidden
  48223. */
  48224. export class _ENVTextureLoader implements IInternalTextureLoader {
  48225. /**
  48226. * Defines wether the loader supports cascade loading the different faces.
  48227. */
  48228. readonly supportCascades: boolean;
  48229. /**
  48230. * This returns if the loader support the current file information.
  48231. * @param extension defines the file extension of the file being loaded
  48232. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48233. * @param fallback defines the fallback internal texture if any
  48234. * @param isBase64 defines whether the texture is encoded as a base64
  48235. * @param isBuffer defines whether the texture data are stored as a buffer
  48236. * @returns true if the loader can load the specified file
  48237. */
  48238. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48239. /**
  48240. * Transform the url before loading if required.
  48241. * @param rootUrl the url of the texture
  48242. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48243. * @returns the transformed texture
  48244. */
  48245. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48246. /**
  48247. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48248. * @param rootUrl the url of the texture
  48249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48250. * @returns the fallback texture
  48251. */
  48252. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48253. /**
  48254. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48255. * @param data contains the texture data
  48256. * @param texture defines the BabylonJS internal texture
  48257. * @param createPolynomials will be true if polynomials have been requested
  48258. * @param onLoad defines the callback to trigger once the texture is ready
  48259. * @param onError defines the callback to trigger in case of error
  48260. */
  48261. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48262. /**
  48263. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48264. * @param data contains the texture data
  48265. * @param texture defines the BabylonJS internal texture
  48266. * @param callback defines the method to call once ready to upload
  48267. */
  48268. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48269. }
  48270. }
  48271. declare module BABYLON {
  48272. /**
  48273. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48274. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48275. */
  48276. export class KhronosTextureContainer {
  48277. /** contents of the KTX container file */
  48278. arrayBuffer: any;
  48279. private static HEADER_LEN;
  48280. private static COMPRESSED_2D;
  48281. private static COMPRESSED_3D;
  48282. private static TEX_2D;
  48283. private static TEX_3D;
  48284. /**
  48285. * Gets the openGL type
  48286. */
  48287. glType: number;
  48288. /**
  48289. * Gets the openGL type size
  48290. */
  48291. glTypeSize: number;
  48292. /**
  48293. * Gets the openGL format
  48294. */
  48295. glFormat: number;
  48296. /**
  48297. * Gets the openGL internal format
  48298. */
  48299. glInternalFormat: number;
  48300. /**
  48301. * Gets the base internal format
  48302. */
  48303. glBaseInternalFormat: number;
  48304. /**
  48305. * Gets image width in pixel
  48306. */
  48307. pixelWidth: number;
  48308. /**
  48309. * Gets image height in pixel
  48310. */
  48311. pixelHeight: number;
  48312. /**
  48313. * Gets image depth in pixels
  48314. */
  48315. pixelDepth: number;
  48316. /**
  48317. * Gets the number of array elements
  48318. */
  48319. numberOfArrayElements: number;
  48320. /**
  48321. * Gets the number of faces
  48322. */
  48323. numberOfFaces: number;
  48324. /**
  48325. * Gets the number of mipmap levels
  48326. */
  48327. numberOfMipmapLevels: number;
  48328. /**
  48329. * Gets the bytes of key value data
  48330. */
  48331. bytesOfKeyValueData: number;
  48332. /**
  48333. * Gets the load type
  48334. */
  48335. loadType: number;
  48336. /**
  48337. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48338. */
  48339. isInvalid: boolean;
  48340. /**
  48341. * Creates a new KhronosTextureContainer
  48342. * @param arrayBuffer contents of the KTX container file
  48343. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48344. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48345. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48346. */
  48347. constructor(
  48348. /** contents of the KTX container file */
  48349. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48350. /**
  48351. * Uploads KTX content to a Babylon Texture.
  48352. * It is assumed that the texture has already been created & is currently bound
  48353. * @hidden
  48354. */
  48355. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48356. private _upload2DCompressedLevels;
  48357. }
  48358. }
  48359. declare module BABYLON {
  48360. /**
  48361. * Implementation of the KTX Texture Loader.
  48362. * @hidden
  48363. */
  48364. export class _KTXTextureLoader implements IInternalTextureLoader {
  48365. /**
  48366. * Defines wether the loader supports cascade loading the different faces.
  48367. */
  48368. readonly supportCascades: boolean;
  48369. /**
  48370. * This returns if the loader support the current file information.
  48371. * @param extension defines the file extension of the file being loaded
  48372. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48373. * @param fallback defines the fallback internal texture if any
  48374. * @param isBase64 defines whether the texture is encoded as a base64
  48375. * @param isBuffer defines whether the texture data are stored as a buffer
  48376. * @returns true if the loader can load the specified file
  48377. */
  48378. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48379. /**
  48380. * Transform the url before loading if required.
  48381. * @param rootUrl the url of the texture
  48382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48383. * @returns the transformed texture
  48384. */
  48385. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48386. /**
  48387. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48388. * @param rootUrl the url of the texture
  48389. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48390. * @returns the fallback texture
  48391. */
  48392. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48393. /**
  48394. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48395. * @param data contains the texture data
  48396. * @param texture defines the BabylonJS internal texture
  48397. * @param createPolynomials will be true if polynomials have been requested
  48398. * @param onLoad defines the callback to trigger once the texture is ready
  48399. * @param onError defines the callback to trigger in case of error
  48400. */
  48401. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48402. /**
  48403. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48404. * @param data contains the texture data
  48405. * @param texture defines the BabylonJS internal texture
  48406. * @param callback defines the method to call once ready to upload
  48407. */
  48408. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48409. }
  48410. }
  48411. declare module BABYLON {
  48412. /**
  48413. * Options for the default xr helper
  48414. */
  48415. export class WebXRDefaultExperienceOptions {
  48416. /**
  48417. * Floor meshes that should be used for teleporting
  48418. */
  48419. floorMeshes: Array<AbstractMesh>;
  48420. }
  48421. /**
  48422. * Default experience which provides a similar setup to the previous webVRExperience
  48423. */
  48424. export class WebXRDefaultExperience {
  48425. /**
  48426. * Base experience
  48427. */
  48428. baseExperience: WebXRExperienceHelper;
  48429. /**
  48430. * Input experience extension
  48431. */
  48432. input: WebXRInput;
  48433. /**
  48434. * Loads the controller models
  48435. */
  48436. controllerModelLoader: WebXRControllerModelLoader;
  48437. /**
  48438. * Enables laser pointer and selection
  48439. */
  48440. pointerSelection: WebXRControllerPointerSelection;
  48441. /**
  48442. * Enables teleportation
  48443. */
  48444. teleportation: WebXRControllerTeleportation;
  48445. /**
  48446. * Enables ui for enetering/exiting xr
  48447. */
  48448. enterExitUI: WebXREnterExitUI;
  48449. /**
  48450. * Default output canvas xr should render to
  48451. */
  48452. outputCanvas: WebXRManagedOutputCanvas;
  48453. /**
  48454. * Creates the default xr experience
  48455. * @param scene scene
  48456. * @param options options for basic configuration
  48457. * @returns resulting WebXRDefaultExperience
  48458. */
  48459. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48460. private constructor();
  48461. /**
  48462. * DIsposes of the experience helper
  48463. */
  48464. dispose(): void;
  48465. }
  48466. }
  48467. declare module BABYLON {
  48468. /** @hidden */
  48469. export var _forceSceneHelpersToBundle: boolean;
  48470. interface Scene {
  48471. /**
  48472. * Creates a default light for the scene.
  48473. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48474. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48475. */
  48476. createDefaultLight(replace?: boolean): void;
  48477. /**
  48478. * Creates a default camera for the scene.
  48479. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48480. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48481. * @param replace has default false, when true replaces the active camera in the scene
  48482. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48483. */
  48484. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48485. /**
  48486. * Creates a default camera and a default light.
  48487. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48488. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48489. * @param replace has the default false, when true replaces the active camera/light in the scene
  48490. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48491. */
  48492. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48493. /**
  48494. * Creates a new sky box
  48495. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48496. * @param environmentTexture defines the texture to use as environment texture
  48497. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48498. * @param scale defines the overall scale of the skybox
  48499. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48500. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48501. * @returns a new mesh holding the sky box
  48502. */
  48503. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48504. /**
  48505. * Creates a new environment
  48506. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48507. * @param options defines the options you can use to configure the environment
  48508. * @returns the new EnvironmentHelper
  48509. */
  48510. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48511. /**
  48512. * Creates a new VREXperienceHelper
  48513. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48514. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48515. * @returns a new VREXperienceHelper
  48516. */
  48517. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48518. /**
  48519. * Creates a new WebXRDefaultExperience
  48520. * @see http://doc.babylonjs.com/how_to/webxr
  48521. * @param options experience options
  48522. * @returns a promise for a new WebXRDefaultExperience
  48523. */
  48524. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48525. }
  48526. }
  48527. declare module BABYLON {
  48528. /**
  48529. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48530. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48531. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48532. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48533. */
  48534. export class VideoDome extends TransformNode {
  48535. /**
  48536. * Define the video source as a Monoscopic panoramic 360 video.
  48537. */
  48538. static readonly MODE_MONOSCOPIC: number;
  48539. /**
  48540. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48541. */
  48542. static readonly MODE_TOPBOTTOM: number;
  48543. /**
  48544. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48545. */
  48546. static readonly MODE_SIDEBYSIDE: number;
  48547. private _halfDome;
  48548. private _useDirectMapping;
  48549. /**
  48550. * The video texture being displayed on the sphere
  48551. */
  48552. protected _videoTexture: VideoTexture;
  48553. /**
  48554. * Gets the video texture being displayed on the sphere
  48555. */
  48556. readonly videoTexture: VideoTexture;
  48557. /**
  48558. * The skybox material
  48559. */
  48560. protected _material: BackgroundMaterial;
  48561. /**
  48562. * The surface used for the skybox
  48563. */
  48564. protected _mesh: Mesh;
  48565. /**
  48566. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48567. */
  48568. private _halfDomeMask;
  48569. /**
  48570. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48571. * Also see the options.resolution property.
  48572. */
  48573. fovMultiplier: number;
  48574. private _videoMode;
  48575. /**
  48576. * Gets or set the current video mode for the video. It can be:
  48577. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48578. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48579. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48580. */
  48581. videoMode: number;
  48582. /**
  48583. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48584. *
  48585. */
  48586. /**
  48587. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48588. */
  48589. halfDome: boolean;
  48590. /**
  48591. * Oberserver used in Stereoscopic VR Mode.
  48592. */
  48593. private _onBeforeCameraRenderObserver;
  48594. /**
  48595. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48596. * @param name Element's name, child elements will append suffixes for their own names.
  48597. * @param urlsOrVideo defines the url(s) or the video element to use
  48598. * @param options An object containing optional or exposed sub element properties
  48599. */
  48600. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48601. resolution?: number;
  48602. clickToPlay?: boolean;
  48603. autoPlay?: boolean;
  48604. loop?: boolean;
  48605. size?: number;
  48606. poster?: string;
  48607. faceForward?: boolean;
  48608. useDirectMapping?: boolean;
  48609. halfDomeMode?: boolean;
  48610. }, scene: Scene);
  48611. private _changeVideoMode;
  48612. /**
  48613. * Releases resources associated with this node.
  48614. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48615. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48616. */
  48617. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48618. }
  48619. }
  48620. declare module BABYLON {
  48621. /**
  48622. * This class can be used to get instrumentation data from a Babylon engine
  48623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48624. */
  48625. export class EngineInstrumentation implements IDisposable {
  48626. /**
  48627. * Define the instrumented engine.
  48628. */
  48629. engine: Engine;
  48630. private _captureGPUFrameTime;
  48631. private _gpuFrameTimeToken;
  48632. private _gpuFrameTime;
  48633. private _captureShaderCompilationTime;
  48634. private _shaderCompilationTime;
  48635. private _onBeginFrameObserver;
  48636. private _onEndFrameObserver;
  48637. private _onBeforeShaderCompilationObserver;
  48638. private _onAfterShaderCompilationObserver;
  48639. /**
  48640. * Gets the perf counter used for GPU frame time
  48641. */
  48642. readonly gpuFrameTimeCounter: PerfCounter;
  48643. /**
  48644. * Gets the GPU frame time capture status
  48645. */
  48646. /**
  48647. * Enable or disable the GPU frame time capture
  48648. */
  48649. captureGPUFrameTime: boolean;
  48650. /**
  48651. * Gets the perf counter used for shader compilation time
  48652. */
  48653. readonly shaderCompilationTimeCounter: PerfCounter;
  48654. /**
  48655. * Gets the shader compilation time capture status
  48656. */
  48657. /**
  48658. * Enable or disable the shader compilation time capture
  48659. */
  48660. captureShaderCompilationTime: boolean;
  48661. /**
  48662. * Instantiates a new engine instrumentation.
  48663. * This class can be used to get instrumentation data from a Babylon engine
  48664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48665. * @param engine Defines the engine to instrument
  48666. */
  48667. constructor(
  48668. /**
  48669. * Define the instrumented engine.
  48670. */
  48671. engine: Engine);
  48672. /**
  48673. * Dispose and release associated resources.
  48674. */
  48675. dispose(): void;
  48676. }
  48677. }
  48678. declare module BABYLON {
  48679. /**
  48680. * This class can be used to get instrumentation data from a Babylon engine
  48681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48682. */
  48683. export class SceneInstrumentation implements IDisposable {
  48684. /**
  48685. * Defines the scene to instrument
  48686. */
  48687. scene: Scene;
  48688. private _captureActiveMeshesEvaluationTime;
  48689. private _activeMeshesEvaluationTime;
  48690. private _captureRenderTargetsRenderTime;
  48691. private _renderTargetsRenderTime;
  48692. private _captureFrameTime;
  48693. private _frameTime;
  48694. private _captureRenderTime;
  48695. private _renderTime;
  48696. private _captureInterFrameTime;
  48697. private _interFrameTime;
  48698. private _captureParticlesRenderTime;
  48699. private _particlesRenderTime;
  48700. private _captureSpritesRenderTime;
  48701. private _spritesRenderTime;
  48702. private _capturePhysicsTime;
  48703. private _physicsTime;
  48704. private _captureAnimationsTime;
  48705. private _animationsTime;
  48706. private _captureCameraRenderTime;
  48707. private _cameraRenderTime;
  48708. private _onBeforeActiveMeshesEvaluationObserver;
  48709. private _onAfterActiveMeshesEvaluationObserver;
  48710. private _onBeforeRenderTargetsRenderObserver;
  48711. private _onAfterRenderTargetsRenderObserver;
  48712. private _onAfterRenderObserver;
  48713. private _onBeforeDrawPhaseObserver;
  48714. private _onAfterDrawPhaseObserver;
  48715. private _onBeforeAnimationsObserver;
  48716. private _onBeforeParticlesRenderingObserver;
  48717. private _onAfterParticlesRenderingObserver;
  48718. private _onBeforeSpritesRenderingObserver;
  48719. private _onAfterSpritesRenderingObserver;
  48720. private _onBeforePhysicsObserver;
  48721. private _onAfterPhysicsObserver;
  48722. private _onAfterAnimationsObserver;
  48723. private _onBeforeCameraRenderObserver;
  48724. private _onAfterCameraRenderObserver;
  48725. /**
  48726. * Gets the perf counter used for active meshes evaluation time
  48727. */
  48728. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48729. /**
  48730. * Gets the active meshes evaluation time capture status
  48731. */
  48732. /**
  48733. * Enable or disable the active meshes evaluation time capture
  48734. */
  48735. captureActiveMeshesEvaluationTime: boolean;
  48736. /**
  48737. * Gets the perf counter used for render targets render time
  48738. */
  48739. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48740. /**
  48741. * Gets the render targets render time capture status
  48742. */
  48743. /**
  48744. * Enable or disable the render targets render time capture
  48745. */
  48746. captureRenderTargetsRenderTime: boolean;
  48747. /**
  48748. * Gets the perf counter used for particles render time
  48749. */
  48750. readonly particlesRenderTimeCounter: PerfCounter;
  48751. /**
  48752. * Gets the particles render time capture status
  48753. */
  48754. /**
  48755. * Enable or disable the particles render time capture
  48756. */
  48757. captureParticlesRenderTime: boolean;
  48758. /**
  48759. * Gets the perf counter used for sprites render time
  48760. */
  48761. readonly spritesRenderTimeCounter: PerfCounter;
  48762. /**
  48763. * Gets the sprites render time capture status
  48764. */
  48765. /**
  48766. * Enable or disable the sprites render time capture
  48767. */
  48768. captureSpritesRenderTime: boolean;
  48769. /**
  48770. * Gets the perf counter used for physics time
  48771. */
  48772. readonly physicsTimeCounter: PerfCounter;
  48773. /**
  48774. * Gets the physics time capture status
  48775. */
  48776. /**
  48777. * Enable or disable the physics time capture
  48778. */
  48779. capturePhysicsTime: boolean;
  48780. /**
  48781. * Gets the perf counter used for animations time
  48782. */
  48783. readonly animationsTimeCounter: PerfCounter;
  48784. /**
  48785. * Gets the animations time capture status
  48786. */
  48787. /**
  48788. * Enable or disable the animations time capture
  48789. */
  48790. captureAnimationsTime: boolean;
  48791. /**
  48792. * Gets the perf counter used for frame time capture
  48793. */
  48794. readonly frameTimeCounter: PerfCounter;
  48795. /**
  48796. * Gets the frame time capture status
  48797. */
  48798. /**
  48799. * Enable or disable the frame time capture
  48800. */
  48801. captureFrameTime: boolean;
  48802. /**
  48803. * Gets the perf counter used for inter-frames time capture
  48804. */
  48805. readonly interFrameTimeCounter: PerfCounter;
  48806. /**
  48807. * Gets the inter-frames time capture status
  48808. */
  48809. /**
  48810. * Enable or disable the inter-frames time capture
  48811. */
  48812. captureInterFrameTime: boolean;
  48813. /**
  48814. * Gets the perf counter used for render time capture
  48815. */
  48816. readonly renderTimeCounter: PerfCounter;
  48817. /**
  48818. * Gets the render time capture status
  48819. */
  48820. /**
  48821. * Enable or disable the render time capture
  48822. */
  48823. captureRenderTime: boolean;
  48824. /**
  48825. * Gets the perf counter used for camera render time capture
  48826. */
  48827. readonly cameraRenderTimeCounter: PerfCounter;
  48828. /**
  48829. * Gets the camera render time capture status
  48830. */
  48831. /**
  48832. * Enable or disable the camera render time capture
  48833. */
  48834. captureCameraRenderTime: boolean;
  48835. /**
  48836. * Gets the perf counter used for draw calls
  48837. */
  48838. readonly drawCallsCounter: PerfCounter;
  48839. /**
  48840. * Instantiates a new scene instrumentation.
  48841. * This class can be used to get instrumentation data from a Babylon engine
  48842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48843. * @param scene Defines the scene to instrument
  48844. */
  48845. constructor(
  48846. /**
  48847. * Defines the scene to instrument
  48848. */
  48849. scene: Scene);
  48850. /**
  48851. * Dispose and release associated resources.
  48852. */
  48853. dispose(): void;
  48854. }
  48855. }
  48856. declare module BABYLON {
  48857. /** @hidden */
  48858. export var glowMapGenerationPixelShader: {
  48859. name: string;
  48860. shader: string;
  48861. };
  48862. }
  48863. declare module BABYLON {
  48864. /** @hidden */
  48865. export var glowMapGenerationVertexShader: {
  48866. name: string;
  48867. shader: string;
  48868. };
  48869. }
  48870. declare module BABYLON {
  48871. /**
  48872. * Effect layer options. This helps customizing the behaviour
  48873. * of the effect layer.
  48874. */
  48875. export interface IEffectLayerOptions {
  48876. /**
  48877. * Multiplication factor apply to the canvas size to compute the render target size
  48878. * used to generated the objects (the smaller the faster).
  48879. */
  48880. mainTextureRatio: number;
  48881. /**
  48882. * Enforces a fixed size texture to ensure effect stability across devices.
  48883. */
  48884. mainTextureFixedSize?: number;
  48885. /**
  48886. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48887. */
  48888. alphaBlendingMode: number;
  48889. /**
  48890. * The camera attached to the layer.
  48891. */
  48892. camera: Nullable<Camera>;
  48893. /**
  48894. * The rendering group to draw the layer in.
  48895. */
  48896. renderingGroupId: number;
  48897. }
  48898. /**
  48899. * The effect layer Helps adding post process effect blended with the main pass.
  48900. *
  48901. * This can be for instance use to generate glow or higlight effects on the scene.
  48902. *
  48903. * The effect layer class can not be used directly and is intented to inherited from to be
  48904. * customized per effects.
  48905. */
  48906. export abstract class EffectLayer {
  48907. private _vertexBuffers;
  48908. private _indexBuffer;
  48909. private _cachedDefines;
  48910. private _effectLayerMapGenerationEffect;
  48911. private _effectLayerOptions;
  48912. private _mergeEffect;
  48913. protected _scene: Scene;
  48914. protected _engine: Engine;
  48915. protected _maxSize: number;
  48916. protected _mainTextureDesiredSize: ISize;
  48917. protected _mainTexture: RenderTargetTexture;
  48918. protected _shouldRender: boolean;
  48919. protected _postProcesses: PostProcess[];
  48920. protected _textures: BaseTexture[];
  48921. protected _emissiveTextureAndColor: {
  48922. texture: Nullable<BaseTexture>;
  48923. color: Color4;
  48924. };
  48925. /**
  48926. * The name of the layer
  48927. */
  48928. name: string;
  48929. /**
  48930. * The clear color of the texture used to generate the glow map.
  48931. */
  48932. neutralColor: Color4;
  48933. /**
  48934. * Specifies wether the highlight layer is enabled or not.
  48935. */
  48936. isEnabled: boolean;
  48937. /**
  48938. * Gets the camera attached to the layer.
  48939. */
  48940. readonly camera: Nullable<Camera>;
  48941. /**
  48942. * Gets the rendering group id the layer should render in.
  48943. */
  48944. renderingGroupId: number;
  48945. /**
  48946. * An event triggered when the effect layer has been disposed.
  48947. */
  48948. onDisposeObservable: Observable<EffectLayer>;
  48949. /**
  48950. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48951. */
  48952. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48953. /**
  48954. * An event triggered when the generated texture is being merged in the scene.
  48955. */
  48956. onBeforeComposeObservable: Observable<EffectLayer>;
  48957. /**
  48958. * An event triggered when the generated texture has been merged in the scene.
  48959. */
  48960. onAfterComposeObservable: Observable<EffectLayer>;
  48961. /**
  48962. * An event triggered when the efffect layer changes its size.
  48963. */
  48964. onSizeChangedObservable: Observable<EffectLayer>;
  48965. /** @hidden */
  48966. static _SceneComponentInitialization: (scene: Scene) => void;
  48967. /**
  48968. * Instantiates a new effect Layer and references it in the scene.
  48969. * @param name The name of the layer
  48970. * @param scene The scene to use the layer in
  48971. */
  48972. constructor(
  48973. /** The Friendly of the effect in the scene */
  48974. name: string, scene: Scene);
  48975. /**
  48976. * Get the effect name of the layer.
  48977. * @return The effect name
  48978. */
  48979. abstract getEffectName(): string;
  48980. /**
  48981. * Checks for the readiness of the element composing the layer.
  48982. * @param subMesh the mesh to check for
  48983. * @param useInstances specify wether or not to use instances to render the mesh
  48984. * @return true if ready otherwise, false
  48985. */
  48986. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48987. /**
  48988. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48989. * @returns true if the effect requires stencil during the main canvas render pass.
  48990. */
  48991. abstract needStencil(): boolean;
  48992. /**
  48993. * Create the merge effect. This is the shader use to blit the information back
  48994. * to the main canvas at the end of the scene rendering.
  48995. * @returns The effect containing the shader used to merge the effect on the main canvas
  48996. */
  48997. protected abstract _createMergeEffect(): Effect;
  48998. /**
  48999. * Creates the render target textures and post processes used in the effect layer.
  49000. */
  49001. protected abstract _createTextureAndPostProcesses(): void;
  49002. /**
  49003. * Implementation specific of rendering the generating effect on the main canvas.
  49004. * @param effect The effect used to render through
  49005. */
  49006. protected abstract _internalRender(effect: Effect): void;
  49007. /**
  49008. * Sets the required values for both the emissive texture and and the main color.
  49009. */
  49010. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49011. /**
  49012. * Free any resources and references associated to a mesh.
  49013. * Internal use
  49014. * @param mesh The mesh to free.
  49015. */
  49016. abstract _disposeMesh(mesh: Mesh): void;
  49017. /**
  49018. * Serializes this layer (Glow or Highlight for example)
  49019. * @returns a serialized layer object
  49020. */
  49021. abstract serialize?(): any;
  49022. /**
  49023. * Initializes the effect layer with the required options.
  49024. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49025. */
  49026. protected _init(options: Partial<IEffectLayerOptions>): void;
  49027. /**
  49028. * Generates the index buffer of the full screen quad blending to the main canvas.
  49029. */
  49030. private _generateIndexBuffer;
  49031. /**
  49032. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49033. */
  49034. private _generateVertexBuffer;
  49035. /**
  49036. * Sets the main texture desired size which is the closest power of two
  49037. * of the engine canvas size.
  49038. */
  49039. private _setMainTextureSize;
  49040. /**
  49041. * Creates the main texture for the effect layer.
  49042. */
  49043. protected _createMainTexture(): void;
  49044. /**
  49045. * Adds specific effects defines.
  49046. * @param defines The defines to add specifics to.
  49047. */
  49048. protected _addCustomEffectDefines(defines: string[]): void;
  49049. /**
  49050. * Checks for the readiness of the element composing the layer.
  49051. * @param subMesh the mesh to check for
  49052. * @param useInstances specify wether or not to use instances to render the mesh
  49053. * @param emissiveTexture the associated emissive texture used to generate the glow
  49054. * @return true if ready otherwise, false
  49055. */
  49056. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49057. /**
  49058. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49059. */
  49060. render(): void;
  49061. /**
  49062. * Determine if a given mesh will be used in the current effect.
  49063. * @param mesh mesh to test
  49064. * @returns true if the mesh will be used
  49065. */
  49066. hasMesh(mesh: AbstractMesh): boolean;
  49067. /**
  49068. * Returns true if the layer contains information to display, otherwise false.
  49069. * @returns true if the glow layer should be rendered
  49070. */
  49071. shouldRender(): boolean;
  49072. /**
  49073. * Returns true if the mesh should render, otherwise false.
  49074. * @param mesh The mesh to render
  49075. * @returns true if it should render otherwise false
  49076. */
  49077. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49078. /**
  49079. * Returns true if the mesh can be rendered, otherwise false.
  49080. * @param mesh The mesh to render
  49081. * @param material The material used on the mesh
  49082. * @returns true if it can be rendered otherwise false
  49083. */
  49084. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49085. /**
  49086. * Returns true if the mesh should render, otherwise false.
  49087. * @param mesh The mesh to render
  49088. * @returns true if it should render otherwise false
  49089. */
  49090. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49091. /**
  49092. * Renders the submesh passed in parameter to the generation map.
  49093. */
  49094. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49095. /**
  49096. * Rebuild the required buffers.
  49097. * @hidden Internal use only.
  49098. */
  49099. _rebuild(): void;
  49100. /**
  49101. * Dispose only the render target textures and post process.
  49102. */
  49103. private _disposeTextureAndPostProcesses;
  49104. /**
  49105. * Dispose the highlight layer and free resources.
  49106. */
  49107. dispose(): void;
  49108. /**
  49109. * Gets the class name of the effect layer
  49110. * @returns the string with the class name of the effect layer
  49111. */
  49112. getClassName(): string;
  49113. /**
  49114. * Creates an effect layer from parsed effect layer data
  49115. * @param parsedEffectLayer defines effect layer data
  49116. * @param scene defines the current scene
  49117. * @param rootUrl defines the root URL containing the effect layer information
  49118. * @returns a parsed effect Layer
  49119. */
  49120. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49121. }
  49122. }
  49123. declare module BABYLON {
  49124. interface AbstractScene {
  49125. /**
  49126. * The list of effect layers (highlights/glow) added to the scene
  49127. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49128. * @see http://doc.babylonjs.com/how_to/glow_layer
  49129. */
  49130. effectLayers: Array<EffectLayer>;
  49131. /**
  49132. * Removes the given effect layer from this scene.
  49133. * @param toRemove defines the effect layer to remove
  49134. * @returns the index of the removed effect layer
  49135. */
  49136. removeEffectLayer(toRemove: EffectLayer): number;
  49137. /**
  49138. * Adds the given effect layer to this scene
  49139. * @param newEffectLayer defines the effect layer to add
  49140. */
  49141. addEffectLayer(newEffectLayer: EffectLayer): void;
  49142. }
  49143. /**
  49144. * Defines the layer scene component responsible to manage any effect layers
  49145. * in a given scene.
  49146. */
  49147. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49148. /**
  49149. * The component name helpfull to identify the component in the list of scene components.
  49150. */
  49151. readonly name: string;
  49152. /**
  49153. * The scene the component belongs to.
  49154. */
  49155. scene: Scene;
  49156. private _engine;
  49157. private _renderEffects;
  49158. private _needStencil;
  49159. private _previousStencilState;
  49160. /**
  49161. * Creates a new instance of the component for the given scene
  49162. * @param scene Defines the scene to register the component in
  49163. */
  49164. constructor(scene: Scene);
  49165. /**
  49166. * Registers the component in a given scene
  49167. */
  49168. register(): void;
  49169. /**
  49170. * Rebuilds the elements related to this component in case of
  49171. * context lost for instance.
  49172. */
  49173. rebuild(): void;
  49174. /**
  49175. * Serializes the component data to the specified json object
  49176. * @param serializationObject The object to serialize to
  49177. */
  49178. serialize(serializationObject: any): void;
  49179. /**
  49180. * Adds all the elements from the container to the scene
  49181. * @param container the container holding the elements
  49182. */
  49183. addFromContainer(container: AbstractScene): void;
  49184. /**
  49185. * Removes all the elements in the container from the scene
  49186. * @param container contains the elements to remove
  49187. * @param dispose if the removed element should be disposed (default: false)
  49188. */
  49189. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49190. /**
  49191. * Disposes the component and the associated ressources.
  49192. */
  49193. dispose(): void;
  49194. private _isReadyForMesh;
  49195. private _renderMainTexture;
  49196. private _setStencil;
  49197. private _setStencilBack;
  49198. private _draw;
  49199. private _drawCamera;
  49200. private _drawRenderingGroup;
  49201. }
  49202. }
  49203. declare module BABYLON {
  49204. /** @hidden */
  49205. export var glowMapMergePixelShader: {
  49206. name: string;
  49207. shader: string;
  49208. };
  49209. }
  49210. declare module BABYLON {
  49211. /** @hidden */
  49212. export var glowMapMergeVertexShader: {
  49213. name: string;
  49214. shader: string;
  49215. };
  49216. }
  49217. declare module BABYLON {
  49218. interface AbstractScene {
  49219. /**
  49220. * Return a the first highlight layer of the scene with a given name.
  49221. * @param name The name of the highlight layer to look for.
  49222. * @return The highlight layer if found otherwise null.
  49223. */
  49224. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49225. }
  49226. /**
  49227. * Glow layer options. This helps customizing the behaviour
  49228. * of the glow layer.
  49229. */
  49230. export interface IGlowLayerOptions {
  49231. /**
  49232. * Multiplication factor apply to the canvas size to compute the render target size
  49233. * used to generated the glowing objects (the smaller the faster).
  49234. */
  49235. mainTextureRatio: number;
  49236. /**
  49237. * Enforces a fixed size texture to ensure resize independant blur.
  49238. */
  49239. mainTextureFixedSize?: number;
  49240. /**
  49241. * How big is the kernel of the blur texture.
  49242. */
  49243. blurKernelSize: number;
  49244. /**
  49245. * The camera attached to the layer.
  49246. */
  49247. camera: Nullable<Camera>;
  49248. /**
  49249. * Enable MSAA by chosing the number of samples.
  49250. */
  49251. mainTextureSamples?: number;
  49252. /**
  49253. * The rendering group to draw the layer in.
  49254. */
  49255. renderingGroupId: number;
  49256. }
  49257. /**
  49258. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49259. *
  49260. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49261. * glowy meshes to your scene.
  49262. *
  49263. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49264. */
  49265. export class GlowLayer extends EffectLayer {
  49266. /**
  49267. * Effect Name of the layer.
  49268. */
  49269. static readonly EffectName: string;
  49270. /**
  49271. * The default blur kernel size used for the glow.
  49272. */
  49273. static DefaultBlurKernelSize: number;
  49274. /**
  49275. * The default texture size ratio used for the glow.
  49276. */
  49277. static DefaultTextureRatio: number;
  49278. /**
  49279. * Sets the kernel size of the blur.
  49280. */
  49281. /**
  49282. * Gets the kernel size of the blur.
  49283. */
  49284. blurKernelSize: number;
  49285. /**
  49286. * Sets the glow intensity.
  49287. */
  49288. /**
  49289. * Gets the glow intensity.
  49290. */
  49291. intensity: number;
  49292. private _options;
  49293. private _intensity;
  49294. private _horizontalBlurPostprocess1;
  49295. private _verticalBlurPostprocess1;
  49296. private _horizontalBlurPostprocess2;
  49297. private _verticalBlurPostprocess2;
  49298. private _blurTexture1;
  49299. private _blurTexture2;
  49300. private _postProcesses1;
  49301. private _postProcesses2;
  49302. private _includedOnlyMeshes;
  49303. private _excludedMeshes;
  49304. /**
  49305. * Callback used to let the user override the color selection on a per mesh basis
  49306. */
  49307. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49308. /**
  49309. * Callback used to let the user override the texture selection on a per mesh basis
  49310. */
  49311. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49312. /**
  49313. * Instantiates a new glow Layer and references it to the scene.
  49314. * @param name The name of the layer
  49315. * @param scene The scene to use the layer in
  49316. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49317. */
  49318. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49319. /**
  49320. * Get the effect name of the layer.
  49321. * @return The effect name
  49322. */
  49323. getEffectName(): string;
  49324. /**
  49325. * Create the merge effect. This is the shader use to blit the information back
  49326. * to the main canvas at the end of the scene rendering.
  49327. */
  49328. protected _createMergeEffect(): Effect;
  49329. /**
  49330. * Creates the render target textures and post processes used in the glow layer.
  49331. */
  49332. protected _createTextureAndPostProcesses(): void;
  49333. /**
  49334. * Checks for the readiness of the element composing the layer.
  49335. * @param subMesh the mesh to check for
  49336. * @param useInstances specify wether or not to use instances to render the mesh
  49337. * @param emissiveTexture the associated emissive texture used to generate the glow
  49338. * @return true if ready otherwise, false
  49339. */
  49340. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49341. /**
  49342. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49343. */
  49344. needStencil(): boolean;
  49345. /**
  49346. * Returns true if the mesh can be rendered, otherwise false.
  49347. * @param mesh The mesh to render
  49348. * @param material The material used on the mesh
  49349. * @returns true if it can be rendered otherwise false
  49350. */
  49351. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49352. /**
  49353. * Implementation specific of rendering the generating effect on the main canvas.
  49354. * @param effect The effect used to render through
  49355. */
  49356. protected _internalRender(effect: Effect): void;
  49357. /**
  49358. * Sets the required values for both the emissive texture and and the main color.
  49359. */
  49360. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49361. /**
  49362. * Returns true if the mesh should render, otherwise false.
  49363. * @param mesh The mesh to render
  49364. * @returns true if it should render otherwise false
  49365. */
  49366. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49367. /**
  49368. * Adds specific effects defines.
  49369. * @param defines The defines to add specifics to.
  49370. */
  49371. protected _addCustomEffectDefines(defines: string[]): void;
  49372. /**
  49373. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49374. * @param mesh The mesh to exclude from the glow layer
  49375. */
  49376. addExcludedMesh(mesh: Mesh): void;
  49377. /**
  49378. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49379. * @param mesh The mesh to remove
  49380. */
  49381. removeExcludedMesh(mesh: Mesh): void;
  49382. /**
  49383. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49384. * @param mesh The mesh to include in the glow layer
  49385. */
  49386. addIncludedOnlyMesh(mesh: Mesh): void;
  49387. /**
  49388. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49389. * @param mesh The mesh to remove
  49390. */
  49391. removeIncludedOnlyMesh(mesh: Mesh): void;
  49392. /**
  49393. * Determine if a given mesh will be used in the glow layer
  49394. * @param mesh The mesh to test
  49395. * @returns true if the mesh will be highlighted by the current glow layer
  49396. */
  49397. hasMesh(mesh: AbstractMesh): boolean;
  49398. /**
  49399. * Free any resources and references associated to a mesh.
  49400. * Internal use
  49401. * @param mesh The mesh to free.
  49402. * @hidden
  49403. */
  49404. _disposeMesh(mesh: Mesh): void;
  49405. /**
  49406. * Gets the class name of the effect layer
  49407. * @returns the string with the class name of the effect layer
  49408. */
  49409. getClassName(): string;
  49410. /**
  49411. * Serializes this glow layer
  49412. * @returns a serialized glow layer object
  49413. */
  49414. serialize(): any;
  49415. /**
  49416. * Creates a Glow Layer from parsed glow layer data
  49417. * @param parsedGlowLayer defines glow layer data
  49418. * @param scene defines the current scene
  49419. * @param rootUrl defines the root URL containing the glow layer information
  49420. * @returns a parsed Glow Layer
  49421. */
  49422. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49423. }
  49424. }
  49425. declare module BABYLON {
  49426. /** @hidden */
  49427. export var glowBlurPostProcessPixelShader: {
  49428. name: string;
  49429. shader: string;
  49430. };
  49431. }
  49432. declare module BABYLON {
  49433. interface AbstractScene {
  49434. /**
  49435. * Return a the first highlight layer of the scene with a given name.
  49436. * @param name The name of the highlight layer to look for.
  49437. * @return The highlight layer if found otherwise null.
  49438. */
  49439. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49440. }
  49441. /**
  49442. * Highlight layer options. This helps customizing the behaviour
  49443. * of the highlight layer.
  49444. */
  49445. export interface IHighlightLayerOptions {
  49446. /**
  49447. * Multiplication factor apply to the canvas size to compute the render target size
  49448. * used to generated the glowing objects (the smaller the faster).
  49449. */
  49450. mainTextureRatio: number;
  49451. /**
  49452. * Enforces a fixed size texture to ensure resize independant blur.
  49453. */
  49454. mainTextureFixedSize?: number;
  49455. /**
  49456. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49457. * of the picture to blur (the smaller the faster).
  49458. */
  49459. blurTextureSizeRatio: number;
  49460. /**
  49461. * How big in texel of the blur texture is the vertical blur.
  49462. */
  49463. blurVerticalSize: number;
  49464. /**
  49465. * How big in texel of the blur texture is the horizontal blur.
  49466. */
  49467. blurHorizontalSize: number;
  49468. /**
  49469. * Alpha blending mode used to apply the blur. Default is combine.
  49470. */
  49471. alphaBlendingMode: number;
  49472. /**
  49473. * The camera attached to the layer.
  49474. */
  49475. camera: Nullable<Camera>;
  49476. /**
  49477. * Should we display highlight as a solid stroke?
  49478. */
  49479. isStroke?: boolean;
  49480. /**
  49481. * The rendering group to draw the layer in.
  49482. */
  49483. renderingGroupId: number;
  49484. }
  49485. /**
  49486. * The highlight layer Helps adding a glow effect around a mesh.
  49487. *
  49488. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49489. * glowy meshes to your scene.
  49490. *
  49491. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49492. */
  49493. export class HighlightLayer extends EffectLayer {
  49494. name: string;
  49495. /**
  49496. * Effect Name of the highlight layer.
  49497. */
  49498. static readonly EffectName: string;
  49499. /**
  49500. * The neutral color used during the preparation of the glow effect.
  49501. * This is black by default as the blend operation is a blend operation.
  49502. */
  49503. static NeutralColor: Color4;
  49504. /**
  49505. * Stencil value used for glowing meshes.
  49506. */
  49507. static GlowingMeshStencilReference: number;
  49508. /**
  49509. * Stencil value used for the other meshes in the scene.
  49510. */
  49511. static NormalMeshStencilReference: number;
  49512. /**
  49513. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49514. */
  49515. innerGlow: boolean;
  49516. /**
  49517. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49518. */
  49519. outerGlow: boolean;
  49520. /**
  49521. * Specifies the horizontal size of the blur.
  49522. */
  49523. /**
  49524. * Gets the horizontal size of the blur.
  49525. */
  49526. blurHorizontalSize: number;
  49527. /**
  49528. * Specifies the vertical size of the blur.
  49529. */
  49530. /**
  49531. * Gets the vertical size of the blur.
  49532. */
  49533. blurVerticalSize: number;
  49534. /**
  49535. * An event triggered when the highlight layer is being blurred.
  49536. */
  49537. onBeforeBlurObservable: Observable<HighlightLayer>;
  49538. /**
  49539. * An event triggered when the highlight layer has been blurred.
  49540. */
  49541. onAfterBlurObservable: Observable<HighlightLayer>;
  49542. private _instanceGlowingMeshStencilReference;
  49543. private _options;
  49544. private _downSamplePostprocess;
  49545. private _horizontalBlurPostprocess;
  49546. private _verticalBlurPostprocess;
  49547. private _blurTexture;
  49548. private _meshes;
  49549. private _excludedMeshes;
  49550. /**
  49551. * Instantiates a new highlight Layer and references it to the scene..
  49552. * @param name The name of the layer
  49553. * @param scene The scene to use the layer in
  49554. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49555. */
  49556. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49557. /**
  49558. * Get the effect name of the layer.
  49559. * @return The effect name
  49560. */
  49561. getEffectName(): string;
  49562. /**
  49563. * Create the merge effect. This is the shader use to blit the information back
  49564. * to the main canvas at the end of the scene rendering.
  49565. */
  49566. protected _createMergeEffect(): Effect;
  49567. /**
  49568. * Creates the render target textures and post processes used in the highlight layer.
  49569. */
  49570. protected _createTextureAndPostProcesses(): void;
  49571. /**
  49572. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49573. */
  49574. needStencil(): boolean;
  49575. /**
  49576. * Checks for the readiness of the element composing the layer.
  49577. * @param subMesh the mesh to check for
  49578. * @param useInstances specify wether or not to use instances to render the mesh
  49579. * @param emissiveTexture the associated emissive texture used to generate the glow
  49580. * @return true if ready otherwise, false
  49581. */
  49582. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49583. /**
  49584. * Implementation specific of rendering the generating effect on the main canvas.
  49585. * @param effect The effect used to render through
  49586. */
  49587. protected _internalRender(effect: Effect): void;
  49588. /**
  49589. * Returns true if the layer contains information to display, otherwise false.
  49590. */
  49591. shouldRender(): boolean;
  49592. /**
  49593. * Returns true if the mesh should render, otherwise false.
  49594. * @param mesh The mesh to render
  49595. * @returns true if it should render otherwise false
  49596. */
  49597. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49598. /**
  49599. * Sets the required values for both the emissive texture and and the main color.
  49600. */
  49601. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49602. /**
  49603. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49604. * @param mesh The mesh to exclude from the highlight layer
  49605. */
  49606. addExcludedMesh(mesh: Mesh): void;
  49607. /**
  49608. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49609. * @param mesh The mesh to highlight
  49610. */
  49611. removeExcludedMesh(mesh: Mesh): void;
  49612. /**
  49613. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49614. * @param mesh mesh to test
  49615. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49616. */
  49617. hasMesh(mesh: AbstractMesh): boolean;
  49618. /**
  49619. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49620. * @param mesh The mesh to highlight
  49621. * @param color The color of the highlight
  49622. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49623. */
  49624. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49625. /**
  49626. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49627. * @param mesh The mesh to highlight
  49628. */
  49629. removeMesh(mesh: Mesh): void;
  49630. /**
  49631. * Force the stencil to the normal expected value for none glowing parts
  49632. */
  49633. private _defaultStencilReference;
  49634. /**
  49635. * Free any resources and references associated to a mesh.
  49636. * Internal use
  49637. * @param mesh The mesh to free.
  49638. * @hidden
  49639. */
  49640. _disposeMesh(mesh: Mesh): void;
  49641. /**
  49642. * Dispose the highlight layer and free resources.
  49643. */
  49644. dispose(): void;
  49645. /**
  49646. * Gets the class name of the effect layer
  49647. * @returns the string with the class name of the effect layer
  49648. */
  49649. getClassName(): string;
  49650. /**
  49651. * Serializes this Highlight layer
  49652. * @returns a serialized Highlight layer object
  49653. */
  49654. serialize(): any;
  49655. /**
  49656. * Creates a Highlight layer from parsed Highlight layer data
  49657. * @param parsedHightlightLayer defines the Highlight layer data
  49658. * @param scene defines the current scene
  49659. * @param rootUrl defines the root URL containing the Highlight layer information
  49660. * @returns a parsed Highlight layer
  49661. */
  49662. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49663. }
  49664. }
  49665. declare module BABYLON {
  49666. interface AbstractScene {
  49667. /**
  49668. * The list of layers (background and foreground) of the scene
  49669. */
  49670. layers: Array<Layer>;
  49671. }
  49672. /**
  49673. * Defines the layer scene component responsible to manage any layers
  49674. * in a given scene.
  49675. */
  49676. export class LayerSceneComponent implements ISceneComponent {
  49677. /**
  49678. * The component name helpfull to identify the component in the list of scene components.
  49679. */
  49680. readonly name: string;
  49681. /**
  49682. * The scene the component belongs to.
  49683. */
  49684. scene: Scene;
  49685. private _engine;
  49686. /**
  49687. * Creates a new instance of the component for the given scene
  49688. * @param scene Defines the scene to register the component in
  49689. */
  49690. constructor(scene: Scene);
  49691. /**
  49692. * Registers the component in a given scene
  49693. */
  49694. register(): void;
  49695. /**
  49696. * Rebuilds the elements related to this component in case of
  49697. * context lost for instance.
  49698. */
  49699. rebuild(): void;
  49700. /**
  49701. * Disposes the component and the associated ressources.
  49702. */
  49703. dispose(): void;
  49704. private _draw;
  49705. private _drawCameraPredicate;
  49706. private _drawCameraBackground;
  49707. private _drawCameraForeground;
  49708. private _drawRenderTargetPredicate;
  49709. private _drawRenderTargetBackground;
  49710. private _drawRenderTargetForeground;
  49711. /**
  49712. * Adds all the elements from the container to the scene
  49713. * @param container the container holding the elements
  49714. */
  49715. addFromContainer(container: AbstractScene): void;
  49716. /**
  49717. * Removes all the elements in the container from the scene
  49718. * @param container contains the elements to remove
  49719. * @param dispose if the removed element should be disposed (default: false)
  49720. */
  49721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49722. }
  49723. }
  49724. declare module BABYLON {
  49725. /** @hidden */
  49726. export var layerPixelShader: {
  49727. name: string;
  49728. shader: string;
  49729. };
  49730. }
  49731. declare module BABYLON {
  49732. /** @hidden */
  49733. export var layerVertexShader: {
  49734. name: string;
  49735. shader: string;
  49736. };
  49737. }
  49738. declare module BABYLON {
  49739. /**
  49740. * This represents a full screen 2d layer.
  49741. * This can be useful to display a picture in the background of your scene for instance.
  49742. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49743. */
  49744. export class Layer {
  49745. /**
  49746. * Define the name of the layer.
  49747. */
  49748. name: string;
  49749. /**
  49750. * Define the texture the layer should display.
  49751. */
  49752. texture: Nullable<Texture>;
  49753. /**
  49754. * Is the layer in background or foreground.
  49755. */
  49756. isBackground: boolean;
  49757. /**
  49758. * Define the color of the layer (instead of texture).
  49759. */
  49760. color: Color4;
  49761. /**
  49762. * Define the scale of the layer in order to zoom in out of the texture.
  49763. */
  49764. scale: Vector2;
  49765. /**
  49766. * Define an offset for the layer in order to shift the texture.
  49767. */
  49768. offset: Vector2;
  49769. /**
  49770. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49771. */
  49772. alphaBlendingMode: number;
  49773. /**
  49774. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49775. * Alpha test will not mix with the background color in case of transparency.
  49776. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49777. */
  49778. alphaTest: boolean;
  49779. /**
  49780. * Define a mask to restrict the layer to only some of the scene cameras.
  49781. */
  49782. layerMask: number;
  49783. /**
  49784. * Define the list of render target the layer is visible into.
  49785. */
  49786. renderTargetTextures: RenderTargetTexture[];
  49787. /**
  49788. * Define if the layer is only used in renderTarget or if it also
  49789. * renders in the main frame buffer of the canvas.
  49790. */
  49791. renderOnlyInRenderTargetTextures: boolean;
  49792. private _scene;
  49793. private _vertexBuffers;
  49794. private _indexBuffer;
  49795. private _effect;
  49796. private _alphaTestEffect;
  49797. /**
  49798. * An event triggered when the layer is disposed.
  49799. */
  49800. onDisposeObservable: Observable<Layer>;
  49801. private _onDisposeObserver;
  49802. /**
  49803. * Back compatibility with callback before the onDisposeObservable existed.
  49804. * The set callback will be triggered when the layer has been disposed.
  49805. */
  49806. onDispose: () => void;
  49807. /**
  49808. * An event triggered before rendering the scene
  49809. */
  49810. onBeforeRenderObservable: Observable<Layer>;
  49811. private _onBeforeRenderObserver;
  49812. /**
  49813. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49814. * The set callback will be triggered just before rendering the layer.
  49815. */
  49816. onBeforeRender: () => void;
  49817. /**
  49818. * An event triggered after rendering the scene
  49819. */
  49820. onAfterRenderObservable: Observable<Layer>;
  49821. private _onAfterRenderObserver;
  49822. /**
  49823. * Back compatibility with callback before the onAfterRenderObservable existed.
  49824. * The set callback will be triggered just after rendering the layer.
  49825. */
  49826. onAfterRender: () => void;
  49827. /**
  49828. * Instantiates a new layer.
  49829. * This represents a full screen 2d layer.
  49830. * This can be useful to display a picture in the background of your scene for instance.
  49831. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49832. * @param name Define the name of the layer in the scene
  49833. * @param imgUrl Define the url of the texture to display in the layer
  49834. * @param scene Define the scene the layer belongs to
  49835. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49836. * @param color Defines a color for the layer
  49837. */
  49838. constructor(
  49839. /**
  49840. * Define the name of the layer.
  49841. */
  49842. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49843. private _createIndexBuffer;
  49844. /** @hidden */
  49845. _rebuild(): void;
  49846. /**
  49847. * Renders the layer in the scene.
  49848. */
  49849. render(): void;
  49850. /**
  49851. * Disposes and releases the associated ressources.
  49852. */
  49853. dispose(): void;
  49854. }
  49855. }
  49856. declare module BABYLON {
  49857. /** @hidden */
  49858. export var lensFlarePixelShader: {
  49859. name: string;
  49860. shader: string;
  49861. };
  49862. }
  49863. declare module BABYLON {
  49864. /** @hidden */
  49865. export var lensFlareVertexShader: {
  49866. name: string;
  49867. shader: string;
  49868. };
  49869. }
  49870. declare module BABYLON {
  49871. /**
  49872. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49873. * It is usually composed of several `lensFlare`.
  49874. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49875. */
  49876. export class LensFlareSystem {
  49877. /**
  49878. * Define the name of the lens flare system
  49879. */
  49880. name: string;
  49881. /**
  49882. * List of lens flares used in this system.
  49883. */
  49884. lensFlares: LensFlare[];
  49885. /**
  49886. * Define a limit from the border the lens flare can be visible.
  49887. */
  49888. borderLimit: number;
  49889. /**
  49890. * Define a viewport border we do not want to see the lens flare in.
  49891. */
  49892. viewportBorder: number;
  49893. /**
  49894. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49895. */
  49896. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49897. /**
  49898. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49899. */
  49900. layerMask: number;
  49901. /**
  49902. * Define the id of the lens flare system in the scene.
  49903. * (equal to name by default)
  49904. */
  49905. id: string;
  49906. private _scene;
  49907. private _emitter;
  49908. private _vertexBuffers;
  49909. private _indexBuffer;
  49910. private _effect;
  49911. private _positionX;
  49912. private _positionY;
  49913. private _isEnabled;
  49914. /** @hidden */
  49915. static _SceneComponentInitialization: (scene: Scene) => void;
  49916. /**
  49917. * Instantiates a lens flare system.
  49918. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49919. * It is usually composed of several `lensFlare`.
  49920. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49921. * @param name Define the name of the lens flare system in the scene
  49922. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49923. * @param scene Define the scene the lens flare system belongs to
  49924. */
  49925. constructor(
  49926. /**
  49927. * Define the name of the lens flare system
  49928. */
  49929. name: string, emitter: any, scene: Scene);
  49930. /**
  49931. * Define if the lens flare system is enabled.
  49932. */
  49933. isEnabled: boolean;
  49934. /**
  49935. * Get the scene the effects belongs to.
  49936. * @returns the scene holding the lens flare system
  49937. */
  49938. getScene(): Scene;
  49939. /**
  49940. * Get the emitter of the lens flare system.
  49941. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49942. * @returns the emitter of the lens flare system
  49943. */
  49944. getEmitter(): any;
  49945. /**
  49946. * Set the emitter of the lens flare system.
  49947. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49948. * @param newEmitter Define the new emitter of the system
  49949. */
  49950. setEmitter(newEmitter: any): void;
  49951. /**
  49952. * Get the lens flare system emitter position.
  49953. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49954. * @returns the position
  49955. */
  49956. getEmitterPosition(): Vector3;
  49957. /**
  49958. * @hidden
  49959. */
  49960. computeEffectivePosition(globalViewport: Viewport): boolean;
  49961. /** @hidden */
  49962. _isVisible(): boolean;
  49963. /**
  49964. * @hidden
  49965. */
  49966. render(): boolean;
  49967. /**
  49968. * Dispose and release the lens flare with its associated resources.
  49969. */
  49970. dispose(): void;
  49971. /**
  49972. * Parse a lens flare system from a JSON repressentation
  49973. * @param parsedLensFlareSystem Define the JSON to parse
  49974. * @param scene Define the scene the parsed system should be instantiated in
  49975. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49976. * @returns the parsed system
  49977. */
  49978. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49979. /**
  49980. * Serialize the current Lens Flare System into a JSON representation.
  49981. * @returns the serialized JSON
  49982. */
  49983. serialize(): any;
  49984. }
  49985. }
  49986. declare module BABYLON {
  49987. /**
  49988. * This represents one of the lens effect in a `lensFlareSystem`.
  49989. * It controls one of the indiviual texture used in the effect.
  49990. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49991. */
  49992. export class LensFlare {
  49993. /**
  49994. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49995. */
  49996. size: number;
  49997. /**
  49998. * 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.
  49999. */
  50000. position: number;
  50001. /**
  50002. * Define the lens color.
  50003. */
  50004. color: Color3;
  50005. /**
  50006. * Define the lens texture.
  50007. */
  50008. texture: Nullable<Texture>;
  50009. /**
  50010. * Define the alpha mode to render this particular lens.
  50011. */
  50012. alphaMode: number;
  50013. private _system;
  50014. /**
  50015. * Creates a new Lens Flare.
  50016. * This represents one of the lens effect in a `lensFlareSystem`.
  50017. * It controls one of the indiviual texture used in the effect.
  50018. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50019. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50020. * @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.
  50021. * @param color Define the lens color
  50022. * @param imgUrl Define the lens texture url
  50023. * @param system Define the `lensFlareSystem` this flare is part of
  50024. * @returns The newly created Lens Flare
  50025. */
  50026. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50027. /**
  50028. * Instantiates a new Lens Flare.
  50029. * This represents one of the lens effect in a `lensFlareSystem`.
  50030. * It controls one of the indiviual texture used in the effect.
  50031. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50032. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50033. * @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.
  50034. * @param color Define the lens color
  50035. * @param imgUrl Define the lens texture url
  50036. * @param system Define the `lensFlareSystem` this flare is part of
  50037. */
  50038. constructor(
  50039. /**
  50040. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50041. */
  50042. size: number,
  50043. /**
  50044. * 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.
  50045. */
  50046. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50047. /**
  50048. * Dispose and release the lens flare with its associated resources.
  50049. */
  50050. dispose(): void;
  50051. }
  50052. }
  50053. declare module BABYLON {
  50054. interface AbstractScene {
  50055. /**
  50056. * The list of lens flare system added to the scene
  50057. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50058. */
  50059. lensFlareSystems: Array<LensFlareSystem>;
  50060. /**
  50061. * Removes the given lens flare system from this scene.
  50062. * @param toRemove The lens flare system to remove
  50063. * @returns The index of the removed lens flare system
  50064. */
  50065. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50066. /**
  50067. * Adds the given lens flare system to this scene
  50068. * @param newLensFlareSystem The lens flare system to add
  50069. */
  50070. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50071. /**
  50072. * Gets a lens flare system using its name
  50073. * @param name defines the name to look for
  50074. * @returns the lens flare system or null if not found
  50075. */
  50076. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50077. /**
  50078. * Gets a lens flare system using its id
  50079. * @param id defines the id to look for
  50080. * @returns the lens flare system or null if not found
  50081. */
  50082. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50083. }
  50084. /**
  50085. * Defines the lens flare scene component responsible to manage any lens flares
  50086. * in a given scene.
  50087. */
  50088. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50089. /**
  50090. * The component name helpfull to identify the component in the list of scene components.
  50091. */
  50092. readonly name: string;
  50093. /**
  50094. * The scene the component belongs to.
  50095. */
  50096. scene: Scene;
  50097. /**
  50098. * Creates a new instance of the component for the given scene
  50099. * @param scene Defines the scene to register the component in
  50100. */
  50101. constructor(scene: Scene);
  50102. /**
  50103. * Registers the component in a given scene
  50104. */
  50105. register(): void;
  50106. /**
  50107. * Rebuilds the elements related to this component in case of
  50108. * context lost for instance.
  50109. */
  50110. rebuild(): void;
  50111. /**
  50112. * Adds all the elements from the container to the scene
  50113. * @param container the container holding the elements
  50114. */
  50115. addFromContainer(container: AbstractScene): void;
  50116. /**
  50117. * Removes all the elements in the container from the scene
  50118. * @param container contains the elements to remove
  50119. * @param dispose if the removed element should be disposed (default: false)
  50120. */
  50121. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50122. /**
  50123. * Serializes the component data to the specified json object
  50124. * @param serializationObject The object to serialize to
  50125. */
  50126. serialize(serializationObject: any): void;
  50127. /**
  50128. * Disposes the component and the associated ressources.
  50129. */
  50130. dispose(): void;
  50131. private _draw;
  50132. }
  50133. }
  50134. declare module BABYLON {
  50135. /**
  50136. * Defines the shadow generator component responsible to manage any shadow generators
  50137. * in a given scene.
  50138. */
  50139. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50140. /**
  50141. * The component name helpfull to identify the component in the list of scene components.
  50142. */
  50143. readonly name: string;
  50144. /**
  50145. * The scene the component belongs to.
  50146. */
  50147. scene: Scene;
  50148. /**
  50149. * Creates a new instance of the component for the given scene
  50150. * @param scene Defines the scene to register the component in
  50151. */
  50152. constructor(scene: Scene);
  50153. /**
  50154. * Registers the component in a given scene
  50155. */
  50156. register(): void;
  50157. /**
  50158. * Rebuilds the elements related to this component in case of
  50159. * context lost for instance.
  50160. */
  50161. rebuild(): void;
  50162. /**
  50163. * Serializes the component data to the specified json object
  50164. * @param serializationObject The object to serialize to
  50165. */
  50166. serialize(serializationObject: any): void;
  50167. /**
  50168. * Adds all the elements from the container to the scene
  50169. * @param container the container holding the elements
  50170. */
  50171. addFromContainer(container: AbstractScene): void;
  50172. /**
  50173. * Removes all the elements in the container from the scene
  50174. * @param container contains the elements to remove
  50175. * @param dispose if the removed element should be disposed (default: false)
  50176. */
  50177. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50178. /**
  50179. * Rebuilds the elements related to this component in case of
  50180. * context lost for instance.
  50181. */
  50182. dispose(): void;
  50183. private _gatherRenderTargets;
  50184. }
  50185. }
  50186. declare module BABYLON {
  50187. /**
  50188. * A point light is a light defined by an unique point in world space.
  50189. * The light is emitted in every direction from this point.
  50190. * A good example of a point light is a standard light bulb.
  50191. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50192. */
  50193. export class PointLight extends ShadowLight {
  50194. private _shadowAngle;
  50195. /**
  50196. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50197. * This specifies what angle the shadow will use to be created.
  50198. *
  50199. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50200. */
  50201. /**
  50202. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50203. * This specifies what angle the shadow will use to be created.
  50204. *
  50205. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50206. */
  50207. shadowAngle: number;
  50208. /**
  50209. * Gets the direction if it has been set.
  50210. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50211. */
  50212. /**
  50213. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50214. */
  50215. direction: Vector3;
  50216. /**
  50217. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50218. * A PointLight emits the light in every direction.
  50219. * It can cast shadows.
  50220. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50221. * ```javascript
  50222. * var pointLight = new PointLight("pl", camera.position, scene);
  50223. * ```
  50224. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50225. * @param name The light friendly name
  50226. * @param position The position of the point light in the scene
  50227. * @param scene The scene the lights belongs to
  50228. */
  50229. constructor(name: string, position: Vector3, scene: Scene);
  50230. /**
  50231. * Returns the string "PointLight"
  50232. * @returns the class name
  50233. */
  50234. getClassName(): string;
  50235. /**
  50236. * Returns the integer 0.
  50237. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50238. */
  50239. getTypeID(): number;
  50240. /**
  50241. * Specifies wether or not the shadowmap should be a cube texture.
  50242. * @returns true if the shadowmap needs to be a cube texture.
  50243. */
  50244. needCube(): boolean;
  50245. /**
  50246. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50247. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50248. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50249. */
  50250. getShadowDirection(faceIndex?: number): Vector3;
  50251. /**
  50252. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50253. * - fov = PI / 2
  50254. * - aspect ratio : 1.0
  50255. * - z-near and far equal to the active camera minZ and maxZ.
  50256. * Returns the PointLight.
  50257. */
  50258. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50259. protected _buildUniformLayout(): void;
  50260. /**
  50261. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50262. * @param effect The effect to update
  50263. * @param lightIndex The index of the light in the effect to update
  50264. * @returns The point light
  50265. */
  50266. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50267. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50268. /**
  50269. * Prepares the list of defines specific to the light type.
  50270. * @param defines the list of defines
  50271. * @param lightIndex defines the index of the light for the effect
  50272. */
  50273. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50274. }
  50275. }
  50276. declare module BABYLON {
  50277. /**
  50278. * Header information of HDR texture files.
  50279. */
  50280. export interface HDRInfo {
  50281. /**
  50282. * The height of the texture in pixels.
  50283. */
  50284. height: number;
  50285. /**
  50286. * The width of the texture in pixels.
  50287. */
  50288. width: number;
  50289. /**
  50290. * The index of the beginning of the data in the binary file.
  50291. */
  50292. dataPosition: number;
  50293. }
  50294. /**
  50295. * This groups tools to convert HDR texture to native colors array.
  50296. */
  50297. export class HDRTools {
  50298. private static Ldexp;
  50299. private static Rgbe2float;
  50300. private static readStringLine;
  50301. /**
  50302. * Reads header information from an RGBE texture stored in a native array.
  50303. * More information on this format are available here:
  50304. * https://en.wikipedia.org/wiki/RGBE_image_format
  50305. *
  50306. * @param uint8array The binary file stored in native array.
  50307. * @return The header information.
  50308. */
  50309. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50310. /**
  50311. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50312. * This RGBE texture needs to store the information as a panorama.
  50313. *
  50314. * More information on this format are available here:
  50315. * https://en.wikipedia.org/wiki/RGBE_image_format
  50316. *
  50317. * @param buffer The binary file stored in an array buffer.
  50318. * @param size The expected size of the extracted cubemap.
  50319. * @return The Cube Map information.
  50320. */
  50321. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50322. /**
  50323. * Returns the pixels data extracted from an RGBE texture.
  50324. * This pixels will be stored left to right up to down in the R G B order in one array.
  50325. *
  50326. * More information on this format are available here:
  50327. * https://en.wikipedia.org/wiki/RGBE_image_format
  50328. *
  50329. * @param uint8array The binary file stored in an array buffer.
  50330. * @param hdrInfo The header information of the file.
  50331. * @return The pixels data in RGB right to left up to down order.
  50332. */
  50333. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50334. private static RGBE_ReadPixels_RLE;
  50335. }
  50336. }
  50337. declare module BABYLON {
  50338. /**
  50339. * This represents a texture coming from an HDR input.
  50340. *
  50341. * The only supported format is currently panorama picture stored in RGBE format.
  50342. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50343. */
  50344. export class HDRCubeTexture extends BaseTexture {
  50345. private static _facesMapping;
  50346. private _generateHarmonics;
  50347. private _noMipmap;
  50348. private _textureMatrix;
  50349. private _size;
  50350. private _onLoad;
  50351. private _onError;
  50352. /**
  50353. * The texture URL.
  50354. */
  50355. url: string;
  50356. /**
  50357. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50358. */
  50359. coordinatesMode: number;
  50360. protected _isBlocking: boolean;
  50361. /**
  50362. * Sets wether or not the texture is blocking during loading.
  50363. */
  50364. /**
  50365. * Gets wether or not the texture is blocking during loading.
  50366. */
  50367. isBlocking: boolean;
  50368. protected _rotationY: number;
  50369. /**
  50370. * Sets texture matrix rotation angle around Y axis in radians.
  50371. */
  50372. /**
  50373. * Gets texture matrix rotation angle around Y axis radians.
  50374. */
  50375. rotationY: number;
  50376. /**
  50377. * Gets or sets the center of the bounding box associated with the cube texture
  50378. * It must define where the camera used to render the texture was set
  50379. */
  50380. boundingBoxPosition: Vector3;
  50381. private _boundingBoxSize;
  50382. /**
  50383. * Gets or sets the size of the bounding box associated with the cube texture
  50384. * When defined, the cubemap will switch to local mode
  50385. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50386. * @example https://www.babylonjs-playground.com/#RNASML
  50387. */
  50388. boundingBoxSize: Vector3;
  50389. /**
  50390. * Instantiates an HDRTexture from the following parameters.
  50391. *
  50392. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50393. * @param scene The scene the texture will be used in
  50394. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50395. * @param noMipmap Forces to not generate the mipmap if true
  50396. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50397. * @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)
  50398. * @param reserved Reserved flag for internal use.
  50399. */
  50400. 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>);
  50401. /**
  50402. * Get the current class name of the texture useful for serialization or dynamic coding.
  50403. * @returns "HDRCubeTexture"
  50404. */
  50405. getClassName(): string;
  50406. /**
  50407. * Occurs when the file is raw .hdr file.
  50408. */
  50409. private loadTexture;
  50410. clone(): HDRCubeTexture;
  50411. delayLoad(): void;
  50412. /**
  50413. * Get the texture reflection matrix used to rotate/transform the reflection.
  50414. * @returns the reflection matrix
  50415. */
  50416. getReflectionTextureMatrix(): Matrix;
  50417. /**
  50418. * Set the texture reflection matrix used to rotate/transform the reflection.
  50419. * @param value Define the reflection matrix to set
  50420. */
  50421. setReflectionTextureMatrix(value: Matrix): void;
  50422. /**
  50423. * Parses a JSON representation of an HDR Texture in order to create the texture
  50424. * @param parsedTexture Define the JSON representation
  50425. * @param scene Define the scene the texture should be created in
  50426. * @param rootUrl Define the root url in case we need to load relative dependencies
  50427. * @returns the newly created texture after parsing
  50428. */
  50429. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50430. serialize(): any;
  50431. }
  50432. }
  50433. declare module BABYLON {
  50434. /**
  50435. * Class used to control physics engine
  50436. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50437. */
  50438. export class PhysicsEngine implements IPhysicsEngine {
  50439. private _physicsPlugin;
  50440. /**
  50441. * Global value used to control the smallest number supported by the simulation
  50442. */
  50443. static Epsilon: number;
  50444. private _impostors;
  50445. private _joints;
  50446. /**
  50447. * Gets the gravity vector used by the simulation
  50448. */
  50449. gravity: Vector3;
  50450. /**
  50451. * Factory used to create the default physics plugin.
  50452. * @returns The default physics plugin
  50453. */
  50454. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50455. /**
  50456. * Creates a new Physics Engine
  50457. * @param gravity defines the gravity vector used by the simulation
  50458. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50459. */
  50460. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50461. /**
  50462. * Sets the gravity vector used by the simulation
  50463. * @param gravity defines the gravity vector to use
  50464. */
  50465. setGravity(gravity: Vector3): void;
  50466. /**
  50467. * Set the time step of the physics engine.
  50468. * Default is 1/60.
  50469. * To slow it down, enter 1/600 for example.
  50470. * To speed it up, 1/30
  50471. * @param newTimeStep defines the new timestep to apply to this world.
  50472. */
  50473. setTimeStep(newTimeStep?: number): void;
  50474. /**
  50475. * Get the time step of the physics engine.
  50476. * @returns the current time step
  50477. */
  50478. getTimeStep(): number;
  50479. /**
  50480. * Release all resources
  50481. */
  50482. dispose(): void;
  50483. /**
  50484. * Gets the name of the current physics plugin
  50485. * @returns the name of the plugin
  50486. */
  50487. getPhysicsPluginName(): string;
  50488. /**
  50489. * Adding a new impostor for the impostor tracking.
  50490. * This will be done by the impostor itself.
  50491. * @param impostor the impostor to add
  50492. */
  50493. addImpostor(impostor: PhysicsImpostor): void;
  50494. /**
  50495. * Remove an impostor from the engine.
  50496. * This impostor and its mesh will not longer be updated by the physics engine.
  50497. * @param impostor the impostor to remove
  50498. */
  50499. removeImpostor(impostor: PhysicsImpostor): void;
  50500. /**
  50501. * Add a joint to the physics engine
  50502. * @param mainImpostor defines the main impostor to which the joint is added.
  50503. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50504. * @param joint defines the joint that will connect both impostors.
  50505. */
  50506. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50507. /**
  50508. * Removes a joint from the simulation
  50509. * @param mainImpostor defines the impostor used with the joint
  50510. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50511. * @param joint defines the joint to remove
  50512. */
  50513. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50514. /**
  50515. * Called by the scene. No need to call it.
  50516. * @param delta defines the timespam between frames
  50517. */
  50518. _step(delta: number): void;
  50519. /**
  50520. * Gets the current plugin used to run the simulation
  50521. * @returns current plugin
  50522. */
  50523. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50524. /**
  50525. * Gets the list of physic impostors
  50526. * @returns an array of PhysicsImpostor
  50527. */
  50528. getImpostors(): Array<PhysicsImpostor>;
  50529. /**
  50530. * Gets the impostor for a physics enabled object
  50531. * @param object defines the object impersonated by the impostor
  50532. * @returns the PhysicsImpostor or null if not found
  50533. */
  50534. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50535. /**
  50536. * Gets the impostor for a physics body object
  50537. * @param body defines physics body used by the impostor
  50538. * @returns the PhysicsImpostor or null if not found
  50539. */
  50540. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50541. /**
  50542. * Does a raycast in the physics world
  50543. * @param from when should the ray start?
  50544. * @param to when should the ray end?
  50545. * @returns PhysicsRaycastResult
  50546. */
  50547. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50548. }
  50549. }
  50550. declare module BABYLON {
  50551. /** @hidden */
  50552. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50553. private _useDeltaForWorldStep;
  50554. world: any;
  50555. name: string;
  50556. private _physicsMaterials;
  50557. private _fixedTimeStep;
  50558. private _cannonRaycastResult;
  50559. private _raycastResult;
  50560. private _physicsBodysToRemoveAfterStep;
  50561. BJSCANNON: any;
  50562. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50563. setGravity(gravity: Vector3): void;
  50564. setTimeStep(timeStep: number): void;
  50565. getTimeStep(): number;
  50566. executeStep(delta: number): void;
  50567. private _removeMarkedPhysicsBodiesFromWorld;
  50568. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50569. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50570. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50571. private _processChildMeshes;
  50572. removePhysicsBody(impostor: PhysicsImpostor): void;
  50573. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50574. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50575. private _addMaterial;
  50576. private _checkWithEpsilon;
  50577. private _createShape;
  50578. private _createHeightmap;
  50579. private _minus90X;
  50580. private _plus90X;
  50581. private _tmpPosition;
  50582. private _tmpDeltaPosition;
  50583. private _tmpUnityRotation;
  50584. private _updatePhysicsBodyTransformation;
  50585. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50586. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50587. isSupported(): boolean;
  50588. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50589. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50590. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50591. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50592. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50593. getBodyMass(impostor: PhysicsImpostor): number;
  50594. getBodyFriction(impostor: PhysicsImpostor): number;
  50595. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50596. getBodyRestitution(impostor: PhysicsImpostor): number;
  50597. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50598. sleepBody(impostor: PhysicsImpostor): void;
  50599. wakeUpBody(impostor: PhysicsImpostor): void;
  50600. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50601. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50602. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50603. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50604. getRadius(impostor: PhysicsImpostor): number;
  50605. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50606. dispose(): void;
  50607. private _extendNamespace;
  50608. /**
  50609. * Does a raycast in the physics world
  50610. * @param from when should the ray start?
  50611. * @param to when should the ray end?
  50612. * @returns PhysicsRaycastResult
  50613. */
  50614. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50615. }
  50616. }
  50617. declare module BABYLON {
  50618. /** @hidden */
  50619. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50620. world: any;
  50621. name: string;
  50622. BJSOIMO: any;
  50623. private _raycastResult;
  50624. constructor(iterations?: number, oimoInjection?: any);
  50625. setGravity(gravity: Vector3): void;
  50626. setTimeStep(timeStep: number): void;
  50627. getTimeStep(): number;
  50628. private _tmpImpostorsArray;
  50629. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50630. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50631. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50632. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50633. private _tmpPositionVector;
  50634. removePhysicsBody(impostor: PhysicsImpostor): void;
  50635. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50636. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50637. isSupported(): boolean;
  50638. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50639. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50640. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50641. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50642. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50643. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50644. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50645. getBodyMass(impostor: PhysicsImpostor): number;
  50646. getBodyFriction(impostor: PhysicsImpostor): number;
  50647. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50648. getBodyRestitution(impostor: PhysicsImpostor): number;
  50649. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50650. sleepBody(impostor: PhysicsImpostor): void;
  50651. wakeUpBody(impostor: PhysicsImpostor): void;
  50652. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50653. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50654. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50655. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50656. getRadius(impostor: PhysicsImpostor): number;
  50657. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50658. dispose(): void;
  50659. /**
  50660. * Does a raycast in the physics world
  50661. * @param from when should the ray start?
  50662. * @param to when should the ray end?
  50663. * @returns PhysicsRaycastResult
  50664. */
  50665. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. /**
  50670. * Class containing static functions to help procedurally build meshes
  50671. */
  50672. export class RibbonBuilder {
  50673. /**
  50674. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50675. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50676. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50677. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50678. * * 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
  50679. * * 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
  50680. * * 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
  50681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50682. * * 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
  50683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50684. * * 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
  50685. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50686. * * 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
  50687. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50689. * @param name defines the name of the mesh
  50690. * @param options defines the options used to create the mesh
  50691. * @param scene defines the hosting scene
  50692. * @returns the ribbon mesh
  50693. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50694. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50695. */
  50696. static CreateRibbon(name: string, options: {
  50697. pathArray: Vector3[][];
  50698. closeArray?: boolean;
  50699. closePath?: boolean;
  50700. offset?: number;
  50701. updatable?: boolean;
  50702. sideOrientation?: number;
  50703. frontUVs?: Vector4;
  50704. backUVs?: Vector4;
  50705. instance?: Mesh;
  50706. invertUV?: boolean;
  50707. uvs?: Vector2[];
  50708. colors?: Color4[];
  50709. }, scene?: Nullable<Scene>): Mesh;
  50710. }
  50711. }
  50712. declare module BABYLON {
  50713. /**
  50714. * Class containing static functions to help procedurally build meshes
  50715. */
  50716. export class ShapeBuilder {
  50717. /**
  50718. * 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.
  50719. * * 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.
  50720. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50721. * * 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.
  50722. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50723. * * 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
  50724. * * 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
  50725. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50727. * * 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
  50728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50730. * @param name defines the name of the mesh
  50731. * @param options defines the options used to create the mesh
  50732. * @param scene defines the hosting scene
  50733. * @returns the extruded shape mesh
  50734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50736. */
  50737. static ExtrudeShape(name: string, options: {
  50738. shape: Vector3[];
  50739. path: Vector3[];
  50740. scale?: number;
  50741. rotation?: number;
  50742. cap?: number;
  50743. updatable?: boolean;
  50744. sideOrientation?: number;
  50745. frontUVs?: Vector4;
  50746. backUVs?: Vector4;
  50747. instance?: Mesh;
  50748. invertUV?: boolean;
  50749. }, scene?: Nullable<Scene>): Mesh;
  50750. /**
  50751. * Creates an custom extruded shape mesh.
  50752. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50753. * * 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.
  50754. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50755. * * 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
  50756. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50757. * * 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
  50758. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50759. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50760. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50761. * * 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
  50762. * * 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
  50763. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50765. * * 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
  50766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50768. * @param name defines the name of the mesh
  50769. * @param options defines the options used to create the mesh
  50770. * @param scene defines the hosting scene
  50771. * @returns the custom extruded shape mesh
  50772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50773. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50775. */
  50776. static ExtrudeShapeCustom(name: string, options: {
  50777. shape: Vector3[];
  50778. path: Vector3[];
  50779. scaleFunction?: any;
  50780. rotationFunction?: any;
  50781. ribbonCloseArray?: boolean;
  50782. ribbonClosePath?: boolean;
  50783. cap?: number;
  50784. updatable?: boolean;
  50785. sideOrientation?: number;
  50786. frontUVs?: Vector4;
  50787. backUVs?: Vector4;
  50788. instance?: Mesh;
  50789. invertUV?: boolean;
  50790. }, scene?: Nullable<Scene>): Mesh;
  50791. private static _ExtrudeShapeGeneric;
  50792. }
  50793. }
  50794. declare module BABYLON {
  50795. /**
  50796. * AmmoJS Physics plugin
  50797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50798. * @see https://github.com/kripken/ammo.js/
  50799. */
  50800. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50801. private _useDeltaForWorldStep;
  50802. /**
  50803. * Reference to the Ammo library
  50804. */
  50805. bjsAMMO: any;
  50806. /**
  50807. * Created ammoJS world which physics bodies are added to
  50808. */
  50809. world: any;
  50810. /**
  50811. * Name of the plugin
  50812. */
  50813. name: string;
  50814. private _timeStep;
  50815. private _fixedTimeStep;
  50816. private _maxSteps;
  50817. private _tmpQuaternion;
  50818. private _tmpAmmoTransform;
  50819. private _tmpAmmoQuaternion;
  50820. private _tmpAmmoConcreteContactResultCallback;
  50821. private _collisionConfiguration;
  50822. private _dispatcher;
  50823. private _overlappingPairCache;
  50824. private _solver;
  50825. private _softBodySolver;
  50826. private _tmpAmmoVectorA;
  50827. private _tmpAmmoVectorB;
  50828. private _tmpAmmoVectorC;
  50829. private _tmpAmmoVectorD;
  50830. private _tmpContactCallbackResult;
  50831. private _tmpAmmoVectorRCA;
  50832. private _tmpAmmoVectorRCB;
  50833. private _raycastResult;
  50834. private static readonly DISABLE_COLLISION_FLAG;
  50835. private static readonly KINEMATIC_FLAG;
  50836. private static readonly DISABLE_DEACTIVATION_FLAG;
  50837. /**
  50838. * Initializes the ammoJS plugin
  50839. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50840. * @param ammoInjection can be used to inject your own ammo reference
  50841. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50842. */
  50843. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50844. /**
  50845. * Sets the gravity of the physics world (m/(s^2))
  50846. * @param gravity Gravity to set
  50847. */
  50848. setGravity(gravity: Vector3): void;
  50849. /**
  50850. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50851. * @param timeStep timestep to use in seconds
  50852. */
  50853. setTimeStep(timeStep: number): void;
  50854. /**
  50855. * 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)
  50856. * @param fixedTimeStep fixedTimeStep to use in seconds
  50857. */
  50858. setFixedTimeStep(fixedTimeStep: number): void;
  50859. /**
  50860. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50861. * @param maxSteps the maximum number of steps by the physics engine per frame
  50862. */
  50863. setMaxSteps(maxSteps: number): void;
  50864. /**
  50865. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50866. * @returns the current timestep in seconds
  50867. */
  50868. getTimeStep(): number;
  50869. private _isImpostorInContact;
  50870. private _isImpostorPairInContact;
  50871. private _stepSimulation;
  50872. /**
  50873. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50874. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50875. * After the step the babylon meshes are set to the position of the physics imposters
  50876. * @param delta amount of time to step forward
  50877. * @param impostors array of imposters to update before/after the step
  50878. */
  50879. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50880. /**
  50881. * Update babylon mesh to match physics world object
  50882. * @param impostor imposter to match
  50883. */
  50884. private _afterSoftStep;
  50885. /**
  50886. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50887. * @param impostor imposter to match
  50888. */
  50889. private _ropeStep;
  50890. /**
  50891. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50892. * @param impostor imposter to match
  50893. */
  50894. private _softbodyOrClothStep;
  50895. private _tmpVector;
  50896. private _tmpMatrix;
  50897. /**
  50898. * Applies an impulse on the imposter
  50899. * @param impostor imposter to apply impulse to
  50900. * @param force amount of force to be applied to the imposter
  50901. * @param contactPoint the location to apply the impulse on the imposter
  50902. */
  50903. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50904. /**
  50905. * Applies a force on the imposter
  50906. * @param impostor imposter to apply force
  50907. * @param force amount of force to be applied to the imposter
  50908. * @param contactPoint the location to apply the force on the imposter
  50909. */
  50910. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50911. /**
  50912. * Creates a physics body using the plugin
  50913. * @param impostor the imposter to create the physics body on
  50914. */
  50915. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50916. /**
  50917. * Removes the physics body from the imposter and disposes of the body's memory
  50918. * @param impostor imposter to remove the physics body from
  50919. */
  50920. removePhysicsBody(impostor: PhysicsImpostor): void;
  50921. /**
  50922. * Generates a joint
  50923. * @param impostorJoint the imposter joint to create the joint with
  50924. */
  50925. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50926. /**
  50927. * Removes a joint
  50928. * @param impostorJoint the imposter joint to remove the joint from
  50929. */
  50930. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50931. private _addMeshVerts;
  50932. /**
  50933. * Initialise the soft body vertices to match its object's (mesh) vertices
  50934. * Softbody vertices (nodes) are in world space and to match this
  50935. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50936. * @param impostor to create the softbody for
  50937. */
  50938. private _softVertexData;
  50939. /**
  50940. * Create an impostor's soft body
  50941. * @param impostor to create the softbody for
  50942. */
  50943. private _createSoftbody;
  50944. /**
  50945. * Create cloth for an impostor
  50946. * @param impostor to create the softbody for
  50947. */
  50948. private _createCloth;
  50949. /**
  50950. * Create rope for an impostor
  50951. * @param impostor to create the softbody for
  50952. */
  50953. private _createRope;
  50954. private _addHullVerts;
  50955. private _createShape;
  50956. /**
  50957. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50958. * @param impostor imposter containing the physics body and babylon object
  50959. */
  50960. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50961. /**
  50962. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50963. * @param impostor imposter containing the physics body and babylon object
  50964. * @param newPosition new position
  50965. * @param newRotation new rotation
  50966. */
  50967. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50968. /**
  50969. * If this plugin is supported
  50970. * @returns true if its supported
  50971. */
  50972. isSupported(): boolean;
  50973. /**
  50974. * Sets the linear velocity of the physics body
  50975. * @param impostor imposter to set the velocity on
  50976. * @param velocity velocity to set
  50977. */
  50978. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50979. /**
  50980. * Sets the angular velocity of the physics body
  50981. * @param impostor imposter to set the velocity on
  50982. * @param velocity velocity to set
  50983. */
  50984. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50985. /**
  50986. * gets the linear velocity
  50987. * @param impostor imposter to get linear velocity from
  50988. * @returns linear velocity
  50989. */
  50990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50991. /**
  50992. * gets the angular velocity
  50993. * @param impostor imposter to get angular velocity from
  50994. * @returns angular velocity
  50995. */
  50996. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50997. /**
  50998. * Sets the mass of physics body
  50999. * @param impostor imposter to set the mass on
  51000. * @param mass mass to set
  51001. */
  51002. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51003. /**
  51004. * Gets the mass of the physics body
  51005. * @param impostor imposter to get the mass from
  51006. * @returns mass
  51007. */
  51008. getBodyMass(impostor: PhysicsImpostor): number;
  51009. /**
  51010. * Gets friction of the impostor
  51011. * @param impostor impostor to get friction from
  51012. * @returns friction value
  51013. */
  51014. getBodyFriction(impostor: PhysicsImpostor): number;
  51015. /**
  51016. * Sets friction of the impostor
  51017. * @param impostor impostor to set friction on
  51018. * @param friction friction value
  51019. */
  51020. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51021. /**
  51022. * Gets restitution of the impostor
  51023. * @param impostor impostor to get restitution from
  51024. * @returns restitution value
  51025. */
  51026. getBodyRestitution(impostor: PhysicsImpostor): number;
  51027. /**
  51028. * Sets resitution of the impostor
  51029. * @param impostor impostor to set resitution on
  51030. * @param restitution resitution value
  51031. */
  51032. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51033. /**
  51034. * Gets pressure inside the impostor
  51035. * @param impostor impostor to get pressure from
  51036. * @returns pressure value
  51037. */
  51038. getBodyPressure(impostor: PhysicsImpostor): number;
  51039. /**
  51040. * Sets pressure inside a soft body impostor
  51041. * Cloth and rope must remain 0 pressure
  51042. * @param impostor impostor to set pressure on
  51043. * @param pressure pressure value
  51044. */
  51045. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51046. /**
  51047. * Gets stiffness of the impostor
  51048. * @param impostor impostor to get stiffness from
  51049. * @returns pressure value
  51050. */
  51051. getBodyStiffness(impostor: PhysicsImpostor): number;
  51052. /**
  51053. * Sets stiffness of the impostor
  51054. * @param impostor impostor to set stiffness on
  51055. * @param stiffness stiffness value from 0 to 1
  51056. */
  51057. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51058. /**
  51059. * Gets velocityIterations of the impostor
  51060. * @param impostor impostor to get velocity iterations from
  51061. * @returns velocityIterations value
  51062. */
  51063. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51064. /**
  51065. * Sets velocityIterations of the impostor
  51066. * @param impostor impostor to set velocity iterations on
  51067. * @param velocityIterations velocityIterations value
  51068. */
  51069. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51070. /**
  51071. * Gets positionIterations of the impostor
  51072. * @param impostor impostor to get position iterations from
  51073. * @returns positionIterations value
  51074. */
  51075. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51076. /**
  51077. * Sets positionIterations of the impostor
  51078. * @param impostor impostor to set position on
  51079. * @param positionIterations positionIterations value
  51080. */
  51081. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51082. /**
  51083. * Append an anchor to a cloth object
  51084. * @param impostor is the cloth impostor to add anchor to
  51085. * @param otherImpostor is the rigid impostor to anchor to
  51086. * @param width ratio across width from 0 to 1
  51087. * @param height ratio up height from 0 to 1
  51088. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51089. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51090. */
  51091. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51092. /**
  51093. * Append an hook to a rope object
  51094. * @param impostor is the rope impostor to add hook to
  51095. * @param otherImpostor is the rigid impostor to hook to
  51096. * @param length ratio along the rope from 0 to 1
  51097. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51098. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51099. */
  51100. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51101. /**
  51102. * Sleeps the physics body and stops it from being active
  51103. * @param impostor impostor to sleep
  51104. */
  51105. sleepBody(impostor: PhysicsImpostor): void;
  51106. /**
  51107. * Activates the physics body
  51108. * @param impostor impostor to activate
  51109. */
  51110. wakeUpBody(impostor: PhysicsImpostor): void;
  51111. /**
  51112. * Updates the distance parameters of the joint
  51113. * @param joint joint to update
  51114. * @param maxDistance maximum distance of the joint
  51115. * @param minDistance minimum distance of the joint
  51116. */
  51117. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51118. /**
  51119. * Sets a motor on the joint
  51120. * @param joint joint to set motor on
  51121. * @param speed speed of the motor
  51122. * @param maxForce maximum force of the motor
  51123. * @param motorIndex index of the motor
  51124. */
  51125. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51126. /**
  51127. * Sets the motors limit
  51128. * @param joint joint to set limit on
  51129. * @param upperLimit upper limit
  51130. * @param lowerLimit lower limit
  51131. */
  51132. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51133. /**
  51134. * Syncs the position and rotation of a mesh with the impostor
  51135. * @param mesh mesh to sync
  51136. * @param impostor impostor to update the mesh with
  51137. */
  51138. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51139. /**
  51140. * Gets the radius of the impostor
  51141. * @param impostor impostor to get radius from
  51142. * @returns the radius
  51143. */
  51144. getRadius(impostor: PhysicsImpostor): number;
  51145. /**
  51146. * Gets the box size of the impostor
  51147. * @param impostor impostor to get box size from
  51148. * @param result the resulting box size
  51149. */
  51150. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51151. /**
  51152. * Disposes of the impostor
  51153. */
  51154. dispose(): void;
  51155. /**
  51156. * Does a raycast in the physics world
  51157. * @param from when should the ray start?
  51158. * @param to when should the ray end?
  51159. * @returns PhysicsRaycastResult
  51160. */
  51161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51162. }
  51163. }
  51164. declare module BABYLON {
  51165. interface AbstractScene {
  51166. /**
  51167. * The list of reflection probes added to the scene
  51168. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51169. */
  51170. reflectionProbes: Array<ReflectionProbe>;
  51171. /**
  51172. * Removes the given reflection probe from this scene.
  51173. * @param toRemove The reflection probe to remove
  51174. * @returns The index of the removed reflection probe
  51175. */
  51176. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51177. /**
  51178. * Adds the given reflection probe to this scene.
  51179. * @param newReflectionProbe The reflection probe to add
  51180. */
  51181. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51182. }
  51183. /**
  51184. * Class used to generate realtime reflection / refraction cube textures
  51185. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51186. */
  51187. export class ReflectionProbe {
  51188. /** defines the name of the probe */
  51189. name: string;
  51190. private _scene;
  51191. private _renderTargetTexture;
  51192. private _projectionMatrix;
  51193. private _viewMatrix;
  51194. private _target;
  51195. private _add;
  51196. private _attachedMesh;
  51197. private _invertYAxis;
  51198. /** Gets or sets probe position (center of the cube map) */
  51199. position: Vector3;
  51200. /**
  51201. * Creates a new reflection probe
  51202. * @param name defines the name of the probe
  51203. * @param size defines the texture resolution (for each face)
  51204. * @param scene defines the hosting scene
  51205. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51206. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51207. */
  51208. constructor(
  51209. /** defines the name of the probe */
  51210. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51211. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51212. samples: number;
  51213. /** Gets or sets the refresh rate to use (on every frame by default) */
  51214. refreshRate: number;
  51215. /**
  51216. * Gets the hosting scene
  51217. * @returns a Scene
  51218. */
  51219. getScene(): Scene;
  51220. /** Gets the internal CubeTexture used to render to */
  51221. readonly cubeTexture: RenderTargetTexture;
  51222. /** Gets the list of meshes to render */
  51223. readonly renderList: Nullable<AbstractMesh[]>;
  51224. /**
  51225. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51226. * @param mesh defines the mesh to attach to
  51227. */
  51228. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51229. /**
  51230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51231. * @param renderingGroupId The rendering group id corresponding to its index
  51232. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51233. */
  51234. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51235. /**
  51236. * Clean all associated resources
  51237. */
  51238. dispose(): void;
  51239. /**
  51240. * Converts the reflection probe information to a readable string for debug purpose.
  51241. * @param fullDetails Supports for multiple levels of logging within scene loading
  51242. * @returns the human readable reflection probe info
  51243. */
  51244. toString(fullDetails?: boolean): string;
  51245. /**
  51246. * Get the class name of the relfection probe.
  51247. * @returns "ReflectionProbe"
  51248. */
  51249. getClassName(): string;
  51250. /**
  51251. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51252. * @returns The JSON representation of the texture
  51253. */
  51254. serialize(): any;
  51255. /**
  51256. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51257. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51258. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51259. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51260. * @returns The parsed reflection probe if successful
  51261. */
  51262. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51263. }
  51264. }
  51265. declare module BABYLON {
  51266. /** @hidden */
  51267. export var _BabylonLoaderRegistered: boolean;
  51268. }
  51269. declare module BABYLON {
  51270. /**
  51271. * The Physically based simple base material of BJS.
  51272. *
  51273. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51274. * It is used as the base class for both the specGloss and metalRough conventions.
  51275. */
  51276. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51277. /**
  51278. * Number of Simultaneous lights allowed on the material.
  51279. */
  51280. maxSimultaneousLights: number;
  51281. /**
  51282. * If sets to true, disables all the lights affecting the material.
  51283. */
  51284. disableLighting: boolean;
  51285. /**
  51286. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51287. */
  51288. environmentTexture: BaseTexture;
  51289. /**
  51290. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51291. */
  51292. invertNormalMapX: boolean;
  51293. /**
  51294. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51295. */
  51296. invertNormalMapY: boolean;
  51297. /**
  51298. * Normal map used in the model.
  51299. */
  51300. normalTexture: BaseTexture;
  51301. /**
  51302. * Emissivie color used to self-illuminate the model.
  51303. */
  51304. emissiveColor: Color3;
  51305. /**
  51306. * Emissivie texture used to self-illuminate the model.
  51307. */
  51308. emissiveTexture: BaseTexture;
  51309. /**
  51310. * Occlusion Channel Strenght.
  51311. */
  51312. occlusionStrength: number;
  51313. /**
  51314. * Occlusion Texture of the material (adding extra occlusion effects).
  51315. */
  51316. occlusionTexture: BaseTexture;
  51317. /**
  51318. * Defines the alpha limits in alpha test mode.
  51319. */
  51320. alphaCutOff: number;
  51321. /**
  51322. * Gets the current double sided mode.
  51323. */
  51324. /**
  51325. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51326. */
  51327. doubleSided: boolean;
  51328. /**
  51329. * Stores the pre-calculated light information of a mesh in a texture.
  51330. */
  51331. lightmapTexture: BaseTexture;
  51332. /**
  51333. * If true, the light map contains occlusion information instead of lighting info.
  51334. */
  51335. useLightmapAsShadowmap: boolean;
  51336. /**
  51337. * Instantiates a new PBRMaterial instance.
  51338. *
  51339. * @param name The material name
  51340. * @param scene The scene the material will be use in.
  51341. */
  51342. constructor(name: string, scene: Scene);
  51343. getClassName(): string;
  51344. }
  51345. }
  51346. declare module BABYLON {
  51347. /**
  51348. * The PBR material of BJS following the metal roughness convention.
  51349. *
  51350. * This fits to the PBR convention in the GLTF definition:
  51351. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51352. */
  51353. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51354. /**
  51355. * The base color has two different interpretations depending on the value of metalness.
  51356. * When the material is a metal, the base color is the specific measured reflectance value
  51357. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51358. * of the material.
  51359. */
  51360. baseColor: Color3;
  51361. /**
  51362. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51363. * well as opacity information in the alpha channel.
  51364. */
  51365. baseTexture: BaseTexture;
  51366. /**
  51367. * Specifies the metallic scalar value of the material.
  51368. * Can also be used to scale the metalness values of the metallic texture.
  51369. */
  51370. metallic: number;
  51371. /**
  51372. * Specifies the roughness scalar value of the material.
  51373. * Can also be used to scale the roughness values of the metallic texture.
  51374. */
  51375. roughness: number;
  51376. /**
  51377. * Texture containing both the metallic value in the B channel and the
  51378. * roughness value in the G channel to keep better precision.
  51379. */
  51380. metallicRoughnessTexture: BaseTexture;
  51381. /**
  51382. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51383. *
  51384. * @param name The material name
  51385. * @param scene The scene the material will be use in.
  51386. */
  51387. constructor(name: string, scene: Scene);
  51388. /**
  51389. * Return the currrent class name of the material.
  51390. */
  51391. getClassName(): string;
  51392. /**
  51393. * Makes a duplicate of the current material.
  51394. * @param name - name to use for the new material.
  51395. */
  51396. clone(name: string): PBRMetallicRoughnessMaterial;
  51397. /**
  51398. * Serialize the material to a parsable JSON object.
  51399. */
  51400. serialize(): any;
  51401. /**
  51402. * Parses a JSON object correponding to the serialize function.
  51403. */
  51404. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51405. }
  51406. }
  51407. declare module BABYLON {
  51408. /**
  51409. * The PBR material of BJS following the specular glossiness convention.
  51410. *
  51411. * This fits to the PBR convention in the GLTF definition:
  51412. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51413. */
  51414. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51415. /**
  51416. * Specifies the diffuse color of the material.
  51417. */
  51418. diffuseColor: Color3;
  51419. /**
  51420. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51421. * channel.
  51422. */
  51423. diffuseTexture: BaseTexture;
  51424. /**
  51425. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51426. */
  51427. specularColor: Color3;
  51428. /**
  51429. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51430. */
  51431. glossiness: number;
  51432. /**
  51433. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51434. */
  51435. specularGlossinessTexture: BaseTexture;
  51436. /**
  51437. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51438. *
  51439. * @param name The material name
  51440. * @param scene The scene the material will be use in.
  51441. */
  51442. constructor(name: string, scene: Scene);
  51443. /**
  51444. * Return the currrent class name of the material.
  51445. */
  51446. getClassName(): string;
  51447. /**
  51448. * Makes a duplicate of the current material.
  51449. * @param name - name to use for the new material.
  51450. */
  51451. clone(name: string): PBRSpecularGlossinessMaterial;
  51452. /**
  51453. * Serialize the material to a parsable JSON object.
  51454. */
  51455. serialize(): any;
  51456. /**
  51457. * Parses a JSON object correponding to the serialize function.
  51458. */
  51459. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51460. }
  51461. }
  51462. declare module BABYLON {
  51463. /**
  51464. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51465. * It can help converting any input color in a desired output one. This can then be used to create effects
  51466. * from sepia, black and white to sixties or futuristic rendering...
  51467. *
  51468. * The only supported format is currently 3dl.
  51469. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51470. */
  51471. export class ColorGradingTexture extends BaseTexture {
  51472. /**
  51473. * The current texture matrix. (will always be identity in color grading texture)
  51474. */
  51475. private _textureMatrix;
  51476. /**
  51477. * The texture URL.
  51478. */
  51479. url: string;
  51480. /**
  51481. * Empty line regex stored for GC.
  51482. */
  51483. private static _noneEmptyLineRegex;
  51484. private _engine;
  51485. /**
  51486. * Instantiates a ColorGradingTexture from the following parameters.
  51487. *
  51488. * @param url The location of the color gradind data (currently only supporting 3dl)
  51489. * @param scene The scene the texture will be used in
  51490. */
  51491. constructor(url: string, scene: Scene);
  51492. /**
  51493. * Returns the texture matrix used in most of the material.
  51494. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51495. */
  51496. getTextureMatrix(): Matrix;
  51497. /**
  51498. * Occurs when the file being loaded is a .3dl LUT file.
  51499. */
  51500. private load3dlTexture;
  51501. /**
  51502. * Starts the loading process of the texture.
  51503. */
  51504. private loadTexture;
  51505. /**
  51506. * Clones the color gradind texture.
  51507. */
  51508. clone(): ColorGradingTexture;
  51509. /**
  51510. * Called during delayed load for textures.
  51511. */
  51512. delayLoad(): void;
  51513. /**
  51514. * Parses a color grading texture serialized by Babylon.
  51515. * @param parsedTexture The texture information being parsedTexture
  51516. * @param scene The scene to load the texture in
  51517. * @param rootUrl The root url of the data assets to load
  51518. * @return A color gradind texture
  51519. */
  51520. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51521. /**
  51522. * Serializes the LUT texture to json format.
  51523. */
  51524. serialize(): any;
  51525. }
  51526. }
  51527. declare module BABYLON {
  51528. /**
  51529. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51530. */
  51531. export class EquiRectangularCubeTexture extends BaseTexture {
  51532. /** The six faces of the cube. */
  51533. private static _FacesMapping;
  51534. private _noMipmap;
  51535. private _onLoad;
  51536. private _onError;
  51537. /** The size of the cubemap. */
  51538. private _size;
  51539. /** The buffer of the image. */
  51540. private _buffer;
  51541. /** The width of the input image. */
  51542. private _width;
  51543. /** The height of the input image. */
  51544. private _height;
  51545. /** The URL to the image. */
  51546. url: string;
  51547. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51548. coordinatesMode: number;
  51549. /**
  51550. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51551. * @param url The location of the image
  51552. * @param scene The scene the texture will be used in
  51553. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51554. * @param noMipmap Forces to not generate the mipmap if true
  51555. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51556. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51557. * @param onLoad — defines a callback called when texture is loaded
  51558. * @param onError — defines a callback called if there is an error
  51559. */
  51560. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51561. /**
  51562. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51563. */
  51564. private loadImage;
  51565. /**
  51566. * Convert the image buffer into a cubemap and create a CubeTexture.
  51567. */
  51568. private loadTexture;
  51569. /**
  51570. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51571. * @param buffer The ArrayBuffer that should be converted.
  51572. * @returns The buffer as Float32Array.
  51573. */
  51574. private getFloat32ArrayFromArrayBuffer;
  51575. /**
  51576. * Get the current class name of the texture useful for serialization or dynamic coding.
  51577. * @returns "EquiRectangularCubeTexture"
  51578. */
  51579. getClassName(): string;
  51580. /**
  51581. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51582. * @returns A clone of the current EquiRectangularCubeTexture.
  51583. */
  51584. clone(): EquiRectangularCubeTexture;
  51585. }
  51586. }
  51587. declare module BABYLON {
  51588. /**
  51589. * Based on jsTGALoader - Javascript loader for TGA file
  51590. * By Vincent Thibault
  51591. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51592. */
  51593. export class TGATools {
  51594. private static _TYPE_INDEXED;
  51595. private static _TYPE_RGB;
  51596. private static _TYPE_GREY;
  51597. private static _TYPE_RLE_INDEXED;
  51598. private static _TYPE_RLE_RGB;
  51599. private static _TYPE_RLE_GREY;
  51600. private static _ORIGIN_MASK;
  51601. private static _ORIGIN_SHIFT;
  51602. private static _ORIGIN_BL;
  51603. private static _ORIGIN_BR;
  51604. private static _ORIGIN_UL;
  51605. private static _ORIGIN_UR;
  51606. /**
  51607. * Gets the header of a TGA file
  51608. * @param data defines the TGA data
  51609. * @returns the header
  51610. */
  51611. static GetTGAHeader(data: Uint8Array): any;
  51612. /**
  51613. * Uploads TGA content to a Babylon Texture
  51614. * @hidden
  51615. */
  51616. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51617. /** @hidden */
  51618. 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;
  51619. /** @hidden */
  51620. 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;
  51621. /** @hidden */
  51622. 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;
  51623. /** @hidden */
  51624. 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;
  51625. /** @hidden */
  51626. 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;
  51627. /** @hidden */
  51628. 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;
  51629. }
  51630. }
  51631. declare module BABYLON {
  51632. /**
  51633. * Implementation of the TGA Texture Loader.
  51634. * @hidden
  51635. */
  51636. export class _TGATextureLoader implements IInternalTextureLoader {
  51637. /**
  51638. * Defines wether the loader supports cascade loading the different faces.
  51639. */
  51640. readonly supportCascades: boolean;
  51641. /**
  51642. * This returns if the loader support the current file information.
  51643. * @param extension defines the file extension of the file being loaded
  51644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51645. * @param fallback defines the fallback internal texture if any
  51646. * @param isBase64 defines whether the texture is encoded as a base64
  51647. * @param isBuffer defines whether the texture data are stored as a buffer
  51648. * @returns true if the loader can load the specified file
  51649. */
  51650. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51651. /**
  51652. * Transform the url before loading if required.
  51653. * @param rootUrl the url of the texture
  51654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51655. * @returns the transformed texture
  51656. */
  51657. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51658. /**
  51659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51660. * @param rootUrl the url of the texture
  51661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51662. * @returns the fallback texture
  51663. */
  51664. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51665. /**
  51666. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51667. * @param data contains the texture data
  51668. * @param texture defines the BabylonJS internal texture
  51669. * @param createPolynomials will be true if polynomials have been requested
  51670. * @param onLoad defines the callback to trigger once the texture is ready
  51671. * @param onError defines the callback to trigger in case of error
  51672. */
  51673. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51674. /**
  51675. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51676. * @param data contains the texture data
  51677. * @param texture defines the BabylonJS internal texture
  51678. * @param callback defines the method to call once ready to upload
  51679. */
  51680. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51681. }
  51682. }
  51683. declare module BABYLON {
  51684. /**
  51685. * Info about the .basis files
  51686. */
  51687. class BasisFileInfo {
  51688. /**
  51689. * If the file has alpha
  51690. */
  51691. hasAlpha: boolean;
  51692. /**
  51693. * Info about each image of the basis file
  51694. */
  51695. images: Array<{
  51696. levels: Array<{
  51697. width: number;
  51698. height: number;
  51699. transcodedPixels: ArrayBufferView;
  51700. }>;
  51701. }>;
  51702. }
  51703. /**
  51704. * Result of transcoding a basis file
  51705. */
  51706. class TranscodeResult {
  51707. /**
  51708. * Info about the .basis file
  51709. */
  51710. fileInfo: BasisFileInfo;
  51711. /**
  51712. * Format to use when loading the file
  51713. */
  51714. format: number;
  51715. }
  51716. /**
  51717. * Configuration options for the Basis transcoder
  51718. */
  51719. export class BasisTranscodeConfiguration {
  51720. /**
  51721. * Supported compression formats used to determine the supported output format of the transcoder
  51722. */
  51723. supportedCompressionFormats?: {
  51724. /**
  51725. * etc1 compression format
  51726. */
  51727. etc1?: boolean;
  51728. /**
  51729. * s3tc compression format
  51730. */
  51731. s3tc?: boolean;
  51732. /**
  51733. * pvrtc compression format
  51734. */
  51735. pvrtc?: boolean;
  51736. /**
  51737. * etc2 compression format
  51738. */
  51739. etc2?: boolean;
  51740. };
  51741. /**
  51742. * If mipmap levels should be loaded for transcoded images (Default: true)
  51743. */
  51744. loadMipmapLevels?: boolean;
  51745. /**
  51746. * Index of a single image to load (Default: all images)
  51747. */
  51748. loadSingleImage?: number;
  51749. }
  51750. /**
  51751. * Used to load .Basis files
  51752. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51753. */
  51754. export class BasisTools {
  51755. private static _IgnoreSupportedFormats;
  51756. /**
  51757. * URL to use when loading the basis transcoder
  51758. */
  51759. static JSModuleURL: string;
  51760. /**
  51761. * URL to use when loading the wasm module for the transcoder
  51762. */
  51763. static WasmModuleURL: string;
  51764. /**
  51765. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51766. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51767. * @returns internal format corresponding to the Basis format
  51768. */
  51769. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51770. private static _WorkerPromise;
  51771. private static _Worker;
  51772. private static _actionId;
  51773. private static _CreateWorkerAsync;
  51774. /**
  51775. * Transcodes a loaded image file to compressed pixel data
  51776. * @param imageData image data to transcode
  51777. * @param config configuration options for the transcoding
  51778. * @returns a promise resulting in the transcoded image
  51779. */
  51780. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51781. /**
  51782. * Loads a texture from the transcode result
  51783. * @param texture texture load to
  51784. * @param transcodeResult the result of transcoding the basis file to load from
  51785. */
  51786. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51787. }
  51788. }
  51789. declare module BABYLON {
  51790. /**
  51791. * Loader for .basis file format
  51792. */
  51793. export class _BasisTextureLoader implements IInternalTextureLoader {
  51794. /**
  51795. * Defines whether the loader supports cascade loading the different faces.
  51796. */
  51797. readonly supportCascades: boolean;
  51798. /**
  51799. * This returns if the loader support the current file information.
  51800. * @param extension defines the file extension of the file being loaded
  51801. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51802. * @param fallback defines the fallback internal texture if any
  51803. * @param isBase64 defines whether the texture is encoded as a base64
  51804. * @param isBuffer defines whether the texture data are stored as a buffer
  51805. * @returns true if the loader can load the specified file
  51806. */
  51807. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51808. /**
  51809. * Transform the url before loading if required.
  51810. * @param rootUrl the url of the texture
  51811. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51812. * @returns the transformed texture
  51813. */
  51814. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51815. /**
  51816. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51817. * @param rootUrl the url of the texture
  51818. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51819. * @returns the fallback texture
  51820. */
  51821. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51822. /**
  51823. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51824. * @param data contains the texture data
  51825. * @param texture defines the BabylonJS internal texture
  51826. * @param createPolynomials will be true if polynomials have been requested
  51827. * @param onLoad defines the callback to trigger once the texture is ready
  51828. * @param onError defines the callback to trigger in case of error
  51829. */
  51830. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51831. /**
  51832. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51833. * @param data contains the texture data
  51834. * @param texture defines the BabylonJS internal texture
  51835. * @param callback defines the method to call once ready to upload
  51836. */
  51837. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51838. }
  51839. }
  51840. declare module BABYLON {
  51841. /**
  51842. * 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.
  51843. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51844. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51845. */
  51846. export class CustomProceduralTexture extends ProceduralTexture {
  51847. private _animate;
  51848. private _time;
  51849. private _config;
  51850. private _texturePath;
  51851. /**
  51852. * Instantiates a new Custom Procedural Texture.
  51853. * 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.
  51854. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51855. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51856. * @param name Define the name of the texture
  51857. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51858. * @param size Define the size of the texture to create
  51859. * @param scene Define the scene the texture belongs to
  51860. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51861. * @param generateMipMaps Define if the texture should creates mip maps or not
  51862. */
  51863. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51864. private _loadJson;
  51865. /**
  51866. * Is the texture ready to be used ? (rendered at least once)
  51867. * @returns true if ready, otherwise, false.
  51868. */
  51869. isReady(): boolean;
  51870. /**
  51871. * Render the texture to its associated render target.
  51872. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51873. */
  51874. render(useCameraPostProcess?: boolean): void;
  51875. /**
  51876. * Update the list of dependant textures samplers in the shader.
  51877. */
  51878. updateTextures(): void;
  51879. /**
  51880. * Update the uniform values of the procedural texture in the shader.
  51881. */
  51882. updateShaderUniforms(): void;
  51883. /**
  51884. * Define if the texture animates or not.
  51885. */
  51886. animate: boolean;
  51887. }
  51888. }
  51889. declare module BABYLON {
  51890. /** @hidden */
  51891. export var noisePixelShader: {
  51892. name: string;
  51893. shader: string;
  51894. };
  51895. }
  51896. declare module BABYLON {
  51897. /**
  51898. * Class used to generate noise procedural textures
  51899. */
  51900. export class NoiseProceduralTexture extends ProceduralTexture {
  51901. private _time;
  51902. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51903. brightness: number;
  51904. /** Defines the number of octaves to process */
  51905. octaves: number;
  51906. /** Defines the level of persistence (0.8 by default) */
  51907. persistence: number;
  51908. /** Gets or sets animation speed factor (default is 1) */
  51909. animationSpeedFactor: number;
  51910. /**
  51911. * Creates a new NoiseProceduralTexture
  51912. * @param name defines the name fo the texture
  51913. * @param size defines the size of the texture (default is 256)
  51914. * @param scene defines the hosting scene
  51915. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51916. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51917. */
  51918. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51919. private _updateShaderUniforms;
  51920. protected _getDefines(): string;
  51921. /** Generate the current state of the procedural texture */
  51922. render(useCameraPostProcess?: boolean): void;
  51923. /**
  51924. * Serializes this noise procedural texture
  51925. * @returns a serialized noise procedural texture object
  51926. */
  51927. serialize(): any;
  51928. /**
  51929. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51930. * @param parsedTexture defines parsed texture data
  51931. * @param scene defines the current scene
  51932. * @param rootUrl defines the root URL containing noise procedural texture information
  51933. * @returns a parsed NoiseProceduralTexture
  51934. */
  51935. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51936. }
  51937. }
  51938. declare module BABYLON {
  51939. /**
  51940. * Raw cube texture where the raw buffers are passed in
  51941. */
  51942. export class RawCubeTexture extends CubeTexture {
  51943. /**
  51944. * Creates a cube texture where the raw buffers are passed in.
  51945. * @param scene defines the scene the texture is attached to
  51946. * @param data defines the array of data to use to create each face
  51947. * @param size defines the size of the textures
  51948. * @param format defines the format of the data
  51949. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51950. * @param generateMipMaps defines if the engine should generate the mip levels
  51951. * @param invertY defines if data must be stored with Y axis inverted
  51952. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51953. * @param compression defines the compression used (null by default)
  51954. */
  51955. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51956. /**
  51957. * Updates the raw cube texture.
  51958. * @param data defines the data to store
  51959. * @param format defines the data format
  51960. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51961. * @param invertY defines if data must be stored with Y axis inverted
  51962. * @param compression defines the compression used (null by default)
  51963. * @param level defines which level of the texture to update
  51964. */
  51965. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51966. /**
  51967. * Updates a raw cube texture with RGBD encoded data.
  51968. * @param data defines the array of data [mipmap][face] to use to create each face
  51969. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51970. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51971. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51972. * @returns a promsie that resolves when the operation is complete
  51973. */
  51974. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51975. /**
  51976. * Clones the raw cube texture.
  51977. * @return a new cube texture
  51978. */
  51979. clone(): CubeTexture;
  51980. /** @hidden */
  51981. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51982. }
  51983. }
  51984. declare module BABYLON {
  51985. /**
  51986. * Class used to store 3D textures containing user data
  51987. */
  51988. export class RawTexture3D extends Texture {
  51989. /** Gets or sets the texture format to use */
  51990. format: number;
  51991. private _engine;
  51992. /**
  51993. * Create a new RawTexture3D
  51994. * @param data defines the data of the texture
  51995. * @param width defines the width of the texture
  51996. * @param height defines the height of the texture
  51997. * @param depth defines the depth of the texture
  51998. * @param format defines the texture format to use
  51999. * @param scene defines the hosting scene
  52000. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52001. * @param invertY defines if texture must be stored with Y axis inverted
  52002. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52003. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52004. */
  52005. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52006. /** Gets or sets the texture format to use */
  52007. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52008. /**
  52009. * Update the texture with new data
  52010. * @param data defines the data to store in the texture
  52011. */
  52012. update(data: ArrayBufferView): void;
  52013. }
  52014. }
  52015. declare module BABYLON {
  52016. /**
  52017. * Creates a refraction texture used by refraction channel of the standard material.
  52018. * It is like a mirror but to see through a material.
  52019. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52020. */
  52021. export class RefractionTexture extends RenderTargetTexture {
  52022. /**
  52023. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52024. * 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.
  52025. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52026. */
  52027. refractionPlane: Plane;
  52028. /**
  52029. * Define how deep under the surface we should see.
  52030. */
  52031. depth: number;
  52032. /**
  52033. * Creates a refraction texture used by refraction channel of the standard material.
  52034. * It is like a mirror but to see through a material.
  52035. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52036. * @param name Define the texture name
  52037. * @param size Define the size of the underlying texture
  52038. * @param scene Define the scene the refraction belongs to
  52039. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52040. */
  52041. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52042. /**
  52043. * Clone the refraction texture.
  52044. * @returns the cloned texture
  52045. */
  52046. clone(): RefractionTexture;
  52047. /**
  52048. * Serialize the texture to a JSON representation you could use in Parse later on
  52049. * @returns the serialized JSON representation
  52050. */
  52051. serialize(): any;
  52052. }
  52053. }
  52054. declare module BABYLON {
  52055. /**
  52056. * Defines the options related to the creation of an HtmlElementTexture
  52057. */
  52058. export interface IHtmlElementTextureOptions {
  52059. /**
  52060. * Defines wether mip maps should be created or not.
  52061. */
  52062. generateMipMaps?: boolean;
  52063. /**
  52064. * Defines the sampling mode of the texture.
  52065. */
  52066. samplingMode?: number;
  52067. /**
  52068. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52069. */
  52070. engine: Nullable<Engine>;
  52071. /**
  52072. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52073. */
  52074. scene: Nullable<Scene>;
  52075. }
  52076. /**
  52077. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52078. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52079. * is automatically managed.
  52080. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52081. * in your application.
  52082. *
  52083. * As the update is not automatic, you need to call them manually.
  52084. */
  52085. export class HtmlElementTexture extends BaseTexture {
  52086. /**
  52087. * The texture URL.
  52088. */
  52089. element: HTMLVideoElement | HTMLCanvasElement;
  52090. private static readonly DefaultOptions;
  52091. private _textureMatrix;
  52092. private _engine;
  52093. private _isVideo;
  52094. private _generateMipMaps;
  52095. private _samplingMode;
  52096. /**
  52097. * Instantiates a HtmlElementTexture from the following parameters.
  52098. *
  52099. * @param name Defines the name of the texture
  52100. * @param element Defines the video or canvas the texture is filled with
  52101. * @param options Defines the other none mandatory texture creation options
  52102. */
  52103. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52104. private _createInternalTexture;
  52105. /**
  52106. * Returns the texture matrix used in most of the material.
  52107. */
  52108. getTextureMatrix(): Matrix;
  52109. /**
  52110. * Updates the content of the texture.
  52111. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52112. */
  52113. update(invertY?: Nullable<boolean>): void;
  52114. }
  52115. }
  52116. declare module BABYLON {
  52117. /**
  52118. * Enum used to define the target of a block
  52119. */
  52120. export enum NodeMaterialBlockTargets {
  52121. /** Vertex shader */
  52122. Vertex = 1,
  52123. /** Fragment shader */
  52124. Fragment = 2,
  52125. /** Neutral */
  52126. Neutral = 4,
  52127. /** Vertex and Fragment */
  52128. VertexAndFragment = 3
  52129. }
  52130. }
  52131. declare module BABYLON {
  52132. /**
  52133. * Defines the kind of connection point for node based material
  52134. */
  52135. export enum NodeMaterialBlockConnectionPointTypes {
  52136. /** Float */
  52137. Float = 1,
  52138. /** Int */
  52139. Int = 2,
  52140. /** Vector2 */
  52141. Vector2 = 4,
  52142. /** Vector3 */
  52143. Vector3 = 8,
  52144. /** Vector4 */
  52145. Vector4 = 16,
  52146. /** Color3 */
  52147. Color3 = 32,
  52148. /** Color4 */
  52149. Color4 = 64,
  52150. /** Matrix */
  52151. Matrix = 128,
  52152. /** Detect type based on connection */
  52153. AutoDetect = 1024,
  52154. /** Output type that will be defined by input type */
  52155. BasedOnInput = 2048
  52156. }
  52157. }
  52158. declare module BABYLON {
  52159. /**
  52160. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52161. */
  52162. export enum NodeMaterialBlockConnectionPointMode {
  52163. /** Value is an uniform */
  52164. Uniform = 0,
  52165. /** Value is a mesh attribute */
  52166. Attribute = 1,
  52167. /** Value is a varying between vertex and fragment shaders */
  52168. Varying = 2,
  52169. /** Mode is undefined */
  52170. Undefined = 3
  52171. }
  52172. }
  52173. declare module BABYLON {
  52174. /**
  52175. * Enum used to define system values e.g. values automatically provided by the system
  52176. */
  52177. export enum NodeMaterialSystemValues {
  52178. /** World */
  52179. World = 1,
  52180. /** View */
  52181. View = 2,
  52182. /** Projection */
  52183. Projection = 3,
  52184. /** ViewProjection */
  52185. ViewProjection = 4,
  52186. /** WorldView */
  52187. WorldView = 5,
  52188. /** WorldViewProjection */
  52189. WorldViewProjection = 6,
  52190. /** CameraPosition */
  52191. CameraPosition = 7,
  52192. /** Fog Color */
  52193. FogColor = 8
  52194. }
  52195. }
  52196. declare module BABYLON {
  52197. /**
  52198. * Root class for all node material optimizers
  52199. */
  52200. export class NodeMaterialOptimizer {
  52201. /**
  52202. * Function used to optimize a NodeMaterial graph
  52203. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52204. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52205. */
  52206. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. /**
  52211. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52212. */
  52213. export class TransformBlock extends NodeMaterialBlock {
  52214. /**
  52215. * Defines the value to use to complement W value to transform it to a Vector4
  52216. */
  52217. complementW: number;
  52218. /**
  52219. * Defines the value to use to complement z value to transform it to a Vector4
  52220. */
  52221. complementZ: number;
  52222. /**
  52223. * Creates a new TransformBlock
  52224. * @param name defines the block name
  52225. */
  52226. constructor(name: string);
  52227. /**
  52228. * Gets the current class name
  52229. * @returns the class name
  52230. */
  52231. getClassName(): string;
  52232. /**
  52233. * Gets the vector input
  52234. */
  52235. readonly vector: NodeMaterialConnectionPoint;
  52236. /**
  52237. * Gets the output component
  52238. */
  52239. readonly output: NodeMaterialConnectionPoint;
  52240. /**
  52241. * Gets the matrix transform input
  52242. */
  52243. readonly transform: NodeMaterialConnectionPoint;
  52244. protected _buildBlock(state: NodeMaterialBuildState): this;
  52245. serialize(): any;
  52246. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52247. protected _dumpPropertiesCode(): string;
  52248. }
  52249. }
  52250. declare module BABYLON {
  52251. /**
  52252. * Block used to output the vertex position
  52253. */
  52254. export class VertexOutputBlock extends NodeMaterialBlock {
  52255. /**
  52256. * Creates a new VertexOutputBlock
  52257. * @param name defines the block name
  52258. */
  52259. constructor(name: string);
  52260. /**
  52261. * Gets the current class name
  52262. * @returns the class name
  52263. */
  52264. getClassName(): string;
  52265. /**
  52266. * Gets the vector input component
  52267. */
  52268. readonly vector: NodeMaterialConnectionPoint;
  52269. protected _buildBlock(state: NodeMaterialBuildState): this;
  52270. }
  52271. }
  52272. declare module BABYLON {
  52273. /**
  52274. * Block used to output the final color
  52275. */
  52276. export class FragmentOutputBlock extends NodeMaterialBlock {
  52277. /**
  52278. * Create a new FragmentOutputBlock
  52279. * @param name defines the block name
  52280. */
  52281. constructor(name: string);
  52282. /**
  52283. * Gets the current class name
  52284. * @returns the class name
  52285. */
  52286. getClassName(): string;
  52287. /**
  52288. * Gets the rgba input component
  52289. */
  52290. readonly rgba: NodeMaterialConnectionPoint;
  52291. /**
  52292. * Gets the rgb input component
  52293. */
  52294. readonly rgb: NodeMaterialConnectionPoint;
  52295. /**
  52296. * Gets the a input component
  52297. */
  52298. readonly a: NodeMaterialConnectionPoint;
  52299. protected _buildBlock(state: NodeMaterialBuildState): this;
  52300. }
  52301. }
  52302. declare module BABYLON {
  52303. /**
  52304. * Block used to read a reflection texture from a sampler
  52305. */
  52306. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52307. private _define3DName;
  52308. private _defineCubicName;
  52309. private _defineExplicitName;
  52310. private _defineProjectionName;
  52311. private _defineLocalCubicName;
  52312. private _defineSphericalName;
  52313. private _definePlanarName;
  52314. private _defineEquirectangularName;
  52315. private _defineMirroredEquirectangularFixedName;
  52316. private _defineEquirectangularFixedName;
  52317. private _defineSkyboxName;
  52318. private _cubeSamplerName;
  52319. private _2DSamplerName;
  52320. private _positionUVWName;
  52321. private _directionWName;
  52322. private _reflectionCoordsName;
  52323. private _reflection2DCoordsName;
  52324. private _reflectionColorName;
  52325. private _reflectionMatrixName;
  52326. /**
  52327. * Gets or sets the texture associated with the node
  52328. */
  52329. texture: Nullable<BaseTexture>;
  52330. /**
  52331. * Create a new TextureBlock
  52332. * @param name defines the block name
  52333. */
  52334. constructor(name: string);
  52335. /**
  52336. * Gets the current class name
  52337. * @returns the class name
  52338. */
  52339. getClassName(): string;
  52340. /**
  52341. * Gets the world position input component
  52342. */
  52343. readonly position: NodeMaterialConnectionPoint;
  52344. /**
  52345. * Gets the world position input component
  52346. */
  52347. readonly worldPosition: NodeMaterialConnectionPoint;
  52348. /**
  52349. * Gets the world normal input component
  52350. */
  52351. readonly worldNormal: NodeMaterialConnectionPoint;
  52352. /**
  52353. * Gets the world input component
  52354. */
  52355. readonly world: NodeMaterialConnectionPoint;
  52356. /**
  52357. * Gets the camera (or eye) position component
  52358. */
  52359. readonly cameraPosition: NodeMaterialConnectionPoint;
  52360. /**
  52361. * Gets the view input component
  52362. */
  52363. readonly view: NodeMaterialConnectionPoint;
  52364. /**
  52365. * Gets the rgb output component
  52366. */
  52367. readonly rgb: NodeMaterialConnectionPoint;
  52368. /**
  52369. * Gets the r output component
  52370. */
  52371. readonly r: NodeMaterialConnectionPoint;
  52372. /**
  52373. * Gets the g output component
  52374. */
  52375. readonly g: NodeMaterialConnectionPoint;
  52376. /**
  52377. * Gets the b output component
  52378. */
  52379. readonly b: NodeMaterialConnectionPoint;
  52380. autoConfigure(material: NodeMaterial): void;
  52381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52382. isReady(): boolean;
  52383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52384. private _injectVertexCode;
  52385. private _writeOutput;
  52386. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52387. serialize(): any;
  52388. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52389. }
  52390. }
  52391. declare module BABYLON {
  52392. /**
  52393. * Interface used to configure the node material editor
  52394. */
  52395. export interface INodeMaterialEditorOptions {
  52396. /** Define the URl to load node editor script */
  52397. editorURL?: string;
  52398. }
  52399. /** @hidden */
  52400. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52401. /** BONES */
  52402. NUM_BONE_INFLUENCERS: number;
  52403. BonesPerMesh: number;
  52404. BONETEXTURE: boolean;
  52405. /** MORPH TARGETS */
  52406. MORPHTARGETS: boolean;
  52407. MORPHTARGETS_NORMAL: boolean;
  52408. MORPHTARGETS_TANGENT: boolean;
  52409. MORPHTARGETS_UV: boolean;
  52410. NUM_MORPH_INFLUENCERS: number;
  52411. /** IMAGE PROCESSING */
  52412. IMAGEPROCESSING: boolean;
  52413. VIGNETTE: boolean;
  52414. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52415. VIGNETTEBLENDMODEOPAQUE: boolean;
  52416. TONEMAPPING: boolean;
  52417. TONEMAPPING_ACES: boolean;
  52418. CONTRAST: boolean;
  52419. EXPOSURE: boolean;
  52420. COLORCURVES: boolean;
  52421. COLORGRADING: boolean;
  52422. COLORGRADING3D: boolean;
  52423. SAMPLER3DGREENDEPTH: boolean;
  52424. SAMPLER3DBGRMAP: boolean;
  52425. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52426. /** MISC. */
  52427. BUMPDIRECTUV: number;
  52428. constructor();
  52429. setValue(name: string, value: boolean): void;
  52430. }
  52431. /**
  52432. * Class used to configure NodeMaterial
  52433. */
  52434. export interface INodeMaterialOptions {
  52435. /**
  52436. * Defines if blocks should emit comments
  52437. */
  52438. emitComments: boolean;
  52439. }
  52440. /**
  52441. * Class used to create a node based material built by assembling shader blocks
  52442. */
  52443. export class NodeMaterial extends PushMaterial {
  52444. private static _BuildIdGenerator;
  52445. private _options;
  52446. private _vertexCompilationState;
  52447. private _fragmentCompilationState;
  52448. private _sharedData;
  52449. private _buildId;
  52450. private _buildWasSuccessful;
  52451. private _cachedWorldViewMatrix;
  52452. private _cachedWorldViewProjectionMatrix;
  52453. private _optimizers;
  52454. private _animationFrame;
  52455. /** Define the URl to load node editor script */
  52456. static EditorURL: string;
  52457. private BJSNODEMATERIALEDITOR;
  52458. /** Get the inspector from bundle or global */
  52459. private _getGlobalNodeMaterialEditor;
  52460. /**
  52461. * 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)
  52462. */
  52463. ignoreAlpha: boolean;
  52464. /**
  52465. * Defines the maximum number of lights that can be used in the material
  52466. */
  52467. maxSimultaneousLights: number;
  52468. /**
  52469. * Observable raised when the material is built
  52470. */
  52471. onBuildObservable: Observable<NodeMaterial>;
  52472. /**
  52473. * Gets or sets the root nodes of the material vertex shader
  52474. */
  52475. _vertexOutputNodes: NodeMaterialBlock[];
  52476. /**
  52477. * Gets or sets the root nodes of the material fragment (pixel) shader
  52478. */
  52479. _fragmentOutputNodes: NodeMaterialBlock[];
  52480. /** Gets or sets options to control the node material overall behavior */
  52481. options: INodeMaterialOptions;
  52482. /**
  52483. * Default configuration related to image processing available in the standard Material.
  52484. */
  52485. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52486. /**
  52487. * Gets the image processing configuration used either in this material.
  52488. */
  52489. /**
  52490. * Sets the Default image processing configuration used either in the this material.
  52491. *
  52492. * If sets to null, the scene one is in use.
  52493. */
  52494. imageProcessingConfiguration: ImageProcessingConfiguration;
  52495. /**
  52496. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52497. */
  52498. attachedBlocks: NodeMaterialBlock[];
  52499. /**
  52500. * Create a new node based material
  52501. * @param name defines the material name
  52502. * @param scene defines the hosting scene
  52503. * @param options defines creation option
  52504. */
  52505. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52506. /**
  52507. * Gets the current class name of the material e.g. "NodeMaterial"
  52508. * @returns the class name
  52509. */
  52510. getClassName(): string;
  52511. /**
  52512. * Keep track of the image processing observer to allow dispose and replace.
  52513. */
  52514. private _imageProcessingObserver;
  52515. /**
  52516. * Attaches a new image processing configuration to the Standard Material.
  52517. * @param configuration
  52518. */
  52519. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52520. /**
  52521. * Get a block by its name
  52522. * @param name defines the name of the block to retrieve
  52523. * @returns the required block or null if not found
  52524. */
  52525. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52526. /**
  52527. * Get a block by its name
  52528. * @param predicate defines the predicate used to find the good candidate
  52529. * @returns the required block or null if not found
  52530. */
  52531. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52532. /**
  52533. * Get an input block by its name
  52534. * @param predicate defines the predicate used to find the good candidate
  52535. * @returns the required input block or null if not found
  52536. */
  52537. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52538. /**
  52539. * Gets the list of input blocks attached to this material
  52540. * @returns an array of InputBlocks
  52541. */
  52542. getInputBlocks(): InputBlock[];
  52543. /**
  52544. * Adds a new optimizer to the list of optimizers
  52545. * @param optimizer defines the optimizers to add
  52546. * @returns the current material
  52547. */
  52548. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52549. /**
  52550. * Remove an optimizer from the list of optimizers
  52551. * @param optimizer defines the optimizers to remove
  52552. * @returns the current material
  52553. */
  52554. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52555. /**
  52556. * Add a new block to the list of output nodes
  52557. * @param node defines the node to add
  52558. * @returns the current material
  52559. */
  52560. addOutputNode(node: NodeMaterialBlock): this;
  52561. /**
  52562. * Remove a block from the list of root nodes
  52563. * @param node defines the node to remove
  52564. * @returns the current material
  52565. */
  52566. removeOutputNode(node: NodeMaterialBlock): this;
  52567. private _addVertexOutputNode;
  52568. private _removeVertexOutputNode;
  52569. private _addFragmentOutputNode;
  52570. private _removeFragmentOutputNode;
  52571. /**
  52572. * Specifies if the material will require alpha blending
  52573. * @returns a boolean specifying if alpha blending is needed
  52574. */
  52575. needAlphaBlending(): boolean;
  52576. /**
  52577. * Specifies if this material should be rendered in alpha test mode
  52578. * @returns a boolean specifying if an alpha test is needed.
  52579. */
  52580. needAlphaTesting(): boolean;
  52581. private _initializeBlock;
  52582. private _resetDualBlocks;
  52583. /**
  52584. * Build the material and generates the inner effect
  52585. * @param verbose defines if the build should log activity
  52586. */
  52587. build(verbose?: boolean): void;
  52588. /**
  52589. * Runs an otpimization phase to try to improve the shader code
  52590. */
  52591. optimize(): void;
  52592. private _prepareDefinesForAttributes;
  52593. /**
  52594. * Get if the submesh is ready to be used and all its information available.
  52595. * Child classes can use it to update shaders
  52596. * @param mesh defines the mesh to check
  52597. * @param subMesh defines which submesh to check
  52598. * @param useInstances specifies that instances should be used
  52599. * @returns a boolean indicating that the submesh is ready or not
  52600. */
  52601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52602. /**
  52603. * Get a string representing the shaders built by the current node graph
  52604. */
  52605. readonly compiledShaders: string;
  52606. /**
  52607. * Binds the world matrix to the material
  52608. * @param world defines the world transformation matrix
  52609. */
  52610. bindOnlyWorldMatrix(world: Matrix): void;
  52611. /**
  52612. * Binds the submesh to this material by preparing the effect and shader to draw
  52613. * @param world defines the world transformation matrix
  52614. * @param mesh defines the mesh containing the submesh
  52615. * @param subMesh defines the submesh to bind the material to
  52616. */
  52617. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52618. /**
  52619. * Gets the active textures from the material
  52620. * @returns an array of textures
  52621. */
  52622. getActiveTextures(): BaseTexture[];
  52623. /**
  52624. * Gets the list of texture blocks
  52625. * @returns an array of texture blocks
  52626. */
  52627. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52628. /**
  52629. * Specifies if the material uses a texture
  52630. * @param texture defines the texture to check against the material
  52631. * @returns a boolean specifying if the material uses the texture
  52632. */
  52633. hasTexture(texture: BaseTexture): boolean;
  52634. /**
  52635. * Disposes the material
  52636. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52637. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52638. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52639. */
  52640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52641. /** Creates the node editor window. */
  52642. private _createNodeEditor;
  52643. /**
  52644. * Launch the node material editor
  52645. * @param config Define the configuration of the editor
  52646. * @return a promise fulfilled when the node editor is visible
  52647. */
  52648. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52649. /**
  52650. * Clear the current material
  52651. */
  52652. clear(): void;
  52653. /**
  52654. * Clear the current material and set it to a default state
  52655. */
  52656. setToDefault(): void;
  52657. /**
  52658. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52659. * @param url defines the url to load from
  52660. * @returns a promise that will fullfil when the material is fully loaded
  52661. */
  52662. loadAsync(url: string): Promise<unknown>;
  52663. private _gatherBlocks;
  52664. /**
  52665. * Generate a string containing the code declaration required to create an equivalent of this material
  52666. * @returns a string
  52667. */
  52668. generateCode(): string;
  52669. /**
  52670. * Serializes this material in a JSON representation
  52671. * @returns the serialized material object
  52672. */
  52673. serialize(): any;
  52674. private _restoreConnections;
  52675. /**
  52676. * Clear the current graph and load a new one from a serialization object
  52677. * @param source defines the JSON representation of the material
  52678. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52679. */
  52680. loadFromSerialization(source: any, rootUrl?: string): void;
  52681. /**
  52682. * Creates a node material from parsed material data
  52683. * @param source defines the JSON representation of the material
  52684. * @param scene defines the hosting scene
  52685. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52686. * @returns a new node material
  52687. */
  52688. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52689. /**
  52690. * Creates a new node material set to default basic configuration
  52691. * @param name defines the name of the material
  52692. * @param scene defines the hosting scene
  52693. * @returns a new NodeMaterial
  52694. */
  52695. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52696. }
  52697. }
  52698. declare module BABYLON {
  52699. /**
  52700. * Block used to read a texture from a sampler
  52701. */
  52702. export class TextureBlock extends NodeMaterialBlock {
  52703. private _defineName;
  52704. private _samplerName;
  52705. private _transformedUVName;
  52706. private _textureTransformName;
  52707. private _textureInfoName;
  52708. private _mainUVName;
  52709. private _mainUVDefineName;
  52710. /**
  52711. * Gets or sets the texture associated with the node
  52712. */
  52713. texture: Nullable<Texture>;
  52714. /**
  52715. * Create a new TextureBlock
  52716. * @param name defines the block name
  52717. */
  52718. constructor(name: string);
  52719. /**
  52720. * Gets the current class name
  52721. * @returns the class name
  52722. */
  52723. getClassName(): string;
  52724. /**
  52725. * Gets the uv input component
  52726. */
  52727. readonly uv: NodeMaterialConnectionPoint;
  52728. /**
  52729. * Gets the rgba output component
  52730. */
  52731. readonly rgba: NodeMaterialConnectionPoint;
  52732. /**
  52733. * Gets the rgb output component
  52734. */
  52735. readonly rgb: NodeMaterialConnectionPoint;
  52736. /**
  52737. * Gets the r output component
  52738. */
  52739. readonly r: NodeMaterialConnectionPoint;
  52740. /**
  52741. * Gets the g output component
  52742. */
  52743. readonly g: NodeMaterialConnectionPoint;
  52744. /**
  52745. * Gets the b output component
  52746. */
  52747. readonly b: NodeMaterialConnectionPoint;
  52748. /**
  52749. * Gets the a output component
  52750. */
  52751. readonly a: NodeMaterialConnectionPoint;
  52752. readonly target: NodeMaterialBlockTargets;
  52753. autoConfigure(material: NodeMaterial): void;
  52754. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52756. isReady(): boolean;
  52757. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52758. private readonly _isMixed;
  52759. private _injectVertexCode;
  52760. private _writeOutput;
  52761. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52762. protected _dumpPropertiesCode(): string;
  52763. serialize(): any;
  52764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52765. }
  52766. }
  52767. declare module BABYLON {
  52768. /**
  52769. * Class used to store shared data between 2 NodeMaterialBuildState
  52770. */
  52771. export class NodeMaterialBuildStateSharedData {
  52772. /**
  52773. * Gets the list of emitted varyings
  52774. */
  52775. temps: string[];
  52776. /**
  52777. * Gets the list of emitted varyings
  52778. */
  52779. varyings: string[];
  52780. /**
  52781. * Gets the varying declaration string
  52782. */
  52783. varyingDeclaration: string;
  52784. /**
  52785. * Input blocks
  52786. */
  52787. inputBlocks: InputBlock[];
  52788. /**
  52789. * Input blocks
  52790. */
  52791. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52792. /**
  52793. * Bindable blocks (Blocks that need to set data to the effect)
  52794. */
  52795. bindableBlocks: NodeMaterialBlock[];
  52796. /**
  52797. * List of blocks that can provide a compilation fallback
  52798. */
  52799. blocksWithFallbacks: NodeMaterialBlock[];
  52800. /**
  52801. * List of blocks that can provide a define update
  52802. */
  52803. blocksWithDefines: NodeMaterialBlock[];
  52804. /**
  52805. * List of blocks that can provide a repeatable content
  52806. */
  52807. repeatableContentBlocks: NodeMaterialBlock[];
  52808. /**
  52809. * List of blocks that can provide a dynamic list of uniforms
  52810. */
  52811. dynamicUniformBlocks: NodeMaterialBlock[];
  52812. /**
  52813. * List of blocks that can block the isReady function for the material
  52814. */
  52815. blockingBlocks: NodeMaterialBlock[];
  52816. /**
  52817. * Gets the list of animated inputs
  52818. */
  52819. animatedInputs: InputBlock[];
  52820. /**
  52821. * Build Id used to avoid multiple recompilations
  52822. */
  52823. buildId: number;
  52824. /** List of emitted variables */
  52825. variableNames: {
  52826. [key: string]: number;
  52827. };
  52828. /** List of emitted defines */
  52829. defineNames: {
  52830. [key: string]: number;
  52831. };
  52832. /** Should emit comments? */
  52833. emitComments: boolean;
  52834. /** Emit build activity */
  52835. verbose: boolean;
  52836. /** Gets or sets the hosting scene */
  52837. scene: Scene;
  52838. /**
  52839. * Gets the compilation hints emitted at compilation time
  52840. */
  52841. hints: {
  52842. needWorldViewMatrix: boolean;
  52843. needWorldViewProjectionMatrix: boolean;
  52844. needAlphaBlending: boolean;
  52845. needAlphaTesting: boolean;
  52846. };
  52847. /**
  52848. * List of compilation checks
  52849. */
  52850. checks: {
  52851. emitVertex: boolean;
  52852. emitFragment: boolean;
  52853. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52854. };
  52855. /** Creates a new shared data */
  52856. constructor();
  52857. /**
  52858. * Emits console errors and exceptions if there is a failing check
  52859. */
  52860. emitErrors(): void;
  52861. }
  52862. }
  52863. declare module BABYLON {
  52864. /**
  52865. * Class used to store node based material build state
  52866. */
  52867. export class NodeMaterialBuildState {
  52868. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52869. supportUniformBuffers: boolean;
  52870. /**
  52871. * Gets the list of emitted attributes
  52872. */
  52873. attributes: string[];
  52874. /**
  52875. * Gets the list of emitted uniforms
  52876. */
  52877. uniforms: string[];
  52878. /**
  52879. * Gets the list of emitted constants
  52880. */
  52881. constants: string[];
  52882. /**
  52883. * Gets the list of emitted uniform buffers
  52884. */
  52885. uniformBuffers: string[];
  52886. /**
  52887. * Gets the list of emitted samplers
  52888. */
  52889. samplers: string[];
  52890. /**
  52891. * Gets the list of emitted functions
  52892. */
  52893. functions: {
  52894. [key: string]: string;
  52895. };
  52896. /**
  52897. * Gets the list of emitted extensions
  52898. */
  52899. extensions: {
  52900. [key: string]: string;
  52901. };
  52902. /**
  52903. * Gets the target of the compilation state
  52904. */
  52905. target: NodeMaterialBlockTargets;
  52906. /**
  52907. * Gets the list of emitted counters
  52908. */
  52909. counters: {
  52910. [key: string]: number;
  52911. };
  52912. /**
  52913. * Shared data between multiple NodeMaterialBuildState instances
  52914. */
  52915. sharedData: NodeMaterialBuildStateSharedData;
  52916. /** @hidden */
  52917. _vertexState: NodeMaterialBuildState;
  52918. /** @hidden */
  52919. _attributeDeclaration: string;
  52920. /** @hidden */
  52921. _uniformDeclaration: string;
  52922. /** @hidden */
  52923. _constantDeclaration: string;
  52924. /** @hidden */
  52925. _samplerDeclaration: string;
  52926. /** @hidden */
  52927. _varyingTransfer: string;
  52928. private _repeatableContentAnchorIndex;
  52929. /** @hidden */
  52930. _builtCompilationString: string;
  52931. /**
  52932. * Gets the emitted compilation strings
  52933. */
  52934. compilationString: string;
  52935. /**
  52936. * Finalize the compilation strings
  52937. * @param state defines the current compilation state
  52938. */
  52939. finalize(state: NodeMaterialBuildState): void;
  52940. /** @hidden */
  52941. readonly _repeatableContentAnchor: string;
  52942. /** @hidden */
  52943. _getFreeVariableName(prefix: string): string;
  52944. /** @hidden */
  52945. _getFreeDefineName(prefix: string): string;
  52946. /** @hidden */
  52947. _excludeVariableName(name: string): void;
  52948. /** @hidden */
  52949. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52950. /** @hidden */
  52951. _emitExtension(name: string, extension: string): void;
  52952. /** @hidden */
  52953. _emitFunction(name: string, code: string, comments: string): void;
  52954. /** @hidden */
  52955. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52956. replaceStrings?: {
  52957. search: RegExp;
  52958. replace: string;
  52959. }[];
  52960. repeatKey?: string;
  52961. }): string;
  52962. /** @hidden */
  52963. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52964. repeatKey?: string;
  52965. removeAttributes?: boolean;
  52966. removeUniforms?: boolean;
  52967. removeVaryings?: boolean;
  52968. removeIfDef?: boolean;
  52969. replaceStrings?: {
  52970. search: RegExp;
  52971. replace: string;
  52972. }[];
  52973. }, storeKey?: string): void;
  52974. /** @hidden */
  52975. _registerTempVariable(name: string): boolean;
  52976. /** @hidden */
  52977. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52978. /** @hidden */
  52979. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52980. }
  52981. }
  52982. declare module BABYLON {
  52983. /**
  52984. * Defines a block that can be used inside a node based material
  52985. */
  52986. export class NodeMaterialBlock {
  52987. private _buildId;
  52988. private _buildTarget;
  52989. private _target;
  52990. private _isFinalMerger;
  52991. private _isInput;
  52992. /** @hidden */
  52993. _codeVariableName: string;
  52994. /** @hidden */
  52995. _inputs: NodeMaterialConnectionPoint[];
  52996. /** @hidden */
  52997. _outputs: NodeMaterialConnectionPoint[];
  52998. /** @hidden */
  52999. _preparationId: number;
  53000. /**
  53001. * Gets or sets the name of the block
  53002. */
  53003. name: string;
  53004. /**
  53005. * Gets or sets the unique id of the node
  53006. */
  53007. uniqueId: number;
  53008. /**
  53009. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53010. */
  53011. readonly isFinalMerger: boolean;
  53012. /**
  53013. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53014. */
  53015. readonly isInput: boolean;
  53016. /**
  53017. * Gets or sets the build Id
  53018. */
  53019. buildId: number;
  53020. /**
  53021. * Gets or sets the target of the block
  53022. */
  53023. target: NodeMaterialBlockTargets;
  53024. /**
  53025. * Gets the list of input points
  53026. */
  53027. readonly inputs: NodeMaterialConnectionPoint[];
  53028. /** Gets the list of output points */
  53029. readonly outputs: NodeMaterialConnectionPoint[];
  53030. /**
  53031. * Find an input by its name
  53032. * @param name defines the name of the input to look for
  53033. * @returns the input or null if not found
  53034. */
  53035. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53036. /**
  53037. * Find an output by its name
  53038. * @param name defines the name of the outputto look for
  53039. * @returns the output or null if not found
  53040. */
  53041. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53042. /**
  53043. * Creates a new NodeMaterialBlock
  53044. * @param name defines the block name
  53045. * @param target defines the target of that block (Vertex by default)
  53046. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53047. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53048. */
  53049. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53050. /**
  53051. * Initialize the block and prepare the context for build
  53052. * @param state defines the state that will be used for the build
  53053. */
  53054. initialize(state: NodeMaterialBuildState): void;
  53055. /**
  53056. * Bind data to effect. Will only be called for blocks with isBindable === true
  53057. * @param effect defines the effect to bind data to
  53058. * @param nodeMaterial defines the hosting NodeMaterial
  53059. * @param mesh defines the mesh that will be rendered
  53060. */
  53061. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53062. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53063. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53064. protected _writeFloat(value: number): string;
  53065. /**
  53066. * Gets the current class name e.g. "NodeMaterialBlock"
  53067. * @returns the class name
  53068. */
  53069. getClassName(): string;
  53070. /**
  53071. * Register a new input. Must be called inside a block constructor
  53072. * @param name defines the connection point name
  53073. * @param type defines the connection point type
  53074. * @param isOptional defines a boolean indicating that this input can be omitted
  53075. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53076. * @returns the current block
  53077. */
  53078. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53079. /**
  53080. * Register a new output. Must be called inside a block constructor
  53081. * @param name defines the connection point name
  53082. * @param type defines the connection point type
  53083. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53084. * @returns the current block
  53085. */
  53086. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53087. /**
  53088. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53089. * @param forOutput defines an optional connection point to check compatibility with
  53090. * @returns the first available input or null
  53091. */
  53092. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53093. /**
  53094. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53095. * @param forBlock defines an optional block to check compatibility with
  53096. * @returns the first available input or null
  53097. */
  53098. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53099. /**
  53100. * Gets the sibling of the given output
  53101. * @param current defines the current output
  53102. * @returns the next output in the list or null
  53103. */
  53104. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53105. /**
  53106. * Connect current block with another block
  53107. * @param other defines the block to connect with
  53108. * @param options define the various options to help pick the right connections
  53109. * @returns the current block
  53110. */
  53111. connectTo(other: NodeMaterialBlock, options?: {
  53112. input?: string;
  53113. output?: string;
  53114. outputSwizzle?: string;
  53115. }): this | undefined;
  53116. protected _buildBlock(state: NodeMaterialBuildState): void;
  53117. /**
  53118. * Add uniforms, samplers and uniform buffers at compilation time
  53119. * @param state defines the state to update
  53120. * @param nodeMaterial defines the node material requesting the update
  53121. * @param defines defines the material defines to update
  53122. */
  53123. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53124. /**
  53125. * Add potential fallbacks if shader compilation fails
  53126. * @param mesh defines the mesh to be rendered
  53127. * @param fallbacks defines the current prioritized list of fallbacks
  53128. */
  53129. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53130. /**
  53131. * Initialize defines for shader compilation
  53132. * @param mesh defines the mesh to be rendered
  53133. * @param nodeMaterial defines the node material requesting the update
  53134. * @param defines defines the material defines to update
  53135. * @param useInstances specifies that instances should be used
  53136. */
  53137. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53138. /**
  53139. * Update defines for shader compilation
  53140. * @param mesh defines the mesh to be rendered
  53141. * @param nodeMaterial defines the node material requesting the update
  53142. * @param defines defines the material defines to update
  53143. * @param useInstances specifies that instances should be used
  53144. */
  53145. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53146. /**
  53147. * Lets the block try to connect some inputs automatically
  53148. * @param material defines the hosting NodeMaterial
  53149. */
  53150. autoConfigure(material: NodeMaterial): void;
  53151. /**
  53152. * Function called when a block is declared as repeatable content generator
  53153. * @param vertexShaderState defines the current compilation state for the vertex shader
  53154. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53155. * @param mesh defines the mesh to be rendered
  53156. * @param defines defines the material defines to update
  53157. */
  53158. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53159. /**
  53160. * Checks if the block is ready
  53161. * @param mesh defines the mesh to be rendered
  53162. * @param nodeMaterial defines the node material requesting the update
  53163. * @param defines defines the material defines to update
  53164. * @param useInstances specifies that instances should be used
  53165. * @returns true if the block is ready
  53166. */
  53167. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53168. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53169. private _processBuild;
  53170. /**
  53171. * Compile the current node and generate the shader code
  53172. * @param state defines the current compilation state (uniforms, samplers, current string)
  53173. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53174. * @returns true if already built
  53175. */
  53176. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53177. protected _inputRename(name: string): string;
  53178. protected _outputRename(name: string): string;
  53179. protected _dumpPropertiesCode(): string;
  53180. /** @hidden */
  53181. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53182. /**
  53183. * Clone the current block to a new identical block
  53184. * @param scene defines the hosting scene
  53185. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53186. * @returns a copy of the current block
  53187. */
  53188. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53189. /**
  53190. * Serializes this block in a JSON representation
  53191. * @returns the serialized block object
  53192. */
  53193. serialize(): any;
  53194. /** @hidden */
  53195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53196. }
  53197. }
  53198. declare module BABYLON {
  53199. /**
  53200. * Enum defining the type of animations supported by InputBlock
  53201. */
  53202. export enum AnimatedInputBlockTypes {
  53203. /** No animation */
  53204. None = 0,
  53205. /** Time based animation. Will only work for floats */
  53206. Time = 1
  53207. }
  53208. }
  53209. declare module BABYLON {
  53210. /**
  53211. * Block used to expose an input value
  53212. */
  53213. export class InputBlock extends NodeMaterialBlock {
  53214. private _mode;
  53215. private _associatedVariableName;
  53216. private _storedValue;
  53217. private _valueCallback;
  53218. private _type;
  53219. private _animationType;
  53220. /** Gets or set a value used to limit the range of float values */
  53221. min: number;
  53222. /** Gets or set a value used to limit the range of float values */
  53223. max: number;
  53224. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53225. matrixMode: number;
  53226. /** @hidden */
  53227. _systemValue: Nullable<NodeMaterialSystemValues>;
  53228. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53229. visibleInInspector: boolean;
  53230. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53231. isConstant: boolean;
  53232. /**
  53233. * Gets or sets the connection point type (default is float)
  53234. */
  53235. readonly type: NodeMaterialBlockConnectionPointTypes;
  53236. /**
  53237. * Creates a new InputBlock
  53238. * @param name defines the block name
  53239. * @param target defines the target of that block (Vertex by default)
  53240. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53241. */
  53242. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53243. /**
  53244. * Gets the output component
  53245. */
  53246. readonly output: NodeMaterialConnectionPoint;
  53247. /**
  53248. * Set the source of this connection point to a vertex attribute
  53249. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53250. * @returns the current connection point
  53251. */
  53252. setAsAttribute(attributeName?: string): InputBlock;
  53253. /**
  53254. * Set the source of this connection point to a system value
  53255. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53256. * @returns the current connection point
  53257. */
  53258. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53259. /**
  53260. * Gets or sets the value of that point.
  53261. * Please note that this value will be ignored if valueCallback is defined
  53262. */
  53263. value: any;
  53264. /**
  53265. * Gets or sets a callback used to get the value of that point.
  53266. * Please note that setting this value will force the connection point to ignore the value property
  53267. */
  53268. valueCallback: () => any;
  53269. /**
  53270. * Gets or sets the associated variable name in the shader
  53271. */
  53272. associatedVariableName: string;
  53273. /** Gets or sets the type of animation applied to the input */
  53274. animationType: AnimatedInputBlockTypes;
  53275. /**
  53276. * Gets a boolean indicating that this connection point not defined yet
  53277. */
  53278. readonly isUndefined: boolean;
  53279. /**
  53280. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53281. * In this case the connection point name must be the name of the uniform to use.
  53282. * Can only be set on inputs
  53283. */
  53284. isUniform: boolean;
  53285. /**
  53286. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53287. * In this case the connection point name must be the name of the attribute to use
  53288. * Can only be set on inputs
  53289. */
  53290. isAttribute: boolean;
  53291. /**
  53292. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53293. * Can only be set on exit points
  53294. */
  53295. isVarying: boolean;
  53296. /**
  53297. * Gets a boolean indicating that the current connection point is a system value
  53298. */
  53299. readonly isSystemValue: boolean;
  53300. /**
  53301. * Gets or sets the current well known value or null if not defined as a system value
  53302. */
  53303. systemValue: Nullable<NodeMaterialSystemValues>;
  53304. /**
  53305. * Gets the current class name
  53306. * @returns the class name
  53307. */
  53308. getClassName(): string;
  53309. /**
  53310. * Animate the input if animationType !== None
  53311. * @param scene defines the rendering scene
  53312. */
  53313. animate(scene: Scene): void;
  53314. private _emitDefine;
  53315. initialize(state: NodeMaterialBuildState): void;
  53316. /**
  53317. * Set the input block to its default value (based on its type)
  53318. */
  53319. setDefaultValue(): void;
  53320. private _emitConstant;
  53321. private _emit;
  53322. /** @hidden */
  53323. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53324. /** @hidden */
  53325. _transmit(effect: Effect, scene: Scene): void;
  53326. protected _buildBlock(state: NodeMaterialBuildState): void;
  53327. protected _dumpPropertiesCode(): string;
  53328. serialize(): any;
  53329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53330. }
  53331. }
  53332. declare module BABYLON {
  53333. /**
  53334. * Defines a connection point for a block
  53335. */
  53336. export class NodeMaterialConnectionPoint {
  53337. /** @hidden */
  53338. _ownerBlock: NodeMaterialBlock;
  53339. /** @hidden */
  53340. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53341. private _endpoints;
  53342. private _associatedVariableName;
  53343. /** @hidden */
  53344. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53345. /** @hidden */
  53346. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53347. private _type;
  53348. /** @hidden */
  53349. _enforceAssociatedVariableName: boolean;
  53350. /**
  53351. * Gets or sets the additional types supported by this connection point
  53352. */
  53353. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53354. /**
  53355. * Gets or sets the additional types excluded by this connection point
  53356. */
  53357. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53358. /**
  53359. * Gets or sets the associated variable name in the shader
  53360. */
  53361. associatedVariableName: string;
  53362. /**
  53363. * Gets or sets the connection point type (default is float)
  53364. */
  53365. type: NodeMaterialBlockConnectionPointTypes;
  53366. /**
  53367. * Gets or sets the connection point name
  53368. */
  53369. name: string;
  53370. /**
  53371. * Gets or sets a boolean indicating that this connection point can be omitted
  53372. */
  53373. isOptional: boolean;
  53374. /**
  53375. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53376. */
  53377. define: string;
  53378. /** Gets or sets the target of that connection point */
  53379. target: NodeMaterialBlockTargets;
  53380. /**
  53381. * Gets a boolean indicating that the current point is connected
  53382. */
  53383. readonly isConnected: boolean;
  53384. /**
  53385. * Gets a boolean indicating that the current point is connected to an input block
  53386. */
  53387. readonly isConnectedToInputBlock: boolean;
  53388. /**
  53389. * Gets a the connected input block (if any)
  53390. */
  53391. readonly connectInputBlock: Nullable<InputBlock>;
  53392. /** Get the other side of the connection (if any) */
  53393. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53394. /** Get the block that owns this connection point */
  53395. readonly ownerBlock: NodeMaterialBlock;
  53396. /** Get the block connected on the other side of this connection (if any) */
  53397. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53398. /** Get the block connected on the endpoints of this connection (if any) */
  53399. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53400. /** Gets the list of connected endpoints */
  53401. readonly endpoints: NodeMaterialConnectionPoint[];
  53402. /** Gets a boolean indicating if that output point is connected to at least one input */
  53403. readonly hasEndpoints: boolean;
  53404. /**
  53405. * Creates a new connection point
  53406. * @param name defines the connection point name
  53407. * @param ownerBlock defines the block hosting this connection point
  53408. */
  53409. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53410. /**
  53411. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53412. * @returns the class name
  53413. */
  53414. getClassName(): string;
  53415. /**
  53416. * Gets an boolean indicating if the current point can be connected to another point
  53417. * @param connectionPoint defines the other connection point
  53418. * @returns true if the connection is possible
  53419. */
  53420. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53421. /**
  53422. * Connect this point to another connection point
  53423. * @param connectionPoint defines the other connection point
  53424. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53425. * @returns the current connection point
  53426. */
  53427. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53428. /**
  53429. * Disconnect this point from one of his endpoint
  53430. * @param endpoint defines the other connection point
  53431. * @returns the current connection point
  53432. */
  53433. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53434. /**
  53435. * Serializes this point in a JSON representation
  53436. * @returns the serialized point object
  53437. */
  53438. serialize(): any;
  53439. }
  53440. }
  53441. declare module BABYLON {
  53442. /**
  53443. * Block used to add support for vertex skinning (bones)
  53444. */
  53445. export class BonesBlock extends NodeMaterialBlock {
  53446. /**
  53447. * Creates a new BonesBlock
  53448. * @param name defines the block name
  53449. */
  53450. constructor(name: string);
  53451. /**
  53452. * Initialize the block and prepare the context for build
  53453. * @param state defines the state that will be used for the build
  53454. */
  53455. initialize(state: NodeMaterialBuildState): void;
  53456. /**
  53457. * Gets the current class name
  53458. * @returns the class name
  53459. */
  53460. getClassName(): string;
  53461. /**
  53462. * Gets the matrix indices input component
  53463. */
  53464. readonly matricesIndices: NodeMaterialConnectionPoint;
  53465. /**
  53466. * Gets the matrix weights input component
  53467. */
  53468. readonly matricesWeights: NodeMaterialConnectionPoint;
  53469. /**
  53470. * Gets the extra matrix indices input component
  53471. */
  53472. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53473. /**
  53474. * Gets the extra matrix weights input component
  53475. */
  53476. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53477. /**
  53478. * Gets the world input component
  53479. */
  53480. readonly world: NodeMaterialConnectionPoint;
  53481. /**
  53482. * Gets the output component
  53483. */
  53484. readonly output: NodeMaterialConnectionPoint;
  53485. autoConfigure(material: NodeMaterial): void;
  53486. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53487. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53489. protected _buildBlock(state: NodeMaterialBuildState): this;
  53490. }
  53491. }
  53492. declare module BABYLON {
  53493. /**
  53494. * Block used to add support for instances
  53495. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53496. */
  53497. export class InstancesBlock extends NodeMaterialBlock {
  53498. /**
  53499. * Creates a new InstancesBlock
  53500. * @param name defines the block name
  53501. */
  53502. constructor(name: string);
  53503. /**
  53504. * Gets the current class name
  53505. * @returns the class name
  53506. */
  53507. getClassName(): string;
  53508. /**
  53509. * Gets the first world row input component
  53510. */
  53511. readonly world0: NodeMaterialConnectionPoint;
  53512. /**
  53513. * Gets the second world row input component
  53514. */
  53515. readonly world1: NodeMaterialConnectionPoint;
  53516. /**
  53517. * Gets the third world row input component
  53518. */
  53519. readonly world2: NodeMaterialConnectionPoint;
  53520. /**
  53521. * Gets the forth world row input component
  53522. */
  53523. readonly world3: NodeMaterialConnectionPoint;
  53524. /**
  53525. * Gets the world input component
  53526. */
  53527. readonly world: NodeMaterialConnectionPoint;
  53528. /**
  53529. * Gets the output component
  53530. */
  53531. readonly output: NodeMaterialConnectionPoint;
  53532. autoConfigure(material: NodeMaterial): void;
  53533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53534. protected _buildBlock(state: NodeMaterialBuildState): this;
  53535. }
  53536. }
  53537. declare module BABYLON {
  53538. /**
  53539. * Block used to add morph targets support to vertex shader
  53540. */
  53541. export class MorphTargetsBlock extends NodeMaterialBlock {
  53542. private _repeatableContentAnchor;
  53543. private _repeatebleContentGenerated;
  53544. /**
  53545. * Create a new MorphTargetsBlock
  53546. * @param name defines the block name
  53547. */
  53548. constructor(name: string);
  53549. /**
  53550. * Gets the current class name
  53551. * @returns the class name
  53552. */
  53553. getClassName(): string;
  53554. /**
  53555. * Gets the position input component
  53556. */
  53557. readonly position: NodeMaterialConnectionPoint;
  53558. /**
  53559. * Gets the normal input component
  53560. */
  53561. readonly normal: NodeMaterialConnectionPoint;
  53562. /**
  53563. * Gets the tangent input component
  53564. */
  53565. readonly tangent: NodeMaterialConnectionPoint;
  53566. /**
  53567. * Gets the tangent input component
  53568. */
  53569. readonly uv: NodeMaterialConnectionPoint;
  53570. /**
  53571. * Gets the position output component
  53572. */
  53573. readonly positionOutput: NodeMaterialConnectionPoint;
  53574. /**
  53575. * Gets the normal output component
  53576. */
  53577. readonly normalOutput: NodeMaterialConnectionPoint;
  53578. /**
  53579. * Gets the tangent output component
  53580. */
  53581. readonly tangentOutput: NodeMaterialConnectionPoint;
  53582. /**
  53583. * Gets the tangent output component
  53584. */
  53585. readonly uvOutput: NodeMaterialConnectionPoint;
  53586. initialize(state: NodeMaterialBuildState): void;
  53587. autoConfigure(material: NodeMaterial): void;
  53588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53590. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53591. protected _buildBlock(state: NodeMaterialBuildState): this;
  53592. }
  53593. }
  53594. declare module BABYLON {
  53595. /**
  53596. * Block used to get data information from a light
  53597. */
  53598. export class LightInformationBlock extends NodeMaterialBlock {
  53599. private _lightDataUniformName;
  53600. private _lightColorUniformName;
  53601. private _lightTypeDefineName;
  53602. /**
  53603. * Gets or sets the light associated with this block
  53604. */
  53605. light: Nullable<Light>;
  53606. /**
  53607. * Creates a new LightInformationBlock
  53608. * @param name defines the block name
  53609. */
  53610. constructor(name: string);
  53611. /**
  53612. * Gets the current class name
  53613. * @returns the class name
  53614. */
  53615. getClassName(): string;
  53616. /**
  53617. * Gets the world position input component
  53618. */
  53619. readonly worldPosition: NodeMaterialConnectionPoint;
  53620. /**
  53621. * Gets the direction output component
  53622. */
  53623. readonly direction: NodeMaterialConnectionPoint;
  53624. /**
  53625. * Gets the direction output component
  53626. */
  53627. readonly color: NodeMaterialConnectionPoint;
  53628. /**
  53629. * Gets the direction output component
  53630. */
  53631. readonly intensity: NodeMaterialConnectionPoint;
  53632. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53634. protected _buildBlock(state: NodeMaterialBuildState): this;
  53635. serialize(): any;
  53636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53637. }
  53638. }
  53639. declare module BABYLON {
  53640. /**
  53641. * Block used to add image processing support to fragment shader
  53642. */
  53643. export class ImageProcessingBlock extends NodeMaterialBlock {
  53644. /**
  53645. * Create a new ImageProcessingBlock
  53646. * @param name defines the block name
  53647. */
  53648. constructor(name: string);
  53649. /**
  53650. * Gets the current class name
  53651. * @returns the class name
  53652. */
  53653. getClassName(): string;
  53654. /**
  53655. * Gets the color input component
  53656. */
  53657. readonly color: NodeMaterialConnectionPoint;
  53658. /**
  53659. * Gets the output component
  53660. */
  53661. readonly output: NodeMaterialConnectionPoint;
  53662. /**
  53663. * Initialize the block and prepare the context for build
  53664. * @param state defines the state that will be used for the build
  53665. */
  53666. initialize(state: NodeMaterialBuildState): void;
  53667. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53670. protected _buildBlock(state: NodeMaterialBuildState): this;
  53671. }
  53672. }
  53673. declare module BABYLON {
  53674. /**
  53675. * Block used to pertub normals based on a normal map
  53676. */
  53677. export class PerturbNormalBlock extends NodeMaterialBlock {
  53678. private _tangentSpaceParameterName;
  53679. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53680. invertX: boolean;
  53681. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53682. invertY: boolean;
  53683. /**
  53684. * Create a new PerturbNormalBlock
  53685. * @param name defines the block name
  53686. */
  53687. constructor(name: string);
  53688. /**
  53689. * Gets the current class name
  53690. * @returns the class name
  53691. */
  53692. getClassName(): string;
  53693. /**
  53694. * Gets the world position input component
  53695. */
  53696. readonly worldPosition: NodeMaterialConnectionPoint;
  53697. /**
  53698. * Gets the world normal input component
  53699. */
  53700. readonly worldNormal: NodeMaterialConnectionPoint;
  53701. /**
  53702. * Gets the uv input component
  53703. */
  53704. readonly uv: NodeMaterialConnectionPoint;
  53705. /**
  53706. * Gets the normal map color input component
  53707. */
  53708. readonly normalMapColor: NodeMaterialConnectionPoint;
  53709. /**
  53710. * Gets the strength input component
  53711. */
  53712. readonly strength: NodeMaterialConnectionPoint;
  53713. /**
  53714. * Gets the output component
  53715. */
  53716. readonly output: NodeMaterialConnectionPoint;
  53717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53718. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53719. autoConfigure(material: NodeMaterial): void;
  53720. protected _buildBlock(state: NodeMaterialBuildState): this;
  53721. protected _dumpPropertiesCode(): string;
  53722. serialize(): any;
  53723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53724. }
  53725. }
  53726. declare module BABYLON {
  53727. /**
  53728. * Block used to discard a pixel if a value is smaller than a cutoff
  53729. */
  53730. export class DiscardBlock extends NodeMaterialBlock {
  53731. /**
  53732. * Create a new DiscardBlock
  53733. * @param name defines the block name
  53734. */
  53735. constructor(name: string);
  53736. /**
  53737. * Gets the current class name
  53738. * @returns the class name
  53739. */
  53740. getClassName(): string;
  53741. /**
  53742. * Gets the color input component
  53743. */
  53744. readonly value: NodeMaterialConnectionPoint;
  53745. /**
  53746. * Gets the cutoff input component
  53747. */
  53748. readonly cutoff: NodeMaterialConnectionPoint;
  53749. protected _buildBlock(state: NodeMaterialBuildState): this;
  53750. }
  53751. }
  53752. declare module BABYLON {
  53753. /**
  53754. * Block used to add support for scene fog
  53755. */
  53756. export class FogBlock extends NodeMaterialBlock {
  53757. private _fogDistanceName;
  53758. private _fogParameters;
  53759. /**
  53760. * Create a new FogBlock
  53761. * @param name defines the block name
  53762. */
  53763. constructor(name: string);
  53764. /**
  53765. * Gets the current class name
  53766. * @returns the class name
  53767. */
  53768. getClassName(): string;
  53769. /**
  53770. * Gets the world position input component
  53771. */
  53772. readonly worldPosition: NodeMaterialConnectionPoint;
  53773. /**
  53774. * Gets the view input component
  53775. */
  53776. readonly view: NodeMaterialConnectionPoint;
  53777. /**
  53778. * Gets the color input component
  53779. */
  53780. readonly input: NodeMaterialConnectionPoint;
  53781. /**
  53782. * Gets the fog color input component
  53783. */
  53784. readonly fogColor: NodeMaterialConnectionPoint;
  53785. /**
  53786. * Gets the output component
  53787. */
  53788. readonly output: NodeMaterialConnectionPoint;
  53789. autoConfigure(material: NodeMaterial): void;
  53790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53791. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53792. protected _buildBlock(state: NodeMaterialBuildState): this;
  53793. }
  53794. }
  53795. declare module BABYLON {
  53796. /**
  53797. * Block used to add light in the fragment shader
  53798. */
  53799. export class LightBlock extends NodeMaterialBlock {
  53800. private _lightId;
  53801. /**
  53802. * Gets or sets the light associated with this block
  53803. */
  53804. light: Nullable<Light>;
  53805. /**
  53806. * Create a new LightBlock
  53807. * @param name defines the block name
  53808. */
  53809. constructor(name: string);
  53810. /**
  53811. * Gets the current class name
  53812. * @returns the class name
  53813. */
  53814. getClassName(): string;
  53815. /**
  53816. * Gets the world position input component
  53817. */
  53818. readonly worldPosition: NodeMaterialConnectionPoint;
  53819. /**
  53820. * Gets the world normal input component
  53821. */
  53822. readonly worldNormal: NodeMaterialConnectionPoint;
  53823. /**
  53824. * Gets the camera (or eye) position component
  53825. */
  53826. readonly cameraPosition: NodeMaterialConnectionPoint;
  53827. /**
  53828. * Gets the diffuse output component
  53829. */
  53830. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53831. /**
  53832. * Gets the specular output component
  53833. */
  53834. readonly specularOutput: NodeMaterialConnectionPoint;
  53835. autoConfigure(material: NodeMaterial): void;
  53836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53837. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53838. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53839. private _injectVertexCode;
  53840. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53841. serialize(): any;
  53842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53843. }
  53844. }
  53845. declare module BABYLON {
  53846. /**
  53847. * Block used to multiply 2 values
  53848. */
  53849. export class MultiplyBlock extends NodeMaterialBlock {
  53850. /**
  53851. * Creates a new MultiplyBlock
  53852. * @param name defines the block name
  53853. */
  53854. constructor(name: string);
  53855. /**
  53856. * Gets the current class name
  53857. * @returns the class name
  53858. */
  53859. getClassName(): string;
  53860. /**
  53861. * Gets the left operand input component
  53862. */
  53863. readonly left: NodeMaterialConnectionPoint;
  53864. /**
  53865. * Gets the right operand input component
  53866. */
  53867. readonly right: NodeMaterialConnectionPoint;
  53868. /**
  53869. * Gets the output component
  53870. */
  53871. readonly output: NodeMaterialConnectionPoint;
  53872. protected _buildBlock(state: NodeMaterialBuildState): this;
  53873. }
  53874. }
  53875. declare module BABYLON {
  53876. /**
  53877. * Block used to add 2 vectors
  53878. */
  53879. export class AddBlock extends NodeMaterialBlock {
  53880. /**
  53881. * Creates a new AddBlock
  53882. * @param name defines the block name
  53883. */
  53884. constructor(name: string);
  53885. /**
  53886. * Gets the current class name
  53887. * @returns the class name
  53888. */
  53889. getClassName(): string;
  53890. /**
  53891. * Gets the left operand input component
  53892. */
  53893. readonly left: NodeMaterialConnectionPoint;
  53894. /**
  53895. * Gets the right operand input component
  53896. */
  53897. readonly right: NodeMaterialConnectionPoint;
  53898. /**
  53899. * Gets the output component
  53900. */
  53901. readonly output: NodeMaterialConnectionPoint;
  53902. protected _buildBlock(state: NodeMaterialBuildState): this;
  53903. }
  53904. }
  53905. declare module BABYLON {
  53906. /**
  53907. * Block used to scale a vector by a float
  53908. */
  53909. export class ScaleBlock extends NodeMaterialBlock {
  53910. /**
  53911. * Creates a new ScaleBlock
  53912. * @param name defines the block name
  53913. */
  53914. constructor(name: string);
  53915. /**
  53916. * Gets the current class name
  53917. * @returns the class name
  53918. */
  53919. getClassName(): string;
  53920. /**
  53921. * Gets the input component
  53922. */
  53923. readonly input: NodeMaterialConnectionPoint;
  53924. /**
  53925. * Gets the factor input component
  53926. */
  53927. readonly factor: NodeMaterialConnectionPoint;
  53928. /**
  53929. * Gets the output component
  53930. */
  53931. readonly output: NodeMaterialConnectionPoint;
  53932. protected _buildBlock(state: NodeMaterialBuildState): this;
  53933. }
  53934. }
  53935. declare module BABYLON {
  53936. /**
  53937. * Block used to clamp a float
  53938. */
  53939. export class ClampBlock extends NodeMaterialBlock {
  53940. /** Gets or sets the minimum range */
  53941. minimum: number;
  53942. /** Gets or sets the maximum range */
  53943. maximum: number;
  53944. /**
  53945. * Creates a new ClampBlock
  53946. * @param name defines the block name
  53947. */
  53948. constructor(name: string);
  53949. /**
  53950. * Gets the current class name
  53951. * @returns the class name
  53952. */
  53953. getClassName(): string;
  53954. /**
  53955. * Gets the value input component
  53956. */
  53957. readonly value: NodeMaterialConnectionPoint;
  53958. /**
  53959. * Gets the output component
  53960. */
  53961. readonly output: NodeMaterialConnectionPoint;
  53962. protected _buildBlock(state: NodeMaterialBuildState): this;
  53963. protected _dumpPropertiesCode(): string;
  53964. serialize(): any;
  53965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53966. }
  53967. }
  53968. declare module BABYLON {
  53969. /**
  53970. * Block used to apply a cross product between 2 vectors
  53971. */
  53972. export class CrossBlock extends NodeMaterialBlock {
  53973. /**
  53974. * Creates a new CrossBlock
  53975. * @param name defines the block name
  53976. */
  53977. constructor(name: string);
  53978. /**
  53979. * Gets the current class name
  53980. * @returns the class name
  53981. */
  53982. getClassName(): string;
  53983. /**
  53984. * Gets the left operand input component
  53985. */
  53986. readonly left: NodeMaterialConnectionPoint;
  53987. /**
  53988. * Gets the right operand input component
  53989. */
  53990. readonly right: NodeMaterialConnectionPoint;
  53991. /**
  53992. * Gets the output component
  53993. */
  53994. readonly output: NodeMaterialConnectionPoint;
  53995. protected _buildBlock(state: NodeMaterialBuildState): this;
  53996. }
  53997. }
  53998. declare module BABYLON {
  53999. /**
  54000. * Block used to apply a dot product between 2 vectors
  54001. */
  54002. export class DotBlock extends NodeMaterialBlock {
  54003. /**
  54004. * Creates a new DotBlock
  54005. * @param name defines the block name
  54006. */
  54007. constructor(name: string);
  54008. /**
  54009. * Gets the current class name
  54010. * @returns the class name
  54011. */
  54012. getClassName(): string;
  54013. /**
  54014. * Gets the left operand input component
  54015. */
  54016. readonly left: NodeMaterialConnectionPoint;
  54017. /**
  54018. * Gets the right operand input component
  54019. */
  54020. readonly right: NodeMaterialConnectionPoint;
  54021. /**
  54022. * Gets the output component
  54023. */
  54024. readonly output: NodeMaterialConnectionPoint;
  54025. protected _buildBlock(state: NodeMaterialBuildState): this;
  54026. }
  54027. }
  54028. declare module BABYLON {
  54029. /**
  54030. * Block used to remap a float from a range to a new one
  54031. */
  54032. export class RemapBlock extends NodeMaterialBlock {
  54033. /**
  54034. * Gets or sets the source range
  54035. */
  54036. sourceRange: Vector2;
  54037. /**
  54038. * Gets or sets the target range
  54039. */
  54040. targetRange: Vector2;
  54041. /**
  54042. * Creates a new RemapBlock
  54043. * @param name defines the block name
  54044. */
  54045. constructor(name: string);
  54046. /**
  54047. * Gets the current class name
  54048. * @returns the class name
  54049. */
  54050. getClassName(): string;
  54051. /**
  54052. * Gets the input component
  54053. */
  54054. readonly input: NodeMaterialConnectionPoint;
  54055. /**
  54056. * Gets the source min input component
  54057. */
  54058. readonly sourceMin: NodeMaterialConnectionPoint;
  54059. /**
  54060. * Gets the source max input component
  54061. */
  54062. readonly sourceMax: NodeMaterialConnectionPoint;
  54063. /**
  54064. * Gets the target min input component
  54065. */
  54066. readonly targetMin: NodeMaterialConnectionPoint;
  54067. /**
  54068. * Gets the target max input component
  54069. */
  54070. readonly targetMax: NodeMaterialConnectionPoint;
  54071. /**
  54072. * Gets the output component
  54073. */
  54074. readonly output: NodeMaterialConnectionPoint;
  54075. protected _buildBlock(state: NodeMaterialBuildState): this;
  54076. protected _dumpPropertiesCode(): string;
  54077. serialize(): any;
  54078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54079. }
  54080. }
  54081. declare module BABYLON {
  54082. /**
  54083. * Block used to normalize a vector
  54084. */
  54085. export class NormalizeBlock extends NodeMaterialBlock {
  54086. /**
  54087. * Creates a new NormalizeBlock
  54088. * @param name defines the block name
  54089. */
  54090. constructor(name: string);
  54091. /**
  54092. * Gets the current class name
  54093. * @returns the class name
  54094. */
  54095. getClassName(): string;
  54096. /**
  54097. * Gets the input component
  54098. */
  54099. readonly input: NodeMaterialConnectionPoint;
  54100. /**
  54101. * Gets the output component
  54102. */
  54103. readonly output: NodeMaterialConnectionPoint;
  54104. protected _buildBlock(state: NodeMaterialBuildState): this;
  54105. }
  54106. }
  54107. declare module BABYLON {
  54108. /**
  54109. * Operations supported by the Trigonometry block
  54110. */
  54111. export enum TrigonometryBlockOperations {
  54112. /** Cos */
  54113. Cos = 0,
  54114. /** Sin */
  54115. Sin = 1,
  54116. /** Abs */
  54117. Abs = 2,
  54118. /** Exp */
  54119. Exp = 3,
  54120. /** Exp2 */
  54121. Exp2 = 4,
  54122. /** Round */
  54123. Round = 5,
  54124. /** Floor */
  54125. Floor = 6,
  54126. /** Ceiling */
  54127. Ceiling = 7,
  54128. /** Square root */
  54129. Sqrt = 8
  54130. }
  54131. /**
  54132. * Block used to apply trigonometry operation to floats
  54133. */
  54134. export class TrigonometryBlock extends NodeMaterialBlock {
  54135. /**
  54136. * Gets or sets the operation applied by the block
  54137. */
  54138. operation: TrigonometryBlockOperations;
  54139. /**
  54140. * Creates a new TrigonometryBlock
  54141. * @param name defines the block name
  54142. */
  54143. constructor(name: string);
  54144. /**
  54145. * Gets the current class name
  54146. * @returns the class name
  54147. */
  54148. getClassName(): string;
  54149. /**
  54150. * Gets the input component
  54151. */
  54152. readonly input: NodeMaterialConnectionPoint;
  54153. /**
  54154. * Gets the output component
  54155. */
  54156. readonly output: NodeMaterialConnectionPoint;
  54157. protected _buildBlock(state: NodeMaterialBuildState): this;
  54158. serialize(): any;
  54159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54160. }
  54161. }
  54162. declare module BABYLON {
  54163. /**
  54164. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54165. */
  54166. export class ColorMergerBlock extends NodeMaterialBlock {
  54167. /**
  54168. * Create a new ColorMergerBlock
  54169. * @param name defines the block name
  54170. */
  54171. constructor(name: string);
  54172. /**
  54173. * Gets the current class name
  54174. * @returns the class name
  54175. */
  54176. getClassName(): string;
  54177. /**
  54178. * Gets the r component (input)
  54179. */
  54180. readonly r: NodeMaterialConnectionPoint;
  54181. /**
  54182. * Gets the g component (input)
  54183. */
  54184. readonly g: NodeMaterialConnectionPoint;
  54185. /**
  54186. * Gets the b component (input)
  54187. */
  54188. readonly b: NodeMaterialConnectionPoint;
  54189. /**
  54190. * Gets the a component (input)
  54191. */
  54192. readonly a: NodeMaterialConnectionPoint;
  54193. /**
  54194. * Gets the rgba component (output)
  54195. */
  54196. readonly rgba: NodeMaterialConnectionPoint;
  54197. /**
  54198. * Gets the rgb component (output)
  54199. */
  54200. readonly rgb: NodeMaterialConnectionPoint;
  54201. protected _buildBlock(state: NodeMaterialBuildState): this;
  54202. }
  54203. }
  54204. declare module BABYLON {
  54205. /**
  54206. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54207. */
  54208. export class VectorMergerBlock extends NodeMaterialBlock {
  54209. /**
  54210. * Create a new VectorMergerBlock
  54211. * @param name defines the block name
  54212. */
  54213. constructor(name: string);
  54214. /**
  54215. * Gets the current class name
  54216. * @returns the class name
  54217. */
  54218. getClassName(): string;
  54219. /**
  54220. * Gets the x component (input)
  54221. */
  54222. readonly x: NodeMaterialConnectionPoint;
  54223. /**
  54224. * Gets the y component (input)
  54225. */
  54226. readonly y: NodeMaterialConnectionPoint;
  54227. /**
  54228. * Gets the z component (input)
  54229. */
  54230. readonly z: NodeMaterialConnectionPoint;
  54231. /**
  54232. * Gets the w component (input)
  54233. */
  54234. readonly w: NodeMaterialConnectionPoint;
  54235. /**
  54236. * Gets the xyzw component (output)
  54237. */
  54238. readonly xyzw: NodeMaterialConnectionPoint;
  54239. /**
  54240. * Gets the xyz component (output)
  54241. */
  54242. readonly xyz: NodeMaterialConnectionPoint;
  54243. /**
  54244. * Gets the xy component (output)
  54245. */
  54246. readonly xy: NodeMaterialConnectionPoint;
  54247. protected _buildBlock(state: NodeMaterialBuildState): this;
  54248. }
  54249. }
  54250. declare module BABYLON {
  54251. /**
  54252. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54253. */
  54254. export class ColorSplitterBlock extends NodeMaterialBlock {
  54255. /**
  54256. * Create a new ColorSplitterBlock
  54257. * @param name defines the block name
  54258. */
  54259. constructor(name: string);
  54260. /**
  54261. * Gets the current class name
  54262. * @returns the class name
  54263. */
  54264. getClassName(): string;
  54265. /**
  54266. * Gets the rgba component (input)
  54267. */
  54268. readonly rgba: NodeMaterialConnectionPoint;
  54269. /**
  54270. * Gets the rgb component (input)
  54271. */
  54272. readonly rgbIn: NodeMaterialConnectionPoint;
  54273. /**
  54274. * Gets the rgb component (output)
  54275. */
  54276. readonly rgbOut: NodeMaterialConnectionPoint;
  54277. /**
  54278. * Gets the r component (output)
  54279. */
  54280. readonly r: NodeMaterialConnectionPoint;
  54281. /**
  54282. * Gets the g component (output)
  54283. */
  54284. readonly g: NodeMaterialConnectionPoint;
  54285. /**
  54286. * Gets the b component (output)
  54287. */
  54288. readonly b: NodeMaterialConnectionPoint;
  54289. /**
  54290. * Gets the a component (output)
  54291. */
  54292. readonly a: NodeMaterialConnectionPoint;
  54293. protected _inputRename(name: string): string;
  54294. protected _outputRename(name: string): string;
  54295. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54296. }
  54297. }
  54298. declare module BABYLON {
  54299. /**
  54300. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54301. */
  54302. export class VectorSplitterBlock extends NodeMaterialBlock {
  54303. /**
  54304. * Create a new VectorSplitterBlock
  54305. * @param name defines the block name
  54306. */
  54307. constructor(name: string);
  54308. /**
  54309. * Gets the current class name
  54310. * @returns the class name
  54311. */
  54312. getClassName(): string;
  54313. /**
  54314. * Gets the xyzw component (input)
  54315. */
  54316. readonly xyzw: NodeMaterialConnectionPoint;
  54317. /**
  54318. * Gets the xyz component (input)
  54319. */
  54320. readonly xyzIn: NodeMaterialConnectionPoint;
  54321. /**
  54322. * Gets the xy component (input)
  54323. */
  54324. readonly xyIn: NodeMaterialConnectionPoint;
  54325. /**
  54326. * Gets the xyz component (output)
  54327. */
  54328. readonly xyzOut: NodeMaterialConnectionPoint;
  54329. /**
  54330. * Gets the xy component (output)
  54331. */
  54332. readonly xyOut: NodeMaterialConnectionPoint;
  54333. /**
  54334. * Gets the x component (output)
  54335. */
  54336. readonly x: NodeMaterialConnectionPoint;
  54337. /**
  54338. * Gets the y component (output)
  54339. */
  54340. readonly y: NodeMaterialConnectionPoint;
  54341. /**
  54342. * Gets the z component (output)
  54343. */
  54344. readonly z: NodeMaterialConnectionPoint;
  54345. /**
  54346. * Gets the w component (output)
  54347. */
  54348. readonly w: NodeMaterialConnectionPoint;
  54349. protected _inputRename(name: string): string;
  54350. protected _outputRename(name: string): string;
  54351. protected _buildBlock(state: NodeMaterialBuildState): this;
  54352. }
  54353. }
  54354. declare module BABYLON {
  54355. /**
  54356. * Block used to lerp 2 values
  54357. */
  54358. export class LerpBlock extends NodeMaterialBlock {
  54359. /**
  54360. * Creates a new LerpBlock
  54361. * @param name defines the block name
  54362. */
  54363. constructor(name: string);
  54364. /**
  54365. * Gets the current class name
  54366. * @returns the class name
  54367. */
  54368. getClassName(): string;
  54369. /**
  54370. * Gets the left operand input component
  54371. */
  54372. readonly left: NodeMaterialConnectionPoint;
  54373. /**
  54374. * Gets the right operand input component
  54375. */
  54376. readonly right: NodeMaterialConnectionPoint;
  54377. /**
  54378. * Gets the gradient operand input component
  54379. */
  54380. readonly gradient: NodeMaterialConnectionPoint;
  54381. /**
  54382. * Gets the output component
  54383. */
  54384. readonly output: NodeMaterialConnectionPoint;
  54385. protected _buildBlock(state: NodeMaterialBuildState): this;
  54386. }
  54387. }
  54388. declare module BABYLON {
  54389. /**
  54390. * Block used to divide 2 vectors
  54391. */
  54392. export class DivideBlock extends NodeMaterialBlock {
  54393. /**
  54394. * Creates a new DivideBlock
  54395. * @param name defines the block name
  54396. */
  54397. constructor(name: string);
  54398. /**
  54399. * Gets the current class name
  54400. * @returns the class name
  54401. */
  54402. getClassName(): string;
  54403. /**
  54404. * Gets the left operand input component
  54405. */
  54406. readonly left: NodeMaterialConnectionPoint;
  54407. /**
  54408. * Gets the right operand input component
  54409. */
  54410. readonly right: NodeMaterialConnectionPoint;
  54411. /**
  54412. * Gets the output component
  54413. */
  54414. readonly output: NodeMaterialConnectionPoint;
  54415. protected _buildBlock(state: NodeMaterialBuildState): this;
  54416. }
  54417. }
  54418. declare module BABYLON {
  54419. /**
  54420. * Block used to subtract 2 vectors
  54421. */
  54422. export class SubtractBlock extends NodeMaterialBlock {
  54423. /**
  54424. * Creates a new SubtractBlock
  54425. * @param name defines the block name
  54426. */
  54427. constructor(name: string);
  54428. /**
  54429. * Gets the current class name
  54430. * @returns the class name
  54431. */
  54432. getClassName(): string;
  54433. /**
  54434. * Gets the left operand input component
  54435. */
  54436. readonly left: NodeMaterialConnectionPoint;
  54437. /**
  54438. * Gets the right operand input component
  54439. */
  54440. readonly right: NodeMaterialConnectionPoint;
  54441. /**
  54442. * Gets the output component
  54443. */
  54444. readonly output: NodeMaterialConnectionPoint;
  54445. protected _buildBlock(state: NodeMaterialBuildState): this;
  54446. }
  54447. }
  54448. declare module BABYLON {
  54449. /**
  54450. * Block used to step a value
  54451. */
  54452. export class StepBlock extends NodeMaterialBlock {
  54453. /**
  54454. * Creates a new AddBlock
  54455. * @param name defines the block name
  54456. */
  54457. constructor(name: string);
  54458. /**
  54459. * Gets the current class name
  54460. * @returns the class name
  54461. */
  54462. getClassName(): string;
  54463. /**
  54464. * Gets the value operand input component
  54465. */
  54466. readonly value: NodeMaterialConnectionPoint;
  54467. /**
  54468. * Gets the edge operand input component
  54469. */
  54470. readonly edge: NodeMaterialConnectionPoint;
  54471. /**
  54472. * Gets the output component
  54473. */
  54474. readonly output: NodeMaterialConnectionPoint;
  54475. protected _buildBlock(state: NodeMaterialBuildState): this;
  54476. }
  54477. }
  54478. declare module BABYLON {
  54479. /**
  54480. * Block used to get the opposite (1 - x) of a value
  54481. */
  54482. export class OneMinusBlock extends NodeMaterialBlock {
  54483. /**
  54484. * Creates a new OneMinusBlock
  54485. * @param name defines the block name
  54486. */
  54487. constructor(name: string);
  54488. /**
  54489. * Gets the current class name
  54490. * @returns the class name
  54491. */
  54492. getClassName(): string;
  54493. /**
  54494. * Gets the input component
  54495. */
  54496. readonly input: NodeMaterialConnectionPoint;
  54497. /**
  54498. * Gets the output component
  54499. */
  54500. readonly output: NodeMaterialConnectionPoint;
  54501. protected _buildBlock(state: NodeMaterialBuildState): this;
  54502. }
  54503. }
  54504. declare module BABYLON {
  54505. /**
  54506. * Block used to get the view direction
  54507. */
  54508. export class ViewDirectionBlock extends NodeMaterialBlock {
  54509. /**
  54510. * Creates a new ViewDirectionBlock
  54511. * @param name defines the block name
  54512. */
  54513. constructor(name: string);
  54514. /**
  54515. * Gets the current class name
  54516. * @returns the class name
  54517. */
  54518. getClassName(): string;
  54519. /**
  54520. * Gets the world position component
  54521. */
  54522. readonly worldPosition: NodeMaterialConnectionPoint;
  54523. /**
  54524. * Gets the camera position component
  54525. */
  54526. readonly cameraPosition: NodeMaterialConnectionPoint;
  54527. /**
  54528. * Gets the output component
  54529. */
  54530. readonly output: NodeMaterialConnectionPoint;
  54531. autoConfigure(material: NodeMaterial): void;
  54532. protected _buildBlock(state: NodeMaterialBuildState): this;
  54533. }
  54534. }
  54535. declare module BABYLON {
  54536. /**
  54537. * Block used to compute fresnel value
  54538. */
  54539. export class FresnelBlock extends NodeMaterialBlock {
  54540. /**
  54541. * Create a new FresnelBlock
  54542. * @param name defines the block name
  54543. */
  54544. constructor(name: string);
  54545. /**
  54546. * Gets the current class name
  54547. * @returns the class name
  54548. */
  54549. getClassName(): string;
  54550. /**
  54551. * Gets the world normal input component
  54552. */
  54553. readonly worldNormal: NodeMaterialConnectionPoint;
  54554. /**
  54555. * Gets the view direction input component
  54556. */
  54557. readonly viewDirection: NodeMaterialConnectionPoint;
  54558. /**
  54559. * Gets the bias input component
  54560. */
  54561. readonly bias: NodeMaterialConnectionPoint;
  54562. /**
  54563. * Gets the camera (or eye) position component
  54564. */
  54565. readonly power: NodeMaterialConnectionPoint;
  54566. /**
  54567. * Gets the fresnel output component
  54568. */
  54569. readonly fresnel: NodeMaterialConnectionPoint;
  54570. autoConfigure(material: NodeMaterial): void;
  54571. protected _buildBlock(state: NodeMaterialBuildState): this;
  54572. }
  54573. }
  54574. declare module BABYLON {
  54575. /**
  54576. * Block used to get the max of 2 values
  54577. */
  54578. export class MaxBlock extends NodeMaterialBlock {
  54579. /**
  54580. * Creates a new MaxBlock
  54581. * @param name defines the block name
  54582. */
  54583. constructor(name: string);
  54584. /**
  54585. * Gets the current class name
  54586. * @returns the class name
  54587. */
  54588. getClassName(): string;
  54589. /**
  54590. * Gets the left operand input component
  54591. */
  54592. readonly left: NodeMaterialConnectionPoint;
  54593. /**
  54594. * Gets the right operand input component
  54595. */
  54596. readonly right: NodeMaterialConnectionPoint;
  54597. /**
  54598. * Gets the output component
  54599. */
  54600. readonly output: NodeMaterialConnectionPoint;
  54601. protected _buildBlock(state: NodeMaterialBuildState): this;
  54602. }
  54603. }
  54604. declare module BABYLON {
  54605. /**
  54606. * Block used to get the min of 2 values
  54607. */
  54608. export class MinBlock extends NodeMaterialBlock {
  54609. /**
  54610. * Creates a new MinBlock
  54611. * @param name defines the block name
  54612. */
  54613. constructor(name: string);
  54614. /**
  54615. * Gets the current class name
  54616. * @returns the class name
  54617. */
  54618. getClassName(): string;
  54619. /**
  54620. * Gets the left operand input component
  54621. */
  54622. readonly left: NodeMaterialConnectionPoint;
  54623. /**
  54624. * Gets the right operand input component
  54625. */
  54626. readonly right: NodeMaterialConnectionPoint;
  54627. /**
  54628. * Gets the output component
  54629. */
  54630. readonly output: NodeMaterialConnectionPoint;
  54631. protected _buildBlock(state: NodeMaterialBuildState): this;
  54632. }
  54633. }
  54634. declare module BABYLON {
  54635. /**
  54636. * Block used to get the distance between 2 values
  54637. */
  54638. export class DistanceBlock extends NodeMaterialBlock {
  54639. /**
  54640. * Creates a new DistanceBlock
  54641. * @param name defines the block name
  54642. */
  54643. constructor(name: string);
  54644. /**
  54645. * Gets the current class name
  54646. * @returns the class name
  54647. */
  54648. getClassName(): string;
  54649. /**
  54650. * Gets the left operand input component
  54651. */
  54652. readonly left: NodeMaterialConnectionPoint;
  54653. /**
  54654. * Gets the right operand input component
  54655. */
  54656. readonly right: NodeMaterialConnectionPoint;
  54657. /**
  54658. * Gets the output component
  54659. */
  54660. readonly output: NodeMaterialConnectionPoint;
  54661. protected _buildBlock(state: NodeMaterialBuildState): this;
  54662. }
  54663. }
  54664. declare module BABYLON {
  54665. /**
  54666. * Block used to get the length of a vector
  54667. */
  54668. export class LengthBlock extends NodeMaterialBlock {
  54669. /**
  54670. * Creates a new LengthBlock
  54671. * @param name defines the block name
  54672. */
  54673. constructor(name: string);
  54674. /**
  54675. * Gets the current class name
  54676. * @returns the class name
  54677. */
  54678. getClassName(): string;
  54679. /**
  54680. * Gets the value input component
  54681. */
  54682. readonly value: NodeMaterialConnectionPoint;
  54683. /**
  54684. * Gets the output component
  54685. */
  54686. readonly output: NodeMaterialConnectionPoint;
  54687. protected _buildBlock(state: NodeMaterialBuildState): this;
  54688. }
  54689. }
  54690. declare module BABYLON {
  54691. /**
  54692. * Block used to get negative version of a value (i.e. x * -1)
  54693. */
  54694. export class NegateBlock extends NodeMaterialBlock {
  54695. /**
  54696. * Creates a new NegateBlock
  54697. * @param name defines the block name
  54698. */
  54699. constructor(name: string);
  54700. /**
  54701. * Gets the current class name
  54702. * @returns the class name
  54703. */
  54704. getClassName(): string;
  54705. /**
  54706. * Gets the value input component
  54707. */
  54708. readonly value: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the output component
  54711. */
  54712. readonly output: NodeMaterialConnectionPoint;
  54713. protected _buildBlock(state: NodeMaterialBuildState): this;
  54714. }
  54715. }
  54716. declare module BABYLON {
  54717. /**
  54718. * Block used to get the value of the first parameter raised to the power of the second
  54719. */
  54720. export class PowBlock extends NodeMaterialBlock {
  54721. /**
  54722. * Creates a new PowBlock
  54723. * @param name defines the block name
  54724. */
  54725. constructor(name: string);
  54726. /**
  54727. * Gets the current class name
  54728. * @returns the class name
  54729. */
  54730. getClassName(): string;
  54731. /**
  54732. * Gets the value operand input component
  54733. */
  54734. readonly value: NodeMaterialConnectionPoint;
  54735. /**
  54736. * Gets the power operand input component
  54737. */
  54738. readonly power: NodeMaterialConnectionPoint;
  54739. /**
  54740. * Gets the output component
  54741. */
  54742. readonly output: NodeMaterialConnectionPoint;
  54743. protected _buildBlock(state: NodeMaterialBuildState): this;
  54744. }
  54745. }
  54746. declare module BABYLON {
  54747. /**
  54748. * Block used to get a random number
  54749. */
  54750. export class RandomNumberBlock extends NodeMaterialBlock {
  54751. /**
  54752. * Creates a new RandomNumberBlock
  54753. * @param name defines the block name
  54754. */
  54755. constructor(name: string);
  54756. /**
  54757. * Gets the current class name
  54758. * @returns the class name
  54759. */
  54760. getClassName(): string;
  54761. /**
  54762. * Gets the seed input component
  54763. */
  54764. readonly seed: NodeMaterialConnectionPoint;
  54765. /**
  54766. * Gets the output component
  54767. */
  54768. readonly output: NodeMaterialConnectionPoint;
  54769. protected _buildBlock(state: NodeMaterialBuildState): this;
  54770. }
  54771. }
  54772. declare module BABYLON {
  54773. /**
  54774. * Effect Render Options
  54775. */
  54776. export interface IEffectRendererOptions {
  54777. /**
  54778. * Defines the vertices positions.
  54779. */
  54780. positions?: number[];
  54781. /**
  54782. * Defines the indices.
  54783. */
  54784. indices?: number[];
  54785. }
  54786. /**
  54787. * Helper class to render one or more effects
  54788. */
  54789. export class EffectRenderer {
  54790. private engine;
  54791. private static _DefaultOptions;
  54792. private _vertexBuffers;
  54793. private _indexBuffer;
  54794. private _ringBufferIndex;
  54795. private _ringScreenBuffer;
  54796. private _fullscreenViewport;
  54797. private _getNextFrameBuffer;
  54798. /**
  54799. * Creates an effect renderer
  54800. * @param engine the engine to use for rendering
  54801. * @param options defines the options of the effect renderer
  54802. */
  54803. constructor(engine: Engine, options?: IEffectRendererOptions);
  54804. /**
  54805. * Sets the current viewport in normalized coordinates 0-1
  54806. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54807. */
  54808. setViewport(viewport?: Viewport): void;
  54809. /**
  54810. * Binds the embedded attributes buffer to the effect.
  54811. * @param effect Defines the effect to bind the attributes for
  54812. */
  54813. bindBuffers(effect: Effect): void;
  54814. /**
  54815. * Sets the current effect wrapper to use during draw.
  54816. * The effect needs to be ready before calling this api.
  54817. * This also sets the default full screen position attribute.
  54818. * @param effectWrapper Defines the effect to draw with
  54819. */
  54820. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54821. /**
  54822. * Draws a full screen quad.
  54823. */
  54824. draw(): void;
  54825. /**
  54826. * renders one or more effects to a specified texture
  54827. * @param effectWrappers list of effects to renderer
  54828. * @param outputTexture texture to draw to, if null it will render to the screen
  54829. */
  54830. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54831. /**
  54832. * Disposes of the effect renderer
  54833. */
  54834. dispose(): void;
  54835. }
  54836. /**
  54837. * Options to create an EffectWrapper
  54838. */
  54839. interface EffectWrapperCreationOptions {
  54840. /**
  54841. * Engine to use to create the effect
  54842. */
  54843. engine: Engine;
  54844. /**
  54845. * Fragment shader for the effect
  54846. */
  54847. fragmentShader: string;
  54848. /**
  54849. * Vertex shader for the effect
  54850. */
  54851. vertexShader?: string;
  54852. /**
  54853. * Attributes to use in the shader
  54854. */
  54855. attributeNames?: Array<string>;
  54856. /**
  54857. * Uniforms to use in the shader
  54858. */
  54859. uniformNames?: Array<string>;
  54860. /**
  54861. * Texture sampler names to use in the shader
  54862. */
  54863. samplerNames?: Array<string>;
  54864. /**
  54865. * The friendly name of the effect displayed in Spector.
  54866. */
  54867. name?: string;
  54868. }
  54869. /**
  54870. * Wraps an effect to be used for rendering
  54871. */
  54872. export class EffectWrapper {
  54873. /**
  54874. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54875. */
  54876. onApplyObservable: Observable<{}>;
  54877. /**
  54878. * The underlying effect
  54879. */
  54880. effect: Effect;
  54881. /**
  54882. * Creates an effect to be renderer
  54883. * @param creationOptions options to create the effect
  54884. */
  54885. constructor(creationOptions: EffectWrapperCreationOptions);
  54886. /**
  54887. * Disposes of the effect wrapper
  54888. */
  54889. dispose(): void;
  54890. }
  54891. }
  54892. declare module BABYLON {
  54893. /**
  54894. * Helper class to push actions to a pool of workers.
  54895. */
  54896. export class WorkerPool implements IDisposable {
  54897. private _workerInfos;
  54898. private _pendingActions;
  54899. /**
  54900. * Constructor
  54901. * @param workers Array of workers to use for actions
  54902. */
  54903. constructor(workers: Array<Worker>);
  54904. /**
  54905. * Terminates all workers and clears any pending actions.
  54906. */
  54907. dispose(): void;
  54908. /**
  54909. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54910. * pended until a worker has completed its action.
  54911. * @param action The action to perform. Call onComplete when the action is complete.
  54912. */
  54913. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54914. private _execute;
  54915. }
  54916. }
  54917. declare module BABYLON {
  54918. /**
  54919. * Configuration for Draco compression
  54920. */
  54921. export interface IDracoCompressionConfiguration {
  54922. /**
  54923. * Configuration for the decoder.
  54924. */
  54925. decoder: {
  54926. /**
  54927. * The url to the WebAssembly module.
  54928. */
  54929. wasmUrl?: string;
  54930. /**
  54931. * The url to the WebAssembly binary.
  54932. */
  54933. wasmBinaryUrl?: string;
  54934. /**
  54935. * The url to the fallback JavaScript module.
  54936. */
  54937. fallbackUrl?: string;
  54938. };
  54939. }
  54940. /**
  54941. * Draco compression (https://google.github.io/draco/)
  54942. *
  54943. * This class wraps the Draco module.
  54944. *
  54945. * **Encoder**
  54946. *
  54947. * The encoder is not currently implemented.
  54948. *
  54949. * **Decoder**
  54950. *
  54951. * 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.
  54952. *
  54953. * To update the configuration, use the following code:
  54954. * ```javascript
  54955. * DracoCompression.Configuration = {
  54956. * decoder: {
  54957. * wasmUrl: "<url to the WebAssembly library>",
  54958. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54959. * fallbackUrl: "<url to the fallback JavaScript library>",
  54960. * }
  54961. * };
  54962. * ```
  54963. *
  54964. * 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.
  54965. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54966. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54967. *
  54968. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54969. * ```javascript
  54970. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54971. * ```
  54972. *
  54973. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54974. */
  54975. export class DracoCompression implements IDisposable {
  54976. private _workerPoolPromise?;
  54977. private _decoderModulePromise?;
  54978. /**
  54979. * The configuration. Defaults to the following urls:
  54980. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54981. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54982. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54983. */
  54984. static Configuration: IDracoCompressionConfiguration;
  54985. /**
  54986. * Returns true if the decoder configuration is available.
  54987. */
  54988. static readonly DecoderAvailable: boolean;
  54989. /**
  54990. * Default number of workers to create when creating the draco compression object.
  54991. */
  54992. static DefaultNumWorkers: number;
  54993. private static GetDefaultNumWorkers;
  54994. private static _Default;
  54995. /**
  54996. * Default instance for the draco compression object.
  54997. */
  54998. static readonly Default: DracoCompression;
  54999. /**
  55000. * Constructor
  55001. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55002. */
  55003. constructor(numWorkers?: number);
  55004. /**
  55005. * Stop all async operations and release resources.
  55006. */
  55007. dispose(): void;
  55008. /**
  55009. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55010. * @returns a promise that resolves when ready
  55011. */
  55012. whenReadyAsync(): Promise<void>;
  55013. /**
  55014. * Decode Draco compressed mesh data to vertex data.
  55015. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55016. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55017. * @returns A promise that resolves with the decoded vertex data
  55018. */
  55019. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55020. [kind: string]: number;
  55021. }): Promise<VertexData>;
  55022. }
  55023. }
  55024. declare module BABYLON {
  55025. /**
  55026. * Class for building Constructive Solid Geometry
  55027. */
  55028. export class CSG {
  55029. private polygons;
  55030. /**
  55031. * The world matrix
  55032. */
  55033. matrix: Matrix;
  55034. /**
  55035. * Stores the position
  55036. */
  55037. position: Vector3;
  55038. /**
  55039. * Stores the rotation
  55040. */
  55041. rotation: Vector3;
  55042. /**
  55043. * Stores the rotation quaternion
  55044. */
  55045. rotationQuaternion: Nullable<Quaternion>;
  55046. /**
  55047. * Stores the scaling vector
  55048. */
  55049. scaling: Vector3;
  55050. /**
  55051. * Convert the Mesh to CSG
  55052. * @param mesh The Mesh to convert to CSG
  55053. * @returns A new CSG from the Mesh
  55054. */
  55055. static FromMesh(mesh: Mesh): CSG;
  55056. /**
  55057. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55058. * @param polygons Polygons used to construct a CSG solid
  55059. */
  55060. private static FromPolygons;
  55061. /**
  55062. * Clones, or makes a deep copy, of the CSG
  55063. * @returns A new CSG
  55064. */
  55065. clone(): CSG;
  55066. /**
  55067. * Unions this CSG with another CSG
  55068. * @param csg The CSG to union against this CSG
  55069. * @returns The unioned CSG
  55070. */
  55071. union(csg: CSG): CSG;
  55072. /**
  55073. * Unions this CSG with another CSG in place
  55074. * @param csg The CSG to union against this CSG
  55075. */
  55076. unionInPlace(csg: CSG): void;
  55077. /**
  55078. * Subtracts this CSG with another CSG
  55079. * @param csg The CSG to subtract against this CSG
  55080. * @returns A new CSG
  55081. */
  55082. subtract(csg: CSG): CSG;
  55083. /**
  55084. * Subtracts this CSG with another CSG in place
  55085. * @param csg The CSG to subtact against this CSG
  55086. */
  55087. subtractInPlace(csg: CSG): void;
  55088. /**
  55089. * Intersect this CSG with another CSG
  55090. * @param csg The CSG to intersect against this CSG
  55091. * @returns A new CSG
  55092. */
  55093. intersect(csg: CSG): CSG;
  55094. /**
  55095. * Intersects this CSG with another CSG in place
  55096. * @param csg The CSG to intersect against this CSG
  55097. */
  55098. intersectInPlace(csg: CSG): void;
  55099. /**
  55100. * Return a new CSG solid with solid and empty space switched. This solid is
  55101. * not modified.
  55102. * @returns A new CSG solid with solid and empty space switched
  55103. */
  55104. inverse(): CSG;
  55105. /**
  55106. * Inverses the CSG in place
  55107. */
  55108. inverseInPlace(): void;
  55109. /**
  55110. * This is used to keep meshes transformations so they can be restored
  55111. * when we build back a Babylon Mesh
  55112. * NB : All CSG operations are performed in world coordinates
  55113. * @param csg The CSG to copy the transform attributes from
  55114. * @returns This CSG
  55115. */
  55116. copyTransformAttributes(csg: CSG): CSG;
  55117. /**
  55118. * Build Raw mesh from CSG
  55119. * Coordinates here are in world space
  55120. * @param name The name of the mesh geometry
  55121. * @param scene The Scene
  55122. * @param keepSubMeshes Specifies if the submeshes should be kept
  55123. * @returns A new Mesh
  55124. */
  55125. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55126. /**
  55127. * Build Mesh from CSG taking material and transforms into account
  55128. * @param name The name of the Mesh
  55129. * @param material The material of the Mesh
  55130. * @param scene The Scene
  55131. * @param keepSubMeshes Specifies if submeshes should be kept
  55132. * @returns The new Mesh
  55133. */
  55134. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55135. }
  55136. }
  55137. declare module BABYLON {
  55138. /**
  55139. * Class used to create a trail following a mesh
  55140. */
  55141. export class TrailMesh extends Mesh {
  55142. private _generator;
  55143. private _autoStart;
  55144. private _running;
  55145. private _diameter;
  55146. private _length;
  55147. private _sectionPolygonPointsCount;
  55148. private _sectionVectors;
  55149. private _sectionNormalVectors;
  55150. private _beforeRenderObserver;
  55151. /**
  55152. * @constructor
  55153. * @param name The value used by scene.getMeshByName() to do a lookup.
  55154. * @param generator The mesh to generate a trail.
  55155. * @param scene The scene to add this mesh to.
  55156. * @param diameter Diameter of trailing mesh. Default is 1.
  55157. * @param length Length of trailing mesh. Default is 60.
  55158. * @param autoStart Automatically start trailing mesh. Default true.
  55159. */
  55160. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55161. /**
  55162. * "TrailMesh"
  55163. * @returns "TrailMesh"
  55164. */
  55165. getClassName(): string;
  55166. private _createMesh;
  55167. /**
  55168. * Start trailing mesh.
  55169. */
  55170. start(): void;
  55171. /**
  55172. * Stop trailing mesh.
  55173. */
  55174. stop(): void;
  55175. /**
  55176. * Update trailing mesh geometry.
  55177. */
  55178. update(): void;
  55179. /**
  55180. * Returns a new TrailMesh object.
  55181. * @param name is a string, the name given to the new mesh
  55182. * @param newGenerator use new generator object for cloned trail mesh
  55183. * @returns a new mesh
  55184. */
  55185. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55186. /**
  55187. * Serializes this trail mesh
  55188. * @param serializationObject object to write serialization to
  55189. */
  55190. serialize(serializationObject: any): void;
  55191. /**
  55192. * Parses a serialized trail mesh
  55193. * @param parsedMesh the serialized mesh
  55194. * @param scene the scene to create the trail mesh in
  55195. * @returns the created trail mesh
  55196. */
  55197. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55198. }
  55199. }
  55200. declare module BABYLON {
  55201. /**
  55202. * Class containing static functions to help procedurally build meshes
  55203. */
  55204. export class TiledBoxBuilder {
  55205. /**
  55206. * Creates a box mesh
  55207. * 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)
  55208. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55210. * * 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
  55211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55212. * @param name defines the name of the mesh
  55213. * @param options defines the options used to create the mesh
  55214. * @param scene defines the hosting scene
  55215. * @returns the box mesh
  55216. */
  55217. static CreateTiledBox(name: string, options: {
  55218. pattern?: number;
  55219. width?: number;
  55220. height?: number;
  55221. depth?: number;
  55222. tileSize?: number;
  55223. tileWidth?: number;
  55224. tileHeight?: number;
  55225. alignHorizontal?: number;
  55226. alignVertical?: number;
  55227. faceUV?: Vector4[];
  55228. faceColors?: Color4[];
  55229. sideOrientation?: number;
  55230. updatable?: boolean;
  55231. }, scene?: Nullable<Scene>): Mesh;
  55232. }
  55233. }
  55234. declare module BABYLON {
  55235. /**
  55236. * Class containing static functions to help procedurally build meshes
  55237. */
  55238. export class TorusKnotBuilder {
  55239. /**
  55240. * Creates a torus knot mesh
  55241. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55242. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55243. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55244. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55246. * * 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
  55247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55248. * @param name defines the name of the mesh
  55249. * @param options defines the options used to create the mesh
  55250. * @param scene defines the hosting scene
  55251. * @returns the torus knot mesh
  55252. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55253. */
  55254. static CreateTorusKnot(name: string, options: {
  55255. radius?: number;
  55256. tube?: number;
  55257. radialSegments?: number;
  55258. tubularSegments?: number;
  55259. p?: number;
  55260. q?: number;
  55261. updatable?: boolean;
  55262. sideOrientation?: number;
  55263. frontUVs?: Vector4;
  55264. backUVs?: Vector4;
  55265. }, scene: any): Mesh;
  55266. }
  55267. }
  55268. declare module BABYLON {
  55269. /**
  55270. * Polygon
  55271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55272. */
  55273. export class Polygon {
  55274. /**
  55275. * Creates a rectangle
  55276. * @param xmin bottom X coord
  55277. * @param ymin bottom Y coord
  55278. * @param xmax top X coord
  55279. * @param ymax top Y coord
  55280. * @returns points that make the resulting rectation
  55281. */
  55282. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55283. /**
  55284. * Creates a circle
  55285. * @param radius radius of circle
  55286. * @param cx scale in x
  55287. * @param cy scale in y
  55288. * @param numberOfSides number of sides that make up the circle
  55289. * @returns points that make the resulting circle
  55290. */
  55291. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55292. /**
  55293. * Creates a polygon from input string
  55294. * @param input Input polygon data
  55295. * @returns the parsed points
  55296. */
  55297. static Parse(input: string): Vector2[];
  55298. /**
  55299. * Starts building a polygon from x and y coordinates
  55300. * @param x x coordinate
  55301. * @param y y coordinate
  55302. * @returns the started path2
  55303. */
  55304. static StartingAt(x: number, y: number): Path2;
  55305. }
  55306. /**
  55307. * Builds a polygon
  55308. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55309. */
  55310. export class PolygonMeshBuilder {
  55311. private _points;
  55312. private _outlinepoints;
  55313. private _holes;
  55314. private _name;
  55315. private _scene;
  55316. private _epoints;
  55317. private _eholes;
  55318. private _addToepoint;
  55319. /**
  55320. * Babylon reference to the earcut plugin.
  55321. */
  55322. bjsEarcut: any;
  55323. /**
  55324. * Creates a PolygonMeshBuilder
  55325. * @param name name of the builder
  55326. * @param contours Path of the polygon
  55327. * @param scene scene to add to when creating the mesh
  55328. * @param earcutInjection can be used to inject your own earcut reference
  55329. */
  55330. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55331. /**
  55332. * Adds a whole within the polygon
  55333. * @param hole Array of points defining the hole
  55334. * @returns this
  55335. */
  55336. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55337. /**
  55338. * Creates the polygon
  55339. * @param updatable If the mesh should be updatable
  55340. * @param depth The depth of the mesh created
  55341. * @returns the created mesh
  55342. */
  55343. build(updatable?: boolean, depth?: number): Mesh;
  55344. /**
  55345. * Creates the polygon
  55346. * @param depth The depth of the mesh created
  55347. * @returns the created VertexData
  55348. */
  55349. buildVertexData(depth?: number): VertexData;
  55350. /**
  55351. * Adds a side to the polygon
  55352. * @param positions points that make the polygon
  55353. * @param normals normals of the polygon
  55354. * @param uvs uvs of the polygon
  55355. * @param indices indices of the polygon
  55356. * @param bounds bounds of the polygon
  55357. * @param points points of the polygon
  55358. * @param depth depth of the polygon
  55359. * @param flip flip of the polygon
  55360. */
  55361. private addSide;
  55362. }
  55363. }
  55364. declare module BABYLON {
  55365. /**
  55366. * Class containing static functions to help procedurally build meshes
  55367. */
  55368. export class PolygonBuilder {
  55369. /**
  55370. * Creates a polygon mesh
  55371. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55372. * * 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
  55373. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55375. * * 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)
  55376. * * Remember you can only change the shape positions, not their number when updating a polygon
  55377. * @param name defines the name of the mesh
  55378. * @param options defines the options used to create the mesh
  55379. * @param scene defines the hosting scene
  55380. * @param earcutInjection can be used to inject your own earcut reference
  55381. * @returns the polygon mesh
  55382. */
  55383. static CreatePolygon(name: string, options: {
  55384. shape: Vector3[];
  55385. holes?: Vector3[][];
  55386. depth?: number;
  55387. faceUV?: Vector4[];
  55388. faceColors?: Color4[];
  55389. updatable?: boolean;
  55390. sideOrientation?: number;
  55391. frontUVs?: Vector4;
  55392. backUVs?: Vector4;
  55393. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55394. /**
  55395. * Creates an extruded polygon mesh, with depth in the Y direction.
  55396. * * 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)
  55397. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55398. * @param name defines the name of the mesh
  55399. * @param options defines the options used to create the mesh
  55400. * @param scene defines the hosting scene
  55401. * @param earcutInjection can be used to inject your own earcut reference
  55402. * @returns the polygon mesh
  55403. */
  55404. static ExtrudePolygon(name: string, options: {
  55405. shape: Vector3[];
  55406. holes?: Vector3[][];
  55407. depth?: number;
  55408. faceUV?: Vector4[];
  55409. faceColors?: Color4[];
  55410. updatable?: boolean;
  55411. sideOrientation?: number;
  55412. frontUVs?: Vector4;
  55413. backUVs?: Vector4;
  55414. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55415. }
  55416. }
  55417. declare module BABYLON {
  55418. /**
  55419. * Class containing static functions to help procedurally build meshes
  55420. */
  55421. export class LatheBuilder {
  55422. /**
  55423. * Creates lathe mesh.
  55424. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55425. * * 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
  55426. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55427. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55428. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55429. * * 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
  55430. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55431. * * 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
  55432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55433. * * 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
  55434. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55436. * @param name defines the name of the mesh
  55437. * @param options defines the options used to create the mesh
  55438. * @param scene defines the hosting scene
  55439. * @returns the lathe mesh
  55440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55441. */
  55442. static CreateLathe(name: string, options: {
  55443. shape: Vector3[];
  55444. radius?: number;
  55445. tessellation?: number;
  55446. clip?: number;
  55447. arc?: number;
  55448. closed?: boolean;
  55449. updatable?: boolean;
  55450. sideOrientation?: number;
  55451. frontUVs?: Vector4;
  55452. backUVs?: Vector4;
  55453. cap?: number;
  55454. invertUV?: boolean;
  55455. }, scene?: Nullable<Scene>): Mesh;
  55456. }
  55457. }
  55458. declare module BABYLON {
  55459. /**
  55460. * Class containing static functions to help procedurally build meshes
  55461. */
  55462. export class TiledPlaneBuilder {
  55463. /**
  55464. * Creates a tiled plane mesh
  55465. * * The parameter `pattern` will, depending on value, do nothing or
  55466. * * * flip (reflect about central vertical) alternate tiles across and up
  55467. * * * flip every tile on alternate rows
  55468. * * * rotate (180 degs) alternate tiles across and up
  55469. * * * rotate every tile on alternate rows
  55470. * * * flip and rotate alternate tiles across and up
  55471. * * * flip and rotate every tile on alternate rows
  55472. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55473. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55474. * * 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
  55475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55476. * * 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)
  55477. * * 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)
  55478. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55479. * @param name defines the name of the mesh
  55480. * @param options defines the options used to create the mesh
  55481. * @param scene defines the hosting scene
  55482. * @returns the box mesh
  55483. */
  55484. static CreateTiledPlane(name: string, options: {
  55485. pattern?: number;
  55486. tileSize?: number;
  55487. tileWidth?: number;
  55488. tileHeight?: number;
  55489. size?: number;
  55490. width?: number;
  55491. height?: number;
  55492. alignHorizontal?: number;
  55493. alignVertical?: number;
  55494. sideOrientation?: number;
  55495. frontUVs?: Vector4;
  55496. backUVs?: Vector4;
  55497. updatable?: boolean;
  55498. }, scene?: Nullable<Scene>): Mesh;
  55499. }
  55500. }
  55501. declare module BABYLON {
  55502. /**
  55503. * Class containing static functions to help procedurally build meshes
  55504. */
  55505. export class TubeBuilder {
  55506. /**
  55507. * Creates a tube mesh.
  55508. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55509. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55510. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55511. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55512. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55513. * * 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)
  55514. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55515. * * 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
  55516. * * 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
  55517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55518. * * 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
  55519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55521. * @param name defines the name of the mesh
  55522. * @param options defines the options used to create the mesh
  55523. * @param scene defines the hosting scene
  55524. * @returns the tube mesh
  55525. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55526. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55527. */
  55528. static CreateTube(name: string, options: {
  55529. path: Vector3[];
  55530. radius?: number;
  55531. tessellation?: number;
  55532. radiusFunction?: {
  55533. (i: number, distance: number): number;
  55534. };
  55535. cap?: number;
  55536. arc?: number;
  55537. updatable?: boolean;
  55538. sideOrientation?: number;
  55539. frontUVs?: Vector4;
  55540. backUVs?: Vector4;
  55541. instance?: Mesh;
  55542. invertUV?: boolean;
  55543. }, scene?: Nullable<Scene>): Mesh;
  55544. }
  55545. }
  55546. declare module BABYLON {
  55547. /**
  55548. * Class containing static functions to help procedurally build meshes
  55549. */
  55550. export class IcoSphereBuilder {
  55551. /**
  55552. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55553. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55554. * * 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`)
  55555. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55556. * * 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
  55557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55558. * * 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
  55559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55560. * @param name defines the name of the mesh
  55561. * @param options defines the options used to create the mesh
  55562. * @param scene defines the hosting scene
  55563. * @returns the icosahedron mesh
  55564. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55565. */
  55566. static CreateIcoSphere(name: string, options: {
  55567. radius?: number;
  55568. radiusX?: number;
  55569. radiusY?: number;
  55570. radiusZ?: number;
  55571. flat?: boolean;
  55572. subdivisions?: number;
  55573. sideOrientation?: number;
  55574. frontUVs?: Vector4;
  55575. backUVs?: Vector4;
  55576. updatable?: boolean;
  55577. }, scene?: Nullable<Scene>): Mesh;
  55578. }
  55579. }
  55580. declare module BABYLON {
  55581. /**
  55582. * Class containing static functions to help procedurally build meshes
  55583. */
  55584. export class DecalBuilder {
  55585. /**
  55586. * Creates a decal mesh.
  55587. * 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
  55588. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55589. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55590. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55591. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55592. * @param name defines the name of the mesh
  55593. * @param sourceMesh defines the mesh where the decal must be applied
  55594. * @param options defines the options used to create the mesh
  55595. * @param scene defines the hosting scene
  55596. * @returns the decal mesh
  55597. * @see https://doc.babylonjs.com/how_to/decals
  55598. */
  55599. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55600. position?: Vector3;
  55601. normal?: Vector3;
  55602. size?: Vector3;
  55603. angle?: number;
  55604. }): Mesh;
  55605. }
  55606. }
  55607. declare module BABYLON {
  55608. /**
  55609. * Class containing static functions to help procedurally build meshes
  55610. */
  55611. export class MeshBuilder {
  55612. /**
  55613. * Creates a box mesh
  55614. * * The parameter `size` sets the size (float) of each box side (default 1)
  55615. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55616. * * 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)
  55617. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55621. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55622. * @param name defines the name of the mesh
  55623. * @param options defines the options used to create the mesh
  55624. * @param scene defines the hosting scene
  55625. * @returns the box mesh
  55626. */
  55627. static CreateBox(name: string, options: {
  55628. size?: number;
  55629. width?: number;
  55630. height?: number;
  55631. depth?: number;
  55632. faceUV?: Vector4[];
  55633. faceColors?: Color4[];
  55634. sideOrientation?: number;
  55635. frontUVs?: Vector4;
  55636. backUVs?: Vector4;
  55637. updatable?: boolean;
  55638. }, scene?: Nullable<Scene>): Mesh;
  55639. /**
  55640. * Creates a tiled box mesh
  55641. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55643. * @param name defines the name of the mesh
  55644. * @param options defines the options used to create the mesh
  55645. * @param scene defines the hosting scene
  55646. * @returns the tiled box mesh
  55647. */
  55648. static CreateTiledBox(name: string, options: {
  55649. pattern?: number;
  55650. size?: number;
  55651. width?: number;
  55652. height?: number;
  55653. depth: number;
  55654. tileSize?: number;
  55655. tileWidth?: number;
  55656. tileHeight?: number;
  55657. faceUV?: Vector4[];
  55658. faceColors?: Color4[];
  55659. alignHorizontal?: number;
  55660. alignVertical?: number;
  55661. sideOrientation?: number;
  55662. updatable?: boolean;
  55663. }, scene?: Nullable<Scene>): Mesh;
  55664. /**
  55665. * Creates a sphere mesh
  55666. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55667. * * 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`)
  55668. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55669. * * 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
  55670. * * 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)
  55671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55672. * * 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
  55673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55674. * @param name defines the name of the mesh
  55675. * @param options defines the options used to create the mesh
  55676. * @param scene defines the hosting scene
  55677. * @returns the sphere mesh
  55678. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55679. */
  55680. static CreateSphere(name: string, options: {
  55681. segments?: number;
  55682. diameter?: number;
  55683. diameterX?: number;
  55684. diameterY?: number;
  55685. diameterZ?: number;
  55686. arc?: number;
  55687. slice?: number;
  55688. sideOrientation?: number;
  55689. frontUVs?: Vector4;
  55690. backUVs?: Vector4;
  55691. updatable?: boolean;
  55692. }, scene?: Nullable<Scene>): Mesh;
  55693. /**
  55694. * Creates a plane polygonal mesh. By default, this is a disc
  55695. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55696. * * 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
  55697. * * 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
  55698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55699. * * 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
  55700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55701. * @param name defines the name of the mesh
  55702. * @param options defines the options used to create the mesh
  55703. * @param scene defines the hosting scene
  55704. * @returns the plane polygonal mesh
  55705. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55706. */
  55707. static CreateDisc(name: string, options: {
  55708. radius?: number;
  55709. tessellation?: number;
  55710. arc?: number;
  55711. updatable?: boolean;
  55712. sideOrientation?: number;
  55713. frontUVs?: Vector4;
  55714. backUVs?: Vector4;
  55715. }, scene?: Nullable<Scene>): Mesh;
  55716. /**
  55717. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55718. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55719. * * 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`)
  55720. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55721. * * 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
  55722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55723. * * 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
  55724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55725. * @param name defines the name of the mesh
  55726. * @param options defines the options used to create the mesh
  55727. * @param scene defines the hosting scene
  55728. * @returns the icosahedron mesh
  55729. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55730. */
  55731. static CreateIcoSphere(name: string, options: {
  55732. radius?: number;
  55733. radiusX?: number;
  55734. radiusY?: number;
  55735. radiusZ?: number;
  55736. flat?: boolean;
  55737. subdivisions?: number;
  55738. sideOrientation?: number;
  55739. frontUVs?: Vector4;
  55740. backUVs?: Vector4;
  55741. updatable?: boolean;
  55742. }, scene?: Nullable<Scene>): Mesh;
  55743. /**
  55744. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55745. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55746. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55747. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55748. * * 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
  55749. * * 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
  55750. * * 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
  55751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55752. * * 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
  55753. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55754. * * 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
  55755. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55756. * * 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
  55757. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55759. * @param name defines the name of the mesh
  55760. * @param options defines the options used to create the mesh
  55761. * @param scene defines the hosting scene
  55762. * @returns the ribbon mesh
  55763. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55765. */
  55766. static CreateRibbon(name: string, options: {
  55767. pathArray: Vector3[][];
  55768. closeArray?: boolean;
  55769. closePath?: boolean;
  55770. offset?: number;
  55771. updatable?: boolean;
  55772. sideOrientation?: number;
  55773. frontUVs?: Vector4;
  55774. backUVs?: Vector4;
  55775. instance?: Mesh;
  55776. invertUV?: boolean;
  55777. uvs?: Vector2[];
  55778. colors?: Color4[];
  55779. }, scene?: Nullable<Scene>): Mesh;
  55780. /**
  55781. * Creates a cylinder or a cone mesh
  55782. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55783. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55784. * * 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.
  55785. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55786. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55787. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55788. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55789. * * 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).
  55790. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55791. * * 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).
  55792. * * 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
  55793. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55794. * * 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
  55795. * * 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.
  55796. * * If `enclose` is false, a ring surface is one element.
  55797. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55798. * * 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
  55799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55800. * * 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
  55801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55802. * @param name defines the name of the mesh
  55803. * @param options defines the options used to create the mesh
  55804. * @param scene defines the hosting scene
  55805. * @returns the cylinder mesh
  55806. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55807. */
  55808. static CreateCylinder(name: string, options: {
  55809. height?: number;
  55810. diameterTop?: number;
  55811. diameterBottom?: number;
  55812. diameter?: number;
  55813. tessellation?: number;
  55814. subdivisions?: number;
  55815. arc?: number;
  55816. faceColors?: Color4[];
  55817. faceUV?: Vector4[];
  55818. updatable?: boolean;
  55819. hasRings?: boolean;
  55820. enclose?: boolean;
  55821. cap?: number;
  55822. sideOrientation?: number;
  55823. frontUVs?: Vector4;
  55824. backUVs?: Vector4;
  55825. }, scene?: Nullable<Scene>): Mesh;
  55826. /**
  55827. * Creates a torus mesh
  55828. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55829. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55830. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55832. * * 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
  55833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55834. * @param name defines the name of the mesh
  55835. * @param options defines the options used to create the mesh
  55836. * @param scene defines the hosting scene
  55837. * @returns the torus mesh
  55838. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55839. */
  55840. static CreateTorus(name: string, options: {
  55841. diameter?: number;
  55842. thickness?: number;
  55843. tessellation?: number;
  55844. updatable?: boolean;
  55845. sideOrientation?: number;
  55846. frontUVs?: Vector4;
  55847. backUVs?: Vector4;
  55848. }, scene?: Nullable<Scene>): Mesh;
  55849. /**
  55850. * Creates a torus knot mesh
  55851. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55852. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55853. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55854. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55856. * * 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
  55857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55858. * @param name defines the name of the mesh
  55859. * @param options defines the options used to create the mesh
  55860. * @param scene defines the hosting scene
  55861. * @returns the torus knot mesh
  55862. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55863. */
  55864. static CreateTorusKnot(name: string, options: {
  55865. radius?: number;
  55866. tube?: number;
  55867. radialSegments?: number;
  55868. tubularSegments?: number;
  55869. p?: number;
  55870. q?: number;
  55871. updatable?: boolean;
  55872. sideOrientation?: number;
  55873. frontUVs?: Vector4;
  55874. backUVs?: Vector4;
  55875. }, scene?: Nullable<Scene>): Mesh;
  55876. /**
  55877. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55878. * * 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
  55879. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55880. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55881. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55882. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55883. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55884. * * 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
  55885. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55888. * @param name defines the name of the new line system
  55889. * @param options defines the options used to create the line system
  55890. * @param scene defines the hosting scene
  55891. * @returns a new line system mesh
  55892. */
  55893. static CreateLineSystem(name: string, options: {
  55894. lines: Vector3[][];
  55895. updatable?: boolean;
  55896. instance?: Nullable<LinesMesh>;
  55897. colors?: Nullable<Color4[][]>;
  55898. useVertexAlpha?: boolean;
  55899. }, scene: Nullable<Scene>): LinesMesh;
  55900. /**
  55901. * Creates a line mesh
  55902. * 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
  55903. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55904. * * The parameter `points` is an array successive Vector3
  55905. * * 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
  55906. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55907. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55908. * * When updating an instance, remember that only point positions can change, not the number of points
  55909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55911. * @param name defines the name of the new line system
  55912. * @param options defines the options used to create the line system
  55913. * @param scene defines the hosting scene
  55914. * @returns a new line mesh
  55915. */
  55916. static CreateLines(name: string, options: {
  55917. points: Vector3[];
  55918. updatable?: boolean;
  55919. instance?: Nullable<LinesMesh>;
  55920. colors?: Color4[];
  55921. useVertexAlpha?: boolean;
  55922. }, scene?: Nullable<Scene>): LinesMesh;
  55923. /**
  55924. * Creates a dashed line mesh
  55925. * * 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
  55926. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55927. * * The parameter `points` is an array successive Vector3
  55928. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55929. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55930. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55931. * * 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
  55932. * * When updating an instance, remember that only point positions can change, not the number of points
  55933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55934. * @param name defines the name of the mesh
  55935. * @param options defines the options used to create the mesh
  55936. * @param scene defines the hosting scene
  55937. * @returns the dashed line mesh
  55938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55939. */
  55940. static CreateDashedLines(name: string, options: {
  55941. points: Vector3[];
  55942. dashSize?: number;
  55943. gapSize?: number;
  55944. dashNb?: number;
  55945. updatable?: boolean;
  55946. instance?: LinesMesh;
  55947. }, scene?: Nullable<Scene>): LinesMesh;
  55948. /**
  55949. * 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.
  55950. * * 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.
  55951. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55952. * * 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.
  55953. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55954. * * 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
  55955. * * 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
  55956. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55958. * * 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
  55959. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55961. * @param name defines the name of the mesh
  55962. * @param options defines the options used to create the mesh
  55963. * @param scene defines the hosting scene
  55964. * @returns the extruded shape mesh
  55965. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55967. */
  55968. static ExtrudeShape(name: string, options: {
  55969. shape: Vector3[];
  55970. path: Vector3[];
  55971. scale?: number;
  55972. rotation?: number;
  55973. cap?: number;
  55974. updatable?: boolean;
  55975. sideOrientation?: number;
  55976. frontUVs?: Vector4;
  55977. backUVs?: Vector4;
  55978. instance?: Mesh;
  55979. invertUV?: boolean;
  55980. }, scene?: Nullable<Scene>): Mesh;
  55981. /**
  55982. * Creates an custom extruded shape mesh.
  55983. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55984. * * 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.
  55985. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55986. * * 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
  55987. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55988. * * 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
  55989. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55990. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55991. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55992. * * 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
  55993. * * 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
  55994. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55996. * * 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
  55997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55999. * @param name defines the name of the mesh
  56000. * @param options defines the options used to create the mesh
  56001. * @param scene defines the hosting scene
  56002. * @returns the custom extruded shape mesh
  56003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56006. */
  56007. static ExtrudeShapeCustom(name: string, options: {
  56008. shape: Vector3[];
  56009. path: Vector3[];
  56010. scaleFunction?: any;
  56011. rotationFunction?: any;
  56012. ribbonCloseArray?: boolean;
  56013. ribbonClosePath?: boolean;
  56014. cap?: number;
  56015. updatable?: boolean;
  56016. sideOrientation?: number;
  56017. frontUVs?: Vector4;
  56018. backUVs?: Vector4;
  56019. instance?: Mesh;
  56020. invertUV?: boolean;
  56021. }, scene?: Nullable<Scene>): Mesh;
  56022. /**
  56023. * Creates lathe mesh.
  56024. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56025. * * 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
  56026. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56027. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56028. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56029. * * 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
  56030. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56031. * * 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
  56032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56033. * * 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
  56034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56036. * @param name defines the name of the mesh
  56037. * @param options defines the options used to create the mesh
  56038. * @param scene defines the hosting scene
  56039. * @returns the lathe mesh
  56040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56041. */
  56042. static CreateLathe(name: string, options: {
  56043. shape: Vector3[];
  56044. radius?: number;
  56045. tessellation?: number;
  56046. clip?: number;
  56047. arc?: number;
  56048. closed?: boolean;
  56049. updatable?: boolean;
  56050. sideOrientation?: number;
  56051. frontUVs?: Vector4;
  56052. backUVs?: Vector4;
  56053. cap?: number;
  56054. invertUV?: boolean;
  56055. }, scene?: Nullable<Scene>): Mesh;
  56056. /**
  56057. * Creates a tiled plane mesh
  56058. * * You can set a limited pattern arrangement with the tiles
  56059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56060. * * 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
  56061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56062. * @param name defines the name of the mesh
  56063. * @param options defines the options used to create the mesh
  56064. * @param scene defines the hosting scene
  56065. * @returns the plane mesh
  56066. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56067. */
  56068. static CreateTiledPlane(name: string, options: {
  56069. pattern?: number;
  56070. tileSize?: number;
  56071. tileWidth?: number;
  56072. tileHeight?: number;
  56073. size?: number;
  56074. width?: number;
  56075. height?: number;
  56076. alignHorizontal?: number;
  56077. alignVertical?: number;
  56078. sideOrientation?: number;
  56079. frontUVs?: Vector4;
  56080. backUVs?: Vector4;
  56081. updatable?: boolean;
  56082. }, scene?: Nullable<Scene>): Mesh;
  56083. /**
  56084. * Creates a plane mesh
  56085. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56086. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56087. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56089. * * 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
  56090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56091. * @param name defines the name of the mesh
  56092. * @param options defines the options used to create the mesh
  56093. * @param scene defines the hosting scene
  56094. * @returns the plane mesh
  56095. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56096. */
  56097. static CreatePlane(name: string, options: {
  56098. size?: number;
  56099. width?: number;
  56100. height?: number;
  56101. sideOrientation?: number;
  56102. frontUVs?: Vector4;
  56103. backUVs?: Vector4;
  56104. updatable?: boolean;
  56105. sourcePlane?: Plane;
  56106. }, scene?: Nullable<Scene>): Mesh;
  56107. /**
  56108. * Creates a ground mesh
  56109. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56110. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56112. * @param name defines the name of the mesh
  56113. * @param options defines the options used to create the mesh
  56114. * @param scene defines the hosting scene
  56115. * @returns the ground mesh
  56116. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56117. */
  56118. static CreateGround(name: string, options: {
  56119. width?: number;
  56120. height?: number;
  56121. subdivisions?: number;
  56122. subdivisionsX?: number;
  56123. subdivisionsY?: number;
  56124. updatable?: boolean;
  56125. }, scene?: Nullable<Scene>): Mesh;
  56126. /**
  56127. * Creates a tiled ground mesh
  56128. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56129. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56130. * * 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
  56131. * * 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
  56132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56133. * @param name defines the name of the mesh
  56134. * @param options defines the options used to create the mesh
  56135. * @param scene defines the hosting scene
  56136. * @returns the tiled ground mesh
  56137. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56138. */
  56139. static CreateTiledGround(name: string, options: {
  56140. xmin: number;
  56141. zmin: number;
  56142. xmax: number;
  56143. zmax: number;
  56144. subdivisions?: {
  56145. w: number;
  56146. h: number;
  56147. };
  56148. precision?: {
  56149. w: number;
  56150. h: number;
  56151. };
  56152. updatable?: boolean;
  56153. }, scene?: Nullable<Scene>): Mesh;
  56154. /**
  56155. * Creates a ground mesh from a height map
  56156. * * The parameter `url` sets the URL of the height map image resource.
  56157. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56158. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56159. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56160. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56161. * * 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.
  56162. * * 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).
  56163. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56165. * @param name defines the name of the mesh
  56166. * @param url defines the url to the height map
  56167. * @param options defines the options used to create the mesh
  56168. * @param scene defines the hosting scene
  56169. * @returns the ground mesh
  56170. * @see https://doc.babylonjs.com/babylon101/height_map
  56171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56172. */
  56173. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56174. width?: number;
  56175. height?: number;
  56176. subdivisions?: number;
  56177. minHeight?: number;
  56178. maxHeight?: number;
  56179. colorFilter?: Color3;
  56180. alphaFilter?: number;
  56181. updatable?: boolean;
  56182. onReady?: (mesh: GroundMesh) => void;
  56183. }, scene?: Nullable<Scene>): GroundMesh;
  56184. /**
  56185. * Creates a polygon mesh
  56186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56187. * * 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
  56188. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56190. * * 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)
  56191. * * Remember you can only change the shape positions, not their number when updating a polygon
  56192. * @param name defines the name of the mesh
  56193. * @param options defines the options used to create the mesh
  56194. * @param scene defines the hosting scene
  56195. * @param earcutInjection can be used to inject your own earcut reference
  56196. * @returns the polygon mesh
  56197. */
  56198. static CreatePolygon(name: string, options: {
  56199. shape: Vector3[];
  56200. holes?: Vector3[][];
  56201. depth?: number;
  56202. faceUV?: Vector4[];
  56203. faceColors?: Color4[];
  56204. updatable?: boolean;
  56205. sideOrientation?: number;
  56206. frontUVs?: Vector4;
  56207. backUVs?: Vector4;
  56208. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56209. /**
  56210. * Creates an extruded polygon mesh, with depth in the Y direction.
  56211. * * 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)
  56212. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56213. * @param name defines the name of the mesh
  56214. * @param options defines the options used to create the mesh
  56215. * @param scene defines the hosting scene
  56216. * @param earcutInjection can be used to inject your own earcut reference
  56217. * @returns the polygon mesh
  56218. */
  56219. static ExtrudePolygon(name: string, options: {
  56220. shape: Vector3[];
  56221. holes?: Vector3[][];
  56222. depth?: number;
  56223. faceUV?: Vector4[];
  56224. faceColors?: Color4[];
  56225. updatable?: boolean;
  56226. sideOrientation?: number;
  56227. frontUVs?: Vector4;
  56228. backUVs?: Vector4;
  56229. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56230. /**
  56231. * Creates a tube mesh.
  56232. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56233. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56234. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56235. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56236. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56237. * * 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)
  56238. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56239. * * 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
  56240. * * 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
  56241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56242. * * 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
  56243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56245. * @param name defines the name of the mesh
  56246. * @param options defines the options used to create the mesh
  56247. * @param scene defines the hosting scene
  56248. * @returns the tube mesh
  56249. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56250. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56251. */
  56252. static CreateTube(name: string, options: {
  56253. path: Vector3[];
  56254. radius?: number;
  56255. tessellation?: number;
  56256. radiusFunction?: {
  56257. (i: number, distance: number): number;
  56258. };
  56259. cap?: number;
  56260. arc?: number;
  56261. updatable?: boolean;
  56262. sideOrientation?: number;
  56263. frontUVs?: Vector4;
  56264. backUVs?: Vector4;
  56265. instance?: Mesh;
  56266. invertUV?: boolean;
  56267. }, scene?: Nullable<Scene>): Mesh;
  56268. /**
  56269. * Creates a polyhedron mesh
  56270. * * 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
  56271. * * The parameter `size` (positive float, default 1) sets the polygon size
  56272. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56273. * * 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`
  56274. * * 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
  56275. * * 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)`)
  56276. * * 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
  56277. * * 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
  56278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56279. * * 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
  56280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56281. * @param name defines the name of the mesh
  56282. * @param options defines the options used to create the mesh
  56283. * @param scene defines the hosting scene
  56284. * @returns the polyhedron mesh
  56285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56286. */
  56287. static CreatePolyhedron(name: string, options: {
  56288. type?: number;
  56289. size?: number;
  56290. sizeX?: number;
  56291. sizeY?: number;
  56292. sizeZ?: number;
  56293. custom?: any;
  56294. faceUV?: Vector4[];
  56295. faceColors?: Color4[];
  56296. flat?: boolean;
  56297. updatable?: boolean;
  56298. sideOrientation?: number;
  56299. frontUVs?: Vector4;
  56300. backUVs?: Vector4;
  56301. }, scene?: Nullable<Scene>): Mesh;
  56302. /**
  56303. * Creates a decal mesh.
  56304. * 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
  56305. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56306. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56307. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56308. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56309. * @param name defines the name of the mesh
  56310. * @param sourceMesh defines the mesh where the decal must be applied
  56311. * @param options defines the options used to create the mesh
  56312. * @param scene defines the hosting scene
  56313. * @returns the decal mesh
  56314. * @see https://doc.babylonjs.com/how_to/decals
  56315. */
  56316. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56317. position?: Vector3;
  56318. normal?: Vector3;
  56319. size?: Vector3;
  56320. angle?: number;
  56321. }): Mesh;
  56322. }
  56323. }
  56324. declare module BABYLON {
  56325. /**
  56326. * A simplifier interface for future simplification implementations
  56327. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56328. */
  56329. export interface ISimplifier {
  56330. /**
  56331. * Simplification of a given mesh according to the given settings.
  56332. * Since this requires computation, it is assumed that the function runs async.
  56333. * @param settings The settings of the simplification, including quality and distance
  56334. * @param successCallback A callback that will be called after the mesh was simplified.
  56335. * @param errorCallback in case of an error, this callback will be called. optional.
  56336. */
  56337. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56338. }
  56339. /**
  56340. * Expected simplification settings.
  56341. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56342. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56343. */
  56344. export interface ISimplificationSettings {
  56345. /**
  56346. * Gets or sets the expected quality
  56347. */
  56348. quality: number;
  56349. /**
  56350. * Gets or sets the distance when this optimized version should be used
  56351. */
  56352. distance: number;
  56353. /**
  56354. * Gets an already optimized mesh
  56355. */
  56356. optimizeMesh?: boolean;
  56357. }
  56358. /**
  56359. * Class used to specify simplification options
  56360. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56361. */
  56362. export class SimplificationSettings implements ISimplificationSettings {
  56363. /** expected quality */
  56364. quality: number;
  56365. /** distance when this optimized version should be used */
  56366. distance: number;
  56367. /** already optimized mesh */
  56368. optimizeMesh?: boolean | undefined;
  56369. /**
  56370. * Creates a SimplificationSettings
  56371. * @param quality expected quality
  56372. * @param distance distance when this optimized version should be used
  56373. * @param optimizeMesh already optimized mesh
  56374. */
  56375. constructor(
  56376. /** expected quality */
  56377. quality: number,
  56378. /** distance when this optimized version should be used */
  56379. distance: number,
  56380. /** already optimized mesh */
  56381. optimizeMesh?: boolean | undefined);
  56382. }
  56383. /**
  56384. * Interface used to define a simplification task
  56385. */
  56386. export interface ISimplificationTask {
  56387. /**
  56388. * Array of settings
  56389. */
  56390. settings: Array<ISimplificationSettings>;
  56391. /**
  56392. * Simplification type
  56393. */
  56394. simplificationType: SimplificationType;
  56395. /**
  56396. * Mesh to simplify
  56397. */
  56398. mesh: Mesh;
  56399. /**
  56400. * Callback called on success
  56401. */
  56402. successCallback?: () => void;
  56403. /**
  56404. * Defines if parallel processing can be used
  56405. */
  56406. parallelProcessing: boolean;
  56407. }
  56408. /**
  56409. * Queue used to order the simplification tasks
  56410. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56411. */
  56412. export class SimplificationQueue {
  56413. private _simplificationArray;
  56414. /**
  56415. * Gets a boolean indicating that the process is still running
  56416. */
  56417. running: boolean;
  56418. /**
  56419. * Creates a new queue
  56420. */
  56421. constructor();
  56422. /**
  56423. * Adds a new simplification task
  56424. * @param task defines a task to add
  56425. */
  56426. addTask(task: ISimplificationTask): void;
  56427. /**
  56428. * Execute next task
  56429. */
  56430. executeNext(): void;
  56431. /**
  56432. * Execute a simplification task
  56433. * @param task defines the task to run
  56434. */
  56435. runSimplification(task: ISimplificationTask): void;
  56436. private getSimplifier;
  56437. }
  56438. /**
  56439. * The implemented types of simplification
  56440. * At the moment only Quadratic Error Decimation is implemented
  56441. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56442. */
  56443. export enum SimplificationType {
  56444. /** Quadratic error decimation */
  56445. QUADRATIC = 0
  56446. }
  56447. }
  56448. declare module BABYLON {
  56449. interface Scene {
  56450. /** @hidden (Backing field) */
  56451. _simplificationQueue: SimplificationQueue;
  56452. /**
  56453. * Gets or sets the simplification queue attached to the scene
  56454. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56455. */
  56456. simplificationQueue: SimplificationQueue;
  56457. }
  56458. interface Mesh {
  56459. /**
  56460. * Simplify the mesh according to the given array of settings.
  56461. * Function will return immediately and will simplify async
  56462. * @param settings a collection of simplification settings
  56463. * @param parallelProcessing should all levels calculate parallel or one after the other
  56464. * @param simplificationType the type of simplification to run
  56465. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56466. * @returns the current mesh
  56467. */
  56468. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56469. }
  56470. /**
  56471. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56472. * created in a scene
  56473. */
  56474. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56475. /**
  56476. * The component name helpfull to identify the component in the list of scene components.
  56477. */
  56478. readonly name: string;
  56479. /**
  56480. * The scene the component belongs to.
  56481. */
  56482. scene: Scene;
  56483. /**
  56484. * Creates a new instance of the component for the given scene
  56485. * @param scene Defines the scene to register the component in
  56486. */
  56487. constructor(scene: Scene);
  56488. /**
  56489. * Registers the component in a given scene
  56490. */
  56491. register(): void;
  56492. /**
  56493. * Rebuilds the elements related to this component in case of
  56494. * context lost for instance.
  56495. */
  56496. rebuild(): void;
  56497. /**
  56498. * Disposes the component and the associated ressources
  56499. */
  56500. dispose(): void;
  56501. private _beforeCameraUpdate;
  56502. }
  56503. }
  56504. declare module BABYLON {
  56505. /**
  56506. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56507. */
  56508. export interface INavigationEnginePlugin {
  56509. /**
  56510. * plugin name
  56511. */
  56512. name: string;
  56513. /**
  56514. * Creates a navigation mesh
  56515. * @param meshes array of all the geometry used to compute the navigatio mesh
  56516. * @param parameters bunch of parameters used to filter geometry
  56517. */
  56518. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56519. /**
  56520. * Create a navigation mesh debug mesh
  56521. * @param scene is where the mesh will be added
  56522. * @returns debug display mesh
  56523. */
  56524. createDebugNavMesh(scene: Scene): Mesh;
  56525. /**
  56526. * Get a navigation mesh constrained position, closest to the parameter position
  56527. * @param position world position
  56528. * @returns the closest point to position constrained by the navigation mesh
  56529. */
  56530. getClosestPoint(position: Vector3): Vector3;
  56531. /**
  56532. * Get a navigation mesh constrained position, within a particular radius
  56533. * @param position world position
  56534. * @param maxRadius the maximum distance to the constrained world position
  56535. * @returns the closest point to position constrained by the navigation mesh
  56536. */
  56537. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56538. /**
  56539. * Compute the final position from a segment made of destination-position
  56540. * @param position world position
  56541. * @param destination world position
  56542. * @returns the resulting point along the navmesh
  56543. */
  56544. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56545. /**
  56546. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56547. * @param start world position
  56548. * @param end world position
  56549. * @returns array containing world position composing the path
  56550. */
  56551. computePath(start: Vector3, end: Vector3): Vector3[];
  56552. /**
  56553. * If this plugin is supported
  56554. * @returns true if plugin is supported
  56555. */
  56556. isSupported(): boolean;
  56557. /**
  56558. * Create a new Crowd so you can add agents
  56559. * @param maxAgents the maximum agent count in the crowd
  56560. * @param maxAgentRadius the maximum radius an agent can have
  56561. * @param scene to attach the crowd to
  56562. * @returns the crowd you can add agents to
  56563. */
  56564. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56565. /**
  56566. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56567. * The queries will try to find a solution within those bounds
  56568. * default is (1,1,1)
  56569. * @param extent x,y,z value that define the extent around the queries point of reference
  56570. */
  56571. setDefaultQueryExtent(extent: Vector3): void;
  56572. /**
  56573. * Get the Bounding box extent specified by setDefaultQueryExtent
  56574. * @returns the box extent values
  56575. */
  56576. getDefaultQueryExtent(): Vector3;
  56577. /**
  56578. * Release all resources
  56579. */
  56580. dispose(): void;
  56581. }
  56582. /**
  56583. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56584. */
  56585. export interface ICrowd {
  56586. /**
  56587. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56588. * You can attach anything to that node. The node position is updated in the scene update tick.
  56589. * @param pos world position that will be constrained by the navigation mesh
  56590. * @param parameters agent parameters
  56591. * @param transform hooked to the agent that will be update by the scene
  56592. * @returns agent index
  56593. */
  56594. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56595. /**
  56596. * Returns the agent position in world space
  56597. * @param index agent index returned by addAgent
  56598. * @returns world space position
  56599. */
  56600. getAgentPosition(index: number): Vector3;
  56601. /**
  56602. * Gets the agent velocity in world space
  56603. * @param index agent index returned by addAgent
  56604. * @returns world space velocity
  56605. */
  56606. getAgentVelocity(index: number): Vector3;
  56607. /**
  56608. * remove a particular agent previously created
  56609. * @param index agent index returned by addAgent
  56610. */
  56611. removeAgent(index: number): void;
  56612. /**
  56613. * get the list of all agents attached to this crowd
  56614. * @returns list of agent indices
  56615. */
  56616. getAgents(): number[];
  56617. /**
  56618. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56619. * @param deltaTime in seconds
  56620. */
  56621. update(deltaTime: number): void;
  56622. /**
  56623. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56624. * @param index agent index returned by addAgent
  56625. * @param destination targeted world position
  56626. */
  56627. agentGoto(index: number, destination: Vector3): void;
  56628. /**
  56629. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56630. * The queries will try to find a solution within those bounds
  56631. * default is (1,1,1)
  56632. * @param extent x,y,z value that define the extent around the queries point of reference
  56633. */
  56634. setDefaultQueryExtent(extent: Vector3): void;
  56635. /**
  56636. * Get the Bounding box extent specified by setDefaultQueryExtent
  56637. * @returns the box extent values
  56638. */
  56639. getDefaultQueryExtent(): Vector3;
  56640. /**
  56641. * Release all resources
  56642. */
  56643. dispose(): void;
  56644. }
  56645. /**
  56646. * Configures an agent
  56647. */
  56648. export interface IAgentParameters {
  56649. /**
  56650. * Agent radius. [Limit: >= 0]
  56651. */
  56652. radius: number;
  56653. /**
  56654. * Agent height. [Limit: > 0]
  56655. */
  56656. height: number;
  56657. /**
  56658. * Maximum allowed acceleration. [Limit: >= 0]
  56659. */
  56660. maxAcceleration: number;
  56661. /**
  56662. * Maximum allowed speed. [Limit: >= 0]
  56663. */
  56664. maxSpeed: number;
  56665. /**
  56666. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56667. */
  56668. collisionQueryRange: number;
  56669. /**
  56670. * The path visibility optimization range. [Limit: > 0]
  56671. */
  56672. pathOptimizationRange: number;
  56673. /**
  56674. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56675. */
  56676. separationWeight: number;
  56677. }
  56678. /**
  56679. * Configures the navigation mesh creation
  56680. */
  56681. export interface INavMeshParameters {
  56682. /**
  56683. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56684. */
  56685. cs: number;
  56686. /**
  56687. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56688. */
  56689. ch: number;
  56690. /**
  56691. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56692. */
  56693. walkableSlopeAngle: number;
  56694. /**
  56695. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56696. * be considered walkable. [Limit: >= 3] [Units: vx]
  56697. */
  56698. walkableHeight: number;
  56699. /**
  56700. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56701. */
  56702. walkableClimb: number;
  56703. /**
  56704. * The distance to erode/shrink the walkable area of the heightfield away from
  56705. * obstructions. [Limit: >=0] [Units: vx]
  56706. */
  56707. walkableRadius: number;
  56708. /**
  56709. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56710. */
  56711. maxEdgeLen: number;
  56712. /**
  56713. * The maximum distance a simplfied contour's border edges should deviate
  56714. * the original raw contour. [Limit: >=0] [Units: vx]
  56715. */
  56716. maxSimplificationError: number;
  56717. /**
  56718. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56719. */
  56720. minRegionArea: number;
  56721. /**
  56722. * Any regions with a span count smaller than this value will, if possible,
  56723. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56724. */
  56725. mergeRegionArea: number;
  56726. /**
  56727. * The maximum number of vertices allowed for polygons generated during the
  56728. * contour to polygon conversion process. [Limit: >= 3]
  56729. */
  56730. maxVertsPerPoly: number;
  56731. /**
  56732. * Sets the sampling distance to use when generating the detail mesh.
  56733. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56734. */
  56735. detailSampleDist: number;
  56736. /**
  56737. * The maximum distance the detail mesh surface should deviate from heightfield
  56738. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56739. */
  56740. detailSampleMaxError: number;
  56741. }
  56742. }
  56743. declare module BABYLON {
  56744. /**
  56745. * RecastJS navigation plugin
  56746. */
  56747. export class RecastJSPlugin implements INavigationEnginePlugin {
  56748. /**
  56749. * Reference to the Recast library
  56750. */
  56751. bjsRECAST: any;
  56752. /**
  56753. * plugin name
  56754. */
  56755. name: string;
  56756. /**
  56757. * the first navmesh created. We might extend this to support multiple navmeshes
  56758. */
  56759. navMesh: any;
  56760. /**
  56761. * Initializes the recastJS plugin
  56762. * @param recastInjection can be used to inject your own recast reference
  56763. */
  56764. constructor(recastInjection?: any);
  56765. /**
  56766. * Creates a navigation mesh
  56767. * @param meshes array of all the geometry used to compute the navigatio mesh
  56768. * @param parameters bunch of parameters used to filter geometry
  56769. */
  56770. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56771. /**
  56772. * Create a navigation mesh debug mesh
  56773. * @param scene is where the mesh will be added
  56774. * @returns debug display mesh
  56775. */
  56776. createDebugNavMesh(scene: Scene): Mesh;
  56777. /**
  56778. * Get a navigation mesh constrained position, closest to the parameter position
  56779. * @param position world position
  56780. * @returns the closest point to position constrained by the navigation mesh
  56781. */
  56782. getClosestPoint(position: Vector3): Vector3;
  56783. /**
  56784. * Get a navigation mesh constrained position, within a particular radius
  56785. * @param position world position
  56786. * @param maxRadius the maximum distance to the constrained world position
  56787. * @returns the closest point to position constrained by the navigation mesh
  56788. */
  56789. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56790. /**
  56791. * Compute the final position from a segment made of destination-position
  56792. * @param position world position
  56793. * @param destination world position
  56794. * @returns the resulting point along the navmesh
  56795. */
  56796. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56797. /**
  56798. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56799. * @param start world position
  56800. * @param end world position
  56801. * @returns array containing world position composing the path
  56802. */
  56803. computePath(start: Vector3, end: Vector3): Vector3[];
  56804. /**
  56805. * Create a new Crowd so you can add agents
  56806. * @param maxAgents the maximum agent count in the crowd
  56807. * @param maxAgentRadius the maximum radius an agent can have
  56808. * @param scene to attach the crowd to
  56809. * @returns the crowd you can add agents to
  56810. */
  56811. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56812. /**
  56813. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56814. * The queries will try to find a solution within those bounds
  56815. * default is (1,1,1)
  56816. * @param extent x,y,z value that define the extent around the queries point of reference
  56817. */
  56818. setDefaultQueryExtent(extent: Vector3): void;
  56819. /**
  56820. * Get the Bounding box extent specified by setDefaultQueryExtent
  56821. * @returns the box extent values
  56822. */
  56823. getDefaultQueryExtent(): Vector3;
  56824. /**
  56825. * Disposes
  56826. */
  56827. dispose(): void;
  56828. /**
  56829. * If this plugin is supported
  56830. * @returns true if plugin is supported
  56831. */
  56832. isSupported(): boolean;
  56833. }
  56834. /**
  56835. * Recast detour crowd implementation
  56836. */
  56837. export class RecastJSCrowd implements ICrowd {
  56838. /**
  56839. * Recast/detour plugin
  56840. */
  56841. bjsRECASTPlugin: RecastJSPlugin;
  56842. /**
  56843. * Link to the detour crowd
  56844. */
  56845. recastCrowd: any;
  56846. /**
  56847. * One transform per agent
  56848. */
  56849. transforms: TransformNode[];
  56850. /**
  56851. * All agents created
  56852. */
  56853. agents: number[];
  56854. /**
  56855. * Link to the scene is kept to unregister the crowd from the scene
  56856. */
  56857. private _scene;
  56858. /**
  56859. * Observer for crowd updates
  56860. */
  56861. private _onBeforeAnimationsObserver;
  56862. /**
  56863. * Constructor
  56864. * @param plugin recastJS plugin
  56865. * @param maxAgents the maximum agent count in the crowd
  56866. * @param maxAgentRadius the maximum radius an agent can have
  56867. * @param scene to attach the crowd to
  56868. * @returns the crowd you can add agents to
  56869. */
  56870. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56871. /**
  56872. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56873. * You can attach anything to that node. The node position is updated in the scene update tick.
  56874. * @param pos world position that will be constrained by the navigation mesh
  56875. * @param parameters agent parameters
  56876. * @param transform hooked to the agent that will be update by the scene
  56877. * @returns agent index
  56878. */
  56879. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56880. /**
  56881. * Returns the agent position in world space
  56882. * @param index agent index returned by addAgent
  56883. * @returns world space position
  56884. */
  56885. getAgentPosition(index: number): Vector3;
  56886. /**
  56887. * Returns the agent velocity in world space
  56888. * @param index agent index returned by addAgent
  56889. * @returns world space velocity
  56890. */
  56891. getAgentVelocity(index: number): Vector3;
  56892. /**
  56893. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56894. * @param index agent index returned by addAgent
  56895. * @param destination targeted world position
  56896. */
  56897. agentGoto(index: number, destination: Vector3): void;
  56898. /**
  56899. * remove a particular agent previously created
  56900. * @param index agent index returned by addAgent
  56901. */
  56902. removeAgent(index: number): void;
  56903. /**
  56904. * get the list of all agents attached to this crowd
  56905. * @returns list of agent indices
  56906. */
  56907. getAgents(): number[];
  56908. /**
  56909. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56910. * @param deltaTime in seconds
  56911. */
  56912. update(deltaTime: number): void;
  56913. /**
  56914. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56915. * The queries will try to find a solution within those bounds
  56916. * default is (1,1,1)
  56917. * @param extent x,y,z value that define the extent around the queries point of reference
  56918. */
  56919. setDefaultQueryExtent(extent: Vector3): void;
  56920. /**
  56921. * Get the Bounding box extent specified by setDefaultQueryExtent
  56922. * @returns the box extent values
  56923. */
  56924. getDefaultQueryExtent(): Vector3;
  56925. /**
  56926. * Release all resources
  56927. */
  56928. dispose(): void;
  56929. }
  56930. }
  56931. declare module BABYLON {
  56932. /**
  56933. * Class used to enable access to IndexedDB
  56934. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56935. */
  56936. export class Database implements IOfflineProvider {
  56937. private _callbackManifestChecked;
  56938. private _currentSceneUrl;
  56939. private _db;
  56940. private _enableSceneOffline;
  56941. private _enableTexturesOffline;
  56942. private _manifestVersionFound;
  56943. private _mustUpdateRessources;
  56944. private _hasReachedQuota;
  56945. private _isSupported;
  56946. private _idbFactory;
  56947. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56948. private static IsUASupportingBlobStorage;
  56949. /**
  56950. * Gets a boolean indicating if Database storate is enabled (off by default)
  56951. */
  56952. static IDBStorageEnabled: boolean;
  56953. /**
  56954. * Gets a boolean indicating if scene must be saved in the database
  56955. */
  56956. readonly enableSceneOffline: boolean;
  56957. /**
  56958. * Gets a boolean indicating if textures must be saved in the database
  56959. */
  56960. readonly enableTexturesOffline: boolean;
  56961. /**
  56962. * Creates a new Database
  56963. * @param urlToScene defines the url to load the scene
  56964. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56965. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56966. */
  56967. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56968. private static _ParseURL;
  56969. private static _ReturnFullUrlLocation;
  56970. private _checkManifestFile;
  56971. /**
  56972. * Open the database and make it available
  56973. * @param successCallback defines the callback to call on success
  56974. * @param errorCallback defines the callback to call on error
  56975. */
  56976. open(successCallback: () => void, errorCallback: () => void): void;
  56977. /**
  56978. * Loads an image from the database
  56979. * @param url defines the url to load from
  56980. * @param image defines the target DOM image
  56981. */
  56982. loadImage(url: string, image: HTMLImageElement): void;
  56983. private _loadImageFromDBAsync;
  56984. private _saveImageIntoDBAsync;
  56985. private _checkVersionFromDB;
  56986. private _loadVersionFromDBAsync;
  56987. private _saveVersionIntoDBAsync;
  56988. /**
  56989. * Loads a file from database
  56990. * @param url defines the URL to load from
  56991. * @param sceneLoaded defines a callback to call on success
  56992. * @param progressCallBack defines a callback to call when progress changed
  56993. * @param errorCallback defines a callback to call on error
  56994. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56995. */
  56996. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56997. private _loadFileAsync;
  56998. private _saveFileAsync;
  56999. /**
  57000. * Validates if xhr data is correct
  57001. * @param xhr defines the request to validate
  57002. * @param dataType defines the expected data type
  57003. * @returns true if data is correct
  57004. */
  57005. private static _ValidateXHRData;
  57006. }
  57007. }
  57008. declare module BABYLON {
  57009. /** @hidden */
  57010. export var gpuUpdateParticlesPixelShader: {
  57011. name: string;
  57012. shader: string;
  57013. };
  57014. }
  57015. declare module BABYLON {
  57016. /** @hidden */
  57017. export var gpuUpdateParticlesVertexShader: {
  57018. name: string;
  57019. shader: string;
  57020. };
  57021. }
  57022. declare module BABYLON {
  57023. /** @hidden */
  57024. export var clipPlaneFragmentDeclaration2: {
  57025. name: string;
  57026. shader: string;
  57027. };
  57028. }
  57029. declare module BABYLON {
  57030. /** @hidden */
  57031. export var gpuRenderParticlesPixelShader: {
  57032. name: string;
  57033. shader: string;
  57034. };
  57035. }
  57036. declare module BABYLON {
  57037. /** @hidden */
  57038. export var clipPlaneVertexDeclaration2: {
  57039. name: string;
  57040. shader: string;
  57041. };
  57042. }
  57043. declare module BABYLON {
  57044. /** @hidden */
  57045. export var gpuRenderParticlesVertexShader: {
  57046. name: string;
  57047. shader: string;
  57048. };
  57049. }
  57050. declare module BABYLON {
  57051. /**
  57052. * This represents a GPU particle system in Babylon
  57053. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57054. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57055. */
  57056. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57057. /**
  57058. * The layer mask we are rendering the particles through.
  57059. */
  57060. layerMask: number;
  57061. private _capacity;
  57062. private _activeCount;
  57063. private _currentActiveCount;
  57064. private _accumulatedCount;
  57065. private _renderEffect;
  57066. private _updateEffect;
  57067. private _buffer0;
  57068. private _buffer1;
  57069. private _spriteBuffer;
  57070. private _updateVAO;
  57071. private _renderVAO;
  57072. private _targetIndex;
  57073. private _sourceBuffer;
  57074. private _targetBuffer;
  57075. private _engine;
  57076. private _currentRenderId;
  57077. private _started;
  57078. private _stopped;
  57079. private _timeDelta;
  57080. private _randomTexture;
  57081. private _randomTexture2;
  57082. private _attributesStrideSize;
  57083. private _updateEffectOptions;
  57084. private _randomTextureSize;
  57085. private _actualFrame;
  57086. private readonly _rawTextureWidth;
  57087. /**
  57088. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57089. */
  57090. static readonly IsSupported: boolean;
  57091. /**
  57092. * An event triggered when the system is disposed.
  57093. */
  57094. onDisposeObservable: Observable<GPUParticleSystem>;
  57095. /**
  57096. * Gets the maximum number of particles active at the same time.
  57097. * @returns The max number of active particles.
  57098. */
  57099. getCapacity(): number;
  57100. /**
  57101. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57102. * to override the particles.
  57103. */
  57104. forceDepthWrite: boolean;
  57105. /**
  57106. * Gets or set the number of active particles
  57107. */
  57108. activeParticleCount: number;
  57109. private _preWarmDone;
  57110. /**
  57111. * Is this system ready to be used/rendered
  57112. * @return true if the system is ready
  57113. */
  57114. isReady(): boolean;
  57115. /**
  57116. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57117. * @returns True if it has been started, otherwise false.
  57118. */
  57119. isStarted(): boolean;
  57120. /**
  57121. * Starts the particle system and begins to emit
  57122. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57123. */
  57124. start(delay?: number): void;
  57125. /**
  57126. * Stops the particle system.
  57127. */
  57128. stop(): void;
  57129. /**
  57130. * Remove all active particles
  57131. */
  57132. reset(): void;
  57133. /**
  57134. * Returns the string "GPUParticleSystem"
  57135. * @returns a string containing the class name
  57136. */
  57137. getClassName(): string;
  57138. private _colorGradientsTexture;
  57139. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57140. /**
  57141. * Adds a new color gradient
  57142. * @param gradient defines the gradient to use (between 0 and 1)
  57143. * @param color1 defines the color to affect to the specified gradient
  57144. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57145. * @returns the current particle system
  57146. */
  57147. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57148. /**
  57149. * Remove a specific color gradient
  57150. * @param gradient defines the gradient to remove
  57151. * @returns the current particle system
  57152. */
  57153. removeColorGradient(gradient: number): GPUParticleSystem;
  57154. private _angularSpeedGradientsTexture;
  57155. private _sizeGradientsTexture;
  57156. private _velocityGradientsTexture;
  57157. private _limitVelocityGradientsTexture;
  57158. private _dragGradientsTexture;
  57159. private _addFactorGradient;
  57160. /**
  57161. * Adds a new size gradient
  57162. * @param gradient defines the gradient to use (between 0 and 1)
  57163. * @param factor defines the size factor to affect to the specified gradient
  57164. * @returns the current particle system
  57165. */
  57166. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57167. /**
  57168. * Remove a specific size gradient
  57169. * @param gradient defines the gradient to remove
  57170. * @returns the current particle system
  57171. */
  57172. removeSizeGradient(gradient: number): GPUParticleSystem;
  57173. /**
  57174. * Adds a new angular speed gradient
  57175. * @param gradient defines the gradient to use (between 0 and 1)
  57176. * @param factor defines the angular speed to affect to the specified gradient
  57177. * @returns the current particle system
  57178. */
  57179. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57180. /**
  57181. * Remove a specific angular speed gradient
  57182. * @param gradient defines the gradient to remove
  57183. * @returns the current particle system
  57184. */
  57185. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57186. /**
  57187. * Adds a new velocity gradient
  57188. * @param gradient defines the gradient to use (between 0 and 1)
  57189. * @param factor defines the velocity to affect to the specified gradient
  57190. * @returns the current particle system
  57191. */
  57192. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57193. /**
  57194. * Remove a specific velocity gradient
  57195. * @param gradient defines the gradient to remove
  57196. * @returns the current particle system
  57197. */
  57198. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57199. /**
  57200. * Adds a new limit velocity gradient
  57201. * @param gradient defines the gradient to use (between 0 and 1)
  57202. * @param factor defines the limit velocity value to affect to the specified gradient
  57203. * @returns the current particle system
  57204. */
  57205. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57206. /**
  57207. * Remove a specific limit velocity gradient
  57208. * @param gradient defines the gradient to remove
  57209. * @returns the current particle system
  57210. */
  57211. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57212. /**
  57213. * Adds a new drag gradient
  57214. * @param gradient defines the gradient to use (between 0 and 1)
  57215. * @param factor defines the drag value to affect to the specified gradient
  57216. * @returns the current particle system
  57217. */
  57218. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57219. /**
  57220. * Remove a specific drag gradient
  57221. * @param gradient defines the gradient to remove
  57222. * @returns the current particle system
  57223. */
  57224. removeDragGradient(gradient: number): GPUParticleSystem;
  57225. /**
  57226. * Not supported by GPUParticleSystem
  57227. * @param gradient defines the gradient to use (between 0 and 1)
  57228. * @param factor defines the emit rate value to affect to the specified gradient
  57229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57230. * @returns the current particle system
  57231. */
  57232. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57233. /**
  57234. * Not supported by GPUParticleSystem
  57235. * @param gradient defines the gradient to remove
  57236. * @returns the current particle system
  57237. */
  57238. removeEmitRateGradient(gradient: number): IParticleSystem;
  57239. /**
  57240. * Not supported by GPUParticleSystem
  57241. * @param gradient defines the gradient to use (between 0 and 1)
  57242. * @param factor defines the start size value to affect to the specified gradient
  57243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57244. * @returns the current particle system
  57245. */
  57246. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57247. /**
  57248. * Not supported by GPUParticleSystem
  57249. * @param gradient defines the gradient to remove
  57250. * @returns the current particle system
  57251. */
  57252. removeStartSizeGradient(gradient: number): IParticleSystem;
  57253. /**
  57254. * Not supported by GPUParticleSystem
  57255. * @param gradient defines the gradient to use (between 0 and 1)
  57256. * @param min defines the color remap minimal range
  57257. * @param max defines the color remap maximal range
  57258. * @returns the current particle system
  57259. */
  57260. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57261. /**
  57262. * Not supported by GPUParticleSystem
  57263. * @param gradient defines the gradient to remove
  57264. * @returns the current particle system
  57265. */
  57266. removeColorRemapGradient(): IParticleSystem;
  57267. /**
  57268. * Not supported by GPUParticleSystem
  57269. * @param gradient defines the gradient to use (between 0 and 1)
  57270. * @param min defines the alpha remap minimal range
  57271. * @param max defines the alpha remap maximal range
  57272. * @returns the current particle system
  57273. */
  57274. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57275. /**
  57276. * Not supported by GPUParticleSystem
  57277. * @param gradient defines the gradient to remove
  57278. * @returns the current particle system
  57279. */
  57280. removeAlphaRemapGradient(): IParticleSystem;
  57281. /**
  57282. * Not supported by GPUParticleSystem
  57283. * @param gradient defines the gradient to use (between 0 and 1)
  57284. * @param color defines the color to affect to the specified gradient
  57285. * @returns the current particle system
  57286. */
  57287. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57288. /**
  57289. * Not supported by GPUParticleSystem
  57290. * @param gradient defines the gradient to remove
  57291. * @returns the current particle system
  57292. */
  57293. removeRampGradient(): IParticleSystem;
  57294. /**
  57295. * Not supported by GPUParticleSystem
  57296. * @returns the list of ramp gradients
  57297. */
  57298. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57299. /**
  57300. * Not supported by GPUParticleSystem
  57301. * Gets or sets a boolean indicating that ramp gradients must be used
  57302. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57303. */
  57304. useRampGradients: boolean;
  57305. /**
  57306. * Not supported by GPUParticleSystem
  57307. * @param gradient defines the gradient to use (between 0 and 1)
  57308. * @param factor defines the life time factor to affect to the specified gradient
  57309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57310. * @returns the current particle system
  57311. */
  57312. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57313. /**
  57314. * Not supported by GPUParticleSystem
  57315. * @param gradient defines the gradient to remove
  57316. * @returns the current particle system
  57317. */
  57318. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57319. /**
  57320. * Instantiates a GPU particle system.
  57321. * 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.
  57322. * @param name The name of the particle system
  57323. * @param options The options used to create the system
  57324. * @param scene The scene the particle system belongs to
  57325. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57326. */
  57327. constructor(name: string, options: Partial<{
  57328. capacity: number;
  57329. randomTextureSize: number;
  57330. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57331. protected _reset(): void;
  57332. private _createUpdateVAO;
  57333. private _createRenderVAO;
  57334. private _initialize;
  57335. /** @hidden */
  57336. _recreateUpdateEffect(): void;
  57337. /** @hidden */
  57338. _recreateRenderEffect(): void;
  57339. /**
  57340. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57341. * @param preWarm defines if we are in the pre-warmimg phase
  57342. */
  57343. animate(preWarm?: boolean): void;
  57344. private _createFactorGradientTexture;
  57345. private _createSizeGradientTexture;
  57346. private _createAngularSpeedGradientTexture;
  57347. private _createVelocityGradientTexture;
  57348. private _createLimitVelocityGradientTexture;
  57349. private _createDragGradientTexture;
  57350. private _createColorGradientTexture;
  57351. /**
  57352. * Renders the particle system in its current state
  57353. * @param preWarm defines if the system should only update the particles but not render them
  57354. * @returns the current number of particles
  57355. */
  57356. render(preWarm?: boolean): number;
  57357. /**
  57358. * Rebuilds the particle system
  57359. */
  57360. rebuild(): void;
  57361. private _releaseBuffers;
  57362. private _releaseVAOs;
  57363. /**
  57364. * Disposes the particle system and free the associated resources
  57365. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57366. */
  57367. dispose(disposeTexture?: boolean): void;
  57368. /**
  57369. * Clones the particle system.
  57370. * @param name The name of the cloned object
  57371. * @param newEmitter The new emitter to use
  57372. * @returns the cloned particle system
  57373. */
  57374. clone(name: string, newEmitter: any): GPUParticleSystem;
  57375. /**
  57376. * Serializes the particle system to a JSON object.
  57377. * @returns the JSON object
  57378. */
  57379. serialize(): any;
  57380. /**
  57381. * Parses a JSON object to create a GPU particle system.
  57382. * @param parsedParticleSystem The JSON object to parse
  57383. * @param scene The scene to create the particle system in
  57384. * @param rootUrl The root url to use to load external dependencies like texture
  57385. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57386. * @returns the parsed GPU particle system
  57387. */
  57388. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57389. }
  57390. }
  57391. declare module BABYLON {
  57392. /**
  57393. * Represents a set of particle systems working together to create a specific effect
  57394. */
  57395. export class ParticleSystemSet implements IDisposable {
  57396. private _emitterCreationOptions;
  57397. private _emitterNode;
  57398. /**
  57399. * Gets the particle system list
  57400. */
  57401. systems: IParticleSystem[];
  57402. /**
  57403. * Gets the emitter node used with this set
  57404. */
  57405. readonly emitterNode: Nullable<TransformNode>;
  57406. /**
  57407. * Creates a new emitter mesh as a sphere
  57408. * @param options defines the options used to create the sphere
  57409. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57410. * @param scene defines the hosting scene
  57411. */
  57412. setEmitterAsSphere(options: {
  57413. diameter: number;
  57414. segments: number;
  57415. color: Color3;
  57416. }, renderingGroupId: number, scene: Scene): void;
  57417. /**
  57418. * Starts all particle systems of the set
  57419. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57420. */
  57421. start(emitter?: AbstractMesh): void;
  57422. /**
  57423. * Release all associated resources
  57424. */
  57425. dispose(): void;
  57426. /**
  57427. * Serialize the set into a JSON compatible object
  57428. * @returns a JSON compatible representation of the set
  57429. */
  57430. serialize(): any;
  57431. /**
  57432. * Parse a new ParticleSystemSet from a serialized source
  57433. * @param data defines a JSON compatible representation of the set
  57434. * @param scene defines the hosting scene
  57435. * @param gpu defines if we want GPU particles or CPU particles
  57436. * @returns a new ParticleSystemSet
  57437. */
  57438. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57439. }
  57440. }
  57441. declare module BABYLON {
  57442. /**
  57443. * This class is made for on one-liner static method to help creating particle system set.
  57444. */
  57445. export class ParticleHelper {
  57446. /**
  57447. * Gets or sets base Assets URL
  57448. */
  57449. static BaseAssetsUrl: string;
  57450. /**
  57451. * Create a default particle system that you can tweak
  57452. * @param emitter defines the emitter to use
  57453. * @param capacity defines the system capacity (default is 500 particles)
  57454. * @param scene defines the hosting scene
  57455. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57456. * @returns the new Particle system
  57457. */
  57458. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57459. /**
  57460. * This is the main static method (one-liner) of this helper to create different particle systems
  57461. * @param type This string represents the type to the particle system to create
  57462. * @param scene The scene where the particle system should live
  57463. * @param gpu If the system will use gpu
  57464. * @returns the ParticleSystemSet created
  57465. */
  57466. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57467. /**
  57468. * Static function used to export a particle system to a ParticleSystemSet variable.
  57469. * Please note that the emitter shape is not exported
  57470. * @param systems defines the particle systems to export
  57471. * @returns the created particle system set
  57472. */
  57473. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57474. }
  57475. }
  57476. declare module BABYLON {
  57477. interface Engine {
  57478. /**
  57479. * Create an effect to use with particle systems.
  57480. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57481. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57482. * @param uniformsNames defines a list of attribute names
  57483. * @param samplers defines an array of string used to represent textures
  57484. * @param defines defines the string containing the defines to use to compile the shaders
  57485. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57486. * @param onCompiled defines a function to call when the effect creation is successful
  57487. * @param onError defines a function to call when the effect creation has failed
  57488. * @returns the new Effect
  57489. */
  57490. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57491. }
  57492. interface Mesh {
  57493. /**
  57494. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57495. * @returns an array of IParticleSystem
  57496. */
  57497. getEmittedParticleSystems(): IParticleSystem[];
  57498. /**
  57499. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57500. * @returns an array of IParticleSystem
  57501. */
  57502. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57503. }
  57504. /**
  57505. * @hidden
  57506. */
  57507. export var _IDoNeedToBeInTheBuild: number;
  57508. }
  57509. declare module BABYLON {
  57510. interface Scene {
  57511. /** @hidden (Backing field) */
  57512. _physicsEngine: Nullable<IPhysicsEngine>;
  57513. /**
  57514. * Gets the current physics engine
  57515. * @returns a IPhysicsEngine or null if none attached
  57516. */
  57517. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57518. /**
  57519. * Enables physics to the current scene
  57520. * @param gravity defines the scene's gravity for the physics engine
  57521. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57522. * @return a boolean indicating if the physics engine was initialized
  57523. */
  57524. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57525. /**
  57526. * Disables and disposes the physics engine associated with the scene
  57527. */
  57528. disablePhysicsEngine(): void;
  57529. /**
  57530. * Gets a boolean indicating if there is an active physics engine
  57531. * @returns a boolean indicating if there is an active physics engine
  57532. */
  57533. isPhysicsEnabled(): boolean;
  57534. /**
  57535. * Deletes a physics compound impostor
  57536. * @param compound defines the compound to delete
  57537. */
  57538. deleteCompoundImpostor(compound: any): void;
  57539. /**
  57540. * An event triggered when physic simulation is about to be run
  57541. */
  57542. onBeforePhysicsObservable: Observable<Scene>;
  57543. /**
  57544. * An event triggered when physic simulation has been done
  57545. */
  57546. onAfterPhysicsObservable: Observable<Scene>;
  57547. }
  57548. interface AbstractMesh {
  57549. /** @hidden */
  57550. _physicsImpostor: Nullable<PhysicsImpostor>;
  57551. /**
  57552. * Gets or sets impostor used for physic simulation
  57553. * @see http://doc.babylonjs.com/features/physics_engine
  57554. */
  57555. physicsImpostor: Nullable<PhysicsImpostor>;
  57556. /**
  57557. * Gets the current physics impostor
  57558. * @see http://doc.babylonjs.com/features/physics_engine
  57559. * @returns a physics impostor or null
  57560. */
  57561. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57562. /** Apply a physic impulse to the mesh
  57563. * @param force defines the force to apply
  57564. * @param contactPoint defines where to apply the force
  57565. * @returns the current mesh
  57566. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57567. */
  57568. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57569. /**
  57570. * Creates a physic joint between two meshes
  57571. * @param otherMesh defines the other mesh to use
  57572. * @param pivot1 defines the pivot to use on this mesh
  57573. * @param pivot2 defines the pivot to use on the other mesh
  57574. * @param options defines additional options (can be plugin dependent)
  57575. * @returns the current mesh
  57576. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57577. */
  57578. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57579. /** @hidden */
  57580. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57581. }
  57582. /**
  57583. * Defines the physics engine scene component responsible to manage a physics engine
  57584. */
  57585. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57586. /**
  57587. * The component name helpful to identify the component in the list of scene components.
  57588. */
  57589. readonly name: string;
  57590. /**
  57591. * The scene the component belongs to.
  57592. */
  57593. scene: Scene;
  57594. /**
  57595. * Creates a new instance of the component for the given scene
  57596. * @param scene Defines the scene to register the component in
  57597. */
  57598. constructor(scene: Scene);
  57599. /**
  57600. * Registers the component in a given scene
  57601. */
  57602. register(): void;
  57603. /**
  57604. * Rebuilds the elements related to this component in case of
  57605. * context lost for instance.
  57606. */
  57607. rebuild(): void;
  57608. /**
  57609. * Disposes the component and the associated ressources
  57610. */
  57611. dispose(): void;
  57612. }
  57613. }
  57614. declare module BABYLON {
  57615. /**
  57616. * A helper for physics simulations
  57617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57618. */
  57619. export class PhysicsHelper {
  57620. private _scene;
  57621. private _physicsEngine;
  57622. /**
  57623. * Initializes the Physics helper
  57624. * @param scene Babylon.js scene
  57625. */
  57626. constructor(scene: Scene);
  57627. /**
  57628. * Applies a radial explosion impulse
  57629. * @param origin the origin of the explosion
  57630. * @param radiusOrEventOptions the radius or the options of radial explosion
  57631. * @param strength the explosion strength
  57632. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57633. * @returns A physics radial explosion event, or null
  57634. */
  57635. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57636. /**
  57637. * Applies a radial explosion force
  57638. * @param origin the origin of the explosion
  57639. * @param radiusOrEventOptions the radius or the options of radial explosion
  57640. * @param strength the explosion strength
  57641. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57642. * @returns A physics radial explosion event, or null
  57643. */
  57644. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57645. /**
  57646. * Creates a gravitational field
  57647. * @param origin the origin of the explosion
  57648. * @param radiusOrEventOptions the radius or the options of radial explosion
  57649. * @param strength the explosion strength
  57650. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57651. * @returns A physics gravitational field event, or null
  57652. */
  57653. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57654. /**
  57655. * Creates a physics updraft event
  57656. * @param origin the origin of the updraft
  57657. * @param radiusOrEventOptions the radius or the options of the updraft
  57658. * @param strength the strength of the updraft
  57659. * @param height the height of the updraft
  57660. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57661. * @returns A physics updraft event, or null
  57662. */
  57663. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57664. /**
  57665. * Creates a physics vortex event
  57666. * @param origin the of the vortex
  57667. * @param radiusOrEventOptions the radius or the options of the vortex
  57668. * @param strength the strength of the vortex
  57669. * @param height the height of the vortex
  57670. * @returns a Physics vortex event, or null
  57671. * A physics vortex event or null
  57672. */
  57673. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57674. }
  57675. /**
  57676. * Represents a physics radial explosion event
  57677. */
  57678. class PhysicsRadialExplosionEvent {
  57679. private _scene;
  57680. private _options;
  57681. private _sphere;
  57682. private _dataFetched;
  57683. /**
  57684. * Initializes a radial explosioin event
  57685. * @param _scene BabylonJS scene
  57686. * @param _options The options for the vortex event
  57687. */
  57688. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57689. /**
  57690. * Returns the data related to the radial explosion event (sphere).
  57691. * @returns The radial explosion event data
  57692. */
  57693. getData(): PhysicsRadialExplosionEventData;
  57694. /**
  57695. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57696. * @param impostor A physics imposter
  57697. * @param origin the origin of the explosion
  57698. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57699. */
  57700. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57701. /**
  57702. * Triggers affecterd impostors callbacks
  57703. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57704. */
  57705. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57706. /**
  57707. * Disposes the sphere.
  57708. * @param force Specifies if the sphere should be disposed by force
  57709. */
  57710. dispose(force?: boolean): void;
  57711. /*** Helpers ***/
  57712. private _prepareSphere;
  57713. private _intersectsWithSphere;
  57714. }
  57715. /**
  57716. * Represents a gravitational field event
  57717. */
  57718. class PhysicsGravitationalFieldEvent {
  57719. private _physicsHelper;
  57720. private _scene;
  57721. private _origin;
  57722. private _options;
  57723. private _tickCallback;
  57724. private _sphere;
  57725. private _dataFetched;
  57726. /**
  57727. * Initializes the physics gravitational field event
  57728. * @param _physicsHelper A physics helper
  57729. * @param _scene BabylonJS scene
  57730. * @param _origin The origin position of the gravitational field event
  57731. * @param _options The options for the vortex event
  57732. */
  57733. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57734. /**
  57735. * Returns the data related to the gravitational field event (sphere).
  57736. * @returns A gravitational field event
  57737. */
  57738. getData(): PhysicsGravitationalFieldEventData;
  57739. /**
  57740. * Enables the gravitational field.
  57741. */
  57742. enable(): void;
  57743. /**
  57744. * Disables the gravitational field.
  57745. */
  57746. disable(): void;
  57747. /**
  57748. * Disposes the sphere.
  57749. * @param force The force to dispose from the gravitational field event
  57750. */
  57751. dispose(force?: boolean): void;
  57752. private _tick;
  57753. }
  57754. /**
  57755. * Represents a physics updraft event
  57756. */
  57757. class PhysicsUpdraftEvent {
  57758. private _scene;
  57759. private _origin;
  57760. private _options;
  57761. private _physicsEngine;
  57762. private _originTop;
  57763. private _originDirection;
  57764. private _tickCallback;
  57765. private _cylinder;
  57766. private _cylinderPosition;
  57767. private _dataFetched;
  57768. /**
  57769. * Initializes the physics updraft event
  57770. * @param _scene BabylonJS scene
  57771. * @param _origin The origin position of the updraft
  57772. * @param _options The options for the updraft event
  57773. */
  57774. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57775. /**
  57776. * Returns the data related to the updraft event (cylinder).
  57777. * @returns A physics updraft event
  57778. */
  57779. getData(): PhysicsUpdraftEventData;
  57780. /**
  57781. * Enables the updraft.
  57782. */
  57783. enable(): void;
  57784. /**
  57785. * Disables the updraft.
  57786. */
  57787. disable(): void;
  57788. /**
  57789. * Disposes the cylinder.
  57790. * @param force Specifies if the updraft should be disposed by force
  57791. */
  57792. dispose(force?: boolean): void;
  57793. private getImpostorHitData;
  57794. private _tick;
  57795. /*** Helpers ***/
  57796. private _prepareCylinder;
  57797. private _intersectsWithCylinder;
  57798. }
  57799. /**
  57800. * Represents a physics vortex event
  57801. */
  57802. class PhysicsVortexEvent {
  57803. private _scene;
  57804. private _origin;
  57805. private _options;
  57806. private _physicsEngine;
  57807. private _originTop;
  57808. private _tickCallback;
  57809. private _cylinder;
  57810. private _cylinderPosition;
  57811. private _dataFetched;
  57812. /**
  57813. * Initializes the physics vortex event
  57814. * @param _scene The BabylonJS scene
  57815. * @param _origin The origin position of the vortex
  57816. * @param _options The options for the vortex event
  57817. */
  57818. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57819. /**
  57820. * Returns the data related to the vortex event (cylinder).
  57821. * @returns The physics vortex event data
  57822. */
  57823. getData(): PhysicsVortexEventData;
  57824. /**
  57825. * Enables the vortex.
  57826. */
  57827. enable(): void;
  57828. /**
  57829. * Disables the cortex.
  57830. */
  57831. disable(): void;
  57832. /**
  57833. * Disposes the sphere.
  57834. * @param force
  57835. */
  57836. dispose(force?: boolean): void;
  57837. private getImpostorHitData;
  57838. private _tick;
  57839. /*** Helpers ***/
  57840. private _prepareCylinder;
  57841. private _intersectsWithCylinder;
  57842. }
  57843. /**
  57844. * Options fot the radial explosion event
  57845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57846. */
  57847. export class PhysicsRadialExplosionEventOptions {
  57848. /**
  57849. * The radius of the sphere for the radial explosion.
  57850. */
  57851. radius: number;
  57852. /**
  57853. * The strenth of the explosion.
  57854. */
  57855. strength: number;
  57856. /**
  57857. * The strenght of the force in correspondence to the distance of the affected object
  57858. */
  57859. falloff: PhysicsRadialImpulseFalloff;
  57860. /**
  57861. * Sphere options for the radial explosion.
  57862. */
  57863. sphere: {
  57864. segments: number;
  57865. diameter: number;
  57866. };
  57867. /**
  57868. * Sphere options for the radial explosion.
  57869. */
  57870. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57871. }
  57872. /**
  57873. * Options fot the updraft event
  57874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57875. */
  57876. export class PhysicsUpdraftEventOptions {
  57877. /**
  57878. * The radius of the cylinder for the vortex
  57879. */
  57880. radius: number;
  57881. /**
  57882. * The strenth of the updraft.
  57883. */
  57884. strength: number;
  57885. /**
  57886. * The height of the cylinder for the updraft.
  57887. */
  57888. height: number;
  57889. /**
  57890. * The mode for the the updraft.
  57891. */
  57892. updraftMode: PhysicsUpdraftMode;
  57893. }
  57894. /**
  57895. * Options fot the vortex event
  57896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57897. */
  57898. export class PhysicsVortexEventOptions {
  57899. /**
  57900. * The radius of the cylinder for the vortex
  57901. */
  57902. radius: number;
  57903. /**
  57904. * The strenth of the vortex.
  57905. */
  57906. strength: number;
  57907. /**
  57908. * The height of the cylinder for the vortex.
  57909. */
  57910. height: number;
  57911. /**
  57912. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57913. */
  57914. centripetalForceThreshold: number;
  57915. /**
  57916. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57917. */
  57918. centripetalForceMultiplier: number;
  57919. /**
  57920. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57921. */
  57922. centrifugalForceMultiplier: number;
  57923. /**
  57924. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57925. */
  57926. updraftForceMultiplier: number;
  57927. }
  57928. /**
  57929. * The strenght of the force in correspondence to the distance of the affected object
  57930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57931. */
  57932. export enum PhysicsRadialImpulseFalloff {
  57933. /** Defines that impulse is constant in strength across it's whole radius */
  57934. Constant = 0,
  57935. /** Defines that impulse gets weaker if it's further from the origin */
  57936. Linear = 1
  57937. }
  57938. /**
  57939. * The strength of the force in correspondence to the distance of the affected object
  57940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57941. */
  57942. export enum PhysicsUpdraftMode {
  57943. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57944. Center = 0,
  57945. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57946. Perpendicular = 1
  57947. }
  57948. /**
  57949. * Interface for a physics hit data
  57950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57951. */
  57952. export interface PhysicsHitData {
  57953. /**
  57954. * The force applied at the contact point
  57955. */
  57956. force: Vector3;
  57957. /**
  57958. * The contact point
  57959. */
  57960. contactPoint: Vector3;
  57961. /**
  57962. * The distance from the origin to the contact point
  57963. */
  57964. distanceFromOrigin: number;
  57965. }
  57966. /**
  57967. * Interface for radial explosion event data
  57968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57969. */
  57970. export interface PhysicsRadialExplosionEventData {
  57971. /**
  57972. * A sphere used for the radial explosion event
  57973. */
  57974. sphere: Mesh;
  57975. }
  57976. /**
  57977. * Interface for gravitational field event data
  57978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57979. */
  57980. export interface PhysicsGravitationalFieldEventData {
  57981. /**
  57982. * A sphere mesh used for the gravitational field event
  57983. */
  57984. sphere: Mesh;
  57985. }
  57986. /**
  57987. * Interface for updraft event data
  57988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57989. */
  57990. export interface PhysicsUpdraftEventData {
  57991. /**
  57992. * A cylinder used for the updraft event
  57993. */
  57994. cylinder: Mesh;
  57995. }
  57996. /**
  57997. * Interface for vortex event data
  57998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57999. */
  58000. export interface PhysicsVortexEventData {
  58001. /**
  58002. * A cylinder used for the vortex event
  58003. */
  58004. cylinder: Mesh;
  58005. }
  58006. /**
  58007. * Interface for an affected physics impostor
  58008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58009. */
  58010. export interface PhysicsAffectedImpostorWithData {
  58011. /**
  58012. * The impostor affected by the effect
  58013. */
  58014. impostor: PhysicsImpostor;
  58015. /**
  58016. * The data about the hit/horce from the explosion
  58017. */
  58018. hitData: PhysicsHitData;
  58019. }
  58020. }
  58021. declare module BABYLON {
  58022. /** @hidden */
  58023. export var blackAndWhitePixelShader: {
  58024. name: string;
  58025. shader: string;
  58026. };
  58027. }
  58028. declare module BABYLON {
  58029. /**
  58030. * Post process used to render in black and white
  58031. */
  58032. export class BlackAndWhitePostProcess extends PostProcess {
  58033. /**
  58034. * Linear about to convert he result to black and white (default: 1)
  58035. */
  58036. degree: number;
  58037. /**
  58038. * Creates a black and white post process
  58039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58040. * @param name The name of the effect.
  58041. * @param options The required width/height ratio to downsize to before computing the render pass.
  58042. * @param camera The camera to apply the render pass to.
  58043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58044. * @param engine The engine which the post process will be applied. (default: current engine)
  58045. * @param reusable If the post process can be reused on the same frame. (default: false)
  58046. */
  58047. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58048. }
  58049. }
  58050. declare module BABYLON {
  58051. /**
  58052. * This represents a set of one or more post processes in Babylon.
  58053. * A post process can be used to apply a shader to a texture after it is rendered.
  58054. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58055. */
  58056. export class PostProcessRenderEffect {
  58057. private _postProcesses;
  58058. private _getPostProcesses;
  58059. private _singleInstance;
  58060. private _cameras;
  58061. private _indicesForCamera;
  58062. /**
  58063. * Name of the effect
  58064. * @hidden
  58065. */
  58066. _name: string;
  58067. /**
  58068. * Instantiates a post process render effect.
  58069. * A post process can be used to apply a shader to a texture after it is rendered.
  58070. * @param engine The engine the effect is tied to
  58071. * @param name The name of the effect
  58072. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58073. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58074. */
  58075. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58076. /**
  58077. * Checks if all the post processes in the effect are supported.
  58078. */
  58079. readonly isSupported: boolean;
  58080. /**
  58081. * Updates the current state of the effect
  58082. * @hidden
  58083. */
  58084. _update(): void;
  58085. /**
  58086. * Attaches the effect on cameras
  58087. * @param cameras The camera to attach to.
  58088. * @hidden
  58089. */
  58090. _attachCameras(cameras: Camera): void;
  58091. /**
  58092. * Attaches the effect on cameras
  58093. * @param cameras The camera to attach to.
  58094. * @hidden
  58095. */
  58096. _attachCameras(cameras: Camera[]): void;
  58097. /**
  58098. * Detaches the effect on cameras
  58099. * @param cameras The camera to detatch from.
  58100. * @hidden
  58101. */
  58102. _detachCameras(cameras: Camera): void;
  58103. /**
  58104. * Detatches the effect on cameras
  58105. * @param cameras The camera to detatch from.
  58106. * @hidden
  58107. */
  58108. _detachCameras(cameras: Camera[]): void;
  58109. /**
  58110. * Enables the effect on given cameras
  58111. * @param cameras The camera to enable.
  58112. * @hidden
  58113. */
  58114. _enable(cameras: Camera): void;
  58115. /**
  58116. * Enables the effect on given cameras
  58117. * @param cameras The camera to enable.
  58118. * @hidden
  58119. */
  58120. _enable(cameras: Nullable<Camera[]>): void;
  58121. /**
  58122. * Disables the effect on the given cameras
  58123. * @param cameras The camera to disable.
  58124. * @hidden
  58125. */
  58126. _disable(cameras: Camera): void;
  58127. /**
  58128. * Disables the effect on the given cameras
  58129. * @param cameras The camera to disable.
  58130. * @hidden
  58131. */
  58132. _disable(cameras: Nullable<Camera[]>): void;
  58133. /**
  58134. * Gets a list of the post processes contained in the effect.
  58135. * @param camera The camera to get the post processes on.
  58136. * @returns The list of the post processes in the effect.
  58137. */
  58138. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58139. }
  58140. }
  58141. declare module BABYLON {
  58142. /** @hidden */
  58143. export var extractHighlightsPixelShader: {
  58144. name: string;
  58145. shader: string;
  58146. };
  58147. }
  58148. declare module BABYLON {
  58149. /**
  58150. * 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.
  58151. */
  58152. export class ExtractHighlightsPostProcess extends PostProcess {
  58153. /**
  58154. * The luminance threshold, pixels below this value will be set to black.
  58155. */
  58156. threshold: number;
  58157. /** @hidden */
  58158. _exposure: number;
  58159. /**
  58160. * Post process which has the input texture to be used when performing highlight extraction
  58161. * @hidden
  58162. */
  58163. _inputPostProcess: Nullable<PostProcess>;
  58164. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58165. }
  58166. }
  58167. declare module BABYLON {
  58168. /** @hidden */
  58169. export var bloomMergePixelShader: {
  58170. name: string;
  58171. shader: string;
  58172. };
  58173. }
  58174. declare module BABYLON {
  58175. /**
  58176. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58177. */
  58178. export class BloomMergePostProcess extends PostProcess {
  58179. /** Weight of the bloom to be added to the original input. */
  58180. weight: number;
  58181. /**
  58182. * Creates a new instance of @see BloomMergePostProcess
  58183. * @param name The name of the effect.
  58184. * @param originalFromInput Post process which's input will be used for the merge.
  58185. * @param blurred Blurred highlights post process which's output will be used.
  58186. * @param weight Weight of the bloom to be added to the original input.
  58187. * @param options The required width/height ratio to downsize to before computing the render pass.
  58188. * @param camera The camera to apply the render pass to.
  58189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58190. * @param engine The engine which the post process will be applied. (default: current engine)
  58191. * @param reusable If the post process can be reused on the same frame. (default: false)
  58192. * @param textureType Type of textures used when performing the post process. (default: 0)
  58193. * @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)
  58194. */
  58195. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58196. /** Weight of the bloom to be added to the original input. */
  58197. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58198. }
  58199. }
  58200. declare module BABYLON {
  58201. /**
  58202. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58203. */
  58204. export class BloomEffect extends PostProcessRenderEffect {
  58205. private bloomScale;
  58206. /**
  58207. * @hidden Internal
  58208. */
  58209. _effects: Array<PostProcess>;
  58210. /**
  58211. * @hidden Internal
  58212. */
  58213. _downscale: ExtractHighlightsPostProcess;
  58214. private _blurX;
  58215. private _blurY;
  58216. private _merge;
  58217. /**
  58218. * The luminance threshold to find bright areas of the image to bloom.
  58219. */
  58220. threshold: number;
  58221. /**
  58222. * The strength of the bloom.
  58223. */
  58224. weight: number;
  58225. /**
  58226. * Specifies the size of the bloom blur kernel, relative to the final output size
  58227. */
  58228. kernel: number;
  58229. /**
  58230. * Creates a new instance of @see BloomEffect
  58231. * @param scene The scene the effect belongs to.
  58232. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58233. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58234. * @param bloomWeight The the strength of bloom.
  58235. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58236. * @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)
  58237. */
  58238. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58239. /**
  58240. * Disposes each of the internal effects for a given camera.
  58241. * @param camera The camera to dispose the effect on.
  58242. */
  58243. disposeEffects(camera: Camera): void;
  58244. /**
  58245. * @hidden Internal
  58246. */
  58247. _updateEffects(): void;
  58248. /**
  58249. * Internal
  58250. * @returns if all the contained post processes are ready.
  58251. * @hidden
  58252. */
  58253. _isReady(): boolean;
  58254. }
  58255. }
  58256. declare module BABYLON {
  58257. /** @hidden */
  58258. export var chromaticAberrationPixelShader: {
  58259. name: string;
  58260. shader: string;
  58261. };
  58262. }
  58263. declare module BABYLON {
  58264. /**
  58265. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58266. */
  58267. export class ChromaticAberrationPostProcess extends PostProcess {
  58268. /**
  58269. * The amount of seperation of rgb channels (default: 30)
  58270. */
  58271. aberrationAmount: number;
  58272. /**
  58273. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58274. */
  58275. radialIntensity: number;
  58276. /**
  58277. * 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))
  58278. */
  58279. direction: Vector2;
  58280. /**
  58281. * 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))
  58282. */
  58283. centerPosition: Vector2;
  58284. /**
  58285. * Creates a new instance ChromaticAberrationPostProcess
  58286. * @param name The name of the effect.
  58287. * @param screenWidth The width of the screen to apply the effect on.
  58288. * @param screenHeight The height of the screen to apply the effect on.
  58289. * @param options The required width/height ratio to downsize to before computing the render pass.
  58290. * @param camera The camera to apply the render pass to.
  58291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58292. * @param engine The engine which the post process will be applied. (default: current engine)
  58293. * @param reusable If the post process can be reused on the same frame. (default: false)
  58294. * @param textureType Type of textures used when performing the post process. (default: 0)
  58295. * @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)
  58296. */
  58297. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58298. }
  58299. }
  58300. declare module BABYLON {
  58301. /** @hidden */
  58302. export var circleOfConfusionPixelShader: {
  58303. name: string;
  58304. shader: string;
  58305. };
  58306. }
  58307. declare module BABYLON {
  58308. /**
  58309. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58310. */
  58311. export class CircleOfConfusionPostProcess extends PostProcess {
  58312. /**
  58313. * 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.
  58314. */
  58315. lensSize: number;
  58316. /**
  58317. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58318. */
  58319. fStop: number;
  58320. /**
  58321. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58322. */
  58323. focusDistance: number;
  58324. /**
  58325. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58326. */
  58327. focalLength: number;
  58328. private _depthTexture;
  58329. /**
  58330. * Creates a new instance CircleOfConfusionPostProcess
  58331. * @param name The name of the effect.
  58332. * @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.
  58333. * @param options The required width/height ratio to downsize to before computing the render pass.
  58334. * @param camera The camera to apply the render pass to.
  58335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58336. * @param engine The engine which the post process will be applied. (default: current engine)
  58337. * @param reusable If the post process can be reused on the same frame. (default: false)
  58338. * @param textureType Type of textures used when performing the post process. (default: 0)
  58339. * @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)
  58340. */
  58341. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58342. /**
  58343. * 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.
  58344. */
  58345. depthTexture: RenderTargetTexture;
  58346. }
  58347. }
  58348. declare module BABYLON {
  58349. /** @hidden */
  58350. export var colorCorrectionPixelShader: {
  58351. name: string;
  58352. shader: string;
  58353. };
  58354. }
  58355. declare module BABYLON {
  58356. /**
  58357. *
  58358. * This post-process allows the modification of rendered colors by using
  58359. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58360. *
  58361. * The object needs to be provided an url to a texture containing the color
  58362. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58363. * Use an image editing software to tweak the LUT to match your needs.
  58364. *
  58365. * For an example of a color LUT, see here:
  58366. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58367. * For explanations on color grading, see here:
  58368. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58369. *
  58370. */
  58371. export class ColorCorrectionPostProcess extends PostProcess {
  58372. private _colorTableTexture;
  58373. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58374. }
  58375. }
  58376. declare module BABYLON {
  58377. /** @hidden */
  58378. export var convolutionPixelShader: {
  58379. name: string;
  58380. shader: string;
  58381. };
  58382. }
  58383. declare module BABYLON {
  58384. /**
  58385. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58386. * input texture to perform effects such as edge detection or sharpening
  58387. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58388. */
  58389. export class ConvolutionPostProcess extends PostProcess {
  58390. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58391. kernel: number[];
  58392. /**
  58393. * Creates a new instance ConvolutionPostProcess
  58394. * @param name The name of the effect.
  58395. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58396. * @param options The required width/height ratio to downsize to before computing the render pass.
  58397. * @param camera The camera to apply the render pass to.
  58398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58399. * @param engine The engine which the post process will be applied. (default: current engine)
  58400. * @param reusable If the post process can be reused on the same frame. (default: false)
  58401. * @param textureType Type of textures used when performing the post process. (default: 0)
  58402. */
  58403. constructor(name: string,
  58404. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58405. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58406. /**
  58407. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58408. */
  58409. static EdgeDetect0Kernel: number[];
  58410. /**
  58411. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58412. */
  58413. static EdgeDetect1Kernel: number[];
  58414. /**
  58415. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58416. */
  58417. static EdgeDetect2Kernel: number[];
  58418. /**
  58419. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58420. */
  58421. static SharpenKernel: number[];
  58422. /**
  58423. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58424. */
  58425. static EmbossKernel: number[];
  58426. /**
  58427. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58428. */
  58429. static GaussianKernel: number[];
  58430. }
  58431. }
  58432. declare module BABYLON {
  58433. /**
  58434. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58435. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58436. * based on samples that have a large difference in distance than the center pixel.
  58437. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58438. */
  58439. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58440. direction: Vector2;
  58441. /**
  58442. * Creates a new instance CircleOfConfusionPostProcess
  58443. * @param name The name of the effect.
  58444. * @param scene The scene the effect belongs to.
  58445. * @param direction The direction the blur should be applied.
  58446. * @param kernel The size of the kernel used to blur.
  58447. * @param options The required width/height ratio to downsize to before computing the render pass.
  58448. * @param camera The camera to apply the render pass to.
  58449. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58450. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58452. * @param engine The engine which the post process will be applied. (default: current engine)
  58453. * @param reusable If the post process can be reused on the same frame. (default: false)
  58454. * @param textureType Type of textures used when performing the post process. (default: 0)
  58455. * @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)
  58456. */
  58457. 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);
  58458. }
  58459. }
  58460. declare module BABYLON {
  58461. /** @hidden */
  58462. export var depthOfFieldMergePixelShader: {
  58463. name: string;
  58464. shader: string;
  58465. };
  58466. }
  58467. declare module BABYLON {
  58468. /**
  58469. * Options to be set when merging outputs from the default pipeline.
  58470. */
  58471. export class DepthOfFieldMergePostProcessOptions {
  58472. /**
  58473. * The original image to merge on top of
  58474. */
  58475. originalFromInput: PostProcess;
  58476. /**
  58477. * Parameters to perform the merge of the depth of field effect
  58478. */
  58479. depthOfField?: {
  58480. circleOfConfusion: PostProcess;
  58481. blurSteps: Array<PostProcess>;
  58482. };
  58483. /**
  58484. * Parameters to perform the merge of bloom effect
  58485. */
  58486. bloom?: {
  58487. blurred: PostProcess;
  58488. weight: number;
  58489. };
  58490. }
  58491. /**
  58492. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58493. */
  58494. export class DepthOfFieldMergePostProcess extends PostProcess {
  58495. private blurSteps;
  58496. /**
  58497. * Creates a new instance of DepthOfFieldMergePostProcess
  58498. * @param name The name of the effect.
  58499. * @param originalFromInput Post process which's input will be used for the merge.
  58500. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58501. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58502. * @param options The required width/height ratio to downsize to before computing the render pass.
  58503. * @param camera The camera to apply the render pass to.
  58504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58505. * @param engine The engine which the post process will be applied. (default: current engine)
  58506. * @param reusable If the post process can be reused on the same frame. (default: false)
  58507. * @param textureType Type of textures used when performing the post process. (default: 0)
  58508. * @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)
  58509. */
  58510. 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);
  58511. /**
  58512. * Updates the effect with the current post process compile time values and recompiles the shader.
  58513. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58514. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58515. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58516. * @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
  58517. * @param onCompiled Called when the shader has been compiled.
  58518. * @param onError Called if there is an error when compiling a shader.
  58519. */
  58520. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58521. }
  58522. }
  58523. declare module BABYLON {
  58524. /**
  58525. * Specifies the level of max blur that should be applied when using the depth of field effect
  58526. */
  58527. export enum DepthOfFieldEffectBlurLevel {
  58528. /**
  58529. * Subtle blur
  58530. */
  58531. Low = 0,
  58532. /**
  58533. * Medium blur
  58534. */
  58535. Medium = 1,
  58536. /**
  58537. * Large blur
  58538. */
  58539. High = 2
  58540. }
  58541. /**
  58542. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58543. */
  58544. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58545. private _circleOfConfusion;
  58546. /**
  58547. * @hidden Internal, blurs from high to low
  58548. */
  58549. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58550. private _depthOfFieldBlurY;
  58551. private _dofMerge;
  58552. /**
  58553. * @hidden Internal post processes in depth of field effect
  58554. */
  58555. _effects: Array<PostProcess>;
  58556. /**
  58557. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58558. */
  58559. focalLength: number;
  58560. /**
  58561. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58562. */
  58563. fStop: number;
  58564. /**
  58565. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58566. */
  58567. focusDistance: number;
  58568. /**
  58569. * 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.
  58570. */
  58571. lensSize: number;
  58572. /**
  58573. * Creates a new instance DepthOfFieldEffect
  58574. * @param scene The scene the effect belongs to.
  58575. * @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.
  58576. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58577. * @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)
  58578. */
  58579. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58580. /**
  58581. * Get the current class name of the current effet
  58582. * @returns "DepthOfFieldEffect"
  58583. */
  58584. getClassName(): string;
  58585. /**
  58586. * 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.
  58587. */
  58588. depthTexture: RenderTargetTexture;
  58589. /**
  58590. * Disposes each of the internal effects for a given camera.
  58591. * @param camera The camera to dispose the effect on.
  58592. */
  58593. disposeEffects(camera: Camera): void;
  58594. /**
  58595. * @hidden Internal
  58596. */
  58597. _updateEffects(): void;
  58598. /**
  58599. * Internal
  58600. * @returns if all the contained post processes are ready.
  58601. * @hidden
  58602. */
  58603. _isReady(): boolean;
  58604. }
  58605. }
  58606. declare module BABYLON {
  58607. /** @hidden */
  58608. export var displayPassPixelShader: {
  58609. name: string;
  58610. shader: string;
  58611. };
  58612. }
  58613. declare module BABYLON {
  58614. /**
  58615. * DisplayPassPostProcess which produces an output the same as it's input
  58616. */
  58617. export class DisplayPassPostProcess extends PostProcess {
  58618. /**
  58619. * Creates the DisplayPassPostProcess
  58620. * @param name The name of the effect.
  58621. * @param options The required width/height ratio to downsize to before computing the render pass.
  58622. * @param camera The camera to apply the render pass to.
  58623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58624. * @param engine The engine which the post process will be applied. (default: current engine)
  58625. * @param reusable If the post process can be reused on the same frame. (default: false)
  58626. */
  58627. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58628. }
  58629. }
  58630. declare module BABYLON {
  58631. /** @hidden */
  58632. export var filterPixelShader: {
  58633. name: string;
  58634. shader: string;
  58635. };
  58636. }
  58637. declare module BABYLON {
  58638. /**
  58639. * Applies a kernel filter to the image
  58640. */
  58641. export class FilterPostProcess extends PostProcess {
  58642. /** The matrix to be applied to the image */
  58643. kernelMatrix: Matrix;
  58644. /**
  58645. *
  58646. * @param name The name of the effect.
  58647. * @param kernelMatrix The matrix to be applied to the image
  58648. * @param options The required width/height ratio to downsize to before computing the render pass.
  58649. * @param camera The camera to apply the render pass to.
  58650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58651. * @param engine The engine which the post process will be applied. (default: current engine)
  58652. * @param reusable If the post process can be reused on the same frame. (default: false)
  58653. */
  58654. constructor(name: string,
  58655. /** The matrix to be applied to the image */
  58656. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58657. }
  58658. }
  58659. declare module BABYLON {
  58660. /** @hidden */
  58661. export var fxaaPixelShader: {
  58662. name: string;
  58663. shader: string;
  58664. };
  58665. }
  58666. declare module BABYLON {
  58667. /** @hidden */
  58668. export var fxaaVertexShader: {
  58669. name: string;
  58670. shader: string;
  58671. };
  58672. }
  58673. declare module BABYLON {
  58674. /**
  58675. * Fxaa post process
  58676. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58677. */
  58678. export class FxaaPostProcess extends PostProcess {
  58679. /** @hidden */
  58680. texelWidth: number;
  58681. /** @hidden */
  58682. texelHeight: number;
  58683. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58684. private _getDefines;
  58685. }
  58686. }
  58687. declare module BABYLON {
  58688. /** @hidden */
  58689. export var grainPixelShader: {
  58690. name: string;
  58691. shader: string;
  58692. };
  58693. }
  58694. declare module BABYLON {
  58695. /**
  58696. * The GrainPostProcess adds noise to the image at mid luminance levels
  58697. */
  58698. export class GrainPostProcess extends PostProcess {
  58699. /**
  58700. * The intensity of the grain added (default: 30)
  58701. */
  58702. intensity: number;
  58703. /**
  58704. * If the grain should be randomized on every frame
  58705. */
  58706. animated: boolean;
  58707. /**
  58708. * Creates a new instance of @see GrainPostProcess
  58709. * @param name The name of the effect.
  58710. * @param options The required width/height ratio to downsize to before computing the render pass.
  58711. * @param camera The camera to apply the render pass to.
  58712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58713. * @param engine The engine which the post process will be applied. (default: current engine)
  58714. * @param reusable If the post process can be reused on the same frame. (default: false)
  58715. * @param textureType Type of textures used when performing the post process. (default: 0)
  58716. * @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)
  58717. */
  58718. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58719. }
  58720. }
  58721. declare module BABYLON {
  58722. /** @hidden */
  58723. export var highlightsPixelShader: {
  58724. name: string;
  58725. shader: string;
  58726. };
  58727. }
  58728. declare module BABYLON {
  58729. /**
  58730. * Extracts highlights from the image
  58731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58732. */
  58733. export class HighlightsPostProcess extends PostProcess {
  58734. /**
  58735. * Extracts highlights from the image
  58736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58737. * @param name The name of the effect.
  58738. * @param options The required width/height ratio to downsize to before computing the render pass.
  58739. * @param camera The camera to apply the render pass to.
  58740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58741. * @param engine The engine which the post process will be applied. (default: current engine)
  58742. * @param reusable If the post process can be reused on the same frame. (default: false)
  58743. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58744. */
  58745. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58746. }
  58747. }
  58748. declare module BABYLON {
  58749. /** @hidden */
  58750. export var mrtFragmentDeclaration: {
  58751. name: string;
  58752. shader: string;
  58753. };
  58754. }
  58755. declare module BABYLON {
  58756. /** @hidden */
  58757. export var geometryPixelShader: {
  58758. name: string;
  58759. shader: string;
  58760. };
  58761. }
  58762. declare module BABYLON {
  58763. /** @hidden */
  58764. export var geometryVertexShader: {
  58765. name: string;
  58766. shader: string;
  58767. };
  58768. }
  58769. declare module BABYLON {
  58770. /** @hidden */
  58771. interface ISavedTransformationMatrix {
  58772. world: Matrix;
  58773. viewProjection: Matrix;
  58774. }
  58775. /**
  58776. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58777. */
  58778. export class GeometryBufferRenderer {
  58779. /**
  58780. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58781. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58782. */
  58783. static readonly POSITION_TEXTURE_TYPE: number;
  58784. /**
  58785. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58786. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58787. */
  58788. static readonly VELOCITY_TEXTURE_TYPE: number;
  58789. /**
  58790. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58791. * in order to compute objects velocities when enableVelocity is set to "true"
  58792. * @hidden
  58793. */
  58794. _previousTransformationMatrices: {
  58795. [index: number]: ISavedTransformationMatrix;
  58796. };
  58797. /**
  58798. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58799. * in order to compute objects velocities when enableVelocity is set to "true"
  58800. * @hidden
  58801. */
  58802. _previousBonesTransformationMatrices: {
  58803. [index: number]: Float32Array;
  58804. };
  58805. /**
  58806. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58807. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58808. */
  58809. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58810. private _scene;
  58811. private _multiRenderTarget;
  58812. private _ratio;
  58813. private _enablePosition;
  58814. private _enableVelocity;
  58815. private _positionIndex;
  58816. private _velocityIndex;
  58817. protected _effect: Effect;
  58818. protected _cachedDefines: string;
  58819. /**
  58820. * Set the render list (meshes to be rendered) used in the G buffer.
  58821. */
  58822. renderList: Mesh[];
  58823. /**
  58824. * Gets wether or not G buffer are supported by the running hardware.
  58825. * This requires draw buffer supports
  58826. */
  58827. readonly isSupported: boolean;
  58828. /**
  58829. * Returns the index of the given texture type in the G-Buffer textures array
  58830. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58831. * @returns the index of the given texture type in the G-Buffer textures array
  58832. */
  58833. getTextureIndex(textureType: number): number;
  58834. /**
  58835. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58836. */
  58837. /**
  58838. * Sets whether or not objects positions are enabled for the G buffer.
  58839. */
  58840. enablePosition: boolean;
  58841. /**
  58842. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58843. */
  58844. /**
  58845. * Sets wether or not objects velocities are enabled for the G buffer.
  58846. */
  58847. enableVelocity: boolean;
  58848. /**
  58849. * Gets the scene associated with the buffer.
  58850. */
  58851. readonly scene: Scene;
  58852. /**
  58853. * Gets the ratio used by the buffer during its creation.
  58854. * How big is the buffer related to the main canvas.
  58855. */
  58856. readonly ratio: number;
  58857. /** @hidden */
  58858. static _SceneComponentInitialization: (scene: Scene) => void;
  58859. /**
  58860. * Creates a new G Buffer for the scene
  58861. * @param scene The scene the buffer belongs to
  58862. * @param ratio How big is the buffer related to the main canvas.
  58863. */
  58864. constructor(scene: Scene, ratio?: number);
  58865. /**
  58866. * Checks wether everything is ready to render a submesh to the G buffer.
  58867. * @param subMesh the submesh to check readiness for
  58868. * @param useInstances is the mesh drawn using instance or not
  58869. * @returns true if ready otherwise false
  58870. */
  58871. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58872. /**
  58873. * Gets the current underlying G Buffer.
  58874. * @returns the buffer
  58875. */
  58876. getGBuffer(): MultiRenderTarget;
  58877. /**
  58878. * Gets the number of samples used to render the buffer (anti aliasing).
  58879. */
  58880. /**
  58881. * Sets the number of samples used to render the buffer (anti aliasing).
  58882. */
  58883. samples: number;
  58884. /**
  58885. * Disposes the renderer and frees up associated resources.
  58886. */
  58887. dispose(): void;
  58888. protected _createRenderTargets(): void;
  58889. private _copyBonesTransformationMatrices;
  58890. }
  58891. }
  58892. declare module BABYLON {
  58893. interface Scene {
  58894. /** @hidden (Backing field) */
  58895. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58896. /**
  58897. * Gets or Sets the current geometry buffer associated to the scene.
  58898. */
  58899. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58900. /**
  58901. * Enables a GeometryBufferRender and associates it with the scene
  58902. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58903. * @returns the GeometryBufferRenderer
  58904. */
  58905. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58906. /**
  58907. * Disables the GeometryBufferRender associated with the scene
  58908. */
  58909. disableGeometryBufferRenderer(): void;
  58910. }
  58911. /**
  58912. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58913. * in several rendering techniques.
  58914. */
  58915. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58916. /**
  58917. * The component name helpful to identify the component in the list of scene components.
  58918. */
  58919. readonly name: string;
  58920. /**
  58921. * The scene the component belongs to.
  58922. */
  58923. scene: Scene;
  58924. /**
  58925. * Creates a new instance of the component for the given scene
  58926. * @param scene Defines the scene to register the component in
  58927. */
  58928. constructor(scene: Scene);
  58929. /**
  58930. * Registers the component in a given scene
  58931. */
  58932. register(): void;
  58933. /**
  58934. * Rebuilds the elements related to this component in case of
  58935. * context lost for instance.
  58936. */
  58937. rebuild(): void;
  58938. /**
  58939. * Disposes the component and the associated ressources
  58940. */
  58941. dispose(): void;
  58942. private _gatherRenderTargets;
  58943. }
  58944. }
  58945. declare module BABYLON {
  58946. /** @hidden */
  58947. export var motionBlurPixelShader: {
  58948. name: string;
  58949. shader: string;
  58950. };
  58951. }
  58952. declare module BABYLON {
  58953. /**
  58954. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58955. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58956. * As an example, all you have to do is to create the post-process:
  58957. * var mb = new BABYLON.MotionBlurPostProcess(
  58958. * 'mb', // The name of the effect.
  58959. * scene, // The scene containing the objects to blur according to their velocity.
  58960. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58961. * camera // The camera to apply the render pass to.
  58962. * );
  58963. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58964. */
  58965. export class MotionBlurPostProcess extends PostProcess {
  58966. /**
  58967. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58968. */
  58969. motionStrength: number;
  58970. /**
  58971. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58972. */
  58973. /**
  58974. * Sets the number of iterations to be used for motion blur quality
  58975. */
  58976. motionBlurSamples: number;
  58977. private _motionBlurSamples;
  58978. private _geometryBufferRenderer;
  58979. /**
  58980. * Creates a new instance MotionBlurPostProcess
  58981. * @param name The name of the effect.
  58982. * @param scene The scene containing the objects to blur according to their velocity.
  58983. * @param options The required width/height ratio to downsize to before computing the render pass.
  58984. * @param camera The camera to apply the render pass to.
  58985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58986. * @param engine The engine which the post process will be applied. (default: current engine)
  58987. * @param reusable If the post process can be reused on the same frame. (default: false)
  58988. * @param textureType Type of textures used when performing the post process. (default: 0)
  58989. * @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)
  58990. */
  58991. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58992. /**
  58993. * Excludes the given skinned mesh from computing bones velocities.
  58994. * 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.
  58995. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58996. */
  58997. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58998. /**
  58999. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59000. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59001. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59002. */
  59003. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59004. /**
  59005. * Disposes the post process.
  59006. * @param camera The camera to dispose the post process on.
  59007. */
  59008. dispose(camera?: Camera): void;
  59009. }
  59010. }
  59011. declare module BABYLON {
  59012. /** @hidden */
  59013. export var refractionPixelShader: {
  59014. name: string;
  59015. shader: string;
  59016. };
  59017. }
  59018. declare module BABYLON {
  59019. /**
  59020. * Post process which applies a refractin texture
  59021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59022. */
  59023. export class RefractionPostProcess extends PostProcess {
  59024. /** the base color of the refraction (used to taint the rendering) */
  59025. color: Color3;
  59026. /** simulated refraction depth */
  59027. depth: number;
  59028. /** the coefficient of the base color (0 to remove base color tainting) */
  59029. colorLevel: number;
  59030. private _refTexture;
  59031. private _ownRefractionTexture;
  59032. /**
  59033. * Gets or sets the refraction texture
  59034. * Please note that you are responsible for disposing the texture if you set it manually
  59035. */
  59036. refractionTexture: Texture;
  59037. /**
  59038. * Initializes the RefractionPostProcess
  59039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59040. * @param name The name of the effect.
  59041. * @param refractionTextureUrl Url of the refraction texture to use
  59042. * @param color the base color of the refraction (used to taint the rendering)
  59043. * @param depth simulated refraction depth
  59044. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59045. * @param camera The camera to apply the render pass to.
  59046. * @param options The required width/height ratio to downsize to before computing the render pass.
  59047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59048. * @param engine The engine which the post process will be applied. (default: current engine)
  59049. * @param reusable If the post process can be reused on the same frame. (default: false)
  59050. */
  59051. constructor(name: string, refractionTextureUrl: string,
  59052. /** the base color of the refraction (used to taint the rendering) */
  59053. color: Color3,
  59054. /** simulated refraction depth */
  59055. depth: number,
  59056. /** the coefficient of the base color (0 to remove base color tainting) */
  59057. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59058. /**
  59059. * Disposes of the post process
  59060. * @param camera Camera to dispose post process on
  59061. */
  59062. dispose(camera: Camera): void;
  59063. }
  59064. }
  59065. declare module BABYLON {
  59066. /** @hidden */
  59067. export var sharpenPixelShader: {
  59068. name: string;
  59069. shader: string;
  59070. };
  59071. }
  59072. declare module BABYLON {
  59073. /**
  59074. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59075. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59076. */
  59077. export class SharpenPostProcess extends PostProcess {
  59078. /**
  59079. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59080. */
  59081. colorAmount: number;
  59082. /**
  59083. * How much sharpness should be applied (default: 0.3)
  59084. */
  59085. edgeAmount: number;
  59086. /**
  59087. * Creates a new instance ConvolutionPostProcess
  59088. * @param name The name of the effect.
  59089. * @param options The required width/height ratio to downsize to before computing the render pass.
  59090. * @param camera The camera to apply the render pass to.
  59091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59092. * @param engine The engine which the post process will be applied. (default: current engine)
  59093. * @param reusable If the post process can be reused on the same frame. (default: false)
  59094. * @param textureType Type of textures used when performing the post process. (default: 0)
  59095. * @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)
  59096. */
  59097. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59098. }
  59099. }
  59100. declare module BABYLON {
  59101. /**
  59102. * PostProcessRenderPipeline
  59103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59104. */
  59105. export class PostProcessRenderPipeline {
  59106. private engine;
  59107. private _renderEffects;
  59108. private _renderEffectsForIsolatedPass;
  59109. /**
  59110. * List of inspectable custom properties (used by the Inspector)
  59111. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59112. */
  59113. inspectableCustomProperties: IInspectable[];
  59114. /**
  59115. * @hidden
  59116. */
  59117. protected _cameras: Camera[];
  59118. /** @hidden */
  59119. _name: string;
  59120. /**
  59121. * Gets pipeline name
  59122. */
  59123. readonly name: string;
  59124. /**
  59125. * Initializes a PostProcessRenderPipeline
  59126. * @param engine engine to add the pipeline to
  59127. * @param name name of the pipeline
  59128. */
  59129. constructor(engine: Engine, name: string);
  59130. /**
  59131. * Gets the class name
  59132. * @returns "PostProcessRenderPipeline"
  59133. */
  59134. getClassName(): string;
  59135. /**
  59136. * If all the render effects in the pipeline are supported
  59137. */
  59138. readonly isSupported: boolean;
  59139. /**
  59140. * Adds an effect to the pipeline
  59141. * @param renderEffect the effect to add
  59142. */
  59143. addEffect(renderEffect: PostProcessRenderEffect): void;
  59144. /** @hidden */
  59145. _rebuild(): void;
  59146. /** @hidden */
  59147. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59148. /** @hidden */
  59149. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59150. /** @hidden */
  59151. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59152. /** @hidden */
  59153. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59154. /** @hidden */
  59155. _attachCameras(cameras: Camera, unique: boolean): void;
  59156. /** @hidden */
  59157. _attachCameras(cameras: Camera[], unique: boolean): void;
  59158. /** @hidden */
  59159. _detachCameras(cameras: Camera): void;
  59160. /** @hidden */
  59161. _detachCameras(cameras: Nullable<Camera[]>): void;
  59162. /** @hidden */
  59163. _update(): void;
  59164. /** @hidden */
  59165. _reset(): void;
  59166. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59167. /**
  59168. * Disposes of the pipeline
  59169. */
  59170. dispose(): void;
  59171. }
  59172. }
  59173. declare module BABYLON {
  59174. /**
  59175. * PostProcessRenderPipelineManager class
  59176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59177. */
  59178. export class PostProcessRenderPipelineManager {
  59179. private _renderPipelines;
  59180. /**
  59181. * Initializes a PostProcessRenderPipelineManager
  59182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59183. */
  59184. constructor();
  59185. /**
  59186. * Gets the list of supported render pipelines
  59187. */
  59188. readonly supportedPipelines: PostProcessRenderPipeline[];
  59189. /**
  59190. * Adds a pipeline to the manager
  59191. * @param renderPipeline The pipeline to add
  59192. */
  59193. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59194. /**
  59195. * Attaches a camera to the pipeline
  59196. * @param renderPipelineName The name of the pipeline to attach to
  59197. * @param cameras the camera to attach
  59198. * @param unique if the camera can be attached multiple times to the pipeline
  59199. */
  59200. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59201. /**
  59202. * Detaches a camera from the pipeline
  59203. * @param renderPipelineName The name of the pipeline to detach from
  59204. * @param cameras the camera to detach
  59205. */
  59206. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59207. /**
  59208. * Enables an effect by name on a pipeline
  59209. * @param renderPipelineName the name of the pipeline to enable the effect in
  59210. * @param renderEffectName the name of the effect to enable
  59211. * @param cameras the cameras that the effect should be enabled on
  59212. */
  59213. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59214. /**
  59215. * Disables an effect by name on a pipeline
  59216. * @param renderPipelineName the name of the pipeline to disable the effect in
  59217. * @param renderEffectName the name of the effect to disable
  59218. * @param cameras the cameras that the effect should be disabled on
  59219. */
  59220. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59221. /**
  59222. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59223. */
  59224. update(): void;
  59225. /** @hidden */
  59226. _rebuild(): void;
  59227. /**
  59228. * Disposes of the manager and pipelines
  59229. */
  59230. dispose(): void;
  59231. }
  59232. }
  59233. declare module BABYLON {
  59234. interface Scene {
  59235. /** @hidden (Backing field) */
  59236. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59237. /**
  59238. * Gets the postprocess render pipeline manager
  59239. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59240. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59241. */
  59242. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59243. }
  59244. /**
  59245. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59246. */
  59247. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59248. /**
  59249. * The component name helpfull to identify the component in the list of scene components.
  59250. */
  59251. readonly name: string;
  59252. /**
  59253. * The scene the component belongs to.
  59254. */
  59255. scene: Scene;
  59256. /**
  59257. * Creates a new instance of the component for the given scene
  59258. * @param scene Defines the scene to register the component in
  59259. */
  59260. constructor(scene: Scene);
  59261. /**
  59262. * Registers the component in a given scene
  59263. */
  59264. register(): void;
  59265. /**
  59266. * Rebuilds the elements related to this component in case of
  59267. * context lost for instance.
  59268. */
  59269. rebuild(): void;
  59270. /**
  59271. * Disposes the component and the associated ressources
  59272. */
  59273. dispose(): void;
  59274. private _gatherRenderTargets;
  59275. }
  59276. }
  59277. declare module BABYLON {
  59278. /**
  59279. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59280. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59281. */
  59282. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59283. private _scene;
  59284. private _camerasToBeAttached;
  59285. /**
  59286. * ID of the sharpen post process,
  59287. */
  59288. private readonly SharpenPostProcessId;
  59289. /**
  59290. * @ignore
  59291. * ID of the image processing post process;
  59292. */
  59293. readonly ImageProcessingPostProcessId: string;
  59294. /**
  59295. * @ignore
  59296. * ID of the Fast Approximate Anti-Aliasing post process;
  59297. */
  59298. readonly FxaaPostProcessId: string;
  59299. /**
  59300. * ID of the chromatic aberration post process,
  59301. */
  59302. private readonly ChromaticAberrationPostProcessId;
  59303. /**
  59304. * ID of the grain post process
  59305. */
  59306. private readonly GrainPostProcessId;
  59307. /**
  59308. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59309. */
  59310. sharpen: SharpenPostProcess;
  59311. private _sharpenEffect;
  59312. private bloom;
  59313. /**
  59314. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59315. */
  59316. depthOfField: DepthOfFieldEffect;
  59317. /**
  59318. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59319. */
  59320. fxaa: FxaaPostProcess;
  59321. /**
  59322. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59323. */
  59324. imageProcessing: ImageProcessingPostProcess;
  59325. /**
  59326. * Chromatic aberration post process which will shift rgb colors in the image
  59327. */
  59328. chromaticAberration: ChromaticAberrationPostProcess;
  59329. private _chromaticAberrationEffect;
  59330. /**
  59331. * Grain post process which add noise to the image
  59332. */
  59333. grain: GrainPostProcess;
  59334. private _grainEffect;
  59335. /**
  59336. * Glow post process which adds a glow to emissive areas of the image
  59337. */
  59338. private _glowLayer;
  59339. /**
  59340. * Animations which can be used to tweak settings over a period of time
  59341. */
  59342. animations: Animation[];
  59343. private _imageProcessingConfigurationObserver;
  59344. private _sharpenEnabled;
  59345. private _bloomEnabled;
  59346. private _depthOfFieldEnabled;
  59347. private _depthOfFieldBlurLevel;
  59348. private _fxaaEnabled;
  59349. private _imageProcessingEnabled;
  59350. private _defaultPipelineTextureType;
  59351. private _bloomScale;
  59352. private _chromaticAberrationEnabled;
  59353. private _grainEnabled;
  59354. private _buildAllowed;
  59355. /**
  59356. * Gets active scene
  59357. */
  59358. readonly scene: Scene;
  59359. /**
  59360. * Enable or disable the sharpen process from the pipeline
  59361. */
  59362. sharpenEnabled: boolean;
  59363. private _resizeObserver;
  59364. private _hardwareScaleLevel;
  59365. private _bloomKernel;
  59366. /**
  59367. * Specifies the size of the bloom blur kernel, relative to the final output size
  59368. */
  59369. bloomKernel: number;
  59370. /**
  59371. * Specifies the weight of the bloom in the final rendering
  59372. */
  59373. private _bloomWeight;
  59374. /**
  59375. * Specifies the luma threshold for the area that will be blurred by the bloom
  59376. */
  59377. private _bloomThreshold;
  59378. private _hdr;
  59379. /**
  59380. * The strength of the bloom.
  59381. */
  59382. bloomWeight: number;
  59383. /**
  59384. * The strength of the bloom.
  59385. */
  59386. bloomThreshold: number;
  59387. /**
  59388. * The scale of the bloom, lower value will provide better performance.
  59389. */
  59390. bloomScale: number;
  59391. /**
  59392. * Enable or disable the bloom from the pipeline
  59393. */
  59394. bloomEnabled: boolean;
  59395. private _rebuildBloom;
  59396. /**
  59397. * If the depth of field is enabled.
  59398. */
  59399. depthOfFieldEnabled: boolean;
  59400. /**
  59401. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59402. */
  59403. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59404. /**
  59405. * If the anti aliasing is enabled.
  59406. */
  59407. fxaaEnabled: boolean;
  59408. private _samples;
  59409. /**
  59410. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59411. */
  59412. samples: number;
  59413. /**
  59414. * If image processing is enabled.
  59415. */
  59416. imageProcessingEnabled: boolean;
  59417. /**
  59418. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59419. */
  59420. glowLayerEnabled: boolean;
  59421. /**
  59422. * Gets the glow layer (or null if not defined)
  59423. */
  59424. readonly glowLayer: Nullable<GlowLayer>;
  59425. /**
  59426. * Enable or disable the chromaticAberration process from the pipeline
  59427. */
  59428. chromaticAberrationEnabled: boolean;
  59429. /**
  59430. * Enable or disable the grain process from the pipeline
  59431. */
  59432. grainEnabled: boolean;
  59433. /**
  59434. * @constructor
  59435. * @param name - The rendering pipeline name (default: "")
  59436. * @param hdr - If high dynamic range textures should be used (default: true)
  59437. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59438. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59439. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59440. */
  59441. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59442. /**
  59443. * Get the class name
  59444. * @returns "DefaultRenderingPipeline"
  59445. */
  59446. getClassName(): string;
  59447. /**
  59448. * Force the compilation of the entire pipeline.
  59449. */
  59450. prepare(): void;
  59451. private _hasCleared;
  59452. private _prevPostProcess;
  59453. private _prevPrevPostProcess;
  59454. private _setAutoClearAndTextureSharing;
  59455. private _depthOfFieldSceneObserver;
  59456. private _buildPipeline;
  59457. private _disposePostProcesses;
  59458. /**
  59459. * Adds a camera to the pipeline
  59460. * @param camera the camera to be added
  59461. */
  59462. addCamera(camera: Camera): void;
  59463. /**
  59464. * Removes a camera from the pipeline
  59465. * @param camera the camera to remove
  59466. */
  59467. removeCamera(camera: Camera): void;
  59468. /**
  59469. * Dispose of the pipeline and stop all post processes
  59470. */
  59471. dispose(): void;
  59472. /**
  59473. * Serialize the rendering pipeline (Used when exporting)
  59474. * @returns the serialized object
  59475. */
  59476. serialize(): any;
  59477. /**
  59478. * Parse the serialized pipeline
  59479. * @param source Source pipeline.
  59480. * @param scene The scene to load the pipeline to.
  59481. * @param rootUrl The URL of the serialized pipeline.
  59482. * @returns An instantiated pipeline from the serialized object.
  59483. */
  59484. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59485. }
  59486. }
  59487. declare module BABYLON {
  59488. /** @hidden */
  59489. export var lensHighlightsPixelShader: {
  59490. name: string;
  59491. shader: string;
  59492. };
  59493. }
  59494. declare module BABYLON {
  59495. /** @hidden */
  59496. export var depthOfFieldPixelShader: {
  59497. name: string;
  59498. shader: string;
  59499. };
  59500. }
  59501. declare module BABYLON {
  59502. /**
  59503. * BABYLON.JS Chromatic Aberration GLSL Shader
  59504. * Author: Olivier Guyot
  59505. * Separates very slightly R, G and B colors on the edges of the screen
  59506. * Inspired by Francois Tarlier & Martins Upitis
  59507. */
  59508. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59509. /**
  59510. * @ignore
  59511. * The chromatic aberration PostProcess id in the pipeline
  59512. */
  59513. LensChromaticAberrationEffect: string;
  59514. /**
  59515. * @ignore
  59516. * The highlights enhancing PostProcess id in the pipeline
  59517. */
  59518. HighlightsEnhancingEffect: string;
  59519. /**
  59520. * @ignore
  59521. * The depth-of-field PostProcess id in the pipeline
  59522. */
  59523. LensDepthOfFieldEffect: string;
  59524. private _scene;
  59525. private _depthTexture;
  59526. private _grainTexture;
  59527. private _chromaticAberrationPostProcess;
  59528. private _highlightsPostProcess;
  59529. private _depthOfFieldPostProcess;
  59530. private _edgeBlur;
  59531. private _grainAmount;
  59532. private _chromaticAberration;
  59533. private _distortion;
  59534. private _highlightsGain;
  59535. private _highlightsThreshold;
  59536. private _dofDistance;
  59537. private _dofAperture;
  59538. private _dofDarken;
  59539. private _dofPentagon;
  59540. private _blurNoise;
  59541. /**
  59542. * @constructor
  59543. *
  59544. * Effect parameters are as follow:
  59545. * {
  59546. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59547. * edge_blur: number; // from 0 to x (1 for realism)
  59548. * distortion: number; // from 0 to x (1 for realism)
  59549. * grain_amount: number; // from 0 to 1
  59550. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59551. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59552. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59553. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59554. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59555. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59556. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59557. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59558. * }
  59559. * Note: if an effect parameter is unset, effect is disabled
  59560. *
  59561. * @param name The rendering pipeline name
  59562. * @param parameters - An object containing all parameters (see above)
  59563. * @param scene The scene linked to this pipeline
  59564. * @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)
  59565. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59566. */
  59567. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59568. /**
  59569. * Get the class name
  59570. * @returns "LensRenderingPipeline"
  59571. */
  59572. getClassName(): string;
  59573. /**
  59574. * Gets associated scene
  59575. */
  59576. readonly scene: Scene;
  59577. /**
  59578. * Gets or sets the edge blur
  59579. */
  59580. edgeBlur: number;
  59581. /**
  59582. * Gets or sets the grain amount
  59583. */
  59584. grainAmount: number;
  59585. /**
  59586. * Gets or sets the chromatic aberration amount
  59587. */
  59588. chromaticAberration: number;
  59589. /**
  59590. * Gets or sets the depth of field aperture
  59591. */
  59592. dofAperture: number;
  59593. /**
  59594. * Gets or sets the edge distortion
  59595. */
  59596. edgeDistortion: number;
  59597. /**
  59598. * Gets or sets the depth of field distortion
  59599. */
  59600. dofDistortion: number;
  59601. /**
  59602. * Gets or sets the darken out of focus amount
  59603. */
  59604. darkenOutOfFocus: number;
  59605. /**
  59606. * Gets or sets a boolean indicating if blur noise is enabled
  59607. */
  59608. blurNoise: boolean;
  59609. /**
  59610. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59611. */
  59612. pentagonBokeh: boolean;
  59613. /**
  59614. * Gets or sets the highlight grain amount
  59615. */
  59616. highlightsGain: number;
  59617. /**
  59618. * Gets or sets the highlight threshold
  59619. */
  59620. highlightsThreshold: number;
  59621. /**
  59622. * Sets the amount of blur at the edges
  59623. * @param amount blur amount
  59624. */
  59625. setEdgeBlur(amount: number): void;
  59626. /**
  59627. * Sets edge blur to 0
  59628. */
  59629. disableEdgeBlur(): void;
  59630. /**
  59631. * Sets the amout of grain
  59632. * @param amount Amount of grain
  59633. */
  59634. setGrainAmount(amount: number): void;
  59635. /**
  59636. * Set grain amount to 0
  59637. */
  59638. disableGrain(): void;
  59639. /**
  59640. * Sets the chromatic aberration amount
  59641. * @param amount amount of chromatic aberration
  59642. */
  59643. setChromaticAberration(amount: number): void;
  59644. /**
  59645. * Sets chromatic aberration amount to 0
  59646. */
  59647. disableChromaticAberration(): void;
  59648. /**
  59649. * Sets the EdgeDistortion amount
  59650. * @param amount amount of EdgeDistortion
  59651. */
  59652. setEdgeDistortion(amount: number): void;
  59653. /**
  59654. * Sets edge distortion to 0
  59655. */
  59656. disableEdgeDistortion(): void;
  59657. /**
  59658. * Sets the FocusDistance amount
  59659. * @param amount amount of FocusDistance
  59660. */
  59661. setFocusDistance(amount: number): void;
  59662. /**
  59663. * Disables depth of field
  59664. */
  59665. disableDepthOfField(): void;
  59666. /**
  59667. * Sets the Aperture amount
  59668. * @param amount amount of Aperture
  59669. */
  59670. setAperture(amount: number): void;
  59671. /**
  59672. * Sets the DarkenOutOfFocus amount
  59673. * @param amount amount of DarkenOutOfFocus
  59674. */
  59675. setDarkenOutOfFocus(amount: number): void;
  59676. private _pentagonBokehIsEnabled;
  59677. /**
  59678. * Creates a pentagon bokeh effect
  59679. */
  59680. enablePentagonBokeh(): void;
  59681. /**
  59682. * Disables the pentagon bokeh effect
  59683. */
  59684. disablePentagonBokeh(): void;
  59685. /**
  59686. * Enables noise blur
  59687. */
  59688. enableNoiseBlur(): void;
  59689. /**
  59690. * Disables noise blur
  59691. */
  59692. disableNoiseBlur(): void;
  59693. /**
  59694. * Sets the HighlightsGain amount
  59695. * @param amount amount of HighlightsGain
  59696. */
  59697. setHighlightsGain(amount: number): void;
  59698. /**
  59699. * Sets the HighlightsThreshold amount
  59700. * @param amount amount of HighlightsThreshold
  59701. */
  59702. setHighlightsThreshold(amount: number): void;
  59703. /**
  59704. * Disables highlights
  59705. */
  59706. disableHighlights(): void;
  59707. /**
  59708. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59709. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59710. */
  59711. dispose(disableDepthRender?: boolean): void;
  59712. private _createChromaticAberrationPostProcess;
  59713. private _createHighlightsPostProcess;
  59714. private _createDepthOfFieldPostProcess;
  59715. private _createGrainTexture;
  59716. }
  59717. }
  59718. declare module BABYLON {
  59719. /** @hidden */
  59720. export var ssao2PixelShader: {
  59721. name: string;
  59722. shader: string;
  59723. };
  59724. }
  59725. declare module BABYLON {
  59726. /** @hidden */
  59727. export var ssaoCombinePixelShader: {
  59728. name: string;
  59729. shader: string;
  59730. };
  59731. }
  59732. declare module BABYLON {
  59733. /**
  59734. * Render pipeline to produce ssao effect
  59735. */
  59736. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59737. /**
  59738. * @ignore
  59739. * The PassPostProcess id in the pipeline that contains the original scene color
  59740. */
  59741. SSAOOriginalSceneColorEffect: string;
  59742. /**
  59743. * @ignore
  59744. * The SSAO PostProcess id in the pipeline
  59745. */
  59746. SSAORenderEffect: string;
  59747. /**
  59748. * @ignore
  59749. * The horizontal blur PostProcess id in the pipeline
  59750. */
  59751. SSAOBlurHRenderEffect: string;
  59752. /**
  59753. * @ignore
  59754. * The vertical blur PostProcess id in the pipeline
  59755. */
  59756. SSAOBlurVRenderEffect: string;
  59757. /**
  59758. * @ignore
  59759. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59760. */
  59761. SSAOCombineRenderEffect: string;
  59762. /**
  59763. * The output strength of the SSAO post-process. Default value is 1.0.
  59764. */
  59765. totalStrength: number;
  59766. /**
  59767. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59768. */
  59769. maxZ: number;
  59770. /**
  59771. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59772. */
  59773. minZAspect: number;
  59774. private _samples;
  59775. /**
  59776. * Number of samples used for the SSAO calculations. Default value is 8
  59777. */
  59778. samples: number;
  59779. private _textureSamples;
  59780. /**
  59781. * Number of samples to use for antialiasing
  59782. */
  59783. textureSamples: number;
  59784. /**
  59785. * Ratio object used for SSAO ratio and blur ratio
  59786. */
  59787. private _ratio;
  59788. /**
  59789. * Dynamically generated sphere sampler.
  59790. */
  59791. private _sampleSphere;
  59792. /**
  59793. * Blur filter offsets
  59794. */
  59795. private _samplerOffsets;
  59796. private _expensiveBlur;
  59797. /**
  59798. * If bilateral blur should be used
  59799. */
  59800. expensiveBlur: boolean;
  59801. /**
  59802. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59803. */
  59804. radius: number;
  59805. /**
  59806. * The base color of the SSAO post-process
  59807. * The final result is "base + ssao" between [0, 1]
  59808. */
  59809. base: number;
  59810. /**
  59811. * Support test.
  59812. */
  59813. static readonly IsSupported: boolean;
  59814. private _scene;
  59815. private _depthTexture;
  59816. private _normalTexture;
  59817. private _randomTexture;
  59818. private _originalColorPostProcess;
  59819. private _ssaoPostProcess;
  59820. private _blurHPostProcess;
  59821. private _blurVPostProcess;
  59822. private _ssaoCombinePostProcess;
  59823. private _firstUpdate;
  59824. /**
  59825. * Gets active scene
  59826. */
  59827. readonly scene: Scene;
  59828. /**
  59829. * @constructor
  59830. * @param name The rendering pipeline name
  59831. * @param scene The scene linked to this pipeline
  59832. * @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 }
  59833. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59834. */
  59835. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59836. /**
  59837. * Get the class name
  59838. * @returns "SSAO2RenderingPipeline"
  59839. */
  59840. getClassName(): string;
  59841. /**
  59842. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59843. */
  59844. dispose(disableGeometryBufferRenderer?: boolean): void;
  59845. private _createBlurPostProcess;
  59846. /** @hidden */
  59847. _rebuild(): void;
  59848. private _bits;
  59849. private _radicalInverse_VdC;
  59850. private _hammersley;
  59851. private _hemisphereSample_uniform;
  59852. private _generateHemisphere;
  59853. private _createSSAOPostProcess;
  59854. private _createSSAOCombinePostProcess;
  59855. private _createRandomTexture;
  59856. /**
  59857. * Serialize the rendering pipeline (Used when exporting)
  59858. * @returns the serialized object
  59859. */
  59860. serialize(): any;
  59861. /**
  59862. * Parse the serialized pipeline
  59863. * @param source Source pipeline.
  59864. * @param scene The scene to load the pipeline to.
  59865. * @param rootUrl The URL of the serialized pipeline.
  59866. * @returns An instantiated pipeline from the serialized object.
  59867. */
  59868. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59869. }
  59870. }
  59871. declare module BABYLON {
  59872. /** @hidden */
  59873. export var ssaoPixelShader: {
  59874. name: string;
  59875. shader: string;
  59876. };
  59877. }
  59878. declare module BABYLON {
  59879. /**
  59880. * Render pipeline to produce ssao effect
  59881. */
  59882. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59883. /**
  59884. * @ignore
  59885. * The PassPostProcess id in the pipeline that contains the original scene color
  59886. */
  59887. SSAOOriginalSceneColorEffect: string;
  59888. /**
  59889. * @ignore
  59890. * The SSAO PostProcess id in the pipeline
  59891. */
  59892. SSAORenderEffect: string;
  59893. /**
  59894. * @ignore
  59895. * The horizontal blur PostProcess id in the pipeline
  59896. */
  59897. SSAOBlurHRenderEffect: string;
  59898. /**
  59899. * @ignore
  59900. * The vertical blur PostProcess id in the pipeline
  59901. */
  59902. SSAOBlurVRenderEffect: string;
  59903. /**
  59904. * @ignore
  59905. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59906. */
  59907. SSAOCombineRenderEffect: string;
  59908. /**
  59909. * The output strength of the SSAO post-process. Default value is 1.0.
  59910. */
  59911. totalStrength: number;
  59912. /**
  59913. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59914. */
  59915. radius: number;
  59916. /**
  59917. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59918. * Must not be equal to fallOff and superior to fallOff.
  59919. * Default value is 0.0075
  59920. */
  59921. area: number;
  59922. /**
  59923. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59924. * Must not be equal to area and inferior to area.
  59925. * Default value is 0.000001
  59926. */
  59927. fallOff: number;
  59928. /**
  59929. * The base color of the SSAO post-process
  59930. * The final result is "base + ssao" between [0, 1]
  59931. */
  59932. base: number;
  59933. private _scene;
  59934. private _depthTexture;
  59935. private _randomTexture;
  59936. private _originalColorPostProcess;
  59937. private _ssaoPostProcess;
  59938. private _blurHPostProcess;
  59939. private _blurVPostProcess;
  59940. private _ssaoCombinePostProcess;
  59941. private _firstUpdate;
  59942. /**
  59943. * Gets active scene
  59944. */
  59945. readonly scene: Scene;
  59946. /**
  59947. * @constructor
  59948. * @param name - The rendering pipeline name
  59949. * @param scene - The scene linked to this pipeline
  59950. * @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 }
  59951. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59952. */
  59953. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59954. /**
  59955. * Get the class name
  59956. * @returns "SSAORenderingPipeline"
  59957. */
  59958. getClassName(): string;
  59959. /**
  59960. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59961. */
  59962. dispose(disableDepthRender?: boolean): void;
  59963. private _createBlurPostProcess;
  59964. /** @hidden */
  59965. _rebuild(): void;
  59966. private _createSSAOPostProcess;
  59967. private _createSSAOCombinePostProcess;
  59968. private _createRandomTexture;
  59969. }
  59970. }
  59971. declare module BABYLON {
  59972. /** @hidden */
  59973. export var standardPixelShader: {
  59974. name: string;
  59975. shader: string;
  59976. };
  59977. }
  59978. declare module BABYLON {
  59979. /**
  59980. * Standard rendering pipeline
  59981. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59982. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59983. */
  59984. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59985. /**
  59986. * Public members
  59987. */
  59988. /**
  59989. * Post-process which contains the original scene color before the pipeline applies all the effects
  59990. */
  59991. originalPostProcess: Nullable<PostProcess>;
  59992. /**
  59993. * Post-process used to down scale an image x4
  59994. */
  59995. downSampleX4PostProcess: Nullable<PostProcess>;
  59996. /**
  59997. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59998. */
  59999. brightPassPostProcess: Nullable<PostProcess>;
  60000. /**
  60001. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60002. */
  60003. blurHPostProcesses: PostProcess[];
  60004. /**
  60005. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60006. */
  60007. blurVPostProcesses: PostProcess[];
  60008. /**
  60009. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60010. */
  60011. textureAdderPostProcess: Nullable<PostProcess>;
  60012. /**
  60013. * Post-process used to create volumetric lighting effect
  60014. */
  60015. volumetricLightPostProcess: Nullable<PostProcess>;
  60016. /**
  60017. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60018. */
  60019. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60020. /**
  60021. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60022. */
  60023. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60024. /**
  60025. * Post-process used to merge the volumetric light effect and the real scene color
  60026. */
  60027. volumetricLightMergePostProces: Nullable<PostProcess>;
  60028. /**
  60029. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60030. */
  60031. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60032. /**
  60033. * Base post-process used to calculate the average luminance of the final image for HDR
  60034. */
  60035. luminancePostProcess: Nullable<PostProcess>;
  60036. /**
  60037. * Post-processes used to create down sample post-processes in order to get
  60038. * the average luminance of the final image for HDR
  60039. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60040. */
  60041. luminanceDownSamplePostProcesses: PostProcess[];
  60042. /**
  60043. * Post-process used to create a HDR effect (light adaptation)
  60044. */
  60045. hdrPostProcess: Nullable<PostProcess>;
  60046. /**
  60047. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60048. */
  60049. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60050. /**
  60051. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60052. */
  60053. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60054. /**
  60055. * Post-process used to merge the final HDR post-process and the real scene color
  60056. */
  60057. hdrFinalPostProcess: Nullable<PostProcess>;
  60058. /**
  60059. * Post-process used to create a lens flare effect
  60060. */
  60061. lensFlarePostProcess: Nullable<PostProcess>;
  60062. /**
  60063. * Post-process that merges the result of the lens flare post-process and the real scene color
  60064. */
  60065. lensFlareComposePostProcess: Nullable<PostProcess>;
  60066. /**
  60067. * Post-process used to create a motion blur effect
  60068. */
  60069. motionBlurPostProcess: Nullable<PostProcess>;
  60070. /**
  60071. * Post-process used to create a depth of field effect
  60072. */
  60073. depthOfFieldPostProcess: Nullable<PostProcess>;
  60074. /**
  60075. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60076. */
  60077. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60078. /**
  60079. * Represents the brightness threshold in order to configure the illuminated surfaces
  60080. */
  60081. brightThreshold: number;
  60082. /**
  60083. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60084. */
  60085. blurWidth: number;
  60086. /**
  60087. * Sets if the blur for highlighted surfaces must be only horizontal
  60088. */
  60089. horizontalBlur: boolean;
  60090. /**
  60091. * Gets the overall exposure used by the pipeline
  60092. */
  60093. /**
  60094. * Sets the overall exposure used by the pipeline
  60095. */
  60096. exposure: number;
  60097. /**
  60098. * Texture used typically to simulate "dirty" on camera lens
  60099. */
  60100. lensTexture: Nullable<Texture>;
  60101. /**
  60102. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60103. */
  60104. volumetricLightCoefficient: number;
  60105. /**
  60106. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60107. */
  60108. volumetricLightPower: number;
  60109. /**
  60110. * Used the set the blur intensity to smooth the volumetric lights
  60111. */
  60112. volumetricLightBlurScale: number;
  60113. /**
  60114. * Light (spot or directional) used to generate the volumetric lights rays
  60115. * The source light must have a shadow generate so the pipeline can get its
  60116. * depth map
  60117. */
  60118. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60119. /**
  60120. * For eye adaptation, represents the minimum luminance the eye can see
  60121. */
  60122. hdrMinimumLuminance: number;
  60123. /**
  60124. * For eye adaptation, represents the decrease luminance speed
  60125. */
  60126. hdrDecreaseRate: number;
  60127. /**
  60128. * For eye adaptation, represents the increase luminance speed
  60129. */
  60130. hdrIncreaseRate: number;
  60131. /**
  60132. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60133. */
  60134. /**
  60135. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60136. */
  60137. hdrAutoExposure: boolean;
  60138. /**
  60139. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60140. */
  60141. lensColorTexture: Nullable<Texture>;
  60142. /**
  60143. * The overall strengh for the lens flare effect
  60144. */
  60145. lensFlareStrength: number;
  60146. /**
  60147. * Dispersion coefficient for lens flare ghosts
  60148. */
  60149. lensFlareGhostDispersal: number;
  60150. /**
  60151. * Main lens flare halo width
  60152. */
  60153. lensFlareHaloWidth: number;
  60154. /**
  60155. * Based on the lens distortion effect, defines how much the lens flare result
  60156. * is distorted
  60157. */
  60158. lensFlareDistortionStrength: number;
  60159. /**
  60160. * Configures the blur intensity used for for lens flare (halo)
  60161. */
  60162. lensFlareBlurWidth: number;
  60163. /**
  60164. * Lens star texture must be used to simulate rays on the flares and is available
  60165. * in the documentation
  60166. */
  60167. lensStarTexture: Nullable<Texture>;
  60168. /**
  60169. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60170. * flare effect by taking account of the dirt texture
  60171. */
  60172. lensFlareDirtTexture: Nullable<Texture>;
  60173. /**
  60174. * Represents the focal length for the depth of field effect
  60175. */
  60176. depthOfFieldDistance: number;
  60177. /**
  60178. * Represents the blur intensity for the blurred part of the depth of field effect
  60179. */
  60180. depthOfFieldBlurWidth: number;
  60181. /**
  60182. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60183. */
  60184. /**
  60185. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60186. */
  60187. motionStrength: number;
  60188. /**
  60189. * Gets wether or not the motion blur post-process is object based or screen based.
  60190. */
  60191. /**
  60192. * Sets wether or not the motion blur post-process should be object based or screen based
  60193. */
  60194. objectBasedMotionBlur: boolean;
  60195. /**
  60196. * List of animations for the pipeline (IAnimatable implementation)
  60197. */
  60198. animations: Animation[];
  60199. /**
  60200. * Private members
  60201. */
  60202. private _scene;
  60203. private _currentDepthOfFieldSource;
  60204. private _basePostProcess;
  60205. private _fixedExposure;
  60206. private _currentExposure;
  60207. private _hdrAutoExposure;
  60208. private _hdrCurrentLuminance;
  60209. private _motionStrength;
  60210. private _isObjectBasedMotionBlur;
  60211. private _floatTextureType;
  60212. private _camerasToBeAttached;
  60213. private _ratio;
  60214. private _bloomEnabled;
  60215. private _depthOfFieldEnabled;
  60216. private _vlsEnabled;
  60217. private _lensFlareEnabled;
  60218. private _hdrEnabled;
  60219. private _motionBlurEnabled;
  60220. private _fxaaEnabled;
  60221. private _motionBlurSamples;
  60222. private _volumetricLightStepsCount;
  60223. private _samples;
  60224. /**
  60225. * @ignore
  60226. * Specifies if the bloom pipeline is enabled
  60227. */
  60228. BloomEnabled: boolean;
  60229. /**
  60230. * @ignore
  60231. * Specifies if the depth of field pipeline is enabed
  60232. */
  60233. DepthOfFieldEnabled: boolean;
  60234. /**
  60235. * @ignore
  60236. * Specifies if the lens flare pipeline is enabed
  60237. */
  60238. LensFlareEnabled: boolean;
  60239. /**
  60240. * @ignore
  60241. * Specifies if the HDR pipeline is enabled
  60242. */
  60243. HDREnabled: boolean;
  60244. /**
  60245. * @ignore
  60246. * Specifies if the volumetric lights scattering effect is enabled
  60247. */
  60248. VLSEnabled: boolean;
  60249. /**
  60250. * @ignore
  60251. * Specifies if the motion blur effect is enabled
  60252. */
  60253. MotionBlurEnabled: boolean;
  60254. /**
  60255. * Specifies if anti-aliasing is enabled
  60256. */
  60257. fxaaEnabled: boolean;
  60258. /**
  60259. * Specifies the number of steps used to calculate the volumetric lights
  60260. * Typically in interval [50, 200]
  60261. */
  60262. volumetricLightStepsCount: number;
  60263. /**
  60264. * Specifies the number of samples used for the motion blur effect
  60265. * Typically in interval [16, 64]
  60266. */
  60267. motionBlurSamples: number;
  60268. /**
  60269. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60270. */
  60271. samples: number;
  60272. /**
  60273. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60274. * @constructor
  60275. * @param name The rendering pipeline name
  60276. * @param scene The scene linked to this pipeline
  60277. * @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)
  60278. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60279. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60280. */
  60281. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60282. private _buildPipeline;
  60283. private _createDownSampleX4PostProcess;
  60284. private _createBrightPassPostProcess;
  60285. private _createBlurPostProcesses;
  60286. private _createTextureAdderPostProcess;
  60287. private _createVolumetricLightPostProcess;
  60288. private _createLuminancePostProcesses;
  60289. private _createHdrPostProcess;
  60290. private _createLensFlarePostProcess;
  60291. private _createDepthOfFieldPostProcess;
  60292. private _createMotionBlurPostProcess;
  60293. private _getDepthTexture;
  60294. private _disposePostProcesses;
  60295. /**
  60296. * Dispose of the pipeline and stop all post processes
  60297. */
  60298. dispose(): void;
  60299. /**
  60300. * Serialize the rendering pipeline (Used when exporting)
  60301. * @returns the serialized object
  60302. */
  60303. serialize(): any;
  60304. /**
  60305. * Parse the serialized pipeline
  60306. * @param source Source pipeline.
  60307. * @param scene The scene to load the pipeline to.
  60308. * @param rootUrl The URL of the serialized pipeline.
  60309. * @returns An instantiated pipeline from the serialized object.
  60310. */
  60311. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60312. /**
  60313. * Luminance steps
  60314. */
  60315. static LuminanceSteps: number;
  60316. }
  60317. }
  60318. declare module BABYLON {
  60319. /** @hidden */
  60320. export var tonemapPixelShader: {
  60321. name: string;
  60322. shader: string;
  60323. };
  60324. }
  60325. declare module BABYLON {
  60326. /** Defines operator used for tonemapping */
  60327. export enum TonemappingOperator {
  60328. /** Hable */
  60329. Hable = 0,
  60330. /** Reinhard */
  60331. Reinhard = 1,
  60332. /** HejiDawson */
  60333. HejiDawson = 2,
  60334. /** Photographic */
  60335. Photographic = 3
  60336. }
  60337. /**
  60338. * Defines a post process to apply tone mapping
  60339. */
  60340. export class TonemapPostProcess extends PostProcess {
  60341. private _operator;
  60342. /** Defines the required exposure adjustement */
  60343. exposureAdjustment: number;
  60344. /**
  60345. * Creates a new TonemapPostProcess
  60346. * @param name defines the name of the postprocess
  60347. * @param _operator defines the operator to use
  60348. * @param exposureAdjustment defines the required exposure adjustement
  60349. * @param camera defines the camera to use (can be null)
  60350. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60351. * @param engine defines the hosting engine (can be ignore if camera is set)
  60352. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60353. */
  60354. constructor(name: string, _operator: TonemappingOperator,
  60355. /** Defines the required exposure adjustement */
  60356. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60357. }
  60358. }
  60359. declare module BABYLON {
  60360. /** @hidden */
  60361. export var depthVertexShader: {
  60362. name: string;
  60363. shader: string;
  60364. };
  60365. }
  60366. declare module BABYLON {
  60367. /** @hidden */
  60368. export var volumetricLightScatteringPixelShader: {
  60369. name: string;
  60370. shader: string;
  60371. };
  60372. }
  60373. declare module BABYLON {
  60374. /** @hidden */
  60375. export var volumetricLightScatteringPassVertexShader: {
  60376. name: string;
  60377. shader: string;
  60378. };
  60379. }
  60380. declare module BABYLON {
  60381. /** @hidden */
  60382. export var volumetricLightScatteringPassPixelShader: {
  60383. name: string;
  60384. shader: string;
  60385. };
  60386. }
  60387. declare module BABYLON {
  60388. /**
  60389. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60390. */
  60391. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60392. private _volumetricLightScatteringPass;
  60393. private _volumetricLightScatteringRTT;
  60394. private _viewPort;
  60395. private _screenCoordinates;
  60396. private _cachedDefines;
  60397. /**
  60398. * If not undefined, the mesh position is computed from the attached node position
  60399. */
  60400. attachedNode: {
  60401. position: Vector3;
  60402. };
  60403. /**
  60404. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60405. */
  60406. customMeshPosition: Vector3;
  60407. /**
  60408. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60409. */
  60410. useCustomMeshPosition: boolean;
  60411. /**
  60412. * If the post-process should inverse the light scattering direction
  60413. */
  60414. invert: boolean;
  60415. /**
  60416. * The internal mesh used by the post-process
  60417. */
  60418. mesh: Mesh;
  60419. /**
  60420. * @hidden
  60421. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60422. */
  60423. useDiffuseColor: boolean;
  60424. /**
  60425. * Array containing the excluded meshes not rendered in the internal pass
  60426. */
  60427. excludedMeshes: AbstractMesh[];
  60428. /**
  60429. * Controls the overall intensity of the post-process
  60430. */
  60431. exposure: number;
  60432. /**
  60433. * Dissipates each sample's contribution in range [0, 1]
  60434. */
  60435. decay: number;
  60436. /**
  60437. * Controls the overall intensity of each sample
  60438. */
  60439. weight: number;
  60440. /**
  60441. * Controls the density of each sample
  60442. */
  60443. density: number;
  60444. /**
  60445. * @constructor
  60446. * @param name The post-process name
  60447. * @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)
  60448. * @param camera The camera that the post-process will be attached to
  60449. * @param mesh The mesh used to create the light scattering
  60450. * @param samples The post-process quality, default 100
  60451. * @param samplingModeThe post-process filtering mode
  60452. * @param engine The babylon engine
  60453. * @param reusable If the post-process is reusable
  60454. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60455. */
  60456. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60457. /**
  60458. * Returns the string "VolumetricLightScatteringPostProcess"
  60459. * @returns "VolumetricLightScatteringPostProcess"
  60460. */
  60461. getClassName(): string;
  60462. private _isReady;
  60463. /**
  60464. * Sets the new light position for light scattering effect
  60465. * @param position The new custom light position
  60466. */
  60467. setCustomMeshPosition(position: Vector3): void;
  60468. /**
  60469. * Returns the light position for light scattering effect
  60470. * @return Vector3 The custom light position
  60471. */
  60472. getCustomMeshPosition(): Vector3;
  60473. /**
  60474. * Disposes the internal assets and detaches the post-process from the camera
  60475. */
  60476. dispose(camera: Camera): void;
  60477. /**
  60478. * Returns the render target texture used by the post-process
  60479. * @return the render target texture used by the post-process
  60480. */
  60481. getPass(): RenderTargetTexture;
  60482. private _meshExcluded;
  60483. private _createPass;
  60484. private _updateMeshScreenCoordinates;
  60485. /**
  60486. * Creates a default mesh for the Volumeric Light Scattering post-process
  60487. * @param name The mesh name
  60488. * @param scene The scene where to create the mesh
  60489. * @return the default mesh
  60490. */
  60491. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60492. }
  60493. }
  60494. declare module BABYLON {
  60495. interface Scene {
  60496. /** @hidden (Backing field) */
  60497. _boundingBoxRenderer: BoundingBoxRenderer;
  60498. /** @hidden (Backing field) */
  60499. _forceShowBoundingBoxes: boolean;
  60500. /**
  60501. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60502. */
  60503. forceShowBoundingBoxes: boolean;
  60504. /**
  60505. * Gets the bounding box renderer associated with the scene
  60506. * @returns a BoundingBoxRenderer
  60507. */
  60508. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60509. }
  60510. interface AbstractMesh {
  60511. /** @hidden (Backing field) */
  60512. _showBoundingBox: boolean;
  60513. /**
  60514. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60515. */
  60516. showBoundingBox: boolean;
  60517. }
  60518. /**
  60519. * Component responsible of rendering the bounding box of the meshes in a scene.
  60520. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60521. */
  60522. export class BoundingBoxRenderer implements ISceneComponent {
  60523. /**
  60524. * The component name helpfull to identify the component in the list of scene components.
  60525. */
  60526. readonly name: string;
  60527. /**
  60528. * The scene the component belongs to.
  60529. */
  60530. scene: Scene;
  60531. /**
  60532. * Color of the bounding box lines placed in front of an object
  60533. */
  60534. frontColor: Color3;
  60535. /**
  60536. * Color of the bounding box lines placed behind an object
  60537. */
  60538. backColor: Color3;
  60539. /**
  60540. * Defines if the renderer should show the back lines or not
  60541. */
  60542. showBackLines: boolean;
  60543. /**
  60544. * @hidden
  60545. */
  60546. renderList: SmartArray<BoundingBox>;
  60547. private _colorShader;
  60548. private _vertexBuffers;
  60549. private _indexBuffer;
  60550. private _fillIndexBuffer;
  60551. private _fillIndexData;
  60552. /**
  60553. * Instantiates a new bounding box renderer in a scene.
  60554. * @param scene the scene the renderer renders in
  60555. */
  60556. constructor(scene: Scene);
  60557. /**
  60558. * Registers the component in a given scene
  60559. */
  60560. register(): void;
  60561. private _evaluateSubMesh;
  60562. private _activeMesh;
  60563. private _prepareRessources;
  60564. private _createIndexBuffer;
  60565. /**
  60566. * Rebuilds the elements related to this component in case of
  60567. * context lost for instance.
  60568. */
  60569. rebuild(): void;
  60570. /**
  60571. * @hidden
  60572. */
  60573. reset(): void;
  60574. /**
  60575. * Render the bounding boxes of a specific rendering group
  60576. * @param renderingGroupId defines the rendering group to render
  60577. */
  60578. render(renderingGroupId: number): void;
  60579. /**
  60580. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60581. * @param mesh Define the mesh to render the occlusion bounding box for
  60582. */
  60583. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60584. /**
  60585. * Dispose and release the resources attached to this renderer.
  60586. */
  60587. dispose(): void;
  60588. }
  60589. }
  60590. declare module BABYLON {
  60591. /** @hidden */
  60592. export var depthPixelShader: {
  60593. name: string;
  60594. shader: string;
  60595. };
  60596. }
  60597. declare module BABYLON {
  60598. /**
  60599. * This represents a depth renderer in Babylon.
  60600. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60601. */
  60602. export class DepthRenderer {
  60603. private _scene;
  60604. private _depthMap;
  60605. private _effect;
  60606. private readonly _storeNonLinearDepth;
  60607. private readonly _clearColor;
  60608. /** Get if the depth renderer is using packed depth or not */
  60609. readonly isPacked: boolean;
  60610. private _cachedDefines;
  60611. private _camera;
  60612. /**
  60613. * Specifiess that the depth renderer will only be used within
  60614. * the camera it is created for.
  60615. * This can help forcing its rendering during the camera processing.
  60616. */
  60617. useOnlyInActiveCamera: boolean;
  60618. /** @hidden */
  60619. static _SceneComponentInitialization: (scene: Scene) => void;
  60620. /**
  60621. * Instantiates a depth renderer
  60622. * @param scene The scene the renderer belongs to
  60623. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60624. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60625. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60626. */
  60627. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60628. /**
  60629. * Creates the depth rendering effect and checks if the effect is ready.
  60630. * @param subMesh The submesh to be used to render the depth map of
  60631. * @param useInstances If multiple world instances should be used
  60632. * @returns if the depth renderer is ready to render the depth map
  60633. */
  60634. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60635. /**
  60636. * Gets the texture which the depth map will be written to.
  60637. * @returns The depth map texture
  60638. */
  60639. getDepthMap(): RenderTargetTexture;
  60640. /**
  60641. * Disposes of the depth renderer.
  60642. */
  60643. dispose(): void;
  60644. }
  60645. }
  60646. declare module BABYLON {
  60647. interface Scene {
  60648. /** @hidden (Backing field) */
  60649. _depthRenderer: {
  60650. [id: string]: DepthRenderer;
  60651. };
  60652. /**
  60653. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60654. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60655. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60656. * @returns the created depth renderer
  60657. */
  60658. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60659. /**
  60660. * Disables a depth renderer for a given camera
  60661. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60662. */
  60663. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60664. }
  60665. /**
  60666. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60667. * in several rendering techniques.
  60668. */
  60669. export class DepthRendererSceneComponent implements ISceneComponent {
  60670. /**
  60671. * The component name helpfull to identify the component in the list of scene components.
  60672. */
  60673. readonly name: string;
  60674. /**
  60675. * The scene the component belongs to.
  60676. */
  60677. scene: Scene;
  60678. /**
  60679. * Creates a new instance of the component for the given scene
  60680. * @param scene Defines the scene to register the component in
  60681. */
  60682. constructor(scene: Scene);
  60683. /**
  60684. * Registers the component in a given scene
  60685. */
  60686. register(): void;
  60687. /**
  60688. * Rebuilds the elements related to this component in case of
  60689. * context lost for instance.
  60690. */
  60691. rebuild(): void;
  60692. /**
  60693. * Disposes the component and the associated ressources
  60694. */
  60695. dispose(): void;
  60696. private _gatherRenderTargets;
  60697. private _gatherActiveCameraRenderTargets;
  60698. }
  60699. }
  60700. declare module BABYLON {
  60701. /** @hidden */
  60702. export var outlinePixelShader: {
  60703. name: string;
  60704. shader: string;
  60705. };
  60706. }
  60707. declare module BABYLON {
  60708. /** @hidden */
  60709. export var outlineVertexShader: {
  60710. name: string;
  60711. shader: string;
  60712. };
  60713. }
  60714. declare module BABYLON {
  60715. interface Scene {
  60716. /** @hidden */
  60717. _outlineRenderer: OutlineRenderer;
  60718. /**
  60719. * Gets the outline renderer associated with the scene
  60720. * @returns a OutlineRenderer
  60721. */
  60722. getOutlineRenderer(): OutlineRenderer;
  60723. }
  60724. interface AbstractMesh {
  60725. /** @hidden (Backing field) */
  60726. _renderOutline: boolean;
  60727. /**
  60728. * Gets or sets a boolean indicating if the outline must be rendered as well
  60729. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60730. */
  60731. renderOutline: boolean;
  60732. /** @hidden (Backing field) */
  60733. _renderOverlay: boolean;
  60734. /**
  60735. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60736. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60737. */
  60738. renderOverlay: boolean;
  60739. }
  60740. /**
  60741. * This class is responsible to draw bothe outline/overlay of meshes.
  60742. * It should not be used directly but through the available method on mesh.
  60743. */
  60744. export class OutlineRenderer implements ISceneComponent {
  60745. /**
  60746. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60747. */
  60748. private static _StencilReference;
  60749. /**
  60750. * The name of the component. Each component must have a unique name.
  60751. */
  60752. name: string;
  60753. /**
  60754. * The scene the component belongs to.
  60755. */
  60756. scene: Scene;
  60757. /**
  60758. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60759. */
  60760. zOffset: number;
  60761. private _engine;
  60762. private _effect;
  60763. private _cachedDefines;
  60764. private _savedDepthWrite;
  60765. /**
  60766. * Instantiates a new outline renderer. (There could be only one per scene).
  60767. * @param scene Defines the scene it belongs to
  60768. */
  60769. constructor(scene: Scene);
  60770. /**
  60771. * Register the component to one instance of a scene.
  60772. */
  60773. register(): void;
  60774. /**
  60775. * Rebuilds the elements related to this component in case of
  60776. * context lost for instance.
  60777. */
  60778. rebuild(): void;
  60779. /**
  60780. * Disposes the component and the associated ressources.
  60781. */
  60782. dispose(): void;
  60783. /**
  60784. * Renders the outline in the canvas.
  60785. * @param subMesh Defines the sumesh to render
  60786. * @param batch Defines the batch of meshes in case of instances
  60787. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60788. */
  60789. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60790. /**
  60791. * Returns whether or not the outline renderer is ready for a given submesh.
  60792. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60793. * @param subMesh Defines the submesh to check readyness for
  60794. * @param useInstances Defines wheter wee are trying to render instances or not
  60795. * @returns true if ready otherwise false
  60796. */
  60797. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60798. private _beforeRenderingMesh;
  60799. private _afterRenderingMesh;
  60800. }
  60801. }
  60802. declare module BABYLON {
  60803. /**
  60804. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60805. * @see http://doc.babylonjs.com/babylon101/sprites
  60806. */
  60807. export class SpritePackedManager extends SpriteManager {
  60808. /** defines the packed manager's name */
  60809. name: string;
  60810. /**
  60811. * Creates a new sprite manager from a packed sprite sheet
  60812. * @param name defines the manager's name
  60813. * @param imgUrl defines the sprite sheet url
  60814. * @param capacity defines the maximum allowed number of sprites
  60815. * @param scene defines the hosting scene
  60816. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60817. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60818. * @param samplingMode defines the smapling mode to use with spritesheet
  60819. * @param fromPacked set to true; do not alter
  60820. */
  60821. constructor(
  60822. /** defines the packed manager's name */
  60823. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60824. }
  60825. }
  60826. declare module BABYLON {
  60827. /**
  60828. * Defines the list of states available for a task inside a AssetsManager
  60829. */
  60830. export enum AssetTaskState {
  60831. /**
  60832. * Initialization
  60833. */
  60834. INIT = 0,
  60835. /**
  60836. * Running
  60837. */
  60838. RUNNING = 1,
  60839. /**
  60840. * Done
  60841. */
  60842. DONE = 2,
  60843. /**
  60844. * Error
  60845. */
  60846. ERROR = 3
  60847. }
  60848. /**
  60849. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60850. */
  60851. export abstract class AbstractAssetTask {
  60852. /**
  60853. * Task name
  60854. */ name: string;
  60855. /**
  60856. * Callback called when the task is successful
  60857. */
  60858. onSuccess: (task: any) => void;
  60859. /**
  60860. * Callback called when the task is not successful
  60861. */
  60862. onError: (task: any, message?: string, exception?: any) => void;
  60863. /**
  60864. * Creates a new AssetsManager
  60865. * @param name defines the name of the task
  60866. */
  60867. constructor(
  60868. /**
  60869. * Task name
  60870. */ name: string);
  60871. private _isCompleted;
  60872. private _taskState;
  60873. private _errorObject;
  60874. /**
  60875. * Get if the task is completed
  60876. */
  60877. readonly isCompleted: boolean;
  60878. /**
  60879. * Gets the current state of the task
  60880. */
  60881. readonly taskState: AssetTaskState;
  60882. /**
  60883. * Gets the current error object (if task is in error)
  60884. */
  60885. readonly errorObject: {
  60886. message?: string;
  60887. exception?: any;
  60888. };
  60889. /**
  60890. * Internal only
  60891. * @hidden
  60892. */
  60893. _setErrorObject(message?: string, exception?: any): void;
  60894. /**
  60895. * Execute the current task
  60896. * @param scene defines the scene where you want your assets to be loaded
  60897. * @param onSuccess is a callback called when the task is successfully executed
  60898. * @param onError is a callback called if an error occurs
  60899. */
  60900. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60901. /**
  60902. * Execute the current task
  60903. * @param scene defines the scene where you want your assets to be loaded
  60904. * @param onSuccess is a callback called when the task is successfully executed
  60905. * @param onError is a callback called if an error occurs
  60906. */
  60907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60908. /**
  60909. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60910. * This can be used with failed tasks that have the reason for failure fixed.
  60911. */
  60912. reset(): void;
  60913. private onErrorCallback;
  60914. private onDoneCallback;
  60915. }
  60916. /**
  60917. * Define the interface used by progress events raised during assets loading
  60918. */
  60919. export interface IAssetsProgressEvent {
  60920. /**
  60921. * Defines the number of remaining tasks to process
  60922. */
  60923. remainingCount: number;
  60924. /**
  60925. * Defines the total number of tasks
  60926. */
  60927. totalCount: number;
  60928. /**
  60929. * Defines the task that was just processed
  60930. */
  60931. task: AbstractAssetTask;
  60932. }
  60933. /**
  60934. * Class used to share progress information about assets loading
  60935. */
  60936. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60937. /**
  60938. * Defines the number of remaining tasks to process
  60939. */
  60940. remainingCount: number;
  60941. /**
  60942. * Defines the total number of tasks
  60943. */
  60944. totalCount: number;
  60945. /**
  60946. * Defines the task that was just processed
  60947. */
  60948. task: AbstractAssetTask;
  60949. /**
  60950. * Creates a AssetsProgressEvent
  60951. * @param remainingCount defines the number of remaining tasks to process
  60952. * @param totalCount defines the total number of tasks
  60953. * @param task defines the task that was just processed
  60954. */
  60955. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60956. }
  60957. /**
  60958. * Define a task used by AssetsManager to load meshes
  60959. */
  60960. export class MeshAssetTask extends AbstractAssetTask {
  60961. /**
  60962. * Defines the name of the task
  60963. */
  60964. name: string;
  60965. /**
  60966. * Defines the list of mesh's names you want to load
  60967. */
  60968. meshesNames: any;
  60969. /**
  60970. * Defines the root url to use as a base to load your meshes and associated resources
  60971. */
  60972. rootUrl: string;
  60973. /**
  60974. * Defines the filename of the scene to load from
  60975. */
  60976. sceneFilename: string;
  60977. /**
  60978. * Gets the list of loaded meshes
  60979. */
  60980. loadedMeshes: Array<AbstractMesh>;
  60981. /**
  60982. * Gets the list of loaded particle systems
  60983. */
  60984. loadedParticleSystems: Array<IParticleSystem>;
  60985. /**
  60986. * Gets the list of loaded skeletons
  60987. */
  60988. loadedSkeletons: Array<Skeleton>;
  60989. /**
  60990. * Gets the list of loaded animation groups
  60991. */
  60992. loadedAnimationGroups: Array<AnimationGroup>;
  60993. /**
  60994. * Callback called when the task is successful
  60995. */
  60996. onSuccess: (task: MeshAssetTask) => void;
  60997. /**
  60998. * Callback called when the task is successful
  60999. */
  61000. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61001. /**
  61002. * Creates a new MeshAssetTask
  61003. * @param name defines the name of the task
  61004. * @param meshesNames defines the list of mesh's names you want to load
  61005. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61006. * @param sceneFilename defines the filename of the scene to load from
  61007. */
  61008. constructor(
  61009. /**
  61010. * Defines the name of the task
  61011. */
  61012. name: string,
  61013. /**
  61014. * Defines the list of mesh's names you want to load
  61015. */
  61016. meshesNames: any,
  61017. /**
  61018. * Defines the root url to use as a base to load your meshes and associated resources
  61019. */
  61020. rootUrl: string,
  61021. /**
  61022. * Defines the filename of the scene to load from
  61023. */
  61024. sceneFilename: string);
  61025. /**
  61026. * Execute the current task
  61027. * @param scene defines the scene where you want your assets to be loaded
  61028. * @param onSuccess is a callback called when the task is successfully executed
  61029. * @param onError is a callback called if an error occurs
  61030. */
  61031. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61032. }
  61033. /**
  61034. * Define a task used by AssetsManager to load text content
  61035. */
  61036. export class TextFileAssetTask extends AbstractAssetTask {
  61037. /**
  61038. * Defines the name of the task
  61039. */
  61040. name: string;
  61041. /**
  61042. * Defines the location of the file to load
  61043. */
  61044. url: string;
  61045. /**
  61046. * Gets the loaded text string
  61047. */
  61048. text: string;
  61049. /**
  61050. * Callback called when the task is successful
  61051. */
  61052. onSuccess: (task: TextFileAssetTask) => void;
  61053. /**
  61054. * Callback called when the task is successful
  61055. */
  61056. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61057. /**
  61058. * Creates a new TextFileAssetTask object
  61059. * @param name defines the name of the task
  61060. * @param url defines the location of the file to load
  61061. */
  61062. constructor(
  61063. /**
  61064. * Defines the name of the task
  61065. */
  61066. name: string,
  61067. /**
  61068. * Defines the location of the file to load
  61069. */
  61070. url: string);
  61071. /**
  61072. * Execute the current task
  61073. * @param scene defines the scene where you want your assets to be loaded
  61074. * @param onSuccess is a callback called when the task is successfully executed
  61075. * @param onError is a callback called if an error occurs
  61076. */
  61077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61078. }
  61079. /**
  61080. * Define a task used by AssetsManager to load binary data
  61081. */
  61082. export class BinaryFileAssetTask extends AbstractAssetTask {
  61083. /**
  61084. * Defines the name of the task
  61085. */
  61086. name: string;
  61087. /**
  61088. * Defines the location of the file to load
  61089. */
  61090. url: string;
  61091. /**
  61092. * Gets the lodaded data (as an array buffer)
  61093. */
  61094. data: ArrayBuffer;
  61095. /**
  61096. * Callback called when the task is successful
  61097. */
  61098. onSuccess: (task: BinaryFileAssetTask) => void;
  61099. /**
  61100. * Callback called when the task is successful
  61101. */
  61102. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61103. /**
  61104. * Creates a new BinaryFileAssetTask object
  61105. * @param name defines the name of the new task
  61106. * @param url defines the location of the file to load
  61107. */
  61108. constructor(
  61109. /**
  61110. * Defines the name of the task
  61111. */
  61112. name: string,
  61113. /**
  61114. * Defines the location of the file to load
  61115. */
  61116. url: string);
  61117. /**
  61118. * Execute the current task
  61119. * @param scene defines the scene where you want your assets to be loaded
  61120. * @param onSuccess is a callback called when the task is successfully executed
  61121. * @param onError is a callback called if an error occurs
  61122. */
  61123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61124. }
  61125. /**
  61126. * Define a task used by AssetsManager to load images
  61127. */
  61128. export class ImageAssetTask extends AbstractAssetTask {
  61129. /**
  61130. * Defines the name of the task
  61131. */
  61132. name: string;
  61133. /**
  61134. * Defines the location of the image to load
  61135. */
  61136. url: string;
  61137. /**
  61138. * Gets the loaded images
  61139. */
  61140. image: HTMLImageElement;
  61141. /**
  61142. * Callback called when the task is successful
  61143. */
  61144. onSuccess: (task: ImageAssetTask) => void;
  61145. /**
  61146. * Callback called when the task is successful
  61147. */
  61148. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61149. /**
  61150. * Creates a new ImageAssetTask
  61151. * @param name defines the name of the task
  61152. * @param url defines the location of the image to load
  61153. */
  61154. constructor(
  61155. /**
  61156. * Defines the name of the task
  61157. */
  61158. name: string,
  61159. /**
  61160. * Defines the location of the image to load
  61161. */
  61162. url: string);
  61163. /**
  61164. * Execute the current task
  61165. * @param scene defines the scene where you want your assets to be loaded
  61166. * @param onSuccess is a callback called when the task is successfully executed
  61167. * @param onError is a callback called if an error occurs
  61168. */
  61169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61170. }
  61171. /**
  61172. * Defines the interface used by texture loading tasks
  61173. */
  61174. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61175. /**
  61176. * Gets the loaded texture
  61177. */
  61178. texture: TEX;
  61179. }
  61180. /**
  61181. * Define a task used by AssetsManager to load 2D textures
  61182. */
  61183. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61184. /**
  61185. * Defines the name of the task
  61186. */
  61187. name: string;
  61188. /**
  61189. * Defines the location of the file to load
  61190. */
  61191. url: string;
  61192. /**
  61193. * Defines if mipmap should not be generated (default is false)
  61194. */
  61195. noMipmap?: boolean | undefined;
  61196. /**
  61197. * Defines if texture must be inverted on Y axis (default is false)
  61198. */
  61199. invertY?: boolean | undefined;
  61200. /**
  61201. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61202. */
  61203. samplingMode: number;
  61204. /**
  61205. * Gets the loaded texture
  61206. */
  61207. texture: Texture;
  61208. /**
  61209. * Callback called when the task is successful
  61210. */
  61211. onSuccess: (task: TextureAssetTask) => void;
  61212. /**
  61213. * Callback called when the task is successful
  61214. */
  61215. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61216. /**
  61217. * Creates a new TextureAssetTask object
  61218. * @param name defines the name of the task
  61219. * @param url defines the location of the file to load
  61220. * @param noMipmap defines if mipmap should not be generated (default is false)
  61221. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61222. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61223. */
  61224. constructor(
  61225. /**
  61226. * Defines the name of the task
  61227. */
  61228. name: string,
  61229. /**
  61230. * Defines the location of the file to load
  61231. */
  61232. url: string,
  61233. /**
  61234. * Defines if mipmap should not be generated (default is false)
  61235. */
  61236. noMipmap?: boolean | undefined,
  61237. /**
  61238. * Defines if texture must be inverted on Y axis (default is false)
  61239. */
  61240. invertY?: boolean | undefined,
  61241. /**
  61242. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61243. */
  61244. samplingMode?: number);
  61245. /**
  61246. * Execute the current task
  61247. * @param scene defines the scene where you want your assets to be loaded
  61248. * @param onSuccess is a callback called when the task is successfully executed
  61249. * @param onError is a callback called if an error occurs
  61250. */
  61251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61252. }
  61253. /**
  61254. * Define a task used by AssetsManager to load cube textures
  61255. */
  61256. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61257. /**
  61258. * Defines the name of the task
  61259. */
  61260. name: string;
  61261. /**
  61262. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61263. */
  61264. url: string;
  61265. /**
  61266. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61267. */
  61268. extensions?: string[] | undefined;
  61269. /**
  61270. * Defines if mipmaps should not be generated (default is false)
  61271. */
  61272. noMipmap?: boolean | undefined;
  61273. /**
  61274. * Defines the explicit list of files (undefined by default)
  61275. */
  61276. files?: string[] | undefined;
  61277. /**
  61278. * Gets the loaded texture
  61279. */
  61280. texture: CubeTexture;
  61281. /**
  61282. * Callback called when the task is successful
  61283. */
  61284. onSuccess: (task: CubeTextureAssetTask) => void;
  61285. /**
  61286. * Callback called when the task is successful
  61287. */
  61288. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61289. /**
  61290. * Creates a new CubeTextureAssetTask
  61291. * @param name defines the name of the task
  61292. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61293. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61294. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61295. * @param files defines the explicit list of files (undefined by default)
  61296. */
  61297. constructor(
  61298. /**
  61299. * Defines the name of the task
  61300. */
  61301. name: string,
  61302. /**
  61303. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61304. */
  61305. url: string,
  61306. /**
  61307. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61308. */
  61309. extensions?: string[] | undefined,
  61310. /**
  61311. * Defines if mipmaps should not be generated (default is false)
  61312. */
  61313. noMipmap?: boolean | undefined,
  61314. /**
  61315. * Defines the explicit list of files (undefined by default)
  61316. */
  61317. files?: string[] | undefined);
  61318. /**
  61319. * Execute the current task
  61320. * @param scene defines the scene where you want your assets to be loaded
  61321. * @param onSuccess is a callback called when the task is successfully executed
  61322. * @param onError is a callback called if an error occurs
  61323. */
  61324. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61325. }
  61326. /**
  61327. * Define a task used by AssetsManager to load HDR cube textures
  61328. */
  61329. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61330. /**
  61331. * Defines the name of the task
  61332. */
  61333. name: string;
  61334. /**
  61335. * Defines the location of the file to load
  61336. */
  61337. url: string;
  61338. /**
  61339. * Defines the desired size (the more it increases the longer the generation will be)
  61340. */
  61341. size: number;
  61342. /**
  61343. * Defines if mipmaps should not be generated (default is false)
  61344. */
  61345. noMipmap: boolean;
  61346. /**
  61347. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61348. */
  61349. generateHarmonics: boolean;
  61350. /**
  61351. * 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)
  61352. */
  61353. gammaSpace: boolean;
  61354. /**
  61355. * Internal Use Only
  61356. */
  61357. reserved: boolean;
  61358. /**
  61359. * Gets the loaded texture
  61360. */
  61361. texture: HDRCubeTexture;
  61362. /**
  61363. * Callback called when the task is successful
  61364. */
  61365. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61366. /**
  61367. * Callback called when the task is successful
  61368. */
  61369. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61370. /**
  61371. * Creates a new HDRCubeTextureAssetTask object
  61372. * @param name defines the name of the task
  61373. * @param url defines the location of the file to load
  61374. * @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.
  61375. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61376. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61377. * @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)
  61378. * @param reserved Internal use only
  61379. */
  61380. constructor(
  61381. /**
  61382. * Defines the name of the task
  61383. */
  61384. name: string,
  61385. /**
  61386. * Defines the location of the file to load
  61387. */
  61388. url: string,
  61389. /**
  61390. * Defines the desired size (the more it increases the longer the generation will be)
  61391. */
  61392. size: number,
  61393. /**
  61394. * Defines if mipmaps should not be generated (default is false)
  61395. */
  61396. noMipmap?: boolean,
  61397. /**
  61398. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61399. */
  61400. generateHarmonics?: boolean,
  61401. /**
  61402. * 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)
  61403. */
  61404. gammaSpace?: boolean,
  61405. /**
  61406. * Internal Use Only
  61407. */
  61408. reserved?: boolean);
  61409. /**
  61410. * Execute the current task
  61411. * @param scene defines the scene where you want your assets to be loaded
  61412. * @param onSuccess is a callback called when the task is successfully executed
  61413. * @param onError is a callback called if an error occurs
  61414. */
  61415. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61416. }
  61417. /**
  61418. * Define a task used by AssetsManager to load Equirectangular cube textures
  61419. */
  61420. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61421. /**
  61422. * Defines the name of the task
  61423. */
  61424. name: string;
  61425. /**
  61426. * Defines the location of the file to load
  61427. */
  61428. url: string;
  61429. /**
  61430. * Defines the desired size (the more it increases the longer the generation will be)
  61431. */
  61432. size: number;
  61433. /**
  61434. * Defines if mipmaps should not be generated (default is false)
  61435. */
  61436. noMipmap: boolean;
  61437. /**
  61438. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61439. * but the standard material would require them in Gamma space) (default is true)
  61440. */
  61441. gammaSpace: boolean;
  61442. /**
  61443. * Gets the loaded texture
  61444. */
  61445. texture: EquiRectangularCubeTexture;
  61446. /**
  61447. * Callback called when the task is successful
  61448. */
  61449. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61450. /**
  61451. * Callback called when the task is successful
  61452. */
  61453. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61454. /**
  61455. * Creates a new EquiRectangularCubeTextureAssetTask object
  61456. * @param name defines the name of the task
  61457. * @param url defines the location of the file to load
  61458. * @param size defines the desired size (the more it increases the longer the generation will be)
  61459. * If the size is omitted this implies you are using a preprocessed cubemap.
  61460. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61461. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61462. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61463. * (default is true)
  61464. */
  61465. constructor(
  61466. /**
  61467. * Defines the name of the task
  61468. */
  61469. name: string,
  61470. /**
  61471. * Defines the location of the file to load
  61472. */
  61473. url: string,
  61474. /**
  61475. * Defines the desired size (the more it increases the longer the generation will be)
  61476. */
  61477. size: number,
  61478. /**
  61479. * Defines if mipmaps should not be generated (default is false)
  61480. */
  61481. noMipmap?: boolean,
  61482. /**
  61483. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61484. * but the standard material would require them in Gamma space) (default is true)
  61485. */
  61486. gammaSpace?: boolean);
  61487. /**
  61488. * Execute the current task
  61489. * @param scene defines the scene where you want your assets to be loaded
  61490. * @param onSuccess is a callback called when the task is successfully executed
  61491. * @param onError is a callback called if an error occurs
  61492. */
  61493. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61494. }
  61495. /**
  61496. * This class can be used to easily import assets into a scene
  61497. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61498. */
  61499. export class AssetsManager {
  61500. private _scene;
  61501. private _isLoading;
  61502. protected _tasks: AbstractAssetTask[];
  61503. protected _waitingTasksCount: number;
  61504. protected _totalTasksCount: number;
  61505. /**
  61506. * Callback called when all tasks are processed
  61507. */
  61508. onFinish: (tasks: AbstractAssetTask[]) => void;
  61509. /**
  61510. * Callback called when a task is successful
  61511. */
  61512. onTaskSuccess: (task: AbstractAssetTask) => void;
  61513. /**
  61514. * Callback called when a task had an error
  61515. */
  61516. onTaskError: (task: AbstractAssetTask) => void;
  61517. /**
  61518. * Callback called when a task is done (whatever the result is)
  61519. */
  61520. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61521. /**
  61522. * Observable called when all tasks are processed
  61523. */
  61524. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61525. /**
  61526. * Observable called when a task had an error
  61527. */
  61528. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61529. /**
  61530. * Observable called when all tasks were executed
  61531. */
  61532. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61533. /**
  61534. * Observable called when a task is done (whatever the result is)
  61535. */
  61536. onProgressObservable: Observable<IAssetsProgressEvent>;
  61537. /**
  61538. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61539. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61540. */
  61541. useDefaultLoadingScreen: boolean;
  61542. /**
  61543. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61544. * when all assets have been downloaded.
  61545. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61546. */
  61547. autoHideLoadingUI: boolean;
  61548. /**
  61549. * Creates a new AssetsManager
  61550. * @param scene defines the scene to work on
  61551. */
  61552. constructor(scene: Scene);
  61553. /**
  61554. * Add a MeshAssetTask to the list of active tasks
  61555. * @param taskName defines the name of the new task
  61556. * @param meshesNames defines the name of meshes to load
  61557. * @param rootUrl defines the root url to use to locate files
  61558. * @param sceneFilename defines the filename of the scene file
  61559. * @returns a new MeshAssetTask object
  61560. */
  61561. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61562. /**
  61563. * Add a TextFileAssetTask to the list of active tasks
  61564. * @param taskName defines the name of the new task
  61565. * @param url defines the url of the file to load
  61566. * @returns a new TextFileAssetTask object
  61567. */
  61568. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61569. /**
  61570. * Add a BinaryFileAssetTask to the list of active tasks
  61571. * @param taskName defines the name of the new task
  61572. * @param url defines the url of the file to load
  61573. * @returns a new BinaryFileAssetTask object
  61574. */
  61575. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61576. /**
  61577. * Add a ImageAssetTask to the list of active tasks
  61578. * @param taskName defines the name of the new task
  61579. * @param url defines the url of the file to load
  61580. * @returns a new ImageAssetTask object
  61581. */
  61582. addImageTask(taskName: string, url: string): ImageAssetTask;
  61583. /**
  61584. * Add a TextureAssetTask to the list of active tasks
  61585. * @param taskName defines the name of the new task
  61586. * @param url defines the url of the file to load
  61587. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61588. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61589. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61590. * @returns a new TextureAssetTask object
  61591. */
  61592. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61593. /**
  61594. * Add a CubeTextureAssetTask to the list of active tasks
  61595. * @param taskName defines the name of the new task
  61596. * @param url defines the url of the file to load
  61597. * @param extensions defines the extension to use to load the cube map (can be null)
  61598. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61599. * @param files defines the list of files to load (can be null)
  61600. * @returns a new CubeTextureAssetTask object
  61601. */
  61602. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61603. /**
  61604. *
  61605. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61606. * @param taskName defines the name of the new task
  61607. * @param url defines the url of the file to load
  61608. * @param size defines the size you want for the cubemap (can be null)
  61609. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61610. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61611. * @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)
  61612. * @param reserved Internal use only
  61613. * @returns a new HDRCubeTextureAssetTask object
  61614. */
  61615. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61616. /**
  61617. *
  61618. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61619. * @param taskName defines the name of the new task
  61620. * @param url defines the url of the file to load
  61621. * @param size defines the size you want for the cubemap (can be null)
  61622. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61623. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61624. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61625. * @returns a new EquiRectangularCubeTextureAssetTask object
  61626. */
  61627. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61628. /**
  61629. * Remove a task from the assets manager.
  61630. * @param task the task to remove
  61631. */
  61632. removeTask(task: AbstractAssetTask): void;
  61633. private _decreaseWaitingTasksCount;
  61634. private _runTask;
  61635. /**
  61636. * Reset the AssetsManager and remove all tasks
  61637. * @return the current instance of the AssetsManager
  61638. */
  61639. reset(): AssetsManager;
  61640. /**
  61641. * Start the loading process
  61642. * @return the current instance of the AssetsManager
  61643. */
  61644. load(): AssetsManager;
  61645. /**
  61646. * Start the loading process as an async operation
  61647. * @return a promise returning the list of failed tasks
  61648. */
  61649. loadAsync(): Promise<void>;
  61650. }
  61651. }
  61652. declare module BABYLON {
  61653. /**
  61654. * Wrapper class for promise with external resolve and reject.
  61655. */
  61656. export class Deferred<T> {
  61657. /**
  61658. * The promise associated with this deferred object.
  61659. */
  61660. readonly promise: Promise<T>;
  61661. private _resolve;
  61662. private _reject;
  61663. /**
  61664. * The resolve method of the promise associated with this deferred object.
  61665. */
  61666. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61667. /**
  61668. * The reject method of the promise associated with this deferred object.
  61669. */
  61670. readonly reject: (reason?: any) => void;
  61671. /**
  61672. * Constructor for this deferred object.
  61673. */
  61674. constructor();
  61675. }
  61676. }
  61677. declare module BABYLON {
  61678. /**
  61679. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61680. */
  61681. export class MeshExploder {
  61682. private _centerMesh;
  61683. private _meshes;
  61684. private _meshesOrigins;
  61685. private _toCenterVectors;
  61686. private _scaledDirection;
  61687. private _newPosition;
  61688. private _centerPosition;
  61689. /**
  61690. * Explodes meshes from a center mesh.
  61691. * @param meshes The meshes to explode.
  61692. * @param centerMesh The mesh to be center of explosion.
  61693. */
  61694. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61695. private _setCenterMesh;
  61696. /**
  61697. * Get class name
  61698. * @returns "MeshExploder"
  61699. */
  61700. getClassName(): string;
  61701. /**
  61702. * "Exploded meshes"
  61703. * @returns Array of meshes with the centerMesh at index 0.
  61704. */
  61705. getMeshes(): Array<Mesh>;
  61706. /**
  61707. * Explodes meshes giving a specific direction
  61708. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61709. */
  61710. explode(direction?: number): void;
  61711. }
  61712. }
  61713. declare module BABYLON {
  61714. /**
  61715. * Class used to help managing file picking and drag'n'drop
  61716. */
  61717. export class FilesInput {
  61718. /**
  61719. * List of files ready to be loaded
  61720. */
  61721. static readonly FilesToLoad: {
  61722. [key: string]: File;
  61723. };
  61724. /**
  61725. * Callback called when a file is processed
  61726. */
  61727. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61728. private _engine;
  61729. private _currentScene;
  61730. private _sceneLoadedCallback;
  61731. private _progressCallback;
  61732. private _additionalRenderLoopLogicCallback;
  61733. private _textureLoadingCallback;
  61734. private _startingProcessingFilesCallback;
  61735. private _onReloadCallback;
  61736. private _errorCallback;
  61737. private _elementToMonitor;
  61738. private _sceneFileToLoad;
  61739. private _filesToLoad;
  61740. /**
  61741. * Creates a new FilesInput
  61742. * @param engine defines the rendering engine
  61743. * @param scene defines the hosting scene
  61744. * @param sceneLoadedCallback callback called when scene is loaded
  61745. * @param progressCallback callback called to track progress
  61746. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61747. * @param textureLoadingCallback callback called when a texture is loading
  61748. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61749. * @param onReloadCallback callback called when a reload is requested
  61750. * @param errorCallback callback call if an error occurs
  61751. */
  61752. 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);
  61753. private _dragEnterHandler;
  61754. private _dragOverHandler;
  61755. private _dropHandler;
  61756. /**
  61757. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61758. * @param elementToMonitor defines the DOM element to track
  61759. */
  61760. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61761. /**
  61762. * Release all associated resources
  61763. */
  61764. dispose(): void;
  61765. private renderFunction;
  61766. private drag;
  61767. private drop;
  61768. private _traverseFolder;
  61769. private _processFiles;
  61770. /**
  61771. * Load files from a drop event
  61772. * @param event defines the drop event to use as source
  61773. */
  61774. loadFiles(event: any): void;
  61775. private _processReload;
  61776. /**
  61777. * Reload the current scene from the loaded files
  61778. */
  61779. reload(): void;
  61780. }
  61781. }
  61782. declare module BABYLON {
  61783. /**
  61784. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61785. */
  61786. export class PerformanceMonitor implements IPerformanceMonitor {
  61787. private _enabled;
  61788. private _rollingFrameTime;
  61789. private _lastFrameTimeMs;
  61790. /**
  61791. * constructor
  61792. * @param frameSampleSize The number of samples required to saturate the sliding window
  61793. */
  61794. constructor(frameSampleSize?: number);
  61795. /**
  61796. * Samples current frame
  61797. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61798. */
  61799. sampleFrame(timeMs?: number): void;
  61800. /**
  61801. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61802. */
  61803. readonly averageFrameTime: number;
  61804. /**
  61805. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61806. */
  61807. readonly averageFrameTimeVariance: number;
  61808. /**
  61809. * Returns the frame time of the most recent frame
  61810. */
  61811. readonly instantaneousFrameTime: number;
  61812. /**
  61813. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61814. */
  61815. readonly averageFPS: number;
  61816. /**
  61817. * Returns the average framerate in frames per second using the most recent frame time
  61818. */
  61819. readonly instantaneousFPS: number;
  61820. /**
  61821. * Returns true if enough samples have been taken to completely fill the sliding window
  61822. */
  61823. readonly isSaturated: boolean;
  61824. /**
  61825. * Enables contributions to the sliding window sample set
  61826. */
  61827. enable(): void;
  61828. /**
  61829. * Disables contributions to the sliding window sample set
  61830. * Samples will not be interpolated over the disabled period
  61831. */
  61832. disable(): void;
  61833. /**
  61834. * Returns true if sampling is enabled
  61835. */
  61836. readonly isEnabled: boolean;
  61837. /**
  61838. * Resets performance monitor
  61839. */
  61840. reset(): void;
  61841. }
  61842. /**
  61843. * RollingAverage
  61844. *
  61845. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61846. */
  61847. export class RollingAverage {
  61848. /**
  61849. * Current average
  61850. */
  61851. average: number;
  61852. /**
  61853. * Current variance
  61854. */
  61855. variance: number;
  61856. protected _samples: Array<number>;
  61857. protected _sampleCount: number;
  61858. protected _pos: number;
  61859. protected _m2: number;
  61860. /**
  61861. * constructor
  61862. * @param length The number of samples required to saturate the sliding window
  61863. */
  61864. constructor(length: number);
  61865. /**
  61866. * Adds a sample to the sample set
  61867. * @param v The sample value
  61868. */
  61869. add(v: number): void;
  61870. /**
  61871. * Returns previously added values or null if outside of history or outside the sliding window domain
  61872. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  61873. * @return Value previously recorded with add() or null if outside of range
  61874. */
  61875. history(i: number): number;
  61876. /**
  61877. * Returns true if enough samples have been taken to completely fill the sliding window
  61878. * @return true if sample-set saturated
  61879. */
  61880. isSaturated(): boolean;
  61881. /**
  61882. * Resets the rolling average (equivalent to 0 samples taken so far)
  61883. */
  61884. reset(): void;
  61885. /**
  61886. * Wraps a value around the sample range boundaries
  61887. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  61888. * @return Wrapped position in sample range
  61889. */
  61890. protected _wrapPosition(i: number): number;
  61891. }
  61892. }
  61893. declare module BABYLON {
  61894. /**
  61895. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61897. */
  61898. export class SceneOptimization {
  61899. /**
  61900. * Defines the priority of this optimization (0 by default which means first in the list)
  61901. */
  61902. priority: number;
  61903. /**
  61904. * Gets a string describing the action executed by the current optimization
  61905. * @returns description string
  61906. */
  61907. getDescription(): string;
  61908. /**
  61909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61910. * @param scene defines the current scene where to apply this optimization
  61911. * @param optimizer defines the current optimizer
  61912. * @returns true if everything that can be done was applied
  61913. */
  61914. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61915. /**
  61916. * Creates the SceneOptimization object
  61917. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61918. * @param desc defines the description associated with the optimization
  61919. */
  61920. constructor(
  61921. /**
  61922. * Defines the priority of this optimization (0 by default which means first in the list)
  61923. */
  61924. priority?: number);
  61925. }
  61926. /**
  61927. * Defines an optimization used to reduce the size of render target textures
  61928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61929. */
  61930. export class TextureOptimization extends SceneOptimization {
  61931. /**
  61932. * Defines the priority of this optimization (0 by default which means first in the list)
  61933. */
  61934. priority: number;
  61935. /**
  61936. * 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
  61937. */
  61938. maximumSize: number;
  61939. /**
  61940. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61941. */
  61942. step: number;
  61943. /**
  61944. * Gets a string describing the action executed by the current optimization
  61945. * @returns description string
  61946. */
  61947. getDescription(): string;
  61948. /**
  61949. * Creates the TextureOptimization object
  61950. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61951. * @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
  61952. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61953. */
  61954. constructor(
  61955. /**
  61956. * Defines the priority of this optimization (0 by default which means first in the list)
  61957. */
  61958. priority?: number,
  61959. /**
  61960. * 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
  61961. */
  61962. maximumSize?: number,
  61963. /**
  61964. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61965. */
  61966. step?: number);
  61967. /**
  61968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61969. * @param scene defines the current scene where to apply this optimization
  61970. * @param optimizer defines the current optimizer
  61971. * @returns true if everything that can be done was applied
  61972. */
  61973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61974. }
  61975. /**
  61976. * Defines an optimization used to increase or decrease the rendering resolution
  61977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61978. */
  61979. export class HardwareScalingOptimization extends SceneOptimization {
  61980. /**
  61981. * Defines the priority of this optimization (0 by default which means first in the list)
  61982. */
  61983. priority: number;
  61984. /**
  61985. * Defines the maximum scale to use (2 by default)
  61986. */
  61987. maximumScale: number;
  61988. /**
  61989. * Defines the step to use between two passes (0.5 by default)
  61990. */
  61991. step: number;
  61992. private _currentScale;
  61993. private _directionOffset;
  61994. /**
  61995. * Gets a string describing the action executed by the current optimization
  61996. * @return description string
  61997. */
  61998. getDescription(): string;
  61999. /**
  62000. * Creates the HardwareScalingOptimization object
  62001. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62002. * @param maximumScale defines the maximum scale to use (2 by default)
  62003. * @param step defines the step to use between two passes (0.5 by default)
  62004. */
  62005. constructor(
  62006. /**
  62007. * Defines the priority of this optimization (0 by default which means first in the list)
  62008. */
  62009. priority?: number,
  62010. /**
  62011. * Defines the maximum scale to use (2 by default)
  62012. */
  62013. maximumScale?: number,
  62014. /**
  62015. * Defines the step to use between two passes (0.5 by default)
  62016. */
  62017. step?: number);
  62018. /**
  62019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62020. * @param scene defines the current scene where to apply this optimization
  62021. * @param optimizer defines the current optimizer
  62022. * @returns true if everything that can be done was applied
  62023. */
  62024. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62025. }
  62026. /**
  62027. * Defines an optimization used to remove shadows
  62028. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62029. */
  62030. export class ShadowsOptimization extends SceneOptimization {
  62031. /**
  62032. * Gets a string describing the action executed by the current optimization
  62033. * @return description string
  62034. */
  62035. getDescription(): string;
  62036. /**
  62037. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62038. * @param scene defines the current scene where to apply this optimization
  62039. * @param optimizer defines the current optimizer
  62040. * @returns true if everything that can be done was applied
  62041. */
  62042. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62043. }
  62044. /**
  62045. * Defines an optimization used to turn post-processes off
  62046. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62047. */
  62048. export class PostProcessesOptimization extends SceneOptimization {
  62049. /**
  62050. * Gets a string describing the action executed by the current optimization
  62051. * @return description string
  62052. */
  62053. getDescription(): string;
  62054. /**
  62055. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62056. * @param scene defines the current scene where to apply this optimization
  62057. * @param optimizer defines the current optimizer
  62058. * @returns true if everything that can be done was applied
  62059. */
  62060. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62061. }
  62062. /**
  62063. * Defines an optimization used to turn lens flares off
  62064. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62065. */
  62066. export class LensFlaresOptimization extends SceneOptimization {
  62067. /**
  62068. * Gets a string describing the action executed by the current optimization
  62069. * @return description string
  62070. */
  62071. getDescription(): string;
  62072. /**
  62073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62074. * @param scene defines the current scene where to apply this optimization
  62075. * @param optimizer defines the current optimizer
  62076. * @returns true if everything that can be done was applied
  62077. */
  62078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62079. }
  62080. /**
  62081. * Defines an optimization based on user defined callback.
  62082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62083. */
  62084. export class CustomOptimization extends SceneOptimization {
  62085. /**
  62086. * Callback called to apply the custom optimization.
  62087. */
  62088. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62089. /**
  62090. * Callback called to get custom description
  62091. */
  62092. onGetDescription: () => string;
  62093. /**
  62094. * Gets a string describing the action executed by the current optimization
  62095. * @returns description string
  62096. */
  62097. getDescription(): string;
  62098. /**
  62099. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62100. * @param scene defines the current scene where to apply this optimization
  62101. * @param optimizer defines the current optimizer
  62102. * @returns true if everything that can be done was applied
  62103. */
  62104. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62105. }
  62106. /**
  62107. * Defines an optimization used to turn particles off
  62108. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62109. */
  62110. export class ParticlesOptimization extends SceneOptimization {
  62111. /**
  62112. * Gets a string describing the action executed by the current optimization
  62113. * @return description string
  62114. */
  62115. getDescription(): string;
  62116. /**
  62117. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62118. * @param scene defines the current scene where to apply this optimization
  62119. * @param optimizer defines the current optimizer
  62120. * @returns true if everything that can be done was applied
  62121. */
  62122. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62123. }
  62124. /**
  62125. * Defines an optimization used to turn render targets off
  62126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62127. */
  62128. export class RenderTargetsOptimization extends SceneOptimization {
  62129. /**
  62130. * Gets a string describing the action executed by the current optimization
  62131. * @return description string
  62132. */
  62133. getDescription(): string;
  62134. /**
  62135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62136. * @param scene defines the current scene where to apply this optimization
  62137. * @param optimizer defines the current optimizer
  62138. * @returns true if everything that can be done was applied
  62139. */
  62140. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62141. }
  62142. /**
  62143. * Defines an optimization used to merge meshes with compatible materials
  62144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62145. */
  62146. export class MergeMeshesOptimization extends SceneOptimization {
  62147. private static _UpdateSelectionTree;
  62148. /**
  62149. * Gets or sets a boolean which defines if optimization octree has to be updated
  62150. */
  62151. /**
  62152. * Gets or sets a boolean which defines if optimization octree has to be updated
  62153. */
  62154. static UpdateSelectionTree: boolean;
  62155. /**
  62156. * Gets a string describing the action executed by the current optimization
  62157. * @return description string
  62158. */
  62159. getDescription(): string;
  62160. private _canBeMerged;
  62161. /**
  62162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62163. * @param scene defines the current scene where to apply this optimization
  62164. * @param optimizer defines the current optimizer
  62165. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62166. * @returns true if everything that can be done was applied
  62167. */
  62168. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62169. }
  62170. /**
  62171. * Defines a list of options used by SceneOptimizer
  62172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62173. */
  62174. export class SceneOptimizerOptions {
  62175. /**
  62176. * Defines the target frame rate to reach (60 by default)
  62177. */
  62178. targetFrameRate: number;
  62179. /**
  62180. * Defines the interval between two checkes (2000ms by default)
  62181. */
  62182. trackerDuration: number;
  62183. /**
  62184. * Gets the list of optimizations to apply
  62185. */
  62186. optimizations: SceneOptimization[];
  62187. /**
  62188. * Creates a new list of options used by SceneOptimizer
  62189. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62190. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62191. */
  62192. constructor(
  62193. /**
  62194. * Defines the target frame rate to reach (60 by default)
  62195. */
  62196. targetFrameRate?: number,
  62197. /**
  62198. * Defines the interval between two checkes (2000ms by default)
  62199. */
  62200. trackerDuration?: number);
  62201. /**
  62202. * Add a new optimization
  62203. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62204. * @returns the current SceneOptimizerOptions
  62205. */
  62206. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62207. /**
  62208. * Add a new custom optimization
  62209. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62210. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62211. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62212. * @returns the current SceneOptimizerOptions
  62213. */
  62214. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62215. /**
  62216. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62217. * @param targetFrameRate defines the target frame rate (60 by default)
  62218. * @returns a SceneOptimizerOptions object
  62219. */
  62220. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62221. /**
  62222. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62223. * @param targetFrameRate defines the target frame rate (60 by default)
  62224. * @returns a SceneOptimizerOptions object
  62225. */
  62226. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62227. /**
  62228. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62229. * @param targetFrameRate defines the target frame rate (60 by default)
  62230. * @returns a SceneOptimizerOptions object
  62231. */
  62232. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62233. }
  62234. /**
  62235. * Class used to run optimizations in order to reach a target frame rate
  62236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62237. */
  62238. export class SceneOptimizer implements IDisposable {
  62239. private _isRunning;
  62240. private _options;
  62241. private _scene;
  62242. private _currentPriorityLevel;
  62243. private _targetFrameRate;
  62244. private _trackerDuration;
  62245. private _currentFrameRate;
  62246. private _sceneDisposeObserver;
  62247. private _improvementMode;
  62248. /**
  62249. * Defines an observable called when the optimizer reaches the target frame rate
  62250. */
  62251. onSuccessObservable: Observable<SceneOptimizer>;
  62252. /**
  62253. * Defines an observable called when the optimizer enables an optimization
  62254. */
  62255. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62256. /**
  62257. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62258. */
  62259. onFailureObservable: Observable<SceneOptimizer>;
  62260. /**
  62261. * Gets a boolean indicating if the optimizer is in improvement mode
  62262. */
  62263. readonly isInImprovementMode: boolean;
  62264. /**
  62265. * Gets the current priority level (0 at start)
  62266. */
  62267. readonly currentPriorityLevel: number;
  62268. /**
  62269. * Gets the current frame rate checked by the SceneOptimizer
  62270. */
  62271. readonly currentFrameRate: number;
  62272. /**
  62273. * Gets or sets the current target frame rate (60 by default)
  62274. */
  62275. /**
  62276. * Gets or sets the current target frame rate (60 by default)
  62277. */
  62278. targetFrameRate: number;
  62279. /**
  62280. * Gets or sets the current interval between two checks (every 2000ms by default)
  62281. */
  62282. /**
  62283. * Gets or sets the current interval between two checks (every 2000ms by default)
  62284. */
  62285. trackerDuration: number;
  62286. /**
  62287. * Gets the list of active optimizations
  62288. */
  62289. readonly optimizations: SceneOptimization[];
  62290. /**
  62291. * Creates a new SceneOptimizer
  62292. * @param scene defines the scene to work on
  62293. * @param options defines the options to use with the SceneOptimizer
  62294. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62295. * @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)
  62296. */
  62297. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62298. /**
  62299. * Stops the current optimizer
  62300. */
  62301. stop(): void;
  62302. /**
  62303. * Reset the optimizer to initial step (current priority level = 0)
  62304. */
  62305. reset(): void;
  62306. /**
  62307. * Start the optimizer. By default it will try to reach a specific framerate
  62308. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62309. */
  62310. start(): void;
  62311. private _checkCurrentState;
  62312. /**
  62313. * Release all resources
  62314. */
  62315. dispose(): void;
  62316. /**
  62317. * Helper function to create a SceneOptimizer with one single line of code
  62318. * @param scene defines the scene to work on
  62319. * @param options defines the options to use with the SceneOptimizer
  62320. * @param onSuccess defines a callback to call on success
  62321. * @param onFailure defines a callback to call on failure
  62322. * @returns the new SceneOptimizer object
  62323. */
  62324. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62325. }
  62326. }
  62327. declare module BABYLON {
  62328. /**
  62329. * Class used to serialize a scene into a string
  62330. */
  62331. export class SceneSerializer {
  62332. /**
  62333. * Clear cache used by a previous serialization
  62334. */
  62335. static ClearCache(): void;
  62336. /**
  62337. * Serialize a scene into a JSON compatible object
  62338. * @param scene defines the scene to serialize
  62339. * @returns a JSON compatible object
  62340. */
  62341. static Serialize(scene: Scene): any;
  62342. /**
  62343. * Serialize a mesh into a JSON compatible object
  62344. * @param toSerialize defines the mesh to serialize
  62345. * @param withParents defines if parents must be serialized as well
  62346. * @param withChildren defines if children must be serialized as well
  62347. * @returns a JSON compatible object
  62348. */
  62349. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62350. }
  62351. }
  62352. declare module BABYLON {
  62353. /**
  62354. * Class used to host texture specific utilities
  62355. */
  62356. export class TextureTools {
  62357. /**
  62358. * Uses the GPU to create a copy texture rescaled at a given size
  62359. * @param texture Texture to copy from
  62360. * @param width defines the desired width
  62361. * @param height defines the desired height
  62362. * @param useBilinearMode defines if bilinear mode has to be used
  62363. * @return the generated texture
  62364. */
  62365. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62366. }
  62367. }
  62368. declare module BABYLON {
  62369. /**
  62370. * This represents the different options available for the video capture.
  62371. */
  62372. export interface VideoRecorderOptions {
  62373. /** Defines the mime type of the video. */
  62374. mimeType: string;
  62375. /** Defines the FPS the video should be recorded at. */
  62376. fps: number;
  62377. /** Defines the chunk size for the recording data. */
  62378. recordChunckSize: number;
  62379. /** The audio tracks to attach to the recording. */
  62380. audioTracks?: MediaStreamTrack[];
  62381. }
  62382. /**
  62383. * This can help with recording videos from BabylonJS.
  62384. * This is based on the available WebRTC functionalities of the browser.
  62385. *
  62386. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62387. */
  62388. export class VideoRecorder {
  62389. private static readonly _defaultOptions;
  62390. /**
  62391. * Returns whether or not the VideoRecorder is available in your browser.
  62392. * @param engine Defines the Babylon Engine.
  62393. * @returns true if supported otherwise false.
  62394. */
  62395. static IsSupported(engine: Engine): boolean;
  62396. private readonly _options;
  62397. private _canvas;
  62398. private _mediaRecorder;
  62399. private _recordedChunks;
  62400. private _fileName;
  62401. private _resolve;
  62402. private _reject;
  62403. /**
  62404. * True when a recording is already in progress.
  62405. */
  62406. readonly isRecording: boolean;
  62407. /**
  62408. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62409. * @param engine Defines the BabylonJS Engine you wish to record.
  62410. * @param options Defines options that can be used to customize the capture.
  62411. */
  62412. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62413. /**
  62414. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62415. */
  62416. stopRecording(): void;
  62417. /**
  62418. * Starts recording the canvas for a max duration specified in parameters.
  62419. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62420. * If null no automatic download will start and you can rely on the promise to get the data back.
  62421. * @param maxDuration Defines the maximum recording time in seconds.
  62422. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62423. * @return A promise callback at the end of the recording with the video data in Blob.
  62424. */
  62425. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62426. /**
  62427. * Releases internal resources used during the recording.
  62428. */
  62429. dispose(): void;
  62430. private _handleDataAvailable;
  62431. private _handleError;
  62432. private _handleStop;
  62433. }
  62434. }
  62435. declare module BABYLON {
  62436. /**
  62437. * Class containing a set of static utilities functions for screenshots
  62438. */
  62439. export class ScreenshotTools {
  62440. /**
  62441. * Captures a screenshot of the current rendering
  62442. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62443. * @param engine defines the rendering engine
  62444. * @param camera defines the source camera
  62445. * @param size This parameter can be set to a single number or to an object with the
  62446. * following (optional) properties: precision, width, height. If a single number is passed,
  62447. * it will be used for both width and height. If an object is passed, the screenshot size
  62448. * will be derived from the parameters. The precision property is a multiplier allowing
  62449. * rendering at a higher or lower resolution
  62450. * @param successCallback defines the callback receives a single parameter which contains the
  62451. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62452. * src parameter of an <img> to display it
  62453. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62454. * Check your browser for supported MIME types
  62455. */
  62456. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62457. /**
  62458. * Captures a screenshot of the current rendering
  62459. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62460. * @param engine defines the rendering engine
  62461. * @param camera defines the source camera
  62462. * @param size This parameter can be set to a single number or to an object with the
  62463. * following (optional) properties: precision, width, height. If a single number is passed,
  62464. * it will be used for both width and height. If an object is passed, the screenshot size
  62465. * will be derived from the parameters. The precision property is a multiplier allowing
  62466. * rendering at a higher or lower resolution
  62467. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62468. * Check your browser for supported MIME types
  62469. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62470. * to the src parameter of an <img> to display it
  62471. */
  62472. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62473. /**
  62474. * Generates an image screenshot from the specified camera.
  62475. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62476. * @param engine The engine to use for rendering
  62477. * @param camera The camera to use for rendering
  62478. * @param size This parameter can be set to a single number or to an object with the
  62479. * following (optional) properties: precision, width, height. If a single number is passed,
  62480. * it will be used for both width and height. If an object is passed, the screenshot size
  62481. * will be derived from the parameters. The precision property is a multiplier allowing
  62482. * rendering at a higher or lower resolution
  62483. * @param successCallback The callback receives a single parameter which contains the
  62484. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62485. * src parameter of an <img> to display it
  62486. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62487. * Check your browser for supported MIME types
  62488. * @param samples Texture samples (default: 1)
  62489. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62490. * @param fileName A name for for the downloaded file.
  62491. */
  62492. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62493. /**
  62494. * Generates an image screenshot from the specified camera.
  62495. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62496. * @param engine The engine to use for rendering
  62497. * @param camera The camera to use for rendering
  62498. * @param size This parameter can be set to a single number or to an object with the
  62499. * following (optional) properties: precision, width, height. If a single number is passed,
  62500. * it will be used for both width and height. If an object is passed, the screenshot size
  62501. * will be derived from the parameters. The precision property is a multiplier allowing
  62502. * rendering at a higher or lower resolution
  62503. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62504. * Check your browser for supported MIME types
  62505. * @param samples Texture samples (default: 1)
  62506. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62507. * @param fileName A name for for the downloaded file.
  62508. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62509. * to the src parameter of an <img> to display it
  62510. */
  62511. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62512. /**
  62513. * Gets height and width for screenshot size
  62514. * @private
  62515. */
  62516. private static _getScreenshotSize;
  62517. }
  62518. }
  62519. declare module BABYLON {
  62520. /**
  62521. * A cursor which tracks a point on a path
  62522. */
  62523. export class PathCursor {
  62524. private path;
  62525. /**
  62526. * Stores path cursor callbacks for when an onchange event is triggered
  62527. */
  62528. private _onchange;
  62529. /**
  62530. * The value of the path cursor
  62531. */
  62532. value: number;
  62533. /**
  62534. * The animation array of the path cursor
  62535. */
  62536. animations: Animation[];
  62537. /**
  62538. * Initializes the path cursor
  62539. * @param path The path to track
  62540. */
  62541. constructor(path: Path2);
  62542. /**
  62543. * Gets the cursor point on the path
  62544. * @returns A point on the path cursor at the cursor location
  62545. */
  62546. getPoint(): Vector3;
  62547. /**
  62548. * Moves the cursor ahead by the step amount
  62549. * @param step The amount to move the cursor forward
  62550. * @returns This path cursor
  62551. */
  62552. moveAhead(step?: number): PathCursor;
  62553. /**
  62554. * Moves the cursor behind by the step amount
  62555. * @param step The amount to move the cursor back
  62556. * @returns This path cursor
  62557. */
  62558. moveBack(step?: number): PathCursor;
  62559. /**
  62560. * Moves the cursor by the step amount
  62561. * If the step amount is greater than one, an exception is thrown
  62562. * @param step The amount to move the cursor
  62563. * @returns This path cursor
  62564. */
  62565. move(step: number): PathCursor;
  62566. /**
  62567. * Ensures that the value is limited between zero and one
  62568. * @returns This path cursor
  62569. */
  62570. private ensureLimits;
  62571. /**
  62572. * Runs onchange callbacks on change (used by the animation engine)
  62573. * @returns This path cursor
  62574. */
  62575. private raiseOnChange;
  62576. /**
  62577. * Executes a function on change
  62578. * @param f A path cursor onchange callback
  62579. * @returns This path cursor
  62580. */
  62581. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62582. }
  62583. }
  62584. declare module BABYLON {
  62585. /** @hidden */
  62586. export var blurPixelShader: {
  62587. name: string;
  62588. shader: string;
  62589. };
  62590. }
  62591. declare module BABYLON {
  62592. /** @hidden */
  62593. export var pointCloudVertexDeclaration: {
  62594. name: string;
  62595. shader: string;
  62596. };
  62597. }
  62598. // Mixins
  62599. interface Window {
  62600. mozIndexedDB: IDBFactory;
  62601. webkitIndexedDB: IDBFactory;
  62602. msIndexedDB: IDBFactory;
  62603. webkitURL: typeof URL;
  62604. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62605. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62606. WebGLRenderingContext: WebGLRenderingContext;
  62607. MSGesture: MSGesture;
  62608. CANNON: any;
  62609. AudioContext: AudioContext;
  62610. webkitAudioContext: AudioContext;
  62611. PointerEvent: any;
  62612. Math: Math;
  62613. Uint8Array: Uint8ArrayConstructor;
  62614. Float32Array: Float32ArrayConstructor;
  62615. mozURL: typeof URL;
  62616. msURL: typeof URL;
  62617. VRFrameData: any; // WebVR, from specs 1.1
  62618. DracoDecoderModule: any;
  62619. setImmediate(handler: (...args: any[]) => void): number;
  62620. }
  62621. interface HTMLCanvasElement {
  62622. requestPointerLock(): void;
  62623. msRequestPointerLock?(): void;
  62624. mozRequestPointerLock?(): void;
  62625. webkitRequestPointerLock?(): void;
  62626. /** Track wether a record is in progress */
  62627. isRecording: boolean;
  62628. /** Capture Stream method defined by some browsers */
  62629. captureStream(fps?: number): MediaStream;
  62630. }
  62631. interface CanvasRenderingContext2D {
  62632. msImageSmoothingEnabled: boolean;
  62633. }
  62634. interface MouseEvent {
  62635. mozMovementX: number;
  62636. mozMovementY: number;
  62637. webkitMovementX: number;
  62638. webkitMovementY: number;
  62639. msMovementX: number;
  62640. msMovementY: number;
  62641. }
  62642. interface Navigator {
  62643. mozGetVRDevices: (any: any) => any;
  62644. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62645. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62646. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62647. webkitGetGamepads(): Gamepad[];
  62648. msGetGamepads(): Gamepad[];
  62649. webkitGamepads(): Gamepad[];
  62650. }
  62651. interface HTMLVideoElement {
  62652. mozSrcObject: any;
  62653. }
  62654. interface Math {
  62655. fround(x: number): number;
  62656. imul(a: number, b: number): number;
  62657. }
  62658. interface WebGLRenderingContext {
  62659. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62660. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62661. vertexAttribDivisor(index: number, divisor: number): void;
  62662. createVertexArray(): any;
  62663. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62664. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62665. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62666. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62667. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62668. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62669. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62670. // Queries
  62671. createQuery(): WebGLQuery;
  62672. deleteQuery(query: WebGLQuery): void;
  62673. beginQuery(target: number, query: WebGLQuery): void;
  62674. endQuery(target: number): void;
  62675. getQueryParameter(query: WebGLQuery, pname: number): any;
  62676. getQuery(target: number, pname: number): any;
  62677. MAX_SAMPLES: number;
  62678. RGBA8: number;
  62679. READ_FRAMEBUFFER: number;
  62680. DRAW_FRAMEBUFFER: number;
  62681. UNIFORM_BUFFER: number;
  62682. HALF_FLOAT_OES: number;
  62683. RGBA16F: number;
  62684. RGBA32F: number;
  62685. R32F: number;
  62686. RG32F: number;
  62687. RGB32F: number;
  62688. R16F: number;
  62689. RG16F: number;
  62690. RGB16F: number;
  62691. RED: number;
  62692. RG: number;
  62693. R8: number;
  62694. RG8: number;
  62695. UNSIGNED_INT_24_8: number;
  62696. DEPTH24_STENCIL8: number;
  62697. MIN: number;
  62698. MAX: number;
  62699. /* Multiple Render Targets */
  62700. drawBuffers(buffers: number[]): void;
  62701. readBuffer(src: number): void;
  62702. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62703. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62704. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62705. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62706. // Occlusion Query
  62707. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62708. ANY_SAMPLES_PASSED: number;
  62709. QUERY_RESULT_AVAILABLE: number;
  62710. QUERY_RESULT: number;
  62711. }
  62712. interface WebGLProgram {
  62713. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62714. }
  62715. interface EXT_disjoint_timer_query {
  62716. QUERY_COUNTER_BITS_EXT: number;
  62717. TIME_ELAPSED_EXT: number;
  62718. TIMESTAMP_EXT: number;
  62719. GPU_DISJOINT_EXT: number;
  62720. QUERY_RESULT_EXT: number;
  62721. QUERY_RESULT_AVAILABLE_EXT: number;
  62722. queryCounterEXT(query: WebGLQuery, target: number): void;
  62723. createQueryEXT(): WebGLQuery;
  62724. beginQueryEXT(target: number, query: WebGLQuery): void;
  62725. endQueryEXT(target: number): void;
  62726. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62727. deleteQueryEXT(query: WebGLQuery): void;
  62728. }
  62729. interface WebGLUniformLocation {
  62730. _currentState: any;
  62731. }
  62732. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62733. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62734. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62735. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62736. interface WebGLRenderingContext {
  62737. readonly RASTERIZER_DISCARD: number;
  62738. readonly DEPTH_COMPONENT24: number;
  62739. readonly TEXTURE_3D: number;
  62740. readonly TEXTURE_2D_ARRAY: number;
  62741. readonly TEXTURE_COMPARE_FUNC: number;
  62742. readonly TEXTURE_COMPARE_MODE: number;
  62743. readonly COMPARE_REF_TO_TEXTURE: number;
  62744. readonly TEXTURE_WRAP_R: number;
  62745. readonly HALF_FLOAT: number;
  62746. readonly RGB8: number;
  62747. readonly RED_INTEGER: number;
  62748. readonly RG_INTEGER: number;
  62749. readonly RGB_INTEGER: number;
  62750. readonly RGBA_INTEGER: number;
  62751. readonly R8_SNORM: number;
  62752. readonly RG8_SNORM: number;
  62753. readonly RGB8_SNORM: number;
  62754. readonly RGBA8_SNORM: number;
  62755. readonly R8I: number;
  62756. readonly RG8I: number;
  62757. readonly RGB8I: number;
  62758. readonly RGBA8I: number;
  62759. readonly R8UI: number;
  62760. readonly RG8UI: number;
  62761. readonly RGB8UI: number;
  62762. readonly RGBA8UI: number;
  62763. readonly R16I: number;
  62764. readonly RG16I: number;
  62765. readonly RGB16I: number;
  62766. readonly RGBA16I: number;
  62767. readonly R16UI: number;
  62768. readonly RG16UI: number;
  62769. readonly RGB16UI: number;
  62770. readonly RGBA16UI: number;
  62771. readonly R32I: number;
  62772. readonly RG32I: number;
  62773. readonly RGB32I: number;
  62774. readonly RGBA32I: number;
  62775. readonly R32UI: number;
  62776. readonly RG32UI: number;
  62777. readonly RGB32UI: number;
  62778. readonly RGBA32UI: number;
  62779. readonly RGB10_A2UI: number;
  62780. readonly R11F_G11F_B10F: number;
  62781. readonly RGB9_E5: number;
  62782. readonly RGB10_A2: number;
  62783. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62784. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62785. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62786. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62787. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62788. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62789. 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;
  62790. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62791. readonly TRANSFORM_FEEDBACK: number;
  62792. readonly INTERLEAVED_ATTRIBS: number;
  62793. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62794. createTransformFeedback(): WebGLTransformFeedback;
  62795. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62796. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62797. beginTransformFeedback(primitiveMode: number): void;
  62798. endTransformFeedback(): void;
  62799. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62800. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62801. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62802. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62803. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62804. }
  62805. interface ImageBitmap {
  62806. readonly width: number;
  62807. readonly height: number;
  62808. close(): void;
  62809. }
  62810. interface WebGLQuery extends WebGLObject {
  62811. }
  62812. declare var WebGLQuery: {
  62813. prototype: WebGLQuery;
  62814. new(): WebGLQuery;
  62815. };
  62816. interface WebGLSampler extends WebGLObject {
  62817. }
  62818. declare var WebGLSampler: {
  62819. prototype: WebGLSampler;
  62820. new(): WebGLSampler;
  62821. };
  62822. interface WebGLSync extends WebGLObject {
  62823. }
  62824. declare var WebGLSync: {
  62825. prototype: WebGLSync;
  62826. new(): WebGLSync;
  62827. };
  62828. interface WebGLTransformFeedback extends WebGLObject {
  62829. }
  62830. declare var WebGLTransformFeedback: {
  62831. prototype: WebGLTransformFeedback;
  62832. new(): WebGLTransformFeedback;
  62833. };
  62834. interface WebGLVertexArrayObject extends WebGLObject {
  62835. }
  62836. declare var WebGLVertexArrayObject: {
  62837. prototype: WebGLVertexArrayObject;
  62838. new(): WebGLVertexArrayObject;
  62839. };
  62840. // Type definitions for WebVR API
  62841. // Project: https://w3c.github.io/webvr/
  62842. // Definitions by: six a <https://github.com/lostfictions>
  62843. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62844. interface VRDisplay extends EventTarget {
  62845. /**
  62846. * Dictionary of capabilities describing the VRDisplay.
  62847. */
  62848. readonly capabilities: VRDisplayCapabilities;
  62849. /**
  62850. * z-depth defining the far plane of the eye view frustum
  62851. * enables mapping of values in the render target depth
  62852. * attachment to scene coordinates. Initially set to 10000.0.
  62853. */
  62854. depthFar: number;
  62855. /**
  62856. * z-depth defining the near plane of the eye view frustum
  62857. * enables mapping of values in the render target depth
  62858. * attachment to scene coordinates. Initially set to 0.01.
  62859. */
  62860. depthNear: number;
  62861. /**
  62862. * An identifier for this distinct VRDisplay. Used as an
  62863. * association point in the Gamepad API.
  62864. */
  62865. readonly displayId: number;
  62866. /**
  62867. * A display name, a user-readable name identifying it.
  62868. */
  62869. readonly displayName: string;
  62870. readonly isConnected: boolean;
  62871. readonly isPresenting: boolean;
  62872. /**
  62873. * If this VRDisplay supports room-scale experiences, the optional
  62874. * stage attribute contains details on the room-scale parameters.
  62875. */
  62876. readonly stageParameters: VRStageParameters | null;
  62877. /**
  62878. * Passing the value returned by `requestAnimationFrame` to
  62879. * `cancelAnimationFrame` will unregister the callback.
  62880. * @param handle Define the hanle of the request to cancel
  62881. */
  62882. cancelAnimationFrame(handle: number): void;
  62883. /**
  62884. * Stops presenting to the VRDisplay.
  62885. * @returns a promise to know when it stopped
  62886. */
  62887. exitPresent(): Promise<void>;
  62888. /**
  62889. * Return the current VREyeParameters for the given eye.
  62890. * @param whichEye Define the eye we want the parameter for
  62891. * @returns the eye parameters
  62892. */
  62893. getEyeParameters(whichEye: string): VREyeParameters;
  62894. /**
  62895. * Populates the passed VRFrameData with the information required to render
  62896. * the current frame.
  62897. * @param frameData Define the data structure to populate
  62898. * @returns true if ok otherwise false
  62899. */
  62900. getFrameData(frameData: VRFrameData): boolean;
  62901. /**
  62902. * Get the layers currently being presented.
  62903. * @returns the list of VR layers
  62904. */
  62905. getLayers(): VRLayer[];
  62906. /**
  62907. * Return a VRPose containing the future predicted pose of the VRDisplay
  62908. * when the current frame will be presented. The value returned will not
  62909. * change until JavaScript has returned control to the browser.
  62910. *
  62911. * The VRPose will contain the position, orientation, velocity,
  62912. * and acceleration of each of these properties.
  62913. * @returns the pose object
  62914. */
  62915. getPose(): VRPose;
  62916. /**
  62917. * Return the current instantaneous pose of the VRDisplay, with no
  62918. * prediction applied.
  62919. * @returns the current instantaneous pose
  62920. */
  62921. getImmediatePose(): VRPose;
  62922. /**
  62923. * The callback passed to `requestAnimationFrame` will be called
  62924. * any time a new frame should be rendered. When the VRDisplay is
  62925. * presenting the callback will be called at the native refresh
  62926. * rate of the HMD. When not presenting this function acts
  62927. * identically to how window.requestAnimationFrame acts. Content should
  62928. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62929. * asynchronously from other displays and at differing refresh rates.
  62930. * @param callback Define the eaction to run next frame
  62931. * @returns the request handle it
  62932. */
  62933. requestAnimationFrame(callback: FrameRequestCallback): number;
  62934. /**
  62935. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62936. * Repeat calls while already presenting will update the VRLayers being displayed.
  62937. * @param layers Define the list of layer to present
  62938. * @returns a promise to know when the request has been fulfilled
  62939. */
  62940. requestPresent(layers: VRLayer[]): Promise<void>;
  62941. /**
  62942. * Reset the pose for this display, treating its current position and
  62943. * orientation as the "origin/zero" values. VRPose.position,
  62944. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62945. * updated when calling resetPose(). This should be called in only
  62946. * sitting-space experiences.
  62947. */
  62948. resetPose(): void;
  62949. /**
  62950. * The VRLayer provided to the VRDisplay will be captured and presented
  62951. * in the HMD. Calling this function has the same effect on the source
  62952. * canvas as any other operation that uses its source image, and canvases
  62953. * created without preserveDrawingBuffer set to true will be cleared.
  62954. * @param pose Define the pose to submit
  62955. */
  62956. submitFrame(pose?: VRPose): void;
  62957. }
  62958. declare var VRDisplay: {
  62959. prototype: VRDisplay;
  62960. new(): VRDisplay;
  62961. };
  62962. interface VRLayer {
  62963. leftBounds?: number[] | Float32Array | null;
  62964. rightBounds?: number[] | Float32Array | null;
  62965. source?: HTMLCanvasElement | null;
  62966. }
  62967. interface VRDisplayCapabilities {
  62968. readonly canPresent: boolean;
  62969. readonly hasExternalDisplay: boolean;
  62970. readonly hasOrientation: boolean;
  62971. readonly hasPosition: boolean;
  62972. readonly maxLayers: number;
  62973. }
  62974. interface VREyeParameters {
  62975. /** @deprecated */
  62976. readonly fieldOfView: VRFieldOfView;
  62977. readonly offset: Float32Array;
  62978. readonly renderHeight: number;
  62979. readonly renderWidth: number;
  62980. }
  62981. interface VRFieldOfView {
  62982. readonly downDegrees: number;
  62983. readonly leftDegrees: number;
  62984. readonly rightDegrees: number;
  62985. readonly upDegrees: number;
  62986. }
  62987. interface VRFrameData {
  62988. readonly leftProjectionMatrix: Float32Array;
  62989. readonly leftViewMatrix: Float32Array;
  62990. readonly pose: VRPose;
  62991. readonly rightProjectionMatrix: Float32Array;
  62992. readonly rightViewMatrix: Float32Array;
  62993. readonly timestamp: number;
  62994. }
  62995. interface VRPose {
  62996. readonly angularAcceleration: Float32Array | null;
  62997. readonly angularVelocity: Float32Array | null;
  62998. readonly linearAcceleration: Float32Array | null;
  62999. readonly linearVelocity: Float32Array | null;
  63000. readonly orientation: Float32Array | null;
  63001. readonly position: Float32Array | null;
  63002. readonly timestamp: number;
  63003. }
  63004. interface VRStageParameters {
  63005. sittingToStandingTransform?: Float32Array;
  63006. sizeX?: number;
  63007. sizeY?: number;
  63008. }
  63009. interface Navigator {
  63010. getVRDisplays(): Promise<VRDisplay[]>;
  63011. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63012. }
  63013. interface Window {
  63014. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63015. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63016. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63017. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63018. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63019. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63020. }
  63021. interface Gamepad {
  63022. readonly displayId: number;
  63023. }
  63024. type XRSessionMode =
  63025. | "inline"
  63026. | "immersive-vr"
  63027. | "immersive-ar";
  63028. type XRReferenceSpaceType =
  63029. | "viewer"
  63030. | "local"
  63031. | "local-floor"
  63032. | "bounded-floor"
  63033. | "unbounded";
  63034. type XREnvironmentBlendMode =
  63035. | "opaque"
  63036. | "additive"
  63037. | "alpha-blend";
  63038. type XRVisibilityState =
  63039. | "visible"
  63040. | "visible-blurred"
  63041. | "hidden";
  63042. type XRHandedness =
  63043. | "none"
  63044. | "left"
  63045. | "right";
  63046. type XRTargetRayMode =
  63047. | "gaze"
  63048. | "tracked-pointer"
  63049. | "screen";
  63050. type XREye =
  63051. | "none"
  63052. | "left"
  63053. | "right";
  63054. interface XRSpace extends EventTarget {
  63055. }
  63056. interface XRRenderState {
  63057. depthNear?: number;
  63058. depthFar?: number;
  63059. inlineVerticalFieldOfView?: number;
  63060. baseLayer?: XRWebGLLayer;
  63061. }
  63062. interface XRInputSource {
  63063. handedness: XRHandedness;
  63064. targetRayMode: XRTargetRayMode;
  63065. targetRaySpace: XRSpace;
  63066. gripSpace: XRSpace | undefined;
  63067. gamepad: Gamepad | undefined;
  63068. profiles: Array<string>;
  63069. }
  63070. interface XRSession {
  63071. addEventListener: Function;
  63072. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63073. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63074. requestAnimationFrame: Function;
  63075. end(): Promise<void>;
  63076. renderState: XRRenderState;
  63077. inputSources: Array<XRInputSource>;
  63078. }
  63079. interface XRReferenceSpace extends XRSpace {
  63080. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63081. onreset: any;
  63082. }
  63083. interface XRFrame {
  63084. session: XRSession;
  63085. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63086. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63087. }
  63088. interface XRViewerPose extends XRPose {
  63089. views: Array<XRView>;
  63090. }
  63091. interface XRPose {
  63092. transform: XRRigidTransform;
  63093. emulatedPosition: boolean;
  63094. }
  63095. declare var XRWebGLLayer: {
  63096. prototype: XRWebGLLayer;
  63097. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63098. };
  63099. interface XRWebGLLayer {
  63100. framebuffer: WebGLFramebuffer;
  63101. framebufferWidth: number;
  63102. framebufferHeight: number;
  63103. getViewport: Function;
  63104. }
  63105. interface XRRigidTransform {
  63106. position: DOMPointReadOnly;
  63107. orientation: DOMPointReadOnly;
  63108. matrix: Float32Array;
  63109. inverse: XRRigidTransform;
  63110. }
  63111. interface XRView {
  63112. eye: XREye;
  63113. projectionMatrix: Float32Array;
  63114. transform: XRRigidTransform;
  63115. }
  63116. interface XRInputSourceChangeEvent {
  63117. session: XRSession;
  63118. removed: Array<XRInputSource>;
  63119. added: Array<XRInputSource>;
  63120. }